2

I try many changes in this code, but I don't see the error. Can someone help me?

\documentclass[10pt]{article}

\usepackage{pgf,tikz}

\usetikzlibrary{arrows}

\pagestyle{empty}

\begin{document}

\definecolor{ffffqq}{rgb}{1,1,0}

\definecolor{qqccqq}{rgb}{0,0.8,0}

\definecolor{ffttzz}{rgb}{1,0.2,0.6}

\definecolor{ttttff}{rgb}{0.2,0.2,1}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]

\draw[->,color=black] (-1.11,0) -- (1.09,0);
\foreach \x in {-1,-0.8,-0.6,-0.4,-0.2,0.2,0.4,0.6,0.8,1}

\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};

\draw[->,color=black] (0,-0.03) -- (0,1.14);
\foreach \y in {,0.2,0.4,0.6,0.8,1}

\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};

\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-1.11,-0.03) rectangle (1.09,1.14);

\draw[color=ttttff, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0.1*2.718281828^((-1)/0.1)*(1-2.718281828^((1-abs((\x)))/0.1))});

\draw (0.62,0.98) node[anchor=north west] {$$\varepsilon= 1/10$$};

\draw[color=ffttzz, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0*(1-2.718281828^((1-abs((\x)))/0.05))});

\draw [line width=1.2pt,color=ffttzz] (0.57,0.86)-- (0.46,0.86);

\draw (0.62,0.91) node[anchor=north west] {$$\varepsilon= 1/20$$};

\draw[color=qqccqq, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0*(1-2.718281828^((1-abs((\x)))/0.03))});

\draw [line width=1.2pt,color=qqccqq] (0.58,0.72)-- (0.47,0.72);

\draw (0.62,0.78) node[anchor=north west] {$$\varepsilon= 1/40$$};

\draw[color=ffffqq, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0*(1-2.718281828^((1-abs((\x)))/0.04))});

\draw [line width=1.2pt,color=ffffqq] (0.57,0.78)-- (0.47,0.78);

\draw (0.62,0.85) node[anchor=north west] {$$\varepsilon= 1/25$$};

\draw (-1,0)-- (0,1);

\draw (1,0)-- (0,1);

\draw [line width=1.2pt,color=ttttff] (0.44,0.97)-- (0.45,0.67);

\draw [line width=1.2pt,color=ttttff] (0.45,0.67)-- (0.84,0.66);

\draw [line width=1.2pt,color=ttttff] (0.84,0.66)-- (0.84,0.97);

\draw [line width=1.2pt,color=ttttff] (0.84,0.97)-- (0.44,0.97);

\draw [line width=1.2pt,color=ttttff] (0.57,0.92)-- (0.46,0.92);

\end{tikzpicture}

\end{document}
4
  • 1
    Welcome! Is there a problem? Do you get an error? If so, what is it?
    – cfr
    Jul 28, 2015 at 2:29
  • @AboAmmar Your edit changes the question. The first source of errors involves the blank lines which you've deleted. Consequently, my answer now makes no sense.
    – cfr
    Jul 28, 2015 at 2:44
  • @cfr Sorry for that, Sublime Text 2 did the job before reading your answer!
    – AboAmmar
    Jul 28, 2015 at 2:49
  • @AboAmmar No problem. I learnt how to rollback an edit!
    – cfr
    Jul 28, 2015 at 3:14

2 Answers 2

0

There are several issues.

Two are easy to solve.

First, do not leave blank line after a \foreach. TikZ wants to read onto the end of the loop without any paragraph breaks.

Second, never use $$ in LaTeX documents. Here, it confuses TikZ but it is, in any case, bad. In this case, just change the $$s to $s.

The third is less easy to solve and you will need to make decide what you meant and what you need to do. The plots you are specifying are exceeding the largest dimension with which TeX can cope. To make the code compile, I had to comment these out:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{ffffqq}{rgb}{1,1,0}
\definecolor{qqccqq}{rgb}{0,0.8,0}
\definecolor{ffttzz}{rgb}{1,0.2,0.6}
\definecolor{ttttff}{rgb}{0.2,0.2,1}

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
  \draw[->,color=black] (-1.11,0) -- (1.09,0);
  \foreach \x in {-1,-0.8,-0.6,-0.4,-0.2,0.2,0.4,0.6,0.8,1}
  \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
  \draw[->,color=black] (0,-0.03) -- (0,1.14);
  \foreach \y in {,0.2,0.4,0.6,0.8,1}
  \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
  \draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
  \clip(-1.11,-0.03) rectangle (1.09,1.14);

%   \draw[color=ttttff, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0.1*2.718281828^((-1)/0.1)*(1-2.718281828^((1-abs((\x)))/0.1))});

  \draw (0.62,0.98) node[anchor=north west] {$\varepsilon= 1/10$};

%   \draw[color=ffttzz, smooth,samples=100,domain=-1:1] plot(\x,{1-abs((\x))+0*(1-2.718281828^((1-abs((\x)))/0.05))});

  \draw [line width=1.2pt,color=ffttzz] (0.57,0.86)-- (0.46,0.86);
  \draw (0.62,0.91) node[anchor=north west] {$\varepsilon= 1/20$};

%   \draw[color=qqccqq, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0*(1-2.718281828^((1-abs((\x)))/0.03))});

  \draw [line width=1.2pt,color=qqccqq] (0.58,0.72)-- (0.47,0.72);
  \draw (0.62,0.78) node[anchor=north west] {$\varepsilon= 1/40$};

%   \draw[color=ffffqq, smooth,samples=100,domain=-1.0:1.0] plot(\x,{1-abs((\x))+0*(1-2.718281828^((1-abs((\x)))/0.04))});

  \draw [line width=1.2pt,color=ffffqq] (0.57,0.78)-- (0.47,0.78);
  \draw (0.62,0.85) node[anchor=north west] {$\varepsilon= 1/25$};
  \draw (-1,0)-- (0,1);
  \draw (1,0)-- (0,1);
  \draw [line width=1.2pt,color=ttttff] (0.44,0.97)-- (0.45,0.67);
  \draw [line width=1.2pt,color=ttttff] (0.45,0.67)-- (0.84,0.66);
  \draw [line width=1.2pt,color=ttttff] (0.84,0.66)-- (0.84,0.97);
  \draw [line width=1.2pt,color=ttttff] (0.84,0.97)-- (0.44,0.97);
  \draw [line width=1.2pt,color=ttttff] (0.57,0.92)-- (0.46,0.92);
\end{tikzpicture}
\end{document}
1
  • Hi cfr, tks for the 2 issues. I Try many values for de samples, but doesn't work... :( Jul 28, 2015 at 2:44
0

enter image description here

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows,calc}
\usepackage{calc}
\pagestyle{empty}
\begin{document}

\definecolor{ffffqq}{rgb}{1,1,0}
\definecolor{qqccqq}{rgb}{0,0.8,0}
\definecolor{ffttzz}{rgb}{1,0.2,0.6}
\definecolor{ttttff}{rgb}{0.2,0.2,1}

\footnotesize
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=6.0cm,y=6.0cm]

\draw[->,color=black] (-1.11,0) -- (1.09,0);
\foreach \x in {-1,-0.8,-0.6,-0.4,-0.2,0.2,0.4,0.6,0.8,1}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {$\x$};

\draw[->,color=black] (0,-0.03) -- (0,1.14);
\foreach \y in {,0.2,0.4,0.6,0.8,1}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {$\y$};

\draw[color=black] (0pt,-10pt) node[right] {$0$};
\clip(-1.11,-0.03) rectangle (1.09,1.14);
\draw[color=ttttff, smooth,samples=100,domain=-1:-.1] plot(\x,{1-abs((\x))+0.1*2.718281828^((-1)/0.1)*(1-2.718281828^((1-abs(\x))/0.1))});

\draw (0.62,0.98) node[anchor=north west] {$\varepsilon= 1/10$};
\draw[color=ffttzz, smooth,samples=100,domain=-1:1] plot(\x,{1-abs(\x)});
\draw [line width=1.2pt,color=ffttzz] (0.57,0.86)-- (0.46,0.86);

\draw (0.62,0.91) node[anchor=north west] {$\varepsilon= 1/20$};
\draw[color=qqccqq, smooth,samples=100,domain=-1:1] plot(\x,{1-abs((\x))});

\draw [line width=1.2pt,color=qqccqq] (0.58,0.72)-- (0.47,0.72);
\draw (0.62,0.78) node[anchor=north west] {$\varepsilon= 1/40$};
\draw[color=ffffqq, smooth,samples=100,domain=-1:1] plot(\x,{1-abs((\x))});
\draw [line width=1.2pt,color=ffffqq] (0.57,0.78)-- (0.47,0.78);
\draw (0.62,0.85) node[anchor=north west] {$\varepsilon= 1/25$};

\draw (-1,0)-- (0,1);
\draw (1,0)-- (0,1);

\draw [line width=1.2pt,color=ttttff] (0.44,0.97)-- (0.45,0.67);
\draw [line width=1.2pt,color=ttttff] (0.45,0.67)-- (0.84,0.66);
\draw [line width=1.2pt,color=ttttff] (0.84,0.66)-- (0.84,0.97);
\draw [line width=1.2pt,color=ttttff] (0.84,0.97)-- (0.44,0.97);
\draw [line width=1.2pt,color=ttttff] (0.57,0.92)-- (0.46,0.92);

\end{tikzpicture}

\end{document}

Besides the notes mentioned by @cfr, I think the real problem here is the inclusion of 0 in the domain of the first expression:

plot(\x,{1-abs((\x))+0.1*2.718281828^((-1)/0.1)*(1-2.718281828^((1-abs(\x))/0.1))})

The last parenthesis in the above expression, 2.718281828^((1-abs(\x))/0.1)), calculates to 22026.4657576099 > 16383.99999 if \x = 0. The pgfmanual says the following:

It Should be Noted did all calculations must not exceed ± 16383.99999 at any point, Because The underlying computations rely on TeX dimensions. This Means thatmany of the underlying computations are Necessarily approximate and That in addition, are not very fast. TeX is, after all, a typesetting language and not ideally suited to Relatively advanced mathematical operations. HOWEVER, it is Possible to Change the computations as described in Section 76th

It is according to the TeX Book

16383.99998 pt (TeX's Largest Dimen)

To get around this, you can make two plots each on half of this domain, that is, -1:-.1 and .1:1, for example.

To enlarge the picture use x=6.0cm,y=6.0cm and also set \footnotesize globally.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .