TikZ PGF – How to Plot This Parametric Curve

tikz-pgf

I am trying to plot this parametric function:

(cos(t)+(t)*sin(t), sin(t)+(t)*cos(t)) (0≤t≤π)

which gives the curve below:

enter image description here

This is my attempt, but for some reason it doesn't work.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thick] plot[variable=\t,domain=0:180,smooth,thick] ({cos(\t)-(\t)*sin(\t)},{sin(\t)-(\t)*cos(\t)});
\end{tikzpicture}
\end{document}

How should I fix these codes?

Best Answer

To expand hpekristiansen's comment:

  1. You don't need (\t r) outside the sin or cos functions. You already defined \t in radians because the domain is 0:pi. However, you need that inside the trigonometric functions, that as default take values in degrees.
  2. You say you want to draw the function
(cos(t)+(t)*sin(t), sin(t)+(t)*cos(t))

but in your code is

(cos(t)-(t)*sin(t), sin(t)-(t)*cos(t))

However, I get an approximate result with

(cos(t)+(t)*sin(t), sin(t)-(t)*cos(t))

The complete code could be:

\documentclass[tikz,border=2mm]{standalone}

\begin{document}
\begin{tikzpicture}[line cap=round,scale=2]
\draw[help lines] (-1.25,0) grid [step=0.5] (1.75,3.75);
\draw[-latex] (-1.25,0) -- (1.75,0) node [right] {$x$};
\draw[-latex] (0,0)     -- (0,3.75) node [above] {$y$};
\foreach[count=\j]\i in {-1,-0.5,0.5,1,1.5}
  \draw (\i,0.05) -- (\i,-0.05) node [below] {$\i\ifnum\j<3\phantom{-}\fi$};
\foreach\i in {0.5,1,...,3.5}
  \draw (0.05,\i) -- (-0.05,\i) node [left]  {$\i$};
\draw[red, thick] plot[variable=\t,domain=0:pi,smooth,thick] ({cos(\t r)+\t*sin(\t r)},{sin(\t r)-\t*cos(\t r)});
\end{tikzpicture}
\end{document}

And the output enter image description here