What is the Graph of $f(x)=3\cos(\pi x-2)+5$ with Amplitude and Period?

  • Context: MHB 
  • Thread starter Thread starter karush
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on graphing the function $f(x)=3\cos(\pi x-2)+5$ using TikZ in LaTeX. Participants share code snippets for rendering the graph, emphasizing the need for correct transformations and axis labeling. Key points include the function's amplitude of 3, a vertical shift of 5, and the period determined by the coefficient of $\pi$, which results in two complete cycles within the specified domain. The final TikZ code provided accurately represents the function with appropriate ticks for minimum and maximum points.

PREREQUISITES
  • Understanding of trigonometric functions and their transformations
  • Familiarity with TikZ for LaTeX typesetting
  • Knowledge of amplitude and period in sinusoidal functions
  • Basic skills in LaTeX document preparation
NEXT STEPS
  • Study TikZ documentation for advanced graphing techniques
  • Learn about trigonometric transformations in detail
  • Explore LaTeX packages for enhanced mathematical typesetting
  • Investigate the effects of phase shifts on sinusoidal graphs
USEFUL FOR

Mathematicians, educators, students, and anyone interested in visualizing trigonometric functions using LaTeX and TikZ.

karush
Gold Member
MHB
Messages
3,240
Reaction score
5
$f(x)=3\cos(\pi x-2)+5$

ok I tried to find a tikz graph online but most were too involved
basically 2 periods
show only ticks for xy intersections and light dashed lines for Amplitude
no background grid just xy axis

ok founut d this it renders in overleaf but not here
also, transformation is not yet applied
\begin{tikzpicture}[help lines/.style={black!50,very thin}]
\draw[<->,thick] (-4.25,0)--(4.25,0) node
{$x$};
\draw[<->,thick] (0,-4.25)--(0,4.25) node[above] {$y$};
\draw[very thick,color=green] plot [domain={-360/90}:{360/90},smooth] (\x,{cos(90*\x)});
\end{tikzpicture}Mahalo​
 
Last edited:
Physics news on Phys.org
\begin{tikzpicture}[help lines/.style={black!50,very thin}]
\draw[<->,thick] (-4.25,0)--(4.25,0) node {$x$};
\draw[<->,thick] (0,-4.25)--(0,4.25) node[above] {$y$};
\draw[very thick,color=green] plot [domain={-360/90}:{360/90},smooth] (\x,{cos(90*\x)});
\end{tikzpicture}

Seems to work for me here.

This is what you posted:
1642042750902.png
It's what we see when we switch to source mode, the wheel at the right top that looks like this:
1642042794813.png


Note the [RIGHT] and [/RIGHT] that are breaking up the TikZ code, and which aligns part of it to the right.
Can't have those. If we remove those markers, then the TikZ picture is rendered as it should.

It seems you accidentally aligned some of the text to the right, which happens if we select this option:
1642043079910.png
 
Last edited:
\begin{tikzpicture}[help lines/.style={black!50,very thin}]
\draw[<->,thick] (-12,0)--(12,0) node {$x$};
\draw[<->,thick] (0,-1)--(0,6) node[above] {$y$};
\draw[very thick,color=black] plot [domain={-360/90}:{360/90},smooth] (3*\x,{cos(90*\x-2)+5});
\end{tikzpicture}

$f(x)=3\cos(\pi x-2)+5$
transform for 2 periods
ok just added A and B i think
but not PS or T
 
\begin{tikzpicture}[xscale=.25,yscale=.5]
[help lines/.style={black!50,very thin}] \draw[<->,thick] (-12,0)--(12,0) node[below] {$x$};
\draw[<->,thick] (0,-1)--(0,6) node[above] {$f(x)$};
\draw[very thick,color=black] plot [domain={-360/90}:{360/90},smooth] (3*\x,{cos(90*\x-2)+5});
\end{tikzpicture}

Ok now I have to do the ticks for the min/max points of the graph
 

karush

Well-known member

Jan 31, 2012 3,175
MHB TikZ Code
\begin{tikzpicture}[xscale=.25,yscale=.5] [help lines/.style={black!50,very thin}] \draw[<->,thick] (-16,0)--(16,0) node[below] {$x$};
\draw[<->,thick] (0,-1)--(0,6) node[above] {$f(x)$};
\node [below] at (-4*3.1416,0) {-4$\pi$};
\node [below] at (-2*3.1416,0) {-2$\pi$};
\node [below] at (2*3.1416,0) {2$\pi$};
\node [below] at (4*3.1416,0) {4$\pi$};
\draw[very thick,color=black] plot [domain={-360/90}:{360/90},smooth] (3*\x,{cos(180*\x-2)+5});
\end{tikzpicture}

ok still don't have this graph right...
 
Last edited:
In the TikZ code, where do you get "cos(90*\x - 2)" from? If you want to change $\pi x-2$ from radians to degrees, I would expect to get 180*\x - 114.59, since 2 radians is (approx.) 114.59 degrees.
 
\begin{tikzpicture}[xscale=1,yscale=.5]
[help lines/.style={black!50,very thin}]
\draw[-,thick] (-4,0)--(4,0) node[below] {$x$};
\draw[-,dashed] (-4,2)--(4,2) node[below] {$y=2$};
\draw[-,dashed] (-4,8)--(4,8) node at (5,8) {$y=8$};
\draw[-,dashed] (-4,5)--(4,5) node[below] {$y=5$};
\draw[->,thick] (0,-1)--(0,8) node[above] {$f(x)=3cos(\pi x-2)+5$};
\node [below] at (-3.1416,0) {-$\pi$};
\node [below] at (3.1416,0) {$\pi$};

\draw[very thick,color=black] plot [domain={-180/90}:{180/90},smooth]
(\x,{3*cos(180*\x-2)+5});
\end{tikzpicture}
 
Last edited:

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • Poll Poll
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 0 ·
Replies
0
Views
6K