From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/882 Path: main.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: mp-tool Date: Fri, 10 Sep 1999 09:03:06 +0000 (GMT) Sender: owner-ntg-context@let.uu.nl Message-ID: <14296.51531.115729.442812@PC709.wkap.nl> References: <3.0.5.32.19990909145556.00b4fb30@mail.northcoast.com> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1035391719 27893 80.91.224.250 (23 Oct 2002 16:48:39 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 16:48:39 +0000 (UTC) Original-To: ntg-context@ntg.nl Xref: main.gmane.org gmane.comp.tex.context:882 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:882 >>>>> "David" == David Arnold writes: David> All, David> Defined in mp-tool is David> def sqr (expr x) = (x*x) enddef; David> def ln (expr x) = (if x=0: 0 else: mlog(x)/256 fi) enddef; David> def exp (expr x) = ((mexp 256)**x) enddef; David> def pow (expr x) = (x**power) enddef; David> def inv (expr x) = (if x=0: 0 else: x**-1 fi) enddef; There are some really tricky ones that are above my mp knowledge that would be a great addition, like a macro that can fake 2**2.5 and another for {\root .5 \of 2}. Also something like binom(10,9) (which quickly goes over 4096) David> def tand (expr x) = (sind(x)/cosd(x)) enddef; David> def asin (expr x) = (x+(x**3)/6+3(x**5)/40) enddef; David> def acos (expr x) = (asin(-x)) enddef; David> def atan (expr x) = (x-(x**3)/3+(x**5)/5-(x**7)/7) enddef; David> It would be useful to add to this list. Specifically, cos, sin, tan for David> radian measure, and create a value for pi. Maybe, David> pi=4*atan(1); gives 2.89526??????????????? I'd rather see the definitions from grafbase for the trig. These defs are both shorter and more accurate: [DHL==Daniel Luecking] %D START. pi := 3.1415926 2pi*radian= 180*deg; %D Extra Trigonometric and Hyperbolic Functions. %D tand, cotd, acos, asin; %D exp, ln, cosh, sinh, acosh, asinh. %D NOTE: acos and asin return angle in degrees. def tand (expr x) = (sind (x) / cosd (x)) enddef; def cotd (expr x) = (cosd (x) / sind (x)) enddef; %D DHL: I \emph{MUST} have these! %D one can say sin(pi/2) or sind((pi/2)*radian) def sin (expr x) = (sind (x*radian)) enddef; def cos (expr x) = (cosd (x*radian)) enddef; def tan (expr x) = (sin (x) / cos (x)) enddef; def cot (expr x) = (cos (x) / sin (x)) enddef; def acos (expr x) = angle ((x, 1+-+x)) enddef; def asin (expr y) = angle ((1+-+y, y)) enddef; def invcos (expr x) = ((acos (x))/radian) enddef; def invsin (expr y) = ((asin (x))/radian) enddef; vardef cosh primary X = save temp; temp = exp X; (temp + 1/temp) / 2 enddef; vardef sinh primary X = save temp; temp = exp X; (temp - 1/temp) / 2 enddef; def acosh (expr y) = ln (y + (y+-+1)) enddef; def asinh (expr y) = ln (y + (y++1)) enddef; %D END. Greetings, Taco