2

I'm trying to generate the picture that I created on Geogebra in Tikz code. enter image description here

The picture came as luck as I was playing with some functions. Now, I'm using the following code to produce the picture on Tikz, but it does not compile the coordinates. Maybe it is something else it does not compile, that I can't see.

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (0.7333308390918073,0.0) -- (5.239998617966438,0.0);
\foreach \x in {,1.0,2.0,3.0,4.0,5.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\clip(0.7333308390918073,-0.6933333333333337) rectangle (5.239998617966438,3.040000000000002);
\draw[smooth,samples=100,domain=2.0400031082342736:4.039997101821316] plot(\x, ((\x)-3.04)^(5)-2*((\x)-3.04)^(3)+(\x)-3.04+1.0]+0.66});
\draw [line width=1.2000000000000002pt,dash pattern=on 1pt off 1pt] (2.04,1.6600000000000001)-- (2.04,0.0);
\draw [line width=1.2000000000000002pt,dash pattern=on 1pt off 1pt] (4.04,1.6600000000000001)-- (4.04,0.0);
\draw (1.933331135241857,-0.026666666666666682) node[anchor=north west] {$a$};
\draw (3.9333316288252727,-0.04000000000000002) node[anchor=north west] {$\beta$};
\draw[smooth,samples=100,domain=4.066665128397554:5.066663234885912] plot(\x,((\x)-0.013333333333333641-5.05333)^(5)-2.0*((\x)-0.013333333333333641-5.05333)^(3)+(\x)-0.013333333333333641-5.05333-1.0]+1.8000033333333345});
\draw [line width=1.2000000000000002pt,dash pattern=on 1pt off 1pt] (2.04,1.6600000000000001)-- (2.04,2.84);
\draw[smooth,samples=100,domain=1.040000568108668:2.039999103789556] plot(\x, ((\x)-1.04)^(2)]+1.5733333333333346});
\begin{scriptsize}
\draw [fill=black] (2.04,1.6600000000000001) circle (1.5pt);
\draw [fill=black] (4.04,1.6600000000000001) circle (1.5pt);
\draw [color=black] (4.04,0.8181088825214906) circle (2.0pt);
\draw [color=black] (2.0399999999999996,2.5733333333333337) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

Any suggestions?

By the way, how do we create random functions (graphs) in Tikz? Thanks!

4

One simplified attempt is drawn to serve as a suggestion and the Geogebra output is debugged and added. For the later, draw plot and dash pattern=on 1pt off 1pt are the main sources of errors.

A starting point for How to draw a random functon is here.

enter image description here

Code

\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc,}
\begin{document}

Simplified equivalent 

\vspace{1cm}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45]
\draw[-,color=black] (0,0) -- (6,0);
\foreach \x in {1.0,2.0,3.0,4.0,5.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\node[below] at (2,0){$\alpha$};
\node[below] at (4,0){$\beta$};
\draw [fill=black]    (2.0,1.66)coordinate(a) circle (1.5pt);
\draw [fill=black]    (4.0,1.66)coordinate(b) circle (1.5pt);
\draw [draw]   (4.0,0.82)coordinate(c) circle (2.0pt);
\draw [draw]   (2.0,2.57)coordinate(d) circle (2.0pt);

\draw ($(a)-(1,0)$) to[out=0,in=-100,looseness=0.5](d);
\draw (a) to[bend right=50,looseness=1.5]node[above]{$c_f$} ($(a)!0.5!(b)$) to[bend left=50,looseness=1.5] (b);
\draw (c) to[bend right=50, looseness=1.5] ++(1,0);
\draw[dashed](2,0)--(d);
\draw[dashed](4,0)--(b);
\end{tikzpicture}

\vspace{1cm}

Geogebra output, 

%dash pattern=on 1pt off 1pt is changed to dashed options

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (0.7333308390918073,0.0) -- (5.239998617966438,0.0);
\foreach \x in {,1.0,2.0,3.0,4.0,5.0}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt);
\clip(0.7333308390918073,-0.6933333333333337) rectangle (5.239998617966438,3.040000000000002);
\draw[smooth,samples=100,domain=2.0400031082342736:4.039997101821316] plot(\x, {((\x)-3.04)^(5)-2*((\x)-3.04)^(3)+(\x)-3.04+1.0+0.66});
\draw [line width=1.2000000000000002pt, dashed] (2.04,1.6600000000000001)-- (2.04,0.0);
\draw [line width=1.2000000000000002pt,dashed] (4.04,1.6600000000000001)-- (4.04,0.0);
\draw (1.933331135241857,-0.026666666666666682) node[anchor=north west] {$a$};
\draw (3.9333316288252727,-0.04000000000000002) node[anchor=north west] {$\beta$};
\draw[smooth,samples=100,domain=4.066665128397554:5.066663234885912] plot(\x,{((\x)-0.013333333333333641-5.05333)^(5)-2.0*((\x)-0.013333333333333641-5.05333)^(3)+(\x)-0.013333333333333641-5.05333-1.0+1.8000033333333345});
\draw [line width=1.2pt,dashed] (2.04,1.66)-- (2.04,2.84);
\draw[smooth,samples=100,domain=1.040000568108668:2.039999103789556] plot(\x,{((\x)-1.04)^(2)+1.5733333333333346});
\begin{scriptsize}
\draw [fill=black] (2.04,1.6600000000000001) circle (1.5pt);
\draw [fill=black] (4.04,1.6600000000000001) circle (1.5pt);
\draw [color=black] (4.04,0.8181088825214906) circle (2.0pt);
\draw [color=black] (2.0399999999999996,2.5733333333333337) circle (2.0pt);
\end{scriptsize}
\end{tikzpicture}

\end{document}
  • Thank you.. very much.. I thought as much that the errors were coming from dashed-pattern but I could not figure them out.. Thank you for the link also. – Tolaso Nov 12 '14 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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