BeSpiceWaveParserLimitedEdition
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
The Curve Calculator

Using The Curve Calculator

All calculator functions require a string expression. In this string expression curves are identified by a "waveform(<section_id or section_name>, <curve_index or curve name>)" string.

So to add curve 10 and 12 contained in the sections 101 and 103 you need to build the string expression

"waveform(101, 10) + waveform(103, 12)"

if only the curve names "V(n1)" and "V(n2)" are known, you can also use

"waveform(101, "V(n1)") + waveform(103, "V(n2)")"

instead. Strings should be enclosed into quotes.

In the calculator page of our graphical tool "BeSpice Wave", these "waveform()" expressions can be generated by dragging a curve from the browser to the calculator terminal.

Please also check the examples for your programming language.

Available Calculator Functions

The below list can also be obtained by typing "help" or "help <function name>" in BeSpice Wave's calculator page.

abs

Usage: abs(x), x <scalar|vector|waveform>

Returns the absolute value or magnitude of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

acos

Usage: acos(x), x <scalar|vector|waveform>

Returns the arc cosine of the function argument in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

acosd

Usage: acosd(x), x <scalar|vector|waveform>

Returns the arc cosine of the function argument in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

acosh

Usage: acosh(x), x <scalar|vector|waveform>

Returns the inverse hyperbolic cosine of the function argument in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

acoshd

Usage: acoshd(x), x <scalar|vector|waveform>

Returns the inverse hyperbolic cosine of the function argument in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

angle

Usage: angle(x), x <scalar|vector|waveform>

Returns the complex angle of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

apply_window_function

Usage: apply_window_function(<waveform>, x0, x1)

This function applies a window function to a curve. The windows function is defined by it's upper and lower limits x0 and x1. For now only rectangular windows are possible.

argument

Usage: argument(x), x <scalar|vector|waveform>

Returns the complex argument or phase of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

asin

Usage: asin(x), x <scalar|vector|waveform>

Returns the arc sine of the function argument in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

asind

Usage: asind(x), x <scalar|vector|waveform>

Returns the arc sine of the function argument in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

asinh

Usage: asinh(x), x <scalar|vector|waveform>

Returns the inverse hyperbolic sine of the function argument in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

asinhd

Usage: asinhd(x), x <scalar|vector|waveform>

Returns the inverse hyperbolic sine of the function argument in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

atan

Usage: atan(x), x <scalar|vector|waveform>

Returns the arc tangent of the function argument in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

atand

Usage: atand(x), x <scalar|vector|waveform>

Returns the arc tangent of the function argument in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

atanh

Usage: atanh(x), x <scalar|vector|waveform>

Returns the inverse hyperbolic tangent of the function argument in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

atanhd

Usage: atanhd(x), x <scalar|vector|waveform>

Returns the inverse hyperbolic tangent of the function argument in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

average

Usage: average(w, [x_min, x_max]), w <waveform>, [x_min, x_max] <scalar>

This function computes the average value of a curve over an optional window.

average_fall_time

Usage: average_fall_time(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the average fall time of a curve. The default percentage values are 10% and 90%.

average_rise_time

Usage: average_rise_time(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the average rise time of a curve. The default percentage values are 10% and 90%.

average_slew_rate

Usage: average_slew_rate(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the average slew rate of a curve. The default percentage values are 10% and 90%.

ceil

Usage: ceil(x), x <scalar|vector|waveform>

Returns the smallest integral value not less than the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

conj

Usage: conj(x), x <scalar|vector|waveform>

Returns the complex conjugate of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

convert_to_step_function

Usage: convert_to_step_function(<waveform>, <eps>, <rise_fall_time>)

This function adds data points to a curve in order to convert it to a step function. The parameter "eps" controls the degree of reduction. The parameter "rise_fall_time" controls the distance of the newly inserted point to the next point.

cos

Usage: cos(x), x <scalar|vector|waveform>

Returns the cosine of the function argument which is given in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

cosd

Usage: cosd(x), x <scalar|vector|waveform>

Returns the cosine of the function argument which is given in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

cosh

Usage: cosh(x), x <scalar|vector|waveform>

Returns the hyperbolic cosine of the function argument which is given in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

coshd

Usage: coshd(x), x <scalar|vector|waveform>

Returns the hyperbolic cosine of the function argument which is given in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

create_waveform

Usage: create_waveform(<x axis type>, <y axis type>, <x vector>, <y vector>)

create_waveform(<x axis type>, <y axis type>, <expression>) This function creates a waveform that can be plotted. It accepts either two vectors or an algebraic expression as arguments. Example: new_curve = create_waveform("x", "y", x^2)

db

Usage: db(x), x <scalar|vector|waveform>

Converts the absolute value of function argument to db. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

derivative

Usage: derivative(<waveform>, [x_value])

This function computes the numerical derivative of a curve. If an optional x-value is specified, the differential quotient will be evaluated in this point. The derivative is compute as (y[i+1]-y[i])/(x[i+1]-x[i]) for the 1st point, as (y[i]-y[i-1])/(x[i]-x[i-1]) for the last point and as (y[i+1]-y[i-1])/(x[i+1]-x[i-1]) for all other points.

duty_cycle

Usage: duty_cycle(<waveform>, [y_level])

This function computes the duty cycle of a curve. It is defined as the percentage of the time the curve is "on". "On" here means above the level specified by the y_level parameter. By default it's 90% of the maximum curve value.

estimate_frequency

Usage: estimate_frequency(<waveform>, [y_level])

This function estimates the frequency of a curve. Therefore it computes the x-distance between points crossing the y_level of the curve. If y_level isn't defined, the average value of the curve is used instead.

exp

Usage: exp(x), x <scalar|vector|waveform>

Raises e to the power of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

extrapolate_linear

Usage: extrapolate_linear(x, [x], [y]), x <scalar|vector>, [x] <vector>, [y] <vector>

This function computes a piecewise linear function interpolating the points defined by the vector [y] at the points defined by the vector[x]. If the value for x is a variable, the function returns a piecewise polynomial. If a scalar or vector value is given for x, the resulting polynomial will be evaluated at x. The value for x might lie outside of the interval defined by the points in [x].

extrapolate_poly

Usage: extrapolate_poly(x, [x], [y]), x <scalar|vector>, [x] <vector>, [y] <vector>

This function computes a polynomial interpolating the points defined by the vector [y] at the points defined by the vector[x]. If the value for x is a variable, the function returns a piecewise polynomial. If a scalar or vector value is given for x, the resulting polynomial will be evaluated at x. The value for x might lie outside of the interval defined by the points in [x].

extrapolate_spline

Usage: extrapolate_spline(x, [x], [y]), x <scalar|vector>, [x] <vector>, [y] <vector>

This function computes a natural cubic spline interpolating the points defined by the vector [y] at the points defined by the vector[x]. If the value for x is a variable, the function returns a piecewise polynomial. If a scalar or vector value is given for x, the resulting polynomial will be evaluated at x. The value for x might lie outside of the interval defined by the points in [x].

floor

Usage: floor(x), x <scalar|vector|waveform>

Returns the largest integral value not greater than the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

imag

Usage: imag(x), x <scalar|vector|waveform>

Returns the imaginary part of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

integral

Usage: integral(<waveform>, [x0, x1])

This function computes the integral of a curve. If an optional x0 and x1 values are specified, the function will evaluate the resulting curve and return integral(x1) - integral(x0). Otherwise a curve is returned.

interpolate_linear

Usage: interpolate_linear(x, [x], [y]), x <scalar|vector>, [x] <vector>, [y] <vector>

This function computes a piecewise linear function interpolating the points defined by the vector [y] at the points defined by the vector[x]. If the value for x is a variable, the function returns a piecewise polynomial. If a scalar or vector value is given for x, the resulting polynomial will be evaluated at x. The value for x must lie within the points given in [x].

interpolate_poly

Usage: interpolate_poly(x, [x], [y]), x <scalar|vector>, [x] <vector>, [y] <vector>

This function computes a polynomial interpolating the points defined by the vector [y] at the points defined by the vector[x]. If the value for x is a variable, the function returns a piecewise polynomial. If a scalar or vector value is given for x, the resulting polynomial will be evaluated at x. The value for x must lie within the points given in [x].

interpolate_spline

Usage: interpolate_spline(x, [x], [y]), x <scalar|vector>, [x] <vector>, [y] <vector>

This function computes a natural cubic spline interpolating the points defined by the vector [y] at the points defined by the vector[x]. If the value for x is a variable, the function returns a piecewise polynomial. If a scalar or vector value is given for x, the resulting polynomial will be evaluated at x. The value for x must lie within the points given in [x].

ln

Usage: ln(x), x <scalar|vector|waveform>

Returns the natural logarithm of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

log10

Usage: log10(x), x <scalar|vector|waveform>

Returns the base 10 logarithm of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

magnitude

Usage: magnitude(x), x <scalar|vector|waveform>

Returns the absolute value or magnitude of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

max_fall_time

Usage: max_fall_time(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the maximum fall time of a curve. The default percentage values are 10% and 90%.

max_rise_time

Usage: max_rise_time(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the maximum rise time of a curve. The default percentage values are 10% and 90%.

max_slew_rate

Usage: max_slew_rate(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the maximum slew rate of a curve. The default percentage values are 10% and 90%.

maximum_value

Usage: maximum_value(<waveform>)

This function returns the maximum y axis value of a curve. For complex curves the maximum real and imaginary parts are returned in a complex value.

maximum_x_value

Usage: maximum_x_value(<waveform>)

This function returns the maximum x axis value of a curve.

min_fall_time

Usage: min_fall_time(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the minimum fall time of a curve. The default percentage values are 10% and 90%.

min_rise_time

Usage: min_rise_time(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the minimum rise time of a curve. The default percentage values are 10% and 90%.

min_slew_rate

Usage: min_slew_rate(w, [min_percentage, max_percentage], [x_min, x_max]), w <waveform>, [min_percentage, max_percentage] <scalar>, [x_min, x_max] <scalar>

This function computes the minimum slew rate of a curve. The default percentage values are 10% and 90%.

minimum_value

Usage: minimum_value(<waveform>)

This function returns the minimum y axis value of a curve. For complex curves the minimum real and imaginary parts are returned in a complex value.

minimum_x_value

Usage: minimum_x_value(<waveform>)

This function returns the minimum x axis value of a curve.

phase

Usage: phase(x), x <scalar|vector|waveform>

Returns the complex argument or phase of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

piecewise_poly

Usage: piecewise_poly(x, [x], [[coeff_1], [coeff_2], .. ]), x <scalar|vector>, [x] <vector>, [[coeff_1], [coeff_2], .. ] <vector of vectors>

This function defines a piecewise polynomial on the intervals defined in the vector [x]. For each interval the coefficients of the polynomials are defined in decreasing order in the coefficient matrix [[coeff_1], [coeff_2], .. ]. If a value is given for x, the piecewise polynomial will be evaluated in x.

plot

Usage: plot<expression>

This function allows to plot an algebraic expression without having to create a waveform. However the x- and y-axis units of the resulting waveform are undefined. Example: plot new_curve = x^2

poly

Usage: poly(x, [coeff]), x <scalar|vector>, [coeff] <vector>

This function defines a polynomial by it's coefficients [coeff]. The coefficients are given in decreasing order (a_n, ... , a_1, a_0). If a value is given for x, the polynomial will be evaluated in x.

real

Usage: real(x), x <scalar|vector|waveform>

Returns the real part of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

reduce_waveform

Usage: reduce_waveform(<waveform>, <eps_y>, [<max_step_x>])

This function reduces the number of points in a waveform. The parameter eps_y and max_step_x control the precision. Eps_y defines the acceptable relative error for the y-axis values. The optional parameter max_step_x controls the maximum step width in x-direction. A value of eps_y = 0.01 should yield reasonable precision. A value of max_step_x = 0.1 will limit the step width to 0.1 * (max_x - min_x).

resample_waveform

Usage: resample_waveform(<waveform>, <delta x>, [<minimum x>], [<maximum x>])

This function creates a new waveform on an equidistant set of x-axis values. These values are computed as x = minimum_x + k * delta_x with k = 0, 1, ... while x <= maximum_x . If the optional parameters minimum_x or maximum_x are omitted, these values are taken from the original curve.

round

Usage: round(x), x <scalar|vector|waveform>

Rounds the function argument to an integer value away from zero. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

shift_waveform

Usage: shift_waveform(<waveform>, <shift_x>, [<scale_x>, [<shift_y>, [<scale_y>]]])

This function shifts the waveform position on the x axis. It can also be scaled in x-direction and scaled and shifted in y-direction.

simplify

Usage: simplify(x), x <expression|scalar|vector|waveform>

Simplifies the function argument. A complex function argument is converted to a real one if possible.

sin

Usage: sin(x), x <scalar|vector|waveform>

Returns the sine of the function argument which is given in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

sind

Usage: sind(x), x <scalar|vector|waveform>

Returns the sine of the function argument which is given in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

sinh

Usage: sinh(x), x <scalar|vector|waveform>

Returns the hyperbolic sine of the function argument which is given in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

sinhd

Usage: sinhd(x), x <scalar|vector|waveform>

Returns the hyperbolic sine of the function argument which is given in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

size

Usage: size(x), x <vector|waveform>

Returns the size of a vector and the number of points in a waveform.

smooth_average

Usage: smooth_average(w, [coeff]), w <waveform>, [coeff] <integer>

This function smooths a curve by computing the moving average using "coeff" adjacent values.

sqrt

Usage: sqrt(x), x <scalar|vector|waveform>

Returns the square root of the function argument. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

tan

Usage: tan(x), x <scalar|vector|waveform>

Returns the tangent of the function argument which is given in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

tand

Usage: tand(x), x <scalar|vector|waveform>

Returns the tangent of the function argument which is given in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

tanh

Usage: tanh(x), x <scalar|vector|waveform>

Returns the hyperbolic tangent of the function argument which is given in radians. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

tanhd

Usage: tanhd(x), x <scalar|vector|waveform>

Returns the hyperbolic tangent of the function argument which is given in degrees. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

trunc

Usage: trunc(x), x <scalar|vector|waveform>

Rounds the function argument to an integer value toward zero. The returned type can be a real or complex. It can be a scalar, a vector or a waveform and is identical to the argument type. For vectors and waveforms the function is applied to each value.

vector

Usage: vector(x, .. ), x <scalar|expression>

vector(start:step:stop), start, step, stop <scalar> This function defines vector. The vector can be defined from discrete values or as a range of real or complex values. The operator [] can be used instead of the function vector().

waveform

Usage: waveform(<section identifier|section name>, <curve index|curve name>)

This function allows to reuse any loaded waveform in the calculator. When dragging a curve from the browser, a waveform() expression is created automatically. Example: new_curve = waveform("gain-stage.spi3", 1)