dot function

“msharpmath”, The Simple is the Best

[100] 021 Tutorial dot function     dot function

//————————————————————————————————————

//  Motive of introducing dot functions
//————————————————————————————————————
The motive of “expression-look-alike” leads us to innovate a concept of dot function. Boldly dropping the constraint of starting names with alphabets, a leading dot (.) is used to designate dot functions.
For example, the Bessel functions of the first kind can be denoted by

.J_nu(x)

where nu can be mathematical expressions. In this case, .J_n(x) is treated as a dot-function-only, i.e. J_n(x) does not work in CEMMATH. After an underline, additive operations can follow. For example

.J_n+5*3/2(x)  // nu = n+5*3/2

This approach leads users not to memorize unfriendly names such as besseli(nu,x), besselj(nu,x) etc. Some dot-function-only functions are

.J_nu(x)  .I_nu(x)  .K_nu(x)  .Y_nu(x)  // Bessel functions
.H_n(x)   .P_n(x)   .T_n(x)   .L_n(x)   // polynomials (Hermite, Legendre, Tchebyshev, Laguerre)

Most of the built-in functions in the CEMMATH (exceptions are listed below) are by default called in two modes, for example

#>  ones(2,3) ;    .ones(2,3) ;   // all-ones matrix of dimension 2 x 3
ans =
[             1             1             1 ]
[             1             1             1 ]
ans =
[             1             1             1 ]
[             1             1             1 ]

The second one starts with a dot and is called a dot-function. When one needs an extra name space for handling many variables, the dot-function-only mode can be activated by

#> .on ;   ones = .ones(2,3) ;   // activate dot-function-only mode, only ‘.ones’ is working.
ones =
[             1             1             1 ]
[             1             1             1 ]

and it is possible to use ‘ones’ as a variable. This mode can be released by

#> .off ;      // dot-off,  both ‘ones’ and ‘.ones’ are working.

This concept is innovated to distinguish name spaces of users and system, when required.   Another advantage of using dot-functions is that it is readily noticeable whether a function is user-defined or system-defined by means of a dot (.) character. All functions with a single character and  a few are always dot-function-only and are listed below.

//————————————————————————————————————
//  list of  dot functions (starting with a dot .  means dot-function-only, others are dual)
//————————————————————————————————————
A,B,X,F        : matrices
a,b,c             : double data
c1,c2,…,cn  : double data
x1,x2,…,xn  : double data
f                    : function f(x,y,z)
m,n              : integer
u,v,w           : function u(x,y,z), v(x,y,z), w(x,y,z)
x                   : double
…                  : mixed data of double and matrix
#1,#2, ..       : one of double,complex, matrix,poly,vertex

//————————————————————————————————————

.[ an, ..., a3, a2, a1, a0]                // a descending polynomial, an x^n + … + a1 x + a0

.B(a,b)                                            // beta function
blkdiag(…)                                      // block diagonal matrix function
.bisect(a,b, ftn(x))                         // bisection to find a root

ceil(x)                                             // integer near +inf
corrcoef(A,B)                                // correlation coefficient
cross(A,B)                                     // cross product

decimal(x)                                     // = x – .round(x)

.del (f) (a,b,c)                                                          // gradient at (a,b,c) for f(x,y,z)
.del*(u,v,w)(a,b,c)                                                  // divergence
.del^(u,v,w)(a,b,c)                                                 // curl
.del2(f)(a,b,c)                                                          // Laplacian
.del[]   .x1.x2 … .xn (f)(c1,c2,…,cn)                     // gradient
.del[][] .x1.x2 … .xn (f1,f2,…,fm) (c1,c2,…,cn) // Jacobian

dfact(x)                          // double factorial, x(x-2)(x-4) …
diag(matrix,k=0)        // matrix function

diagcat(…)                     // diagonal concatenation
.div(a,b)                          // quotient q  in   a = bq+r
divisor(n)                      // divisors,  .divisor(10) = [1,2,5,10]
.dot(A,B)                        // dot product,  A .. B

.e_k(n)                          // k-th unit column vector in the n-dimensional space
expm(A)                       // I + A + A^2/2! + A^3/3! + …
eye(m,n=m)                 //  .I(m,n=m)  for identity matrix, a_ij = 1 if i = j

fact(x)                          // factorial,  x(x-1)(x-2) ..
factor(x)                      // factorization,  .factor(10) = [ 2,5 ]
find(A)                         // non-zero entries,  A.find = A.true
fix(x)                            // integer  near  0
floor(x)                        // integer near -inf

.G(x)                            // x.G,   .G(x)=(x-1)!,   Gamma function
.gcd(a,b)                      // greatest common divisor
.H(x)                           // x.H,  Heaviside function
.H_n(x)                      // Hermite polynomial
horzcat(A,B)              // horizontal concatenation, A | B

.I(m,n=m)                  // .eye(m,n=m)    unity matrix
.I_nu(x)                      // Bessel function
interp(X,F)                 // polynomial for interpolation of F(X)
isprime(x)                  // return (1) if x is a prime number, otherwise returns (0)

.J_nu(x)                     // Bessel function

.K_nu(x)                    // Bessel function
kron(A,B)                  // kronecker product, A ^^ B

.L_n(x)                       // Laguerre polynomial
.lcm(a,b)                      // least common multiplier
logm(A)                       // expm(logm(A)) = A

.max(x1,x2, … , xn)      // maximum
.min(x1,x2, … , xn)      // minimum
.mod(a,b)                      // remainder  r  in   a = bq+r

.nCr(a,b)                             // combination
.nPr(a,b)                            // permutation
.norm1(x1,x2, … , xn)      // |x1| + |x2| + … + |xn|
.norm2(x1,x2, … , xn)      // sqrt(x1*x1 + … + xn*xn)
.norm22(x1,x2, … , xn)    // x1*x1 + … + xn*xn

.on                                   // ‘dot-on’ activates dot function only, e.g. only ‘.ones’ works
.off                                   // ‘dot-off’ default mode, both ‘ones’ and ‘.ones’ work
ones(m,n=m)                // all-ones matrix of dimension m x n

.P_n(x)                          // Legendre polynomial
.pm(n)                             // returns 1 if n is even, otherwise returns (-1)
.polyfit(X,F, kth)          // polynomial for regression, .regress(X,F,kth)
primes(a,b)                   // prime numbers between a and b

.regress(X,F, kth)        // polynomial for regression
.regress(X,F, mftn)       // matrix for regression, mftn=matrix function
round(x)                  // integer near   x

.secant(a,b, ftn(x))      // secant method for root finding
sign(x)                   // +1 if x > 0, -1 if x < 0 and 0 if x = 0
.spline(X,F)              // 3rd-order splines, return spline matrix
.splinebc1(X,F)           // 3rd-order splines, return spline matrix
.splinebc2(X,F)           // 3rd-order splines, return spline matrix
.spline1(X,F)             // 1st-order splines, return spline matrix
sqrtm(A)                  // X = sqrtm(A);  X*X = A
.swap(#1,#2)              // swap two arguments

.T_n(x)                          // Tchebyshev polynomial
todeg(x)                         // x*180/pi
torad(x)                         // x*pi/180

vertcat(A,B)                  // vertical concatenation,  A _ B

.Y_nu(x)                        // Bessel function
.ym(year,month)         // print calendar,  .ym(2012,8)

zeros(m,n=m)              // all-zeros matrix of dimension m x n

//————————————————————————————————————
//  list of well-known mathematical functions
//————————————————————————————————————
abs(x)                                                        // absolute
acos(x),    acosd(x),     acosh(x)            // arc cosine
acot(x),    acotd(x),     acoth(x)             //  arc cotangent
acsc(x),    acscd(x),     acsch(x)             //  arc cosecant
asec(x),    asecd(x),    asech(x)             //  arc secant
asin(x),    asind(x),     asinh(x)             //  arc sine
atan(x),    atand(x),    atanh(x)            //  arc tangent
atan2(x,y), atand2(x,y)

cos(x),     cosd(x),     cosh(x)                 // cosine
cot(x),     cotd(x),     coth(x)                 // cotangent
csc(x),     cscd(x),     csch(x)                 // cosecant

erf(x)                                                        // error function
erfc(x)                                                      // complimentary error function
exp(x)                                                       // exponential

log(x)                                                        // natural log with base _e
log2(x)                                                     // log with base 2
log10(x)                                                   // log with base 10

pow(x,a)                                                  //  x^a

sec(x),      secd(x),      sech(x)              // secant
sin(x),      sind(x),      sinh(x)              // sine
sqrt(x)                                                     // square root

tan(x),      tand(x),      tanh(x)              // tangent

//—————————————————–
//  end of file
//—————————————————–

Comments are closed.