Welcome to our community

Be a part of something great, join today!

TiKZ -tikz7.8.1 y =3cos(pi x-2)+5

karush

Well-known member
Jan 31, 2012
3,179
$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:

Klaas van Aarsen

MHB Seeker
Staff member
Mar 5, 2012
9,773
\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:

karush

Well-known member
Jan 31, 2012
3,179
\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
 

karush

Well-known member
Jan 31, 2012
3,179
\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,179

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:

Opalg

MHB Oldtimer
Staff member
Feb 7, 2012
2,807
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.
 

karush

Well-known member
Jan 31, 2012
3,179
\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: