DMelt:JMathlab/6 Functions

From HandWiki
Revision as of 19:38, 10 December 2016 by imported>Jworkorg (Created page with "== Functions == The basic arithmetic operations are marked with the usual symbols (+ - * / ) . Exponention is performed with the accent character (^). Multiplication and divi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Member

Functions

The basic arithmetic operations are marked with the usual symbols (+ - * / ) . Exponention is performed with the accent character (^). Multiplication and division precede addition and subtraction; any order of evaluation can be forced by parenthesis.

>> 3.23*(14-2^5)/(15-(3^3-2^3))
ans = 14.535
>> 4.5e-23/0.0000013
ans = 3.4615E-17
>> 17.4^((3-2.13^1.2)^0.16)
ans = 13.125
>> 17.23e4/(1.12-17.23e4/(1.12-17.23e4/1.12))
ans = 76919

In addition to these arithmetic operators Jasymca provides operators for comparing numbers

< > >= <= == ~=

and for boolean functions

& | ~

. Logical true is the number 1, false is 0.

>> 1+eps>1
ans = 1
>> 1+eps/2>1      % defines eps 
ans = 0
>> A=1;B=1;C=1;   % semicolon suppresses output.
>> !(A&B)|(B&C) == (C~=A)
ans = 1

The most common implemented functions are the squareroot (sqrt(x)), the trigonometric functions (sin(x), cos(x), tan(x)) and inverses (atan(x), atan2(y,x)), and the hyperbolic functions (exp(x), log(x)). A large number of additional functions are available, see the list in chapter 4. Some functions are specific to integers, and also work with arbitrary large numbers: primes(Z) expands Z into primefactors, factorial(Z) calculates the factorial function. Modular division is provided by divide and treated later in the context of polynomials.

>> log(sqrt(854))         % natural logarithm
ans = 3.375
>> 0.5*log(854)
ans = 3.375
>> float(sin(pi/2))       % argument in radian
ans = 1
>> gammaln(1234)          % log( gamma( x ) )
ans = 7547
>> primes(1000000000000000001)      
ans = [ 101  9901  999999000001 ]
>> factorial(35)
ans = 1.0333E40
>> factorial(rat(35))     % to make it exact.
ans = 10333147966386144929666651337523200000000

Scalar

Name(Arguments) Function Mod
float($var$) $var$ as floating point number M,O
rat($var$) $var$ as exact number M,O
realpart($var$) realpart of $var$ M,O
imagpart($var$) imaginary part of $var$ M,O
abs($var$) absolute value of $var$ M,O
sign($var$) sign of $var$ M,O
conj($var$) $var$ conjugate complex M,O
angle($var$) angle of $var$ M,O
cfs($var$) [$var_T$]) continued fraction expansion of $var$ with accuracy $var_T$ M,O
primes(VAR) VAR decomposed into primes M,O


Scalar functions

Name(Arguments) Function Mod
sqrt($var$) squareroot M,O
exp($var$) exponential M,O
log($var$) natural logarithm M,O
sinh($var$) hyperbolic sine O
cosh($var$) hyperbolic cosine O
asinh($var$) hyperbolic areasine O
acosh($var$) hyperbolic areacosine O
sech($var$) hyperbolic secans O
csch($var$) hyperbolic cosecans O
asech($var$) hyperbolic areasecans O
acsch($var$) hyperbolic areacosecans O
sin($var$) sine (radian) M,O
cos($var$) cosine (radian) M,O
tan($var$) tangens (radian) M,O
asin($var$) arcsine (radian) M,O
acos($var$) arccosine (radian) M,O
atan($var$) arctangens (radian) M,O
atan2($var_1$, $var_2$) arctangens (radian) M,O
sec($var$) secans (radian) O
csc($var$) cosecans (radian) O
asec($var$) arcsecans (radian) O
acsc($var$) arccosecans (radian) O
factorial(N) factorial $N!$ M,O
nchoosek(N,K) binomial coefficient $N \choose K$ O
gamma($var$) gammafunction M,O
gammaln($var$) logarithm of gammafunction M,O