Graphics, Figures & TablesWrong cosine plot

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Wrong cosine plot

Post by coachbennett1981 »

Good morning,
I am having difficulty with the following graph y=3cos3x and my plot in pstricks. I checked the graph by hand and also using a graphing calculator. My graph in PSTRICKS does not match that of the graphing calculator, and the one I created by hand. The amplitude is 3, there are 3 cycles from 0 to 2pi and the period is 2pi/3, but the value for \pi should be -3, not 3. Any suggestions?

Code: Select all

\documentclass{article}
\usepackage{pstricks-add}

\begin{document}
\psset{trigLabels=true,labelFontSize=\scriptstyle,xunit=\pstRadUnit}
\begin{pspicture}(-\psPiTwo,-4)(10,4)
\psaxes[trigLabelBase=2]{<->}(0,0)(-\psPiTwo,-5)(\psPiTwo,5)
\psplot[xunit=1cm,linecolor=red,linewidth=1.5pt,plotpoints=1000]{-\psPiTwo}{\psPiTwo}{x 3 mul RadtoDeg cos 3 mul }

\end{pspicture}

\end{document}


Any help will be grateful. Thank you.
Last edited by coachbennett1981 on Tue May 25, 2010 6:11 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

Wrong cosine plot

Post by CrazyHorse »

coachbennett1981 wrote: I am having difficulty with the following graph y=3cos3x and my plot in pstricks. I checked the graph by hand and also using a graphing calculator. My graph in PSTRICKS does not match that of the graphing calculator, and the one I created by hand. The amplitude is 3, there are 3 cycles from 0 to 2pi and the period is 2pi/3, but the value for \pi should be -3, not 3. Any suggestions?

Code: Select all

\documentclass{article}
\usepackage{pstricks-add}

\begin{document}
\psset{trigLabels,labelFontSize=\scriptstyle}

\begin{pspicture}(-\psPiTwo,-4)(7,4)
\psaxes[trigLabelBase=3,xunit=\pstRadUnit]%
   {<->}(0,0)(-\psPiTwo,-4)(\psPiTwo,4)
\psplot[linecolor=red,linewidth=1.5pt,
  plotpoints=1000,algebraic]{-\psPiTwo}{\psPiTwo}{3*cos(3*x)}

\end{pspicture}

\end{document}
Herbert
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: Wrong cosine plot

Post by coachbennett1981 »

Thank you for the graph.. I appreciate it. Works great
Post Reply