Re: New number systems compute cyclic path strangely

luigi scarso <[email protected]> Mon, 29 Apr 2024 20:11:38 +0200
Newsgroups gmane.comp.tex.metapost
Message-ID <CAG5iGsC48EkvKpVKAPCDXoe1sT5W2Ef0jasPejnpaYPo+=asCQ@mail.gmail.com>
--===============4590648522888106669==
Content-Type: multipart/alternative; boundary="000000000000e9f93e0617402fc8"

--000000000000e9f93e0617402fc8
Content-Type: text/plain; charset="UTF-8"

On Sun, 28 Apr 2024 at 17:21, Toby Thurston <[email protected]> wrote:

> This recent question on TexSE seems to have uncovered an anomaly in the
> way that MP computes the `arclength` of cyclic paths when using any of the
> new number systems.
>
> https://tex.stackexchange.com/q/716630/15036
>
>
> The poster supplied this example code
>
> beginfig(1);
> path p;
> p = (0,0){up}..{right}(200,100)..{up}(300,400)..cycle;
> len := arclength p;
> s := arctime (2500) of p;
> t := arctime (len+2500) of p;
> draw p;
> show len;% 2799
> show s;% 2.92...
> show t;% 2.67...
> show arctime arclength p of p;
> show numbersystem;
>
> endfig;
> end
>
> With the default number system the value of t is 5.92... as you might
> expect, but with any of the new number systems the value is 2.67.....
>
> The original poster as TeX.SE was using MP 2.02 but I I see this behaviour
> with  MetaPost, version 2.10 (TeX Live 2024).
>
> Toby
> --
> http://tug.org/metapost/


Hm I fear that
 @<Update |arc| and |t_tot| after |do_arc_test| has just returned |t|@>;
implicitly uses the fact that scaled is an integer type, i.e.
set_number_from_div (n1, arc, d1); /* n1 = (arc / d1) */
and
number_add (v1, epsilon_t);       /* v1 = n1+1 */
look suspicious in double mode  ( epsilon_t is not 1 but 2^-52, 1 is unity
)

--
luigi

--000000000000e9f93e0617402fc8
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Sun, 28 Apr 2024 at 17:21, Toby Th=
urston &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote=
:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>This rece=
nt question on TexSE seems to have uncovered an anomaly in the way that MP =
computes the `arclength` of cyclic paths when using any of the new number s=
ystems. =C2=A0<div><br></div><div><a href=3D"https://tex.stackexchange.com/=
q/716630/15036" target=3D"_blank">https://tex.stackexchange.com/q/716630/15=
036</a></div><div><br></div><div><br>The poster supplied this example code<=
/div><div><br></div><div><div><font face=3D"Courier New">beginfig(1);</font=
></div><div><font face=3D"Courier New">path p;</font></div><div><font face=
=3D"Courier New">p =3D (0,0){up}..{right}(200,100)..{up}(300,400)..cycle;</=
font></div><div><font face=3D"Courier New">len :=3D arclength p;</font></di=
v><div><font face=3D"Courier New">s :=3D arctime (2500) of p;</font></div><=
div><font face=3D"Courier New">t :=3D arctime (len+2500) of p;</font></div>=
<div><font face=3D"Courier New">draw p;</font></div><div><font face=3D"Cour=
ier New">show len;% 2799</font></div><div><font face=3D"Courier New">show s=
;% 2.92...</font></div><div><font face=3D"Courier New">show t;% 2.67...</fo=
nt></div><div><font face=3D"Courier New">show arctime arclength p of p;</fo=
nt></div><div><font face=3D"Courier New">show numbersystem;</font></div><di=
v><font face=3D"Courier New"><br></font></div><div><font face=3D"Courier Ne=
w">endfig;</font></div><div><font face=3D"Courier New">end</font></div></di=
v><div><br></div><div><div>With the default number system the value of t is=
 5.92... as you might expect, but with any of the new number systems the va=
lue is 2.67.....</div></div><div><br></div><div>The original poster as TeX.=
SE was using MP 2.02 but I I see this behaviour with=C2=A0<span style=3D"fo=
nt-family:inherit;font-style:inherit;font-variant-caps:inherit;white-space:=
inherit;color:rgb(12,13,14)"> MetaPost, version 2.10 (TeX Live 2024).</span=
></div><div><span style=3D"font-family:inherit;font-style:inherit;font-vari=
ant-caps:inherit;white-space:inherit;color:rgb(12,13,14)"><br></span></div>=
<div><span style=3D"font-family:inherit;font-style:inherit;font-variant-cap=
s:inherit;white-space:inherit;color:rgb(12,13,14)">Toby</span></div></div>-=
-<br>
<a href=3D"http://tug.org/metapost/" rel=3D"noreferrer" target=3D"_blank">h=
ttp://tug.org/metapost/</a></blockquote><div><br></div><div>Hm I fear that=
=C2=A0</div><div>=C2=A0@&lt;Update |arc| and |t_tot| after |do_arc_test| ha=
s just returned |t|@&gt;;</div><div>implicitly=C2=A0uses the fact that scal=
ed is an integer type, i.e.</div><div>set_number_from_div (n1, arc, d1); /*=
 n1 =3D (arc / d1) */<br></div><div>and=C2=A0</div><div>number_add (v1, eps=
ilon_t); =C2=A0 =C2=A0 =C2=A0 /* v1 =3D n1+1 */<br></div><div>look suspicio=
us in double mode=C2=A0 ( epsilon_t is not 1 but 2^-52, 1 is unity=C2=A0 )<=
/div><div><br></div><div>--</div><div>luigi</div></div></div>

--000000000000e9f93e0617402fc8--

--===============4590648522888106669==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
http://tug.org/metapost/

--===============4590648522888106669==--