3

I'm tryin to demonstate an odd function using this:

\begin{tikzpicture}[domain=-2:2]
\draw[->] (-2,0) -- (2,0) node[right] {$x$};
\draw[->] (0,-2) -- (0,2) node[above] {$y$};
\draw[dotted] (0,-.8) node[right] {$-f(x)$} -- (-.86,-.8) ;
\draw[dotted] (-.86,-.8) -- (-.86,0) node[above] {$-x$} ;
\draw[dotted] (0,.8) node[left] {$f(x)$} -- (.86,.8) ;
\draw[dotted] (.86,.8) -- (.86,0) node[below] {$x$} ;
\draw[color=blue] plot (\x,{sin(\x r)});
\end{tikzpicture}

but i'm drawing approximate lines for x and f(x). How can I draw exactly from sin(x)??

enter image description here

4

You can either mark a point on the curve by direct evaluation

\coordinate (a) at (1,{sin(1 r)});
\draw[dashed] (a|-o) -- (a) -- (a-|o);

or you can use pgfplots

\documentclass[]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\myx{1}
\pgfmathsetmacro\myfx{sin(\myx r)}
\begin{axis}[axis lines=middle,
trig format=rad, 
xtick={-\myx,\myx},ytick={-\myfx,\myfx},
xmin=-2,ymin=-2,xmax=2,ymax=2,
xlabel=$x$,ylabel=$y$,
xticklabels={$-x$,$x$},yticklabels={$-f(x)$,$f(x)$}]

\addplot[draw=blue,domain=-2:2,samples=101] {sin(x)};
\draw[densely dashed] (\myx,0) |- (0,\myfx) ;

\end{axis}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.