Difference between revisions of "Math functions"

Line 5: Line 5:
 
These functions can be accessed from the '''Math '''library from the '''Definition '''menu.
 
These functions can be accessed from the '''Math '''library from the '''Definition '''menu.
  
'''Abs(x)''': Returns the absolute value of <code>x</code>. When <code>x</code> in complex, returns the magnitude, see [[Complex number functions]].
+
'''[[Abs]](x)''': Returns the absolute value of <code>x</code>. When <code>x</code> in complex, returns the magnitude, see [[Complex number functions]].
 
:<code>Abs(180) &rarr; 180</code>
 
:<code>Abs(180) &rarr; 180</code>
 
:<code>Abs(-210) &rarr; 210</code>
 
:<code>Abs(-210) &rarr; 210</code>
  
'''Ceil(x)''': Returns the smallest integer that is greater than or equal to <code>x</code>.
+
'''[[Ceil]](x)''': Returns the smallest integer that is greater than or equal to <code>x</code>.
 
:<code>Ceil(3.1) &rarr; 4</code>
 
:<code>Ceil(3.1) &rarr; 4</code>
 
:<code>Ceil(5) &rarr; 5</code>
 
:<code>Ceil(5) &rarr; 5</code>
Line 15: Line 15:
 
:<code>Ceil(-7) &rarr; -7</code>
 
:<code>Ceil(-7) &rarr; -7</code>
  
'''Ceil(x,digits)''': Returns the smallest number with the indicated of digits to the right of the decimal that is greater than or equal to x.
+
'''[[Ceil]](x,digits)''': Returns the smallest number with the indicated of digits to the right of the decimal that is greater than or equal to x.
 
:<code>Ceil(Pi,4) &rarr; 3.1416</code>
 
:<code>Ceil(Pi,4) &rarr; 3.1416</code>
 
:<code>Ceil(-12345,-2) &rarr; -12300</code>
 
:<code>Ceil(-12345,-2) &rarr; -12300</code>
  
'''Floor(x)''': Returns the largest integer that is smaller than or equal to <code>x</code>.
+
'''[[Floor]](x)''': Returns the largest integer that is smaller than or equal to <code>x</code>.
 
:<code>Floor(2.999) &rarr; 2</code>
 
:<code>Floor(2.999) &rarr; 2</code>
 
:<code>Floor(3) &rarr; 3</code>
 
:<code>Floor(3) &rarr; 3</code>
Line 25: Line 25:
 
:<code>Floor(-5) &rarr; -5</code>
 
:<code>Floor(-5) &rarr; -5</code>
  
'''Floor(x,digits)''': Returns the largest number with the indicated number of digits past the decimal that is less than or equal to <code>x</code>.
+
'''[[Floor]](x,digits)''': Returns the largest number with the indicated number of digits past the decimal that is less than or equal to <code>x</code>.
 
:<code>Floor(Pi,4) &rarr; 3.1415</code>
 
:<code>Floor(Pi,4) &rarr; 3.1415</code>
 
:<code>Floor(-12345,-2) &rarr; -12400</code>
 
:<code>Floor(-12345,-2) &rarr; -12400</code>
  
'''Round(x)''': Returns the value of <code>x</code> rounded to the nearest integer.
+
'''[[Round]](x)''': Returns the value of <code>x</code> rounded to the nearest integer.
 
:<code>Round(1.8) &rarr; 2</code>
 
:<code>Round(1.8) &rarr; 2</code>
 
:<code>Round(-2.8) &rarr; -3</code>
 
:<code>Round(-2.8) &rarr; -3</code>
Line 35: Line 35:
 
:<code>Round(-2.499) &rarr; -2</code>
 
:<code>Round(-2.499) &rarr; -2</code>
  
'''Round(x,digits)''': Rounds the value of <code>x</code> to the indicated number of decimal digits to the right of the decimal point.
+
'''[[Round]](x,digits)''': Rounds the value of <code>x</code> to the indicated number of decimal digits to the right of the decimal point.
 
:<code>Round(Pi,1) &rarr; 3.100</code>
 
:<code>Round(Pi,1) &rarr; 3.100</code>
 
:<code>Round(Pi,3) &rarr; 3.142</code>
 
:<code>Round(Pi,3) &rarr; 3.142</code>
Line 46: Line 46:
 
:<code>Exp(-4) &rarr; 0.01832</code>
 
:<code>Exp(-4) &rarr; 0.01832</code>
  
'''Ln(x)''': Returns the natural logarithm of <code>x</code>, which must be positive unless the system variable <code>Enable-ComplexNumbers</code> is set.
+
'''[[Ln]](x)''': Returns the natural logarithm of <code>x</code>, which must be positive unless the system variable <code>Enable-ComplexNumbers</code> is set.
 
:<code>Ln(150) &rarr; 5.011</code>
 
:<code>Ln(150) &rarr; 5.011</code>
 
:<code>Ln(Exp(5)) &rarr; 5</code>
 
:<code>Ln(Exp(5)) &rarr; 5</code>
  
'''Logten(x)''': Returns the logarithm to the base 10 of <code>x</code>, which must be positive unless the system variable <code>EnableComplexNumbers</code> is set.
+
'''[[Logten]](x)''': Returns the logarithm to the base 10 of <code>x</code>, which must be positive unless the system variable <code>EnableComplexNumbers</code> is set.
 
:<code>Logten(180) &rarr; 2.255</code>
 
:<code>Logten(180) &rarr; 2.255</code>
 
:<code>Logten(10 ^ 30) &rarr; 30</code>
 
:<code>Logten(10 ^ 30) &rarr; 30</code>
  
'''Sign(x)''': Returns -1 when <code>x</code> is negative, 1 when <code>x</code> is positive, 0 when <code>x</code> is zero, and <code>NaN</code> when x is <code>NaN</code>.
+
'''[[Sign]](x)''': Returns -1 when <code>x</code> is negative, 1 when <code>x</code> is positive, 0 when <code>x</code> is zero, and <code>NaN</code> when x is <code>NaN</code>.
 
:<code>Sign(-15.2) &rarr; -1</code>
 
:<code>Sign(-15.2) &rarr; -1</code>
 
:<code>Sign(7.3) &rarr; 1</code>
 
:<code>Sign(7.3) &rarr; 1</code>
Line 60: Line 60:
 
:<code>Sign(0/0) &rarr; NaN</code>
 
:<code>Sign(0/0) &rarr; NaN</code>
  
'''Sqr(x)''': Returns the square of <code>x</code>.
+
'''[[Sqr]](x)''': Returns the square of <code>x</code>.
 
:<code>Sqr(5) &rarr; 25</code>
 
:<code>Sqr(5) &rarr; 25</code>
 
:<code>Sqr(-4) &rarr; 16</code>
 
:<code>Sqr(-4) &rarr; 16</code>
  
'''Sqrt(x)''': Returns the square root of <code>x</code>. x must be positive unless the system variable <code>EnableComplex-Numbers</code> is set.
+
'''[[Sqrt]](x)''': Returns the square root of <code>x</code>. x must be positive unless the system variable <code>EnableComplex-Numbers</code> is set.
 
:<code>Sqrt(25) &rarr; 5 </code>
 
:<code>Sqrt(25) &rarr; 5 </code>
 
:<code>Sqrt(-1)&rarr; NAN</code>
 
:<code>Sqrt(-1)&rarr; NAN</code>
 
:<code>Sqrt(-1) &rarr; 1j ''{ when EnableComplexNumbers is set }''</code>
 
:<code>Sqrt(-1) &rarr; 1j ''{ when EnableComplexNumbers is set }''</code>
  
'''Mod(x, y)''': Returns the remainder (modulus) of <code>x/y</code>.
+
'''[[Mod]](x, y)''': Returns the remainder (modulus) of <code>x/y</code>.
 
:<code>Mod(7, 3)&rarr; 1</code>
 
:<code>Mod(7, 3)&rarr; 1</code>
 
:<code>Mod(12, 4) &rarr; 0</code>
 
:<code>Mod(12, 4) &rarr; 0</code>
 
:<code>Mod(-14, 5) &rarr; -4</code>
 
:<code>Mod(-14, 5) &rarr; -4</code>
  
'''Factorial(x)''': Returns the factorial of <code>x</code>, which must be between 0 and 170.
+
'''[[Factorial]](x)''': Returns the factorial of <code>x</code>, which must be between 0 and 170.
 
:<code>Factorial(5) &rarr; 120</code>
 
:<code>Factorial(5) &rarr; 120</code>
 
:<code>Factorial(0) &rarr; 1</code>
 
:<code>Factorial(0) &rarr; 1</code>
 
If <code>x</code> is not an integer, it rounds <code>x</code> to the nearest integer before taking the factorial.
 
If <code>x</code> is not an integer, it rounds <code>x</code> to the nearest integer before taking the factorial.
  
'''Cos(x), Sin(x), Tan(x)''': Returns the cosine, sine, and tangent of <code>x</code>, <code>x</code> assumed in degrees.
+
'''[[Cos]](x), [[Sin]](x), [[Tan]](x)''': Returns the cosine, sine, and tangent of <code>x</code>, <code>x</code> assumed in degrees.
 
:<code>Cos(180) &rarr; -1</code>
 
:<code>Cos(180) &rarr; -1</code>
 
:<code>Cos(-210) &rarr; -0.866</code>
 
:<code>Cos(-210) &rarr; -0.866</code>
Line 86: Line 86:
 
:<code>Tan(45) &rarr; 1</code>
 
:<code>Tan(45) &rarr; 1</code>
  
'''Arctan(x)''': Returns the arctangent of <code>x</code> in degrees (the inverse of Tan).
+
'''[[Arctan]](x)''': Returns the arctangent of <code>x</code> in degrees (the inverse of Tan).
 
:<code>Arctan(0) &rarr; 0</code>
 
:<code>Arctan(0) &rarr; 0</code>
 
:<code>Arctan(1) &rarr; 45</code>
 
:<code>Arctan(1) &rarr; 45</code>
 
:<code>Arctan(Tan(45)) &rarr; 45</code>
 
:<code>Arctan(Tan(45)) &rarr; 45</code>
  
See also [[Advanced math functions|“Arccos(x), Arcsin(x), Arctan2(y, x)”]].
+
See also [[Advanced math functions|“[[Arccos]](x), [[Arcsin]](x), [[Arctan2]](y, x)”]].
  
'''Degrees(r), Radians(d)''': Degrees gives degrees from radians, and radians gives radians from degrees
+
'''[[Degrees]](r), [[Radians]](d)''': Degrees gives degrees from radians, and radians gives radians from degrees
 
:<code>Degrees(Pi/2) &rarr; 90</code>
 
:<code>Degrees(Pi/2) &rarr; 90</code>
 
:<code>Degrees(-Pi) &rarr; -180</code>
 
:<code>Degrees(-Pi) &rarr; -180</code>

Revision as of 08:24, 16 November 2015


These functions can be accessed from the Math library from the Definition menu.

Abs(x): Returns the absolute value of x. When x in complex, returns the magnitude, see Complex number functions.

Abs(180) → 180
Abs(-210) → 210

Ceil(x): Returns the smallest integer that is greater than or equal to x.

Ceil(3.1) → 4
Ceil(5) → 5
Ceil(-2.9999) → -2
Ceil(-7) → -7

Ceil(x,digits): Returns the smallest number with the indicated of digits to the right of the decimal that is greater than or equal to x.

Ceil(Pi,4) → 3.1416
Ceil(-12345,-2) → -12300

Floor(x): Returns the largest integer that is smaller than or equal to x.

Floor(2.999) → 2
Floor(3) → 3
Floor(-2.01) → -3
Floor(-5) → -5

Floor(x,digits): Returns the largest number with the indicated number of digits past the decimal that is less than or equal to x.

Floor(Pi,4) → 3.1415
Floor(-12345,-2) → -12400

Round(x): Returns the value of x rounded to the nearest integer.

Round(1.8) → 2
Round(-2.8) → -3
Round(1.499) → 1
Round(-2.499) → -2

Round(x,digits): Rounds the value of x to the indicated number of decimal digits to the right of the decimal point.

Round(Pi,1) → 3.100
Round(Pi,3) → 3.142
Round(14243.4,-2) → 14200

Note: The Number Format setting determines how many digits are included when a number is displayed, while Round(x,digits) returns a new rounded number so that the rounded value can be used in subsequent computations.

Exp(x): Returns the exponential of x, e raised to the power of x.

Exp(5) → 148.4
Exp(-4) → 0.01832

Ln(x): Returns the natural logarithm of x, which must be positive unless the system variable Enable-ComplexNumbers is set.

Ln(150) → 5.011
Ln(Exp(5)) → 5

Logten(x): Returns the logarithm to the base 10 of x, which must be positive unless the system variable EnableComplexNumbers is set.

Logten(180) → 2.255
Logten(10 ^ 30) → 30

Sign(x): Returns -1 when x is negative, 1 when x is positive, 0 when x is zero, and NaN when x is NaN.

Sign(-15.2) → -1
Sign(7.3) → 1
Sign(0)→ 0
Sign(0/0) → NaN

Sqr(x): Returns the square of x.

Sqr(5) → 25
Sqr(-4) → 16

Sqrt(x): Returns the square root of x. x must be positive unless the system variable EnableComplex-Numbers is set.

Sqrt(25) → 5
Sqrt(-1)→ NAN
Sqrt(-1) → 1j { when EnableComplexNumbers is set }

Mod(x, y): Returns the remainder (modulus) of x/y.

Mod(7, 3)→ 1
Mod(12, 4) → 0
Mod(-14, 5) → -4

Factorial(x): Returns the factorial of x, which must be between 0 and 170.

Factorial(5) → 120
Factorial(0) → 1

If x is not an integer, it rounds x to the nearest integer before taking the factorial.

Cos(x), Sin(x), Tan(x): Returns the cosine, sine, and tangent of x, x assumed in degrees.

Cos(180) → -1
Cos(-210) → -0.866
Sin(30) → 0.5
Sin(-45) → -0.7071
Tan(45) → 1

Arctan(x): Returns the arctangent of x in degrees (the inverse of Tan).

Arctan(0) → 0
Arctan(1) → 45
Arctan(Tan(45)) → 45

See also [[Advanced math functions|“Arccos(x), Arcsin(x), Arctan2(y, x)”]].

Degrees(r), Radians(d): Degrees gives degrees from radians, and radians gives radians from degrees

Degrees(Pi/2) → 90
Degrees(-Pi) → -180
Degrees(90) → -1.57079633
Degrees(180) → 3.141592654

See Also

Comments


You are not allowed to post comments.