3

Using Tikz, I can to make the graph of the $f(x) = \cos x$, $f(x) = \sin x$ , buta I can't to make the of $f (x) = \cos | x |$

  • 7
    cos(-x) = cos(x)cos(x) = cos(|x|) – Heiko Oberdiek Sep 28 '15 at 21:37
6

pgfmath has an abs function. That said, cosine being an even function, cos(x) = cos(-x), so there is no difference between the plots of cos(x) and cos(abs(x)).

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot[blue,domain=-360:360,samples=400] {cos(abs(x))};
\addplot[red,ultra thick,dashed,domain=-360:360,samples=400] {cos(x)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • I was wrong when I wrote cos x (which is a function pair, so the graph of cos |x| is no problem). Actually, I wanted to do was make the graph of f (x) = | sin |x| |, and I thought I'd just ask a simple question (f(x) = sin|x| )and, after suggestions, I would complete the rest. When I wrote, I changed the sine by the cosine. – benedito Sep 28 '15 at 22:04
  • @benedito sin(abs(deg(x))) – user11232 Sep 29 '15 at 1:41

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.