# Basic Built-in Functions

This section introduces you into

- the basic mathematical functions in EULER,
- how these functions work for matrix input,
- how to sort and compare matrices,
- how to sum up or multiply rows of matrices,
- rounding,
- basic string functions.

## Basic Functions

There are the usual functions

    abs, sqrt, exp,
    log, sin, cos,
    tan, asin, acos,
    atan, re, im, conj.

They all work for complex values. In this case they yield the principle value. There are some functions which make sense only for real values

    floor, ceil, sign,
    fak, bin, logfak, logbin.

floor and ceil give integer approximations to a real number. "bin(n,m)" computes the binomial coefficient of n and m. logbin(n,m) computes the logarithm of that (for large values of n,m)

        >pi()

(or simply ">pi") is a built-in constant.

        >mod(x,y)

return x modulus y.

## Functions and Matrices

Note, that most of these internal functions work for matrix input. They simply evaluate to any element of the matrix. If this is not the case, or if you have written an own function, which does not accept matrix input, you can map it to a matrix with

        >map("function",...)

where the elements of the matrix parameters ... are passed to a the function. This mapping obeys the rules explained in the matrix section. That is, if you pass a row v and a column w to it, both are expanded to full matrices with as many rows as v and as many columns as w.

## Max, Min etc.

        >max(x,y)

and min(x,y) return the maximum (minimum resp.) of x and y.

        >max(A)

and min(A) return a column vector containing the maxima (minima resp.) of the rows of A. The functions totalmax and totalmin from UTIL compute the maximum about all elements of a matrix.

If A is a NxM matrix, then

        >extrema(A)

is a Nx4 matrix, which contains in each row a vector of the form [min imin max imax], where min and max are the minima and maxima of the corresponding row of A, and imin and imax are the indices, where those are obtained.

If v is a 1xN vector, then

        >nonzeros(v)

returns a vector, containing all indices i, where v[i] is not zero. Furthermore,

        >count(v,M)

returns a 1xM vector, the i-th component of which contains the number of v[i] in the interval [i-1,i).

        >find(v,x)

assumes that the elements of v are ordered. It returns the index (or indices, if x is a vector) i such that v[i]< = x< v[i+1], or 0 if there is no such i.

        >sort(v)

sorts the elements of v with the quicksort algorithm. It returns the sorted vector and the rearranged indices. If

        >{w,i}=sort(v);

then v[i] is equal to w.

## Sum, Prod etc.

If A is NxM matrix

        >sum(A)

returns a column vector containing the sums of the rows of A. Analogously,

        >prod(A)

returns the products.

        >cumsum(A)

returns a NxM matrix containing the cumulative sums of the columns of A.

        >cumprod(A)

works the same way. E.g.,

        >cumprod(1:20)

returns a vector with the faculty function at 1 to 20.

## Rounding

        >round(x,n)

rounds x to n digits after the decimal dot. It also works for complex numbers. x may be a matrix.

## String Functions

The only string functions in EULER are

        >stringcompare("string1","string2")

which returns 0, if the strings are equal, -1 if string1 is alphabetically prior to string2, and 1 else, and the comparing operators ==,< ,> ,< =,> =.

Besides this, you can concatenate strings with |.

Furthermore,

        >interpret("expression");

will interpret the expression and return the result of the evaluation.

## Timer, Wait etc.

        >time()

returns a timer in seconds. It is useful for benchmarks etc.

        >wait(n)

waits for n seconds or until a key was pressed. It returns the actual waiting time in seconds.

        >key()

waits for a key press and returns the internal scan code, or the ASCII code of the key. You can check this ASCII code against a character with key()==ascii("a").