ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* mp-tool
@ 1999-09-09 21:55 David Arnold
  1999-09-10  9:03 ` mp-tool Taco Hoekwater
  0 siblings, 1 reply; 3+ messages in thread
From: David Arnold @ 1999-09-09 21:55 UTC (permalink / raw)


All,

Defined in mp-tool is

def tand (expr x) = (sind(x)/cosd(x))                enddef;
def sqr  (expr
x) = (x*x)                            enddef;
def ln   (expr x) = (if x=0:
0 else: mlog(x)/256 fi) enddef;
def exp  (expr x) = ((mexp 256)**x)
         enddef;
def pow  (expr x) = (x**power)
enddef;
def inv  (expr x) = (if x=0: 0 else: x**-1 fi)       enddef;
def
asin (expr x) = (x+(x**3)/6+3(x**5)/40)          enddef;
def acos (expr x)
= (asin(-x))                       enddef;
def atan (expr x) =
(x-(x**3)/3+(x**5)/5-(x**7)/7)   enddef;

It would be useful to add to this list. Specifically, cos, sin, tan for
radian measure, and create a value for pi. Maybe,

pi=4*atan(1);
def sin (expr x) = sind(x*(180/pi)) enddef;

etc.

Any other suggested additions?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mp-tool
  1999-09-10  9:03 ` mp-tool Taco Hoekwater
@ 1999-09-10  8:03   ` Hans Hagen
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Hagen @ 1999-09-10  8:03 UTC (permalink / raw)
  Cc: ntg-context

Taco Hoekwater wrote:

> There are some really tricky ones that are above my mp knowledge that
> would be a great addition, like a macro that can fake

  scaled 2*height 

I never understood why that is not possible (must be scald (2*height)
now). 

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.nl
-----------------------------------------------------------------


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mp-tool
  1999-09-09 21:55 mp-tool David Arnold
@ 1999-09-10  9:03 ` Taco Hoekwater
  1999-09-10  8:03   ` mp-tool Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Taco Hoekwater @ 1999-09-10  9:03 UTC (permalink / raw)


>>>>> "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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-09-10  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-09 21:55 mp-tool David Arnold
1999-09-10  9:03 ` mp-tool Taco Hoekwater
1999-09-10  8:03   ` mp-tool Hans Hagen

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).