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

  • Thread starter Thread starter karush
  • Start date Start date
AI Thread Summary
The discussion revolves around creating a TikZ graph for the function f(x) = 3cos(πx - 2) + 5, focusing on rendering it correctly without a background grid and with specific tick marks for x and y intersections. Participants share code snippets and troubleshoot issues related to the alignment and rendering of the TikZ graphics in Overleaf. Key points include the need to transform the function for two periods, the importance of correctly applying transformations, and addressing the conversion from radians to degrees in the cosine function. There is an emphasis on ensuring the graph accurately reflects the amplitude and periodicity of the function while maintaining clarity in the visual presentation.
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
Views
2K
Replies
4
Views
2K
Replies
8
Views
2K
Replies
1
Views
2K
  • Poll Poll
Replies
11
Views
3K
Replies
7
Views
2K
Replies
2
Views
1K
Replies
0
Views
5K
Back
Top