2

I am trying to plot the function f(x) using \datavisualization like this

\datavisualization [school book axes,
                visualize as smooth line,
                y axis={label},
                x axis={label} ]
data [format=function] {
  var x : interval [0:60] samples 60;
  func y = -(1/300000)*(\value x)^4 + (113/240000)*(\value x)^3 - (1063/48000)*(\value x)^2 + (1253/3200)*(\value x) - (871/640);
};

However, I get an error telling me the plot is too large (Dimension too large.<to be read again>\relax l.87 };).

How can I properly plot this function?

Philipp
  • 255

1 Answers1

0

The tikz user guide has the following to say about number accuracy:

enter image description here

This means that by using (...) you fall back to the tex accuracy and run into problems with too large numbers.

You can avoid the problem with this trick taken from Is it possible to plot complicated functions with TikZ datavisualization?

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{datavisualization.formats.functions} \newcommand{\pgfmathparseFPU}[1]{\begingroup% \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}% \pgfmathparse{#1}% \pgfmathsmuggle\pgfmathresult\endgroup}

\begin{document}

\begin{tikzpicture} \datavisualization [school book axes, visualize as smooth line, y axis={label}, x axis={label}, /pgf/data/evaluator=\pgfmathparseFPU, x axis={length=.8\linewidth, ticks=few} ] data [format=function] { var x : interval [0:60] samples 60; func y = -1/300000(\value x)^4 + 113/240000(\value x)^3 - 1063/48000(\value x)^2 + 1253/3200(\value x) - (871/640); };

\end{tikzpicture}

\end{document}

enter image description here