### - Qucs -
Quite Universal Circuit Simulator

# Short Description of Mathematical Functions

The following operations and functions can be applied in Qucs equations. For detailed description please refer to the "Measurement Expressions Reference Manual". Parameters in brackets "[]" are optional.

## Operators

### Arithmetic Operators

`+x` | Unary plus
`-x` | Unary minus
`x+y` | Addition
`x-y` | Subtraction
`x*y` | Multiplication
`x/y` | Division
`x%y` | Modulo (remainder of division)
`x^y` | Power

### Logical Operators

`!x` | Negation
`x&&y` | And
`x||y` | Or
`x^^y` | Exclusive or
`x?y:z` | Abbreviation for conditional expression "if `x` then `y` else `z`"
`x==y` | Equal
`x!=y` | Not equal
`x<y` | Less than
`x<=y` | Less than or equal
`x>y` | Larger than
`x>=y` | Larger than or equal

## Alphabetical List of Functions

abs`` adjoint`` angle`` arccos`` arccosec`` arccot`` arcosech`` arcosh`` arcoth`` arcsec`` arcsin`` arctan`` arg`` arsech`` arsinh`` artanh`` avg`` besseli0`` besselj`` bessely`` ceil`` conj`` cos`` cosec`` cosech`` cosh`` cot`` coth`` cumavg`` cumprod`` cumsum`` dB`` dbm`` dbm2w`` ddx`` deg2rad`` det`` dft`` diff`` erf`` erfc`` erfcinv`` erfinv`` exp`` eye`` fft`` fftshift`` fix`` floor`` Freq2Time`` GaCircle`` GpCircle`` hypot`` idft`` ifft`` imag`` integrate`` interpolate`` inverse`` kbd`` length`` limexp`` linspace`` ln`` log10`` log2`` logspace`` mag`` max`` min`` Mu`` Mu2`` NoiseCircle`` norm`` phase`` PlotVs`` polar`` prod`` rad2deg`` random`` real`` rms`` Rollet`` round`` rtoswr`` rtoy`` rtoz`` runavg`` sec`` sech`` sign`` sin`` sinc`` sinh`` sqr`` sqrt`` srandom`` StabCircleL`` StabCircleS`` StabFactor`` StabMeasure`` stddev`` step`` stos`` stoy`` stoz`` sum`` tan`` tanh`` Time2Freq`` transpose`` twoport`` unwrap`` variance`` vt`` w2dbm`` xvalue`` ytor`` ytos`` ytoz`` yvalue`` ztor`` ztos`` ztoy``

## Math Functions

### Vectors and Matrices: Creation

`eye(n)` | Creates `n` x `n` identity matrix
`length(y)` | Returns the length of the given vector
`linspace(from,to,n)` | Creates a real vector with `n` linearly spaced components between `from` and `to`, both inclusively
`logspace(from,to,n)` | Creates a real vector with `n` logarithmically spaced components between `from` and `to`, both inclusively

### Vectors and Matrices: Basic Matrix Functions

`adjoint(x)` | Adjoint matrix of `x` (transposed and conjugate complex)
`det(x)` | Determinant of a matrix `x`
`inverse(x)` | Inverse matrix of `x`
`transpose(x)` | Transposed matrix of `x` (rows and columns exchanged)

### Elementary Mathematical Functions: Basic Real and Complex Functions

`abs(x)` | Absolute value, magnitude of complex number
`angle(x)` | Phase angle in radians of a complex number. Synonym for `arg()`
`arg(x)` | Phase angle in radians of a complex number
`conj(x)` | Conjugate of a complex number
`deg2rad(x)` | Converts phase from degrees into radians
`hypot(x,y)` | Euclidean distance function
`imag(x)` | Imaginary part of a complex number
`mag(x)` | Magnitude of a complex number
`norm(x)` | Square of the absolute value of a vector
`phase(x)` | Phase angle in degrees of a complex number
`polar(m,p)` | Transform from polar coordinates (magnitude `m`, phase `p`) into complex number
`rad2deg(x)` | Converts phase from radians into degrees
`real(x)` | Real part of a complex number
`sign(x)` | Signum function
`sqr(x)` | Square (power of two) of a number
`sqrt(x)` | Square root
`unwrap(p[,tol[,step]])` | Unwraps the angle `p` (in radians -- default `step` is 2*pi) using the optional tolerance value `tol` (default is pi)

### Elementary Mathematical Functions: Exponential and Logarithmic Functions

`exp(x)` | Exponential function to basis e
`limexp(x)` | Limited exponential function
`log10(x)` | Decimal logarithm
`log2(x)` | Binary logarithm
`ln(x)` | Natural logarithm (base e )

### Elementary Mathematical Functions: Trigonometry

`cos(x)` | Cosine function
`cosec(x)` | Cosecant
`cot(x)` | Cotangent function
`sec(x)` | Secant
`sin(x)` | Sine function
`tan(x)` | Tangent function

### Elementary Mathematical Functions: Inverse Trigonometric Functions

`arccos(x)` | Arc cosine (also known as "inverse cosine")
`arccosec(x)` | Arc cosecant
`arccot(x)` | Arc cotangent
`arcsec(x)` | Arc secant
`arcsin(x)` | Arc sine (also known as "inverse sine")
`arctan(x[,y])` | Arc tangent (also known as "inverse tangent")

### Elementary Mathematical Functions: Hyperbolic Functions

`cosh(x)` | Hyperbolic cosine
`cosech(x)` | Hyperbolic cosecant
`coth(x)` | Hyperbolic cotangent
`sech(x)` | Hyperbolic secant
`sinh(x)` | Hyperbolic sine
`tanh(x)` | Hyperbolic tangent

### Elementary Mathematical Functions: Inverse Hyperbolic Functions

`arcosh(x)` | Hyperbolic area cosine
`arcosech(x)` | Hyperbolic area cosecant
`arcoth(x)` | Hyperbolic area cotangent
`arsech(x)` | Hyperbolic area secant
`arsinh(x)` | Hyperbolic area sine
`artanh(x)` | Hyperbolic area tangent

### Elementary Mathematical Functions: Rounding

`ceil(x)` | Round to the next higher integer
`fix(x)` | Truncate decimal places from real number
`floor(x)` | Round to the next lower integer
`round(x)` | Round to nearest integer

### Elementary Mathematical Functions: Special Mathematical Functions

`besseli0(x)` | Modified Bessel function of order zero
`besselj(n,x)` | Bessel function of first kind and `n`-th order
`bessely(n,x)` | Bessel function of second kind and `n`-th order
`erf(x)` | Error function
`erfc(x)` | Complementary error function
`erfinv(x)` | Inverse error function
`erfcinv(x)` | Inverse complementary error function
`sinc(x)` | Sinc function (sin(`x`)/`x` or 1 at `x` = 0)
`step(x)` | Step function

### Data Analysis: Basic Statistics

`avg(x[,range])` | Arithmetic average of vector elements; if a range is given then `x` must have a single data dependency
`cumavg(x)` | Cumulative average of vector elements
`max(x,y)` | Returns the greater of the values `x` and `y`
`max(x[,range])` | Maximum value in vector; if a range is given then `x` must have a single data dependency
`min(x,y)` | Returns the lesser of the values `x` and `y`
`min(x[,range])` | Minimum value in vector; if a range is given then `x` must have a single data dependency
`rms(x)` | Root Mean Square of vector elements
`runavg(x)` | Running average of vector elements
`stddev(x)` | Standard deviation of vector elements
`variance(x)` | Variance of vector elements
`random()` | Random number between 0.0 and 1.0
`srandom(x)` | Give random seed

### Data Analysis: Basic Operation

`cumprod(x)` | Cumulative product of vector elements
`cumsum(x)` | Cumulative sum of vector elements
`interpolate(f,x[,n])` | Equidistant spline interpolation of real function vector `f(x)` using `n` equidistant datapoints; the latter can be omitted and defaults to a reasonable value
`prod(x)` | Product of vector elements
`sum(x)` | Sum of vector elements
`xvalue(f,yval)` | Returns the x-value which is associated with the y-value nearest to a specified y-value `yval` in a given vector `f`; therefore the vector `f` must have a single data dependency
`yvalue(f,xval)` | Returns the y-value of the given vector `f` which is located nearest to the x-value `xval`; therefore the vector `f` must have a single data dependency

### Data Analysis: Differentiation and Integration

`ddx(expr,var)` | Derives mathematical expression `expr` with respect to the variable `var`
`diff(y,x[,n])` | Differentiate vector `y` with respect to vector `x` `n` times. If `n` is omitted it defaults to `n` = 1
`integrate(x,h)` | Integrate vector `x` numerically assuming a constant step-size `h`

### Data Analysis: Signal Processing

`dft(x)` | Discrete Fourier Transform of vector `x`
`fft(x)` | Fast Fourier Transform of vector `x`
`fftshift(x)` | Shuffles the FFT values of vector `x` in order to move the frequency 0 to the center of the vector
`Freq2Time(V,f)` | Inverse Discrete Fourier Transform of function `V(f)` interpreting it physically
`idft(x)` | Inverse Discrete Fourier Transform of vector `x`
`ifft(x)` | Inverse Fast Fourier Transform of vector `x`
`kbd(x[,n])` | Kaiser-Bessel derived window
`Time2Freq(v,t)` | Discrete Fourier Transform of function `v(t)` interpreting it physically

## Electronics Functions

### Unit Conversion

`dB(x)` | dB value
`dbm(x)` | Convert voltage to power in dBm
`dbm2w(x)` | Convert power in dBm to power in Watts
`w2dbm(x)` | Convert power in Watts to power in dBm
`vt(t)` | Thermal voltage for a given temperature `t` in Kelvin

### Reflection Coefficients and VSWR

`rtoswr(x)` | Converts reflection coefficient to voltage standing wave ratio (VSWR)
`rtoy(x[,zref])` | Converts reflection coefficient to admittance; by default reference `zref` is 50 ohms
`rtoz(x[,zref])` | Converts reflection coefficient to impedance; by default reference `zref` is 50 ohms
`ytor(x[,zref])` | Converts admittance to reflection coefficient; by default reference `zref` is 50 ohms
`ztor(x[,zref])` | Converts impedance to reflection coefficient; by default reference `zref` is 50 ohms

### N-Port Matrix Conversions

`stos(s,zref[,z0])` | Converts S-parameter matrix to S-parameter matrix with different reference impedance(s)
`stoy(s[,zref])` | Converts S-parameter matrix to Y-parameter matrix
`stoz(s[,zref])` | Converts S-parameter matrix to Z-parameter matrix
`twoport(m,from,to)` | Converts a two-port matrix from one representation into another, possible values for `from` and `to` are 'Y', 'Z', 'H', 'G', 'A', 'S' and 'T'.
`ytos(y[,z0])` | Converts Y-parameter matrix to S-parameter matrix
`ytoz(y)` | Converts Y-parameter matrix to Z-parameter matrix
`ztos(z[,z0])` | Converts Z-parameter matrix to S-parameter matrix
`ztoy(z)` | Converts Z-parameter matrix to Y-parameter matrix

### Amplifiers

`GaCircle(s,Ga[,arcs])` | Circle(s) with constant available power gain `Ga` in the source plane
`GpCircle(s,Gp[,arcs])` | Circle(s) with constant operating power gain `Gp` in the load plane
`Mu(s)` | Mu stability factor of a two-port S-parameter matrix
`Mu2(s)` | Mu' stability factor of a two-port S-parameter matrix
`NoiseCircle(Sopt, Fmin,Rn,F[,Arcs])` | Generates circle(s) with constant Noise Figure(s) `F`. `Arcs` specifies the angles in degrees created by e.g. `linspace(0,360,100)`. If Arcs is a number it specifies the number of equally spaced circle segments, if it is omitted this number defaults to a reasonable value
`PlotVs(data,dep)` | Returns a data item based upon vector or matrix vector `data` with dependency on a given vector `dep`, e.g. `PlotVs(Gain,frequency/1e9)`
`Rollet(s)` | Rollet stability factor of a two-port S-parameter matrix
`StabCircleL(s[,arcs])` | Stability circle in the load plane
`StabCircleS(s[,arcs])` | Stability circle in the source plane
`StabFactor(s)` | Stability factor of a two-port S-parameter matrix. Synonym for `Rollet()`
`StabMeasure(s)` | Stability measure B1 of a two-port S-parameter matrix

## Nomenclature

### Ranges

`LO:HI` | Range from `LO` to `HI`
`:HI` | Up to `HI`
`LO:` | From `LO`
`:` | No range limitations

### Matrices and Matrix Elements

`M` | The whole matrix `M`
`M[2,3]` | Element being in 2nd row and 3rd column of matrix `M`
`M[:,3]` | Vector consisting of 3rd column of matrix `M`

### Immediate

`2.5` | Real number
`1.4+j5.1` | Complex number
`[1,3,5,7]` | Vector
`[11,12;21,22]` | Matrix

### Number suffixes

`E` | exa, * 1e+18
`P` | peta, * 1e+15
`T` | tera, * 1e+12
`G` | giga, * 1e+9
`M` | mega, * 1e+6
`k` | kilo, * 1e+3
`m` | milli, * 1e-3
`u` | micro, * 1e-6
`n` | nano, * 1e-9
`p` | pico, * 1e-12
`f` | femto, * 1e-15
`a` | atto, * 1e-18

### Name of Values

`S[1,1]` | S-parameter value
nodename.`V` | DC voltage at node nodename
name.`I` | DC current through component name
nodename.`v` | AC voltage at node nodename
name.`i` | AC current through component name
nodename.`vn` | AC noise voltage at node nodename
name.`in` | AC noise current through component name
nodename.`Vt` | Transient voltage at node nodename
name.`It` | Transient current through component name

Note: All voltages and currents are peak values.
Note: Noise voltages are RMS values at 1 Hz bandwidth.

## Constants

`i, j` | Imaginary unit ("square root of -1")
`pi` | 4*arctan(1) = 3.14159...
`e` | Euler = 2.71828...
`kB` | Boltzmann constant = 1.38065e-23 J/K
`q` | Elementary charge = 1.6021765e-19 C

back to the top