BasicMathematical

Parent Previous Next

VisualSim                                                                                                                                    

Basic_Mathematical_Functions

 

Function & Argument Type(s)

 

Description

 


Examples

Abs

double/int/long/complex

Return Type: double/ int/long (complex returns double)

absolute value complex case:

x = abs(-2.0)

   = 2.0

Angle

complex

Return Type: double in the range [-pi, pi]

angle / argument of the complex number:  


x = angle(2.0+1.0i)

  = 0.46

ceil

double

Return Type: double

Ceiling function, which returns the smallest (closest to negative infinity) double value that is not less than the argument and is an integer.


x = ceil(1.7)

  = 2.0

compare

double, double

Return Type: int

Compare two numbers, returning 

-1 if if the first argument is less than; 

0, if the first argument is equal to;

1 if the first argument is greater than the second;


x = compare(1.5,2.0)

  = -1

conjugate

complex

Return Type: complex

Complex conjugate


x = conjugate(2.0+1.0i)

= 2.0 - 1.0i

Token.equivalent

(Token Argument)

Return true if the argument is equivalent value of the Token, else false.  The Token and Argument can be of different types.  Supported types are int, long, double, or string.


x = 2.equivalent(2.0)
true

x = 2.equivalent(2L)
true
x = 2.equivalent("2")
true

exp

double / complex

Return Type: double in the range[0.0, infinity] / complex

Exponential function (e^argument) complex case:


x = exp(-1)

  = 0.367

floor

double

Return Type: double

Floor function, which is the largest (closest to positive infinity) value not greater than the argument that is an integer.



x = floor(2.4)

  = 2.0

gaussian

double, double / double, double, int, / double, double, int, int

Return Type: double / {double} / [double]

One or more Gaussian random variables with the specified mean and standard deviation.



 x = gaussian(4.0,2.5)

   = 7.6282997399571

imag

complex

Return Type: double

Imaginary part

x = imag(1.0+2.0i)

  = 2.0

isInfinite

double

Return Type: boolean

Return true if the argument is infinite

x = isInfinite(2.0)

  = false

isNaN

double

Return Type: boolean

Return true if the argument is "not a number"


x = isNaN(1.0)

  = false

log

double / complex

Return Type: double / complex

Natural logarithm complex case:


x = log(1.5)

  = 0.405

log10

double

Return Type: double

Log base 10



x = log10(1.5)

  = 0.176

log2

double

Return Type: double

Log base 2


x = log2(1.5)

  = 0.584

max

double, double/int, int/long, long/unsignedByte, unsignedByte/{double}/

{int}/{long}/{unsignedByte}

Return Type: double / int / long / unsignedByte

Maximum

a = {2L,3L,1L,5L,2L,4L}

x = max(a)

   = 5L

min

double, double/int, int/ long, long/unsignedByte, unsignedByte/{double}/ {int}/{long}/ {unsignedByte}

Return Type: double/int/ long/unsignedByte

Minimum

a = {2.0,3.0,1.0,5.0,4.0}

x = min(a)

   = 1.0

 

pow

double, double/complex, complex

Return Type: double/complex

First argument to the power of the second

x = pow(3,2)

   = 9.0

random

no arguments/int/int, int

Return Type: double/ {double}/[double]

One or more random numbers between 0.0 and 1.0


x = random()

  = 0.4649

x = random(1)

  = {0.646}

real

complex

Return Type: double

Real part


x = real(3.0+5.0i)

  = 3.0

remainder

double, double

Return Type: double

Remainder after division, according to the IEEE 754 floating-point standard


x = remainder(9,2)

  = 1.0

 

round

double

Return Type: long

Round to the nearest long, choosing the next greater integer when exactly in between, and throwing an exception if out of range. If the argument is NaN, the result is 0L. If the argument is out of range, the result is either MaxLong / MinLong, depending on the sign.




x = round(1.6)

  = 2L

roundToInt

double

Return Type: int

Round to the nearest int, choosing the next greater integer when exactly in between, and throwing an exception if out of range. If the argument is NaN, the result is 0. If the argument is out of range, the result is either MaxInt / MinInt, depending on the sign.






x = roundToInt(1.4)

  = 1

sgn

double

Return Type: int

-1 if the argument is negative, 1 otherwise


x = sgn(-9)

  = -1

x = sgn(9)

  = 1

sqrt

double/complex

Return Type: double/complex

Square root. If the argument is double with value less than zero, then the result is NaN. complex case:


x = sqrt(9)

  = 3

toDegrees

double

Return Type: double

Convert radians to degrees


x = toDegrees(3.0)

  = 171.88

toRadians

double

Return Type: double

Convert degrees to radians



x = toRadians(1)

  = 0.0174

 

 

Created with the Personal Edition of HelpNDoc: Easily create CHM Help documents