3

I've looked at this answer, but it doesn't seem to work:

Dimension too large, <to be read again> error

\documentclass[10pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}

%<<<<<<<WARNING>>>>>>> % PGF/Tikz doesn't support the following mathematical functions: % cosh, acosh, sinh, asinh, tanh, atanh, % x^r with r not integer

% Plotting will be done using GNUPLOT % GNUPLOT must be installed and you must allow Latex to call external % programs by adding the following option to your compiler % shell-escape OR enable-write18 % Example: pdflatex --shell-escape file.tex

\begin{document} \definecolor{wrwrwr}{rgb}{0.3803921568627451,0.3803921568627451,0.3803921568627451} \definecolor{dtsfsf}{rgb}{0.8274509803921568,0.1843137254901961,0.1843137254901961} \definecolor{rvwvcq}{rgb}{0.08235294117647059,0.396078431372549,0.7529411764705882} \definecolor{sexdts}{rgb}{0.1803921568627451,0.49019607843137253,0.19607843137254902} \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm] \begin{axis}[ x=1cm,y=1cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin=1.3267631992181441, xmax=3.0815031792940615, ymin=-1.2315594843495015, ymax=0.428590551805931, xtick={1.4000000000000001,1.5000000000000002,...,3}, ytick={-1.2000000000000002,-1.1,...,0.4},] \clip(1.3267631992181441,-1.2315594843495015) rectangle (3.0815031792940615,0.428590551805931); \draw[line width=0.8pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] {[smooth,samples=50,domain=2.475353221098382:3.1415926535899534] plot(\x,{sin(((\x))180/pi)+cos(((\x))180/pi)})} -- (3.1415926535899534,-1.6019374007595787E-13) {-- plot[raw gnuplot, id=func0] function{set parametric ; set samples 100; set trange [2.475353221098382:3.1415926535899534]; plot 5.616945874688335-t,sin((5.616945874688335-t)180/pi)+tan((5.616945874688335-t)180/pi)}} -- (2.475353221098382,-0.1681173890090787) -- cycle; \draw[line width=0.8pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.10000000149011612] { plot[raw gnuplot, id=func1] function{set samples 100; set xrange [3.1415926535899534:3.9269908169715837]; plot sin((x)180/pi)+tan((x)180/pi)}} -- (3.9269908169715837,0.292893218771065) {-- plot[raw gnuplot, id=func2] function{set parametric ; set samples 100; set trange [3.1415926535899534:3.9269908169715837]; plot 7.068583470561537-t,cos((7.068583470561537-t)180/pi)+tan((7.068583470561537-t)180/pi)}} -- (3.1415926535899534,-1.6019374007595787E-13) -- cycle; \draw[line width=2pt,color=sexdts,smooth,samples=100,domain=1.3267631992181441:3.0815031792940615] plot(\x,{sin(((\x))180/pi)+cos(((\x))180/pi)}); \draw[line width=2pt,color=rvwvcq,smooth,samples=100,domain=1.3267631992181441:3.0815031792940615] plot(\x,{sin(((\x))180/pi)+tan(((\x))180/pi)}); \draw[line width=2pt,color=dtsfsf,smooth,samples=100,domain=1.3267631992181441:3.0815031792940615] plot(\x,{cos(((\x))180/pi)+tan(((\x))180/pi)}); \begin{scriptsize} \draw[color=sexdts] (2.100856413751085,0.296357671019132) node {$f$}; \draw[color=rvwvcq] (2.0101272838681714,-1.0529968351118533) node {$g$}; \draw[color=dtsfsf] (2.9811220143172217,-1.081952940393634) node {$h$}; \draw [fill=wrwrwr] (2.475353221098382,-0.1681173890090787) circle (2.5pt); \draw[color=wrwrwr] (2.490798631545733,-0.1264014660948676) node {$A$}; \draw [fill=wrwrwr] (3.1415926535899534,-1.00000000000016) circle (2.5pt); \draw[color=wrwrwr] (3.1567890530266918,-0.9584068911913692) node {$B$}; \draw [fill=wrwrwr] (3.9269908169715837,0.2928932187932085) circle (2.5pt); \draw[color=wrwrwr] (3.9424647096723446,0.3349658113948398) node {$C$}; \draw[color=rvwvcq] (2.8575759651149566,-0.28083402759769854) node {$a = -0.377$}; \draw[color=rvwvcq] (3.461793361994783,-0.2750428065413424) node {$b = 0.414$}; \end{scriptsize} \end{axis} \end{tikzpicture} \end{document}

This is an export from GeoGebra with complex functions

And I receive the following error:

(c:/texlive/2022/texmf-dist/tex/latex/jknapltx/ursfs.fd)
! Dimension too large.
<to be read again> 
                   \relax 
l.55 \end{axis}

?

I've tried reducing the number of decimal places, scaling the tikzpicture down, but to no avail.

  • Just out of idle curiosity: Is there something you're trying to gain by writing xtick={1.4000000000000001,1.5000000000000002,...,3} instead of xtick={1.4,1.5,...,3}? Likewise, what is the advantage of writing -1.6019374007595787E-13 instead of 0? Ditto for dozens of similar issues. – Mico Nov 19 '23 at 21:45
  • 2
    tan(((pi/2)*180/pi) is not defined try to change domain=1.3267631992181441:3.0815031792940615: by domain=1.58:3.08 – Manuel Cart Nov 19 '23 at 21:48
  • Changing the domain doesn't seem to work – John Smith Nov 19 '23 at 22:08
  • @Mico It was generated by GeoGebra – John Smith Nov 19 '23 at 22:10
  • @ManuelCart Thank you very much! How did you work that out? – John Smith Nov 19 '23 at 22:51
  • @JohnSmith - pi/2 \approx 1.571. Making the domain start at 1.58 avoids any complications. – Mico Nov 19 '23 at 23:21

1 Answers1

5

As @ManuelCart has already pointed out in a comment, the immediate cause of the error is that tan(90 degrees)=tan(((pi/2)*180/pi) isn't defined. You must restrict the domain of the functions that involve tan(((\x))*180/pi)}) to start at no less than 1.58. (1.571 would be ok too...)

There are quite a few formatting choices in your code that are, shall we say, unusual. I suggest you clip the image so that its lower-left point is (1.5,-2.0) and its upper-right point is (4.0,0.5). And, I'd like to suggest that you make the labels for the three main curves a bit more informative than just "f", "g", and "h"; see the following screenshot for a specific alternative suggestion. Finally, the 2nd of the 5 \draw directives doesn't appear to do anything; is it redundant?

enter image description here

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
%\usepackage{mathrsfs} % why?
\usetikzlibrary{arrows}
\pagestyle{empty}

\definecolor{wrwrwr}{rgb}{0.3804,0.3804,0.3804} \definecolor{dtsfsf}{rgb}{0.8275,0.1843,0.1843} \definecolor{rvwvcq}{rgb}{0.0824,0.3961,0.7529} \definecolor{sexdts}{rgb}{0.1804,0.4902,0.1961}

\begin{document}

\begin{tikzpicture}[line cap=round, line join=round, >=triangle 45, x=3cm, y=3cm] \begin{axis}[ x=3cm, y=3cm, axis lines=middle, ymajorgrids=true, xmajorgrids=true, xmin= 1.5, xmax= 4.0, ymin=-2.0, ymax= 0.5, xtick={1.5,2,...,4}, ytick={-2.0,-1.5,...,0.5},] \clip(1.5,-2.0) rectangle (4,0.5); % is this instruction needed?

\draw[line width=0.5pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.1] {[smooth,samples=50,domain=2.475:3.142] plot(\x,{sin(\x180/pi)+cos(\x180/pi)})} -- (3.142,0) { -- plot[raw gnuplot, id=func0] function{set parametric ; set samples 100; set trange [2.5:4.0]; plot 5.617-t,sin((5.617-t)180/pi)+tan((5.617-t)180/pi)}} -- (2.475,-0.168) -- cycle; %% Q: What is the following '\draw' instruction supposed to do? %\draw[line width=0.5pt,color=rvwvcq,fill=rvwvcq,fill opacity=0.1] % { plot[raw gnuplot, id=func1] % function{set samples 100; set xrange [3.142:4]; % plot sin(x180/pi)+tan(x180/pi)}} -- (3.927,0.293) % {-- plot[raw gnuplot, id=func2] % function{set parametric ; set samples 100; set trange [3.142:4.0]; % plot 7.069-t,cos((7.069-t)180/pi)+tan((7.069-t)180/pi)}} % -- (3.142,0) -- cycle; \draw[line width=0.5pt,color=sexdts,smooth,samples=100,domain=1.50:4.0] plot(\x,{sin(\x180/pi)+cos(\x180/pi)}); \draw[line width=0.5pt,color=rvwvcq,smooth,samples=100,domain=1.58:4.0] plot(\x,{sin(\x180/pi)+tan(\x180/pi)}); \draw[line width=0.5pt,color=dtsfsf,smooth,samples=100,domain=1.58:4.0] plot(\x,{cos(\x180/pi)+tan(\x180/pi)});

\scriptsize % labels for the three main curves \draw[color=sexdts] (2.60, 0.28) node {$f(x)=\sin x+\cos x$}; % not just "f", "g", etc \draw[color=rvwvcq] (2.47,-1.09) node {$g(x)=\sin x+\tan x$}; \draw[color=dtsfsf] (2.71,-1.83) node {$h(x)=\cos x+\tan x$}; % labels for the three intersection points A, B, and C \draw[fill =wrwrwr] (2.475,-0.168) circle (1.25pt); \draw[color=wrwrwr] (2.39,-0.16) node {$A$}; \draw[fill =wrwrwr] (3.142,-1.000) circle (1.25pt); \draw[color=wrwrwr] (3.23,-1.00) node {$B$}; \draw[fill =wrwrwr] (3.927, 0.293) circle (1.25pt); \draw[color=wrwrwr] (3.87, 0.32) node {$C$}; % no idea about the next two instructions \draw[color=rvwvcq] (2.87,-0.30) node {$a =-0.38$}; \draw[color=rvwvcq] (3.42,-0.30) node {$b = 0.41$}; \end{tikzpicture}

\end{document}

Mico
  • 506,678