Computation problems

View: New views
1 Messages — Rating Filter:   Alert me  

Computation problems

by Christian Feuersaenger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Concerning rounding problems during PGF math operations: what if you just round the desired number to
- say - 2 digits?

That means your example now looks like

\documentclass[10pt]{article}
\usepackage{tikz,pgf}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[/pgf/number format/fixed]
\draw [->] (-4,0)--(4,0);
\foreach \x in {-3.6,-2.4,...,3.6}
        \draw[xshift=\x cm] (0,-2pt) -- (0,2pt) node [above] {\pgfmathprintnumber\x};
\end{tikzpicture}
\end{document}

I guess this is the only solution to your problem. And in fact, it is the same solution which gnuplot offers: it has also rounding inaccuracies, but it rounds to the desired number of digits so now-one ever sees them (of course it works with a relative precision of 10^-16, which is somewhat more precise than an absolute precision of 10^-5 of TeX).

> The fact that TeX arithmetic isn't very good makes me think that to plot
> functions, it's better to use the GnuPlot method than the native plot
> command.

I have tested your example from
  http://www.nabble.com/Plotting-Problem-to18545611.html
and it worked correctly. Maybe the bug has been fixed in the meantime?

Concerning the question as such: surely GNUPlot offers higher precision. But you can use the 'plot function'
method to invoke gnuplot as "desktop calculator", allowing you to benefit from the result. Of course, this will only
work if the resulting numbers are within TeX accuracy (-16000 ... 16000 max and 0.00001 min) and the relative accuracy
drops dramatically if you use small numbers.

The high-level plot frontend pgfplots supports 'plot function' for those accuracies, see
  http://pgfplots.sourceforge.net/pgfplots.pdf .

Regards,

Christian

--
Christian Feuersaenger
Institut fuer Numerische Simulation
Rheinische Friedrich-Wilhelms Universitaet Bonn
Wegelerstrasse 6
D-53115 Bonn
Germany

Tel:  +49 228 733848
URL:  http://wissrech.ins.uni-bonn.de/people/feuersaenger.html

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users
LightInTheBox - Buy quality products at wholesale price