Exponentiation Operator (^) (FPScript)
Raises an expression by a power.
Syntax
Basis ^ Exponent
The syntax of the ^ operator consists of the following elements:
Element |
Description |
---|---|
Basis |
Any expression. All data types except Boolean values are permitted. |
Exponent |
Same as Basis. |
Remarks
The operator can process scalar values or entire data series and data matrices. If at least one argument is a data series or a data matrix, the exponentiation takes place on a per-element basis and the result is once again a data series or a data matrix. If at least one of the two arguments is a data matrix, then both arguments must have the same number of rows. For a different number of columns in data matrices or for a different number of rows in data series, extra columns or values are removed.
If signals, signal series or space curves are used, only their Y components are taken into consideration. The result then preferably contains the X component and possibly the Z component of Basis. Otherwise, it contains those of Exponent. If one of the expressions returns a list, then the operation is executed for each item in the list and the result is also a list.
You can apply the operator to real and complex data types as well as to time spans and strings. For complex arguments, complex exponentiation occurs and the result is also complex. The result is always of the same data type as the expressions. If the expressions have different data types, then these are adapted to each other in such a way that there is no loss of resolution in the result, i.e. lower resolutions are converted into higher resolutions, integers are converted into floating point values and real numbers converted into complex numbers.
The complex exponentiation is defined as (a, b) ^ (c, d) = Exp((c, d) * Log((a, b))).
If one argument is numeric and the other is a string, the string is changed to the numeric type before the operation. Both arguments cannot be strings.
You can use time span values as Basis or Exponent. Both operands are then interpreted as seconds and the result is a time span value.
If Basis equals zero and Exponent is negative, this results in a void value for floating point data types. When integral data types are used, then an error is output. If Exponent is equal to zero, then the result is always one.
The operator is right-associative, i.e. sequences of exponentiations are processed from right to left.
If Basis is a quantity, its unit is exponentiated. Exponent in this case must either be an integer or presentable as a fraction with no more than two places in the denominator and in the numerator. If Exponent is a quantity, then it has to have the SI dimension 1 and it will be transformed to the unit 1 before exponentiation.
Available in
FlexPro View, Basic, Professional, Developer Suite
Examples
Signal ^ 2. |
Squares the amplitude in a signal. |
(1., 2.) ^ 2. |
Returns the complex 64-bit floating point value (-3., 4.). |
"3,23" ^ 2n |
Returns the 32-bit integer 9, since the string is changed to the data type of the numeric result. Note that the country-specific decimal symbol set in Windows must be used in the string. |
{ 0., 0.} ^ {0., -1.} |
Returns the data series with 64-bit floating point values { 1., ? }. |
2 m ^ 2 |
Returns the quantity 4 m². |
2 cm ^ 1.5 |
Returns the quantity 2.82842712474619 cm3/2. |
2. ^ 2 Pi |
Returns 2. ^ 6.2831853 = 77.8802336. |