8

I'm trying to draw a smooth third grade spiral (r^3 = a^3\cdot \varphi) over $60\times 60$mm grid and I'm getting the "Dimension too large"-error if I set $a > 320$ but I need to fill the grid area completely:

\begin{tikzpicture}[x=1mm, y=1mm]

    \draw[step=1, line width=0.1mm, opacity=0.3] (-30, -30) grid (30, 30);

    \draw [domain=0:50, variable=\t, samples=1000] 
        plot ({\t r}:{pow(320*\t, 1/3)});
\end{tikzpicture}

output_mwe

Is there any way to avoid this error?

14

A different math library helps. For example, library fixedpointarithmetic uses package fp for the fixed point calculations with a much larger number range.

\documentclass{article}
\usepackage{tikz}
\usepackage{fp}
\usetikzlibrary{fixedpointarithmetic}

\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]

    \draw[step=1, line width=0.1mm, opacity=0.3] (-30, -30) grid (30, 30);

    \draw [domain=0:50, variable=\t, samples=1000]
        plot[fixed point arithmetic] ({\t r}:{pow(600*\t, 1/3)});
\end{tikzpicture}
\end{document}

Result

11

I would use pgfplots for this for increased math precision and more flexibility for other issues

I've deliberately drew a strange grid and axes lines to show some options other than what you have. And you can change the values to much bigger range.

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both,xmax=100,ymax=100,xmin=-100,ymin=-100,
axis equal,
xtick={-100,-80,...,100},
ytick={-100,-80,...,100},
minor x tick num=4,
xticklabels={},
yticklabels={}]
\addplot+[no marks,data cs=polar,domain=0:100, samples=1000] 
({deg(x)},{(320*deg(x))^(1/3)});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

10

Mathematically, pow(600*\t,1/3) is equivalent to pow(600,1/3)*pow(\t,1/3)...

Just TikZ and its default math engine:

enter image description here

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]
  \draw[step=1, line width=0.1mm, opacity=0.3] (-30, -30) grid (30, 30);

  \draw [domain=0:50, variable=\t, samples=1000] 
  plot ({\t r}:{pow(600,1/3)*pow(\t,1/3)});
\end{tikzpicture}
\end{document}

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.