Difference between revisions of "Math functions"

m (Added see also to Sigmoid, Logit, ProductLog)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Analytica User Guide]]
 
[[Category:Analytica User Guide]]
<languages />
+
[[Category: Math Functions]]
<translate>
+
<breadcrumbs>Analytica User Guide > Expressions > {{PAGENAME}}</breadcrumbs>
[[Analytica User Guide]] > [[Using Expressions]] > [[Math functions]]
+
{{ReleaseBar}}
  
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 «x». When «x» is complex, returns the magnitude, see [[Complex number functions]]. See also [[Abs]]().
 
:<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 «x». See also [[Ceil]]().
 
:<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 16: Line 16:
 
:<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». See also [[Ceil]]().
:<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>.
+
'''Ceil(x, ,dateUnit)''': Rounds a date-time «x» up to the indicated «dateUnit», where «dateUnit» can be 'Y', 'Q', 'M', 'D', 'h', 'm', or 's' (year, quarter, month, day, hour, minute, second).
 +
:<code>Ceil(26-July-2017, dateUnit:'Y') &rarr; 1-Jan-2018</code>
 +
:<code>Ceil(26-July-2017, dateUnit:'M') &rarr; 1-Aug-2017</code>
 +
:<code>Ceil(26-July-2017, dateUnit:'D') &rarr; 26-July-2017</code>
 +
 
 +
'''Floor(x)''': Returns the largest integer that is smaller than or equal to «x». See also [[Floor]]().
 
:<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>
 
:<code>Floor(-2.01) &rarr; -3</code>
 
:<code>Floor(-2.01) &rarr; -3</code>
 
:<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 «x». See also [[Floor]]().
 +
:<code>Floor(Pi, 4) &rarr; 3.1415</code>
 +
:<code>Floor(-12345, -2) &rarr; -12400</code>
 +
 +
'''Floor(x, ,dateUnit)''': Rounds a date-time «x» down to the indicated «dateUnit», where «dateUnit» can be 'Y', 'Q', 'M', 'D', 'h', 'm', or 's' (year, quarter, month, day, hour, minute, second).
 +
:<code>Floor(26-July-2017, dateUnit:'Y') &rarr; 1-Jan-2017</code>
 +
:<code>Floor(26-July-2017, dateUnit:'M') &rarr; 1-July-2017</code>
 +
:<code>Floor(26-July-2017, dateUnit:'D') &rarr; 26-July-2017</code>
 +
 +
'''Round(x)''': Returns the value of «x» rounded to the nearest integer. See also [[Round]]().
 +
:<code>Round(1.8) &rarr; 2</code>
 +
:<code>Round(-2.8) &rarr; -3</code>
 +
:<code>Round(1.499) &rarr; 1</code>
 +
:<code>Round(-2.499) &rarr; -2</code>
 +
 +
'''Round(x, digits)''': Rounds the value of «x» to the number of decimal digits, indicated by «digits», to the right of the decimal point. See also [[Round]]().
 +
:<code>Round(Pi, 1) &rarr; 3.100</code>
 +
:<code>Round(Pi, 3) &rarr; 3.142</code>
 +
:<code>Round(14243.4, -2) &rarr; 14200</code>
 +
 +
'''''Note: '''The Number Format setting determines how many digits are included when a number is displayed, while'' <code>Round(x,digits)</code> ''returns a new rounded number so that the rounded value can be used in subsequent computations.''
 +
 +
'''Exp(x)''': Returns the exponential of «x», <code>e</code> raised to the power of «x». See also [[Exp]]().
 +
:<code>Exp(5) &rarr; 148.4</code>
 +
:<code>Exp(-4) &rarr; 0.01832</code>
 +
 +
'''Ln(x)''': Returns the natural logarithm of «x», which must be positive unless the system variable [[EnableComplexNumbers]] is set. See also [[Ln]]().
 +
:<code>Ln(150) &rarr; 5.011</code>
 +
:<code>Ln(Exp(5)) &rarr; 5</code>
 +
 +
'''Logten(x)''': Returns the logarithm to the base 10 of «x», which must be positive unless the system variable [[EnableComplexNumbers]] is set. See also [[Logten]]().
 +
:<code>Logten(180) &rarr; 2.255</code>
 +
:<code>Logten(10^30) &rarr; 30</code>
 +
 +
'''Sign(x)''': Returns -1 when «x» is negative, 1 when «x» is positive, 0 when «x» is zero, and <code>NaN</code> when «x» is <code>NaN</code>. See also [[Sign]]().
 +
:<code>Sign(-15.2) &rarr; -1</code>
 +
:<code>Sign(7.3) &rarr; 1</code>
 +
:<code>Sign(0) &rarr; 0</code>
 +
:<code>Sign(0/0) &rarr; NaN</code>
 +
 +
'''Sqr(x)''': Returns the square of «x». See also [[Sqr]]().
 +
:<code>Sqr(5) &rarr; 25</code>
 +
:<code>Sqr(-4) &rarr; 16</code>
 +
 +
'''Sqrt(x)''': Returns the square root of «x». «x» must be positive unless the system variable [[EnableComplexNumbers]] is set. See also [[Sqrt]]().
 +
:<code>Sqrt(25) &rarr; 5 </code>
 +
:<code>Sqrt(-1) &rarr; NAN</code>
 +
:<code>Sqrt(-1) &rarr; 1j ''{ when EnableComplexNumbers is set }''</code>
 +
 +
'''Mod(x, y)''': Returns the remainder (modulus) of <code>«x»/«y»</code>. See also [[Mod]]().
 +
:<code>Mod(7, 3) &rarr; 1</code>
 +
:<code>Mod(12, 4) &rarr; 0</code>
 +
:<code>Mod(-14, 5) &rarr; -4</code>
 +
 +
'''Factorial(x)''': Returns the factorial of «x», which must be between 0 and 170. See also [[Factorial]]().
 +
:<code>Factorial(5) &rarr; 120</code>
 +
:<code>Factorial(0) &rarr; 1</code>
 +
If «x» is not an integer, it rounds «x» to the nearest integer before taking the factorial.
 +
 +
'''Logit(p)''': The inverse of the [[Sigmoid]] function, is defined for <code>0 < p < 1</code> and is equal to <code>[[Ln]](p / (1-p))</code>. See alse [[Logit]]().
 +
:<code>Logit(0.5) &rarr;0</code>
 +
:<code>Logit(0.25) &rarr; -1.099</code>
 +
 +
{{Release|5.0||'''ProductLog(z)''': Returns the value for x that solves <code>z {{=}} x * [[Exp]](x)</code>. It is also known as the Lambert W function. It is real-valued for a real-valued parameter with <code>z &ge; -[[Exp]](-1)</code>. It is also defined for all complex numbers. For real-valued '''z''' with <code>z<-[[Exp]](-1)</code>, a complex result is returned only when [[EnableComplexNumbers]] is on, and in which case, the so called ''first branch'' or ''upper branch'' (<math>W_0(z)</math>) is returned. See also [[ProductLog]]().
 +
:<code>ProductLog(0) &rarr; 0</code>
 +
:<code>ProductLog(100) &rarr; 3.386</code>
 +
::<code> 3.386 * Exp(3.386) &rarr; 100</code>
 +
}}
 +
 +
'''Sigmoid(x)''': The sigmoid function is also called the logistic function, the expit function, or the inverse logit function. It serves as a continuous approximation to the step function <code>(x>=0)</code>. It approaches 0 as '''x''' approaches <code>-Inf</code>, approaches 1 as x approaches <code>Inf</code> and is 1/2 at x=0. It is equal to <code>1/(1+[[Exp]](-x))</code>. See also [[Sigmoid]]().
 +
:<code>Sigmoid(0) &rarr; 0.5</code>
 +
:<code>Sigmoid(1) &rarr; 0.7311</code>
 +
 +
'''Cos(x), Sin(x), Tan(x)''': Return the cosine, sine, and tangent of «x», «x» assumed in degrees. See also [[Cos]](x), [[Sin]](x), [[Tan]](x).
 +
:<code>Cos(180) &rarr; -1</code>
 +
:<code>Cos(-210) &rarr; -0.866</code>
 +
:<code>Sin(30) &rarr; 0.5</code>
 +
:<code>Sin(-45) &rarr; -0.7071</code>
 +
:<code>Tan(45) &rarr; 1</code>
 +
 +
'''Arctan(x)''': Returns the arctangent of «x» in degrees (the inverse of Tan). See also [[Arctan]](x), [[Arccos]](x), [[Arcsin]](x), [[Arctan2]](y, x) and [[Advanced math functions]].
 +
:<code>Arctan(0) &rarr; 0</code>
 +
:<code>Arctan(1) &rarr; 45</code>
 +
:<code>Arctan(Tan(45)) &rarr; 45</code>
 +
 +
'''Degrees(r), Radians(d)''': Degrees(r) gives degrees from radians, and Radians(d) gives radians from degrees. See also [[Degrees]](r) and [[Radians]](d).
 +
:<code>Degrees(Pi/2) &rarr; 90</code>
 +
:<code>Degrees(-Pi) &rarr; -180</code>
 +
:<code>Degrees(90) &rarr; -1.57079633</code>
 +
:<code>Degrees(180) &rarr; 3.141592654</code>
  
 
==See Also==
 
==See Also==
{| style="margin: 1em auto 1em auto;width: 100%;border:0;table-layout: fixed;" cellpadding=5
+
* [[Numbers]]
|- style="text-align: center"
+
* [[Number formats]]
| [[Function calls and parameters]] <- || [[Math functions]] || -> [[Numbers and text]]
+
* [[Text, Date, Math, and Financial Functions]]
|}
+
* [[Advanced math functions]]
</translate>
+
* [[Complex number functions]]
 +
* [[EnableComplexNumbers]]
 +
* [[Operators]]
 +
* [[Sum]]
 +
* [[Product]]
 +
 
 +
 
 +
 
 +
<footer>Function calls and parameters / {{PAGENAME}} / Numbers and text</footer>

Latest revision as of 17:48, 4 August 2017



Release:

4.6  •  5.0  •  5.1  •  5.2  •  5.3  •  5.4  •  6.0  •  6.1  •  6.2  •  6.3  •  6.4  •  6.5


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

Abs(x): Returns the absolute value of «x». When «x» is complex, returns the magnitude, see Complex number functions. See also Abs().

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

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

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». See also Ceil().

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

Ceil(x, ,dateUnit): Rounds a date-time «x» up to the indicated «dateUnit», where «dateUnit» can be 'Y', 'Q', 'M', 'D', 'h', 'm', or 's' (year, quarter, month, day, hour, minute, second).

Ceil(26-July-2017, dateUnit:'Y') → 1-Jan-2018
Ceil(26-July-2017, dateUnit:'M') → 1-Aug-2017
Ceil(26-July-2017, dateUnit:'D') → 26-July-2017

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

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». See also Floor().

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

Floor(x, ,dateUnit): Rounds a date-time «x» down to the indicated «dateUnit», where «dateUnit» can be 'Y', 'Q', 'M', 'D', 'h', 'm', or 's' (year, quarter, month, day, hour, minute, second).

Floor(26-July-2017, dateUnit:'Y') → 1-Jan-2017
Floor(26-July-2017, dateUnit:'M') → 1-July-2017
Floor(26-July-2017, dateUnit:'D') → 26-July-2017

Round(x): Returns the value of «x» rounded to the nearest integer. See also Round().

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 number of decimal digits, indicated by «digits», to the right of the decimal point. See also Round().

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». See also Exp().

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

Ln(x): Returns the natural logarithm of «x», which must be positive unless the system variable EnableComplexNumbers is set. See also Ln().

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. See also Logten().

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. See also Sign().

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

Sqr(x): Returns the square of «x». See also Sqr().

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

Sqrt(x): Returns the square root of «x». «x» must be positive unless the system variable EnableComplexNumbers is set. See also Sqrt().

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

Mod(x, y): Returns the remainder (modulus) of «x»/«y». See also Mod().

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. See also Factorial().

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

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

Logit(p): The inverse of the Sigmoid function, is defined for 0 < p < 1 and is equal to Ln(p / (1-p)). See alse Logit().

Logit(0.5) →0
Logit(0.25) → -1.099

ProductLog(z): Returns the value for x that solves z = x * Exp(x). It is also known as the Lambert W function. It is real-valued for a real-valued parameter with z ≥ -Exp(-1). It is also defined for all complex numbers. For real-valued z with z<-Exp(-1), a complex result is returned only when EnableComplexNumbers is on, and in which case, the so called first branch or upper branch ([math]\displaystyle{ W_0(z) }[/math]) is returned. See also ProductLog().

ProductLog(0) → 0
ProductLog(100) → 3.386
3.386 * Exp(3.386) → 100

Sigmoid(x): The sigmoid function is also called the logistic function, the expit function, or the inverse logit function. It serves as a continuous approximation to the step function (x>=0). It approaches 0 as x approaches -Inf, approaches 1 as x approaches Inf and is 1/2 at x=0. It is equal to 1/(1+Exp(-x)). See also Sigmoid().

Sigmoid(0) → 0.5
Sigmoid(1) → 0.7311

Cos(x), Sin(x), Tan(x): Return the cosine, sine, and tangent of «x», «x» assumed in degrees. See also Cos(x), Sin(x), Tan(x).

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). See also Arctan(x), Arccos(x), Arcsin(x), Arctan2(y, x) and Advanced math functions.

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

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

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.