Computation problems

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

Computation problems

by xlogo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I encounter a new problem with computation
Here is my code:

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

I know it's easy to draw this axis writing:
\foreach \x in {-3.6 -2.4 -1.2 0 1.2 2.4 3.6}

What interests me is if this computation problem  is a bug and if it is
possible to solve it in a near future.  Or is this approximation with
mathematical expression is part of pgf and pdf features and cannot be
solved?

Thanks in advance,
Best regards

Loïc



-------------------------------------------------------------------------
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

Re: Computation problems

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/7/22 Loïc <xlogo@...>:
>
>
> What interests me is if this computation problem  is a bug and if it is
> possible to solve it in a near future.  Or is this approximation with
> mathematical expression is part of pgf and pdf features and cannot be
> solved?
>

In this case, the foreach loop is actually using native TeX
arithmetic. As is pointed out in the manual, TeX is not good with
numbers that are not multiples of 2^-n. This can be seen with a simple
example:

\newdimen\mydimen
\mydimen=-3.6pt
\advance\mydimen by1.2pt

Unfortunately there isn't a lot that can be done about it currently,
so the ``long hand'' method is really the only option.

Sorry

Mark

-------------------------------------------------------------------------
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

Re: Computation problems

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/7/22 Mark Wibrow <m.wibrow@...>:
>
> \newdimen\mydimen
> \mydimen=-3.6pt
> \advance\mydimen by1.2pt
>

I missed out the line

\the\mydimen

This gives -2.40001pt on my system.

-Mark

-------------------------------------------------------------------------
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

Re: Computation problems

by xlogo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Many thanks for your answer.
I explain why it's important for me:

I have written a PGF/TikZ export for the dynamic geometry software
called GeoGeBra (http://www.geogebra.org) and I'm finalizing it.

As I explain before here on the list:

http://www.nabble.com/Plotting-Problem-to18545611.html

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.

Am I right?

Loïc




Le mardi 22 juillet 2008 à 17:19 +0100, Mark Wibrow a écrit :

> 2008/7/22 Mark Wibrow <m.wibrow@...>:
> >
> > \newdimen\mydimen
> > \mydimen=-3.6pt
> > \advance\mydimen by1.2pt
> >
>
> I missed out the line
>
> \the\mydimen
>
> This gives -2.40001pt on my system.
>
> -Mark
>


Le mardi 22 juillet 2008 à 17:17 +0100, Mark Wibrow a écrit :

> 2008/7/22 Loïc <xlogo@...>:
> >
> >
> > What interests me is if this computation problem  is a bug and if it is
> > possible to solve it in a near future.  Or is this approximation with
> > mathematical expression is part of pgf and pdf features and cannot be
> > solved?
> >
>
> In this case, the foreach loop is actually using native TeX
> arithmetic. As is pointed out in the manual, TeX is not good with
> numbers that are not multiples of 2^-n. This can be seen with a simple
> example:
>
> \newdimen\mydimen
> \mydimen=-3.6pt
> \advance\mydimen by1.2pt
>
> Unfortunately there isn't a lot that can be done about it currently,
> so the ``long hand'' method is really the only option.
>
> Sorry
>
> Mark
>



-------------------------------------------------------------------------
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

Re: Computation problems

by TeXWorld :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Loïc a écrit :
> Many thanks for your answer.
> I explain why it's important for me:
>
> I have written a PGF/TikZ export for the dynamic geometry software
> called GeoGeBra (http://www.geogebra.org) and I'm finalizing it.
>
>  
Is it a PGF or a TikZ export ?

> As I explain before here on the list:
>
> http://www.nabble.com/Plotting-Problem-to18545611.html
>
> 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.
>
> Am I right?
>
> Loïc
>
>  
Yes.


-------------------------------------------------------------------------
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

Re: Computation problems

by xlogo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le mercredi 23 juillet 2008 à 01:08 +0200, TeXWorld a écrit :
> Loïc a écrit :
> > Many thanks for your answer.
> > I explain why it's important for me:
> >
> > I have written a PGF/TikZ export for the dynamic geometry software
> > called GeoGeBra (http://www.geogebra.org) and I'm finalizing it.
> >
> >  
> Is it a PGF or a TikZ export ?

All instruction are inside a "tikzpicture" environment.

Loïc



-------------------------------------------------------------------------
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