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

Daniel H. Luecking luecking at uark.edu
Sun Jan 12 20:02:31 CET 2014

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. 


Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas
Fayetteville, Arkansas

More information about the metapost mailing list