You are a guest. Restricted access. Read more

Built-in functions

There are more than 250 built-in functions included with jMathLab. They are implemented as a external MatLab functions (with the extension .m) or as a Java classes. You can look at them using the command path. Look at the reference manual Reference manual.

Here is a simple example. Compute the inverse cosine of an angle:

`x=acos(0.4); printf('%f',x)`

which calls “acos” function. One can get help for this function as:

`help("acos")`

The most common implemented functions are the square root (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 prime factors, factorial(Z) calculates the factorial function. Modular division is provided by divide and treated later in the context of polynomials.

`a=log(sqrt(854)); printf('%f',a)         % natural logarithm`

Try also these examples:

```a=0.5*log(854); printf('%f\n',a)
a=gammaln(1234);  printf('%f\n',a)           % log( gamma( x ) )
a=primes(1000000000000000001);  printf('%f\n',a)
a=factorial(35); printf('%f\n',a)```

Let us calculate factorial. We will use “rat” and therefore we specify syms to use it here:

`a=factorial(rat(8));   printf('%f',a)    % to make it exact.`

Standard functions

Here is the table with the rebuild functions for scalar values:

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

Built-in unctions

The functions can accept either a value (number), a vector of numbers, or symbolic value. In case of vectors, a function returns a vector. See [jmathlab:vectors]].

Name(Arguments) Function
sqrt(\$var\$) squareroot
exp(\$var\$) exponential
log(\$var\$) natural logarithm
sinh(\$var\$) hyperbolic sine
cosh(\$var\$) hyperbolic cosine
asinh(\$var\$) hyperbolic areasine
acosh(\$var\$) hyperbolic areacosine
sech(\$var\$) hyperbolic secans
csch(\$var\$) hyperbolic cosecans
asech(\$var\$) hyperbolic areasecans
acsch(\$var\$) hyperbolic areacosecans
factorial(N) factorial \$N!\$
nchoosek(N,K) binomial coefficient \$N \choose K\$

Special functions

See the reference reference API

Name(Arguments) Function
erf(\$var\$) error function
inverf(\$var\$) inverse error function
gamma(\$var\$) gamma function
gammaln(\$var\$) logarithm of gamma function
beta(\$var\$) beta function
betaln(\$var\$) logarithm of beta function
j0(\$var\$) Bessel function of the first kind of order 0

as before, the functions can accept values and vectors.