Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to plot a function like this

enter image description here

f(x)= (sin(x)^2)*(cos((x/2)^2)) on a tiny bandwidth around 180 degrees

on various tools like PyXPlot, Asymptote and GNUPlot, I'm not expert in any of these but all tools give me almost the same result, the result is inaccurate as at x=180, y=0.I tried to plot with more samples but with no success.

share|improve this question
2  
Many plot programs use radians as default for sine and cosine - in which case your function is not 0 at x=180 - notice the period of your fuction in the above picture corresponds to this. Some programs provide a sind function instead for degrees, otherwise you have to scale x by Pi/180. –  Andrew Swann Mar 3 '13 at 11:51
    
Welcome to TeX.sx! I would use pst-plot. –  Marco Daniel Mar 3 '13 at 11:56
add comment

2 Answers

up vote 3 down vote accepted

run with xelatex

\documentclass{article}
\usepackage{pst-plot}
\begin{document}

\psset{xunit=2cm,yunit=4}
\begin{pspicture}(-3.3,-0.2)(3.3,1)
\psaxes[]{->}(0,0)(-3.2,-0.2)(3.2,1)[$x$,90][$y$,0]
\psplot[algebraic,plotpoints=100,plotstyle=LineToXAxis,
  linecolor=red,linewidth=1pt]{-3.2}{3.2}{(sin(x)^2)*(cos((x/2)^2))}
\psplot[algebraic,plotpoints=1000,linestyle=dashed,
  linewidth=1pt]{-3.2}{3.2}{(sin(x)^2)*(cos((x/2)^2))}
\end{pspicture}
\end{document}

enter image description here

share|improve this answer
add comment

Run with any compiler:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7} 

\begin{document} 
\begin{tikzpicture}
\begin{axis}[
    axis lines*=middle,
    samples=11,
    domain=179.9:180.1
]
\addplot [thick, smooth]  {(sin(x)^2)*(cos((x/2)^2))};
\end{axis}  
\end{tikzpicture} 
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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