Intrinsic functions

sqrt(x)   square root
exp(x)    
log(x)   ln, base e
log10(x)   lg, base 10
sin(x)    
cos(x)    
tan(x)    
asin(x)   arc sine
acos(x)    
atan(x)    
sinh(x)   hyperbolic sine
cosh(x)    
tanh(x)    

 

abs(a) integer, real absolute
int(a) integer truncation
nint(a) integer nearest
floor(a) integer  
ceiling(a) integer  
real(a) real  
aint(a) real truncation
anint(a) real nearest
aimag(z) real imaginary part
cmplx(a)
cmplx(a, b)
complex  
conjg(z) complex conjugate
max(a1, a2, ...) integer, real maximum
min(a1, a2, ...) integer, real minimum
mod(a, p) integer, real remainder
modulo(a, p) integer, real remainder
sign(a, b) integer, real abs(a) with sign of b

 

index(string, substring) integer starting position or 0
len(string) integer length
len_trim(string) integer length w/o trailing blanks
trim(string) character trailing blanks removed

 

dot_product(vector_a, vector_b)    
matmul(matrix_a, matrix_b)    
maxval(array)    
minval(array)    
sum(array)    
product(array)    

Horner's rule for polynomials

p(x) = a0 + a1x + a2x2 + ... + an-1xn-1 + anxn

1 + 2 + ... + (n-1) + n = n(n+1)/2 multiplications

p(x) = (((anx + an-1)x  + ... + a2)x + a1)x + a0

Only n multiplications, better accuracy

Exercises

1. Compute the coefficients of the Hermite polynomials up to H11(z).

2. Compute Hn(z) for given n and z using Horner's rule.

3. Compute ex using the series 1 + x + x2/2 + x3/6 + ... and compare with the intrinsic function.

4. Compute the complex numbers eix for angles x from 0 to 360 degrees in steps of 15.