ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Taco Hoekwater <taco.hoekwater@wkap.nl>
Subject: Re: mp-tool
Date: Fri, 10 Sep 1999 09:03:06 +0000 (GMT)	[thread overview]
Message-ID: <14296.51531.115729.442812@PC709.wkap.nl> (raw)
In-Reply-To: <3.0.5.32.19990909145556.00b4fb30@mail.northcoast.com>

>>>>> "David" == David Arnold <darnold@northcoast.com> 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


  reply	other threads:[~1999-09-10  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-09 21:55 mp-tool David Arnold
1999-09-10  9:03 ` Taco Hoekwater [this message]
1999-09-10  8:03   ` mp-tool Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14296.51531.115729.442812@PC709.wkap.nl \
    --to=taco.hoekwater@wkap.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).