Libraries.Compute.Math Documentation

The Math class has a number of math actions you might find on a scientific calculator. For example, this class has Sine, Tangent, and Cosine actions, as well as a few different round actions. Authors: Most math functions call down to Java's java.lang.math class. The plugin calls and custom methods were written by Elliot Motl and Melissa Stefik.

Example Code

use Libraries.Compute.Math

class Main
    action main
        Math math
        number result = math:Power(2, 4)
    end
end

Inherits from: Libraries.Language.Object

Variables Table

VariablesDescription
number squareRoot2The Square Root of 2
number squareRoot1Over2The value of 1 / Square Root of 2.
number eThe value of e.
number twoOverPiThe value of 2.0 / pi.
number piOver4The value of pi / 4.
number log10OfEBase 10 logarithm of e.
number logTwoOfEBase 2 logarithm of e.
number eulerThe euler constant.
number naturalLog2Natural logarithm of 2.
number naturalLog10Natural Log of 10.
number piOver2The value of pi / 2.
number piThe value of pi.
number oneOverPiThe value of 1.0 / pi.

Actions Documentation

AbsoluteValue(number value)

This action calculates the absolute value of a number and returns the result.

Parameters

  • number value: The value that the absolute value will be calculated from.

Return

number: Returns the absolute value of the parameter value. The type returned is number.

Example

use Libraries.Compute.Math
Math math
number absValue = math:AbsoluteValue(-2443.4)

AbsoluteValue(integer value)

This action calculates the absolute value of an integer and returns the result.

Parameters

  • integer value: The value that the absolute value will be calculated from.

Return

integer: Returns the absolute value of the parameter value. The type returned is integer.

Example

use Libraries.Compute.Math
Math math
integer absValue = math:AbsoluteValue(-2443)

Ceiling(number value)

This action calculates the ceiling of a number (it rounds it up).

Parameters

  • number value: The number to take the ceiling of.

Return

number: Returns the ceiling of a number.

Example

use Libraries.Compute.Math
Math math
number result = math:Ceiling(11.9)
output result

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Cosine(number value)

This action calculates the cosine of a number in radians and returns the result.

Parameters

  • number value: The value that the cosine will be calculated from.

Return

number: Returns the cosine of the parameter value. The type returned is number.

Example

use Libraries.Compute.Math
Math math
number cosine = math:Cosine(4.32)

DegreesToRadians(number degrees)

This action converts a number from a value in degrees to a value in radians.

Parameters

  • number degrees: The number of degrees to convert to radians.

Return

number: Returns the value of the given number as radians.

Example

use Libraries.Compute.Math
Math math
number radians = math:DegreesToRadians(75.4)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

Equals(number x, number y, number epsilon)

This action returns true if the values x and y are within epsilon of each other. If epsilon is greater than 1, it is set to 1.

Parameters

  • number x: The first number
  • number y: The second number
  • number epsilon: The max distance between the values

Return

boolean: true if the values are equal within epison

Example

use Libraries.Compute.Math
Math math
boolean value = math:Equals(11.9, 11.901, 0.001)

Factorial(integer n)

This action calculates the factorial of n.

Parameters

  • integer n

Return

integer:

Floor(number value)

This action calculates the floor of a number (it rounds it down).

Parameters

  • number value: The number to take the floor of.

Return

number: Returns the floor of a number.

Example

use Libraries.Compute.Math
Math math
number result = math:Floor(11.9)
output result

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

HyperbolicCosine(number value)

This action calculates the hyperbolic cosine of a number value in radians.

Parameters

  • number value: The value to take the hyperbolic cosine of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:HyperbolicCosine(1.3)

HyperbolicSine(number value)

This action calculates the hyperbolic sine of a number value in radians.

Parameters

  • number value: The value to take the hyperbolic sine of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:HyperbolicSine(1.3)

HyperbolicTangent(number value)

This action calculates the hyperbolic tangent of a number value in radians.

Parameters

  • number value: The value to take the hyperbolic tangent of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:HyperbolicTangent(1.3)

InverseCosine(number value)

This action calculates the inverse cosine of a number value in radians.

Parameters

  • number value: The value to take the inverse cosine of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseCosine(1.3)

InverseHyperbolicCosine(number value)

This action calculates the inverse hyperbolic cosine of a number value in radians.

Parameters

  • number value: The value to take the inverse hyperbolic cosine of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseHyperbolicCosine(1.3)

InverseHyperbolicSine(number value)

This action calculates the inverse hyperbolic sine of a number value in radians.

Parameters

  • number value: The value to take the inverse hyperbolic sine of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseHyperbolicSine(1.3)

InverseHyperbolicTangent(number value)

This action calculates the inverse hyperbolic tangent of a number value in radians.

Parameters

  • number value: The value to take the inverse hyperbolic tangent of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseHyperbolicCosine(1.3)

InverseSine(number value)

This action calculates the inverse sine of a number value in radians.

Parameters

  • number value: The value to take the inverse sine of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseSine(1.3)

InverseTangent(number x, number y)

This action calculates the inverse tangent of a cartesian point, where its coordinates are of the form (x, y).

Parameters

  • number x: The x value of the cartesian point.
  • number y: The y value of the cartesian point.

Return

number: Returns the inverse tangent of the point as a number in radians.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseTangent(0.8, 2)

InverseTangent(number value)

This action calculates the inverse tangent of a number value in radians.

Parameters

  • number value: The value to take the inverse tangent of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:InverseTangent(1.3)

InverseTangent2(number x, number y)

return result in radians

Parameters

  • number x
  • number y

Return

number:

Logarithm(number value)

This action calculates the logarithm with base 10 of a number value.

Parameters

  • number value: The value to take the logarithm of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:Logarithm(17.2)

MaximumOf(number a, number b)

This action calculates the maximum between two numbers.

Parameters

  • number a
  • number b

Return

number:

MinimumOf(number a, number b)

This action calculates the minimum between two numbers.

Parameters

  • number a
  • number b

Return

number:

NaturalLogarithm(number value)

This action calculates the natural logarithm with base ''e'' of a number value.

Parameters

  • number value: The value to take the natural logarithm of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:NaturalLogarithm(17.2)

RadiansToDegrees(number radians)

This action converts a number from a value in radians to a value in degrees.

Parameters

  • number radians

Return

number: Returns the value of the given number as degrees.

Example

use Libraries.Compute.Math
Math math
number degrees = math:RadiansToDegrees(2.8)

RaiseNaturalNumberToPower(number power)

This action raises the natural number 'e' to the power of x.

Parameters

  • number power: the power to raise e to.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:RaiseNaturalNumberToPower(5)

RaiseToPower(number value, number power)

This action raises a value to the power of some number(for example "value^power").

Parameters

  • number value: The value to raise.
  • number power: The power.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:RaiseToPower(13,2)

Remainder(number a, number b)

This action calculates the remainder between two numbers.

Parameters

  • number a
  • number b

Return

number:

Round(number value)

This action rounds a number to the closest integer value. A midpoint value (5) will round up.

Parameters

  • number value: The value to round.

Return

number: the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:Round(11.932356)

Round(number value, boolean roundUp)

This action rounds a number to the nearest integer and will either round up or down when at a midpoint.

Parameters

  • number value: The value to round.
  • boolean roundUp: When roundUp is true rounding from a midpoint will round up. When it is false the number will be round down.

Return

number: the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:Round(11.532356, true)

Round(number value, integer decimalPlace)

This action rounds a number to the given number of decimal places.

Parameters

  • number value: The value to round.
  • integer decimalPlace: The number of decimal places to round to.

Return

number: the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:Round(11.932356, 3)

Round(number value, integer decimalPlace, boolean roundUp)

This action rounds a number to the given number of decimal places and will either round up or down when at a midpoint.

Parameters

  • number value: The value to round.
  • integer decimalPlace: The number of decimal places to round to.
  • boolean roundUp: When roundUp is true rounding from a midpoint will round up. When it is false the number will be round down.

Return

number: the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:Round(11.932356, 3)

RoundToNearestInteger(number value)

This action rounds a number to the closest integer value. A midpoint value (5) will round up.

Parameters

  • number value: The value to round.

Return

number: the number result.

Example

use Libraries.Compute.Math

Math math
number result = math:RoundToNearestInteger(11.932356)

Sine(number value)

This action calculates the sine of a number in radians and returns the result.

Parameters

  • number value: The value that the sine will be calculated from.

Return

number: Returns the sine of the parameter value. The type returned is number.

Example

use Libraries.Compute.Math
Math math
number result = math:Sine(11.9)

SquareRoot(number value)

This action calculates the square root of a number value.

Parameters

  • number value: The value to take the square root of.

Return

number: Returns the number result.

Example

use Libraries.Compute.Math
Math math
number result = math:SquareRoot(6)

Tangent(number value)

This action calculates the tangent of a number in radians and returns the result.

Parameters

  • number value: The value that the tangent will be calculated from.

Return

number: Returns the tangent of the parameter value. The type returned is number.

Example

use Libraries.Compute.Math
Math math
number cosine = math:Tangent(11.9)