[metapost] Metafun : is "atan" the arctangent function?

John Kitzmiller jkitzm at gmail.com
Sun Jan 12 16:32:11 CET 2014


On Jan 12, 2014, at 6:28 AM, Franck Pastor <franck.pastor at me.com> wrote:

> Hello,
> 
> Reading the "Metafun manual" (2010 edition), I noticed that it mentions p. 324 the existence of a specific "atan" unary operator. I assumed it was the arctangent function and I was pleasantly surprised, since this important inverse trigonometric function was not referenced in chapter 9 ("Functions") of the same Metafun manual. So I gave this atan operator a try but it returned me surprising results. For example, this short line
> 
> show atan(1);
> 
> gives me "0.7282" as result ("0.7238095238095239" with numbersystem set to "double"), whereas the right result  should be something like "0.7854" in radians (approximation of the exact result, pi/4) and exactly "45" in degrees.
> 
> Is "atan" thus actually meant as the arctangent function, of something else? Or is it a bug?


atan is vardef'd in mp-tool.mpiv as: x = 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))?

John




More information about the metapost mailing list