Next: Expression Lists
Up: Plots, Vectors and Expressions
Previous: Operators in Expressions
Contents
Index
Math Functions
There are a number of built-in math functions which take and return
vectors. Generally, these functions operate on the supplied vector
term-by-term, returning a vector of the same length as that given.
The pre-defined functions available are listed below. In general, all
operations and functions will work on either real or complex values,
providing complex data output when necessary.
It should be noted that the mathematics subsystem used to evaluate
expressions in voltage/current sources is completely different. In
that subsystem, functions take real valued scalars as input. Although
many of the same functions are available in both systems, the
correspondence is not absolute.
- abs(vector)
Each point of the returned vector is the absolute value of the
corresponding point of vector. This is the same as the mag function.
- acos(vector)
Each point of the returned vector is the arc-cosine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- acosh(vector)
Each point of the returned vector is the arc-hyperbolic cosine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- asin(vector)
Each point of the returned vector is the arc-sine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- asinh(vector)
Each point of the returned vector is the arc-hyperbolic sine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- atan(vector)
Each point of the returned vector is the arc-tangent of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- atanh(vector)
Each point of the returned vector is the arc-hyperbolic tangent of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- cbrt(vector)
Each point of the returned vector is a cube root of the corresponding
point of vector.
- ceil(vector)
This function return the smallest integer greater than or equal to the
argument, in the manner of the C function of the same name. If the
argument is complex, the operation is performed on both components,
with the result being complex. This operation is performed at each
point in the given vector.
- cos(vector)
Each point of the returned vector is the cosine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- cosh(vector)
Each point of the returned vector is the hyperbolic cosine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- db(vector)
Each point of the returned vector is the decibel value (20 *
log10(mag())) of the corresponding point of vector.
- deriv(vector)
This calculates the derivative of the given vector, using
numeric differentiation by interpolating a polynomial. However, it
may be prone to numerical errors, particularly with iterated
differentiation. The implementation only calculates the derivative
with respect to the real component of that vector's scale. The
polynomial degree used for differentiation can be specified with the
dpolydegree variable. If dpolydegree is unset, the value
taken is 2 (quadratic). The valid range is 0-7.
- erf(vector)
Each point of the real returned vector is the error function of the
corresponding real point of vector.
- erfc(vector)
Each point of the real returned vector is the complementary error
function of the corresponding real point of vector.
- exp(vector)
Each point of the returned vector is the exponentiation (ex)
of the corresponding point of vector.
- fft(vector)
The fft function returns the Fourier transform of vector, using the present scale of vector. The scale should
be linear and monotonic. The length is zero-padded to the next binary
power. Only the real values are considered in the transform, so that
the negative frequency terms are the complex conjugates of the
positive frequency terms. The negative frequency terms are not
included in the (complex) vector returned. A scale for the returned
vector is also generated and linked to the returned vector.
- floor(vector)
This function return the largest integer less than or equal to the
argument, in the manner of the C function of the same name. If the
argument is complex, the operation is performed on both components,
with the result being complex. The operation is performed at each
point of the argument.
- gamma(vector)
Each point of the real returned vector is the gamma function of the
corresponding real point of vector.
- gauss(vector)
The result is a real vector of Gaussian random numbers, with a
term-by-term standard deviation and mean of the corresponding real and
imaginary parts of vector. If vector is real, the means
are 0. The random number sequence can be reset with the seed
command.
- ifft(vector)
The ifft function returns the inverse Fourier transform of vector, using the present scale of vector. The scale
should be linear and monotonically increasing, starting at 0.
Negative frequency terms are assumed to be complex conjugates of the
positive frequency terms. The length is zero-padded to the next
binary power. A scale for the returned vector is also generated and
linked to the returned vector. The returned vector is always real.
- im(vector)
Each point of the real returned vector is the imaginary part of the
corresponding point of the given vector. This function can
also be calld as ``imag()''.
- int(vector)
The returned value is the nearest integer to the argument, in the
manner of the C rint function. If the argument is complex, the
operation is performed on each component with the result being
complex. The operation is performed at each point in the argument.
- integ(vector)
The returned vector is the (trapezoidal) integral of vector
with respect to the vector's scale (which must exist).
- interpolate(vector)
This function takes its data and interpolates it onto a grid which is
determined by the default scale of the currently active plot. The
degree is determined by the polydegree variable. This is useful
if the argument belongs to a plot which is not the current one. Some
restrictions are that the current scale, the vector's scale,
and the argument must be real, and that either both scales must be
strictly increasing or strictly decreasing if they are different.
- j(vector)
Each point of the returned vector is the corresponding point of
vector multiplied by the square root of -1.
- j0(vector)
Each point of the real returned vector is the Bessel order 0 function
of the corresponding real point of vector. Unlike most of the
functions, this function operates only on the real part of a complex
argument, and always returns a real valued result.
- j1(vector)
Each point of the real returned vector is the Bessel order 1 function
of the corresponding real point of vector. Unlike most of the
functions, this function operates only on the real part of a complex
argument, and always returns a real valued result.
- jn(n, vector)
Each point of the real returned vector is the Bessel order n
function of the corresponding real point of vector. This
function takes two parameters, unlike most other functions. The first
is the function order, which is truncated to an integer, and the
second is the function argument. If a (single) complex vector is
given as an argument, then for each element the real part is taken as
the function order and the imaginary part is the function argument.
The return is always real-valued.
- length(vector)
This function returns the scalar length of vector.
- ln(vector)
Each point of the returned vector is the natural logarithm of the
corresponding point of vector.
- log(vector)
Each point of the returned vector is the base-10 logarithm of the
corresponding point of vector.
- mag(vector)
Each point of the real returned vector is the magnitude of the
corresponding point of vector.
- mean(vector)
This function returns is a scalar (a length 1 vector)
that is the mean of the elements of vector.
- norm(vector)
Each point of the returned vector is the corresponding point of the
given vector multiplied by the magnitude of the inverse of the largest
value in the given vector. The returned vector is therefor normalized
to 1 (i. e, the largest magnitude of any component will be 1).
- ph(vector)
Each point of the real returned vector is the phase in radians of the
corresponding point of vector.
- pos(vector)
This function returns a real vector which is 1 if the corresponding
element of the argument has a non-zero real part, and 0 otherwise.
- re(vector)
Each point of the real returned vector is the real part of the
corresponding point of vector. The function can also be called
as ``real()''.
- rms(vector)
This function integrates the magnitude-squared of vector over
the vector's scale (using trapezoidal integration), divides by
the scale range, and returns the square root of this result. If the
vector has no scale, the square root of the sum of the squares
of the elements is returned.
- rnd(vector)
This function returns a vector which contains random values between 0
and the corresponding element of vector. If vector is
complex then the random value is also complex. The random number
sequence can be reset with the seed command.
- sin(vector)
Each point of the returned vector is the sine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- sinh(vector)
Each point of the returned vector is the hyperbolic sine of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- sqrt(vector)
Each point of the returned vector is the square root of the
corresponding point of vector.
- sum(vector)
The return value is a scalar which is the sum of the elements of the
vector vector.
- tan(vector)
Each point of the returned vector is the tangent of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- tanh(vector)
Each point of the returned vector is the hyperbolic tangent of the
corresponding point of vector. This and all trig functions
operate with radians unless the units variable is set to degrees.
- unitvec(vector)
This function returns a real vector consisting of all 1's, with length
equal to the magnitude of the first element of the argument.
- vector(vector)
This function returns a vector consisting of the integers from 0 up to the
magnitude of the first element of its argument.
- y0(vector)
Each point of the real returned vector is the Neumann order 0 function
of the corresponding real point of vector. Unlike most of the
functions, this function operates only on the real part of a complex
argument, and always returns a real valued result.
- y1(vector)
Each point of the real returned vector is the Neumann order 1 function
of the corresponding real point of vector. Unlike most of the
functions, this function operates only on the real part of a complex
argument, and always returns a real valued result.
- yn(n, vector)
Each point of the real returned vector is the Neumann order n
function of the corresponding real point of vector. This
function takes two arguments, unlike most other functions. The first
is the function order, which is truncated to an integer, and the
second is the function argument. If a (single) complex vector is
given as an argument, then for each element the real part is taken as
the function order and the imaginary part is the function argument.
The return is always real-valued.
Next: Expression Lists
Up: Plots, Vectors and Expressions
Previous: Operators in Expressions
Contents
Index
Stephen R. Whiteley
2006-10-23