[metapost] Metafun : is "atan" the arctangent function?
John Kitzmiller
jkitzm at gmail.com
Sun Jan 12 20:30:49 CET 2014
On Jan 12, 2014, at 2:02 PM, "Daniel H. Luecking" <luecking at uark.edu> wrote:
> On Jan 12, 2014, at 9:32am, jkitzm wrote:
>
>> atan is vardef'd in mp-tool.mpiv as: x-(x**3)/3+(x**5)/5-(x**7)/7 ,
>> part of the infinite series form. Maybe better to use asin(a/sqrt(a**2+1))?
>
> The functions asin and acos are similarly defined in mp-tool:
>
> vardef asin primary x = (x+(x**3)/6+3(x**5)/40) enddef ;
> vardef acos primary x = (asin(-x)) enddef ;
>
> (That second one is just wrong, it should be (90-asin(x)).)
> But those functions are redefined a few lines later using "angle":
>
> vardef asin primary x = angle((1+-+x,x)) enddef ;
> vardef acos primary x = angle((x,1+-+x)) enddef ;
>
> It is unclear why only atan was left with its bad definition.
> This is clearly a bug.
>
> Note that the asin and acos functions return degrees. The file
> mp-tool.mpiv also also defines the alternatives invsin and
> invcos, which return radians.
On Jan 12, 2014, at 12:25 PM, Dirk Laurie <dirk.laurie at gmail.com> wrote:
> Or use the builtin `angle`.
>
> $ mf null
> This is METAFONT, Version 2.718281 (TeX Live 2012)
> (/usr1/local/texlive/2012/texmf-dist/metafont/base/null.mf)
>
> * Pi=3.141592653589793;
>
> * vardef atan(expr t) = angle(1,t)*Pi/180 enddef;
>
> * show atan(1);
>>> 0.7854
>>
I was attracted to the elegance of Dirk's solution, but it looks like the precision of both of our solutions varies? (Using my old HP calculator as the standard…maybe weak.) And Dan is right, the definitions are inconsistent.
If we can get this sorted out should we go over to the Contextgarden and have Hans et al fix it in the next beta?
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/metapost/attachments/20140112/24015145/attachment-0001.html>
More information about the metapost
mailing list