Libraries.Compute.ComplexNumber Documentation
The ComplexNumber class is used to represent an extension of real numbers that can store and express negative numbers' roots. Additionally, it contains actions to perform basic operations on these ComplexNumbers, such as addition, division, multiplication and so on. This was ported and adapted from the same model in Apache Commons, but was expanded upon to simplify the library and add a variety of helper actions that were missing. More information about this class can be found on its documentation page Complex: https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html For more information: https://en.wikipedia.org/wiki/Complex_number
Example Code
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
complex = complex:RaiseToPower(2)
output complex:ToText()
end
end
Inherits from: Libraries.Language.Object
Actions Documentation
AbsoluteValue()
Return the absolute value of this complex number. Returns NaN if either real or imaginary part is NaN and Double.POSITIVE_INFINITY if neither part is NaN, but at least one part is infinite.
Return
number: the absolute value.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = -3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:AbsoluteValue()
end
end
Add(Libraries.Compute.ComplexNumber value)
Returns a Complex Number. Uses the definitional formula (a + bi) + (c + di) = (a+c) + (b+d)i If either the complex number or the addend has an not a number value in either part, not a number is returned; otherwise Infinite and not a number values are returned in the parts of the result according to the rules for java.lang.Double arithmetic. throws an exception if the addend is undefined.
Parameters
Return
Libraries.Compute.ComplexNumber: this + addend.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber complex2
complex2:SetValue(imaginaryPart, realPart)
ComplexNumber value = complex:Add(complex2)
output value:ToText()
end
end
Add(number value)
Returns a Complex Number whose value is this + addend, with addend interpreted as a real number.
Parameters
- number value
Return
Libraries.Compute.ComplexNumber: this + addend.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber value = complex:Add(2)
output value:ToText()
end
end
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
- Libraries.Language.Object: The object to compare to.
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)
Conjugate()
Returns the conjugate of this complex number. The conjugate of a + bi is a - bi. #NaN is returned if either the real or imaginary part of this Complex number equals Double.NaN. If the imaginary part is infinite, and the real part is not NaN, the returned value has infinite imaginary part of the opposite sign, e.g. the conjugate of 1 + POSITIVE_INFINITY i is 1 - NEGATIVE_INFINITY i.
Return
Libraries.Compute.ComplexNumber: the conjugate of this Complex object.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber value = complex:Conjugate()
output value:ToText()
end
end
Cosine()
Compute the "http://mathworld.wolfram.com/Cosine.html" cosine of this complex number. Implements the formula: cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: cos(1 ± INFINITY i) = 1 \u2213 INFINITY i cos(±INFINITY + i) = NaN + NaN i cos(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the cosine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Cosine():ToText()
end
end
Divide(number divisor)
Returns a Complex whose value is me / divisor), with divisor interpreted as a real number.
Parameters
- number divisor: Value by which this Complex is to be divided.
Return
Libraries.Compute.ComplexNumber: me / divisor.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber value = complex:Divide(3)
output value:ToText()
end
end
Divide(Libraries.Compute.ComplexNumber divisor)
Returns a Complex whose value is (me / divisor). Implements the definitional formula (a + bi)/(c + di) = (ac + bd + (bc - ad)i)/(c^2 + d^2) but uses "http://doi.acm.org/10.1145/1039813.1039814" prescaling of operands to limit the effects of overflows and underflows in the computation. Infinite and NaN values are handled according to the following rules, applied in the order presented: If either me or divisor has a NaN valuein either part, #NaN is returned. If divisor equals #ZERO, #NaN is returned. If this and divisor are both infinite, #NaN is returned. If this is finite (i.e., has no Infinite or NaN parts) and divisor is infinite (one or both parts infinite), #ZERO is returned. If me is infinite and divisor is finite, Na values are returned in the parts of the result if the Double rules applied to the definitional formula force NaN results. Throws NullArgumentException if divisor is undefined.
Parameters
- Libraries.Compute.ComplexNumber: Value by which this Complex is to be divided.
Return
Libraries.Compute.ComplexNumber: me / divisor.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber complex2
complex2:SetValue(3, 3)
ComplexNumber value = complex:Divide(complex2)
output value:ToText()
end
end
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Parameters
- Libraries.Language.Object: The to be compared.
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(Libraries.Compute.ComplexNumber other)
Test for equality with another object. If both the real and imaginary parts of two complex numbers are exactly the same, and neither is Double.NaN, the two Complex objects are considered to be equal. The behavior is the same as for JDK's Double#equals(Object) Double: All NaN values are considered to be equal, i.e, if either (or both) real and imaginary parts of the complex number are equal to Double.NaN, the complex number is equal to NaN. Instances constructed with different representations of zero (i.e. either "0" or "-0") are not considered to be equal.
Parameters
- Libraries.Compute.ComplexNumber: Object to test for equality with this instance.
Return
boolean: true if the objects are equal, false if object is undefined, not an instance of Complex, or not equal to this instance. Attribut: Example use Libraries.Compute.ComplexNumber class Main action Main number realPart = 3 number imaginaryPart = 9 ComplexNumber complex complex:SetValue(realPart, imaginaryPart) ComplexNumber complex2 complex2:SetValue(3, 17) output complex:Equals(complex2) end end
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()
GetImaginary()
Compute the exponential function of this complex number. Implements the formula: exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i Returns Complex Not a Number if either real or imaginary part of the input argument is Not a Number. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Return
number: e^me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:NaturalExponent():ToText()
end
end
GetImaginaryOneValue()
Compute the "http://mathworld.wolfram.com/Sine.html" sine of this complex number. Implements the formula: sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: sin(1 ± INFINITY i) = 1 ± INFINITY i sin(±INFINITY + i) = NaN + NaN i sin(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the sine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Sine():ToText()
end
end
GetNotANumberValue()
Compute the "http://mathworld.wolfram.com/Tangent.html" tangent of this complex number. Implements the formula: tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: tan(a ± INFINITY i) = 0 ± i tan(±INFINITY + bi) = NaN + NaN i tan(±INFINITY ± INFINITY i) = NaN + NaN i tan(±π/2 + 0 i) = ±INFINITY + NaN i
Return
Libraries.Compute.ComplexNumber: the tangent of me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Tangent():ToText()
end
end
GetOneValue()
Compute the "http://mathworld.wolfram.com/HyperbolicCosine.html" hyperbolic cosine of this complex number. Implements the formula: cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh, and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: cosh(1 ± INFINITY i) = NaN + NaN i cosh(±INFINITY + i) = INFINITY ± INFINITY i cosh(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the hyperbolic cosine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:HyperbolicCosine():ToText()
end
end
GetPositiveInfinityValue()
Compute the "http://mathworld.wolfram.com/HyperbolicSine.html" hyperbolic sine of this complex number. Implements the formula: sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: sinh(1 ± INFINITY i) = NaN + NaN i sinh(±INFINITY + i) = ± INFINITY + INFINITY i sinh(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the hyperbolic sine of this.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:HyperbolicSine():ToText()
end
end
GetReal()
Compute the "http://mathworld.wolfram.com/HyperbolicTangent.html" hyperbolic tangent of this complex number. Implements the formula: tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: tanh(a ± INFINITY i) = NaN + NaN i tanh(±INFINITY + bi) = ±1 + 0 i tanh(±INFINITY ± INFINITY i) = NaN + NaN i tanh(0 + (π/2)i) = NaN + INFINITY i
Return
number: the hyperbolic tangent of me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:HyperbolicTangent():ToText()
end
end
GetZeroValue()
Compute the "http://mathworld.wolfram.com/Cosine.html" cosine of this complex number. Implements the formula: cos(a + bi) = cos(a)cosh(b) - sin(a)sinh(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: cos(1 ± INFINITY i) = 1 \u2213 INFINITY i cos(±INFINITY + i) = NaN + NaN i cos(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the cosine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Cosine():ToText()
end
end
HyperbolicCosine()
Compute the "http://mathworld.wolfram.com/HyperbolicCosine.html" hyperbolic cosine of this complex number. Implements the formula: cosh(a + bi) = cosh(a)cos(b) + sinh(a)sin(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh, and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: cosh(1 ± INFINITY i) = NaN + NaN i cosh(±INFINITY + i) = INFINITY ± INFINITY i cosh(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the hyperbolic cosine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:HyperbolicCosine():ToText()
end
end
HyperbolicSine()
Compute the "http://mathworld.wolfram.com/HyperbolicSine.html" hyperbolic sine of this complex number. Implements the formula: sinh(a + bi) = sinh(a)cos(b)) + cosh(a)sin(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: sinh(1 ± INFINITY i) = NaN + NaN i sinh(±INFINITY + i) = ± INFINITY + INFINITY i sinh(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the hyperbolic sine of this.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:HyperbolicSine():ToText()
end
end
HyperbolicTangent()
Compute the "http://mathworld.wolfram.com/HyperbolicTangent.html" hyperbolic tangent of this complex number. Implements the formula: tan(a + bi) = sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b))]i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: tanh(a ± INFINITY i) = NaN + NaN i tanh(±INFINITY + bi) = ±1 + 0 i tanh(±INFINITY ± INFINITY i) = NaN + NaN i tanh(0 + (π/2)i) = NaN + INFINITY i
Return
Libraries.Compute.ComplexNumber: the hyperbolic tangent of me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:HyperbolicTangent():ToText()
end
end
InverseCosine()
Compute the "http://mathworld.wolfram.com/InverseCosine.html" inverse cosine of this complex number. Implements the formula: acos(z) = -i (log(z + i (sqrt(1 - z^2)))) Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite.
Return
Libraries.Compute.ComplexNumber: the inverse cosine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:InverseCosine():ToText()
end
end
InverseSine()
Compute the "http://mathworld.wolfram.com/InverseSine.html" inverse sine of this complex number. Implements the formula: asin(z) = -i (log(sqrt(1 - z^2) + iz)) Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite.
Return
Libraries.Compute.ComplexNumber: the inverse sine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:InverseSine():ToText()
end
end
InverseTangent()
Compute the "http://mathworld.wolfram.com/InverseTangent.html" inverse tangent of this complex number. Implements the formula: atan(z) = (i/2) log((i + z)/(i - z)) Returns Complex#NaN if either real or imaginary part of the input argument is NaN or infinite.
Return
Libraries.Compute.ComplexNumber: the inverse tangent of this complex number
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:InverseTangent():ToText()
end
end
IsInfinite()
Returns of value of this complex number raised to the power of x. Implements the formula: y^x = exp(x*log(y)) where exp and log are NaturalExplonent and NaturalLogorithm, respectively. Returns Complex Not a number if either real or imaginary part of the input argument is not a number or infinite, or if y equals Complex#ZERO.
Return
boolean: me^x.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber complex2
complex2:SetValue(2,2)
output complex:RaiseToPower(complex2):ToText()
end
end
IsNotANumber()
Returns of value of this complex number raised to the power of x.
Return
boolean: me^x.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:RaiseToPower(2):ToText()
end
end
Multiply(Libraries.Compute.ComplexNumber multiplier)
Returns a {@code Complex} whose value is me * factor. Implements preliminary checks for NaN and infinity followed by the definitional formula: (a + bi)(c + di) = (ac - bd) + (ad + bc)i Returns #NaN if either me or factor has one or more NaN parts. Returns #INF if neither me nor factor has one or more NaN parts and if either me or factor has one or more infinite parts (same result is returned regardless of the sign of the components). Returns finite values in components of the result per the definitional formula in all remaining cases.Throws NullArgumentException if factor is undefined.
Parameters
- Libraries.Compute.ComplexNumber: factor value to be multiplied by this Complex.
Return
Libraries.Compute.ComplexNumber: me * factor.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber complex2
complex2:SetValue(1, 1)
output complex:Multiply(complex2):ToText()
end
end
Multiply(number multiplier)
Returns a Complex whose value is me * factor, with factor interpreted as a real number.
Parameters
- number multiplier: factor value to be multiplied by this Complex.
Return
Libraries.Compute.ComplexNumber: me * factor.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Multiply(2):ToText()
end
end
NaturalExponent()
Compute the exponential function of this complex number. Implements the formula: exp(a + bi) = exp(a)cos(b) + exp(a)sin(b)i Returns Complex Not a Number if either real or imaginary part of the input argument is Not a Number. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.
Return
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:NaturalExponent():ToText()
end
end
NaturalLogarithm()
Compute the "http://mathworld.wolfram.com/NaturalLogarithm.html" natural logarithm of this complex number. Implements the formula: log(a + bi) = ln(|a + bi|) + arg(a + bi)i where ln on the right hand side isFastMath#log, |a + bi|} is the modulus, Complex#abs, and arg(a + bi) = FastMath#atan2(b, a). Returns {@link Complex#NaN} if either real or imaginary part of the input argument is NaN. Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: log(1 ± INFINITY i) = INFINITY ± (π/2)i log(INFINITY + i) = INFINITY + 0i log(-INFINITY + i) = INFINITY + πi log(INFINITY ± INFINITY i) = INFINITY ± (π/4)i log(-INFINITY ± INFINITY i) = INFINITY ± (3π/4)i log(0 + 0i) = -INFINITY + 0i
Return
Libraries.Compute.ComplexNumber: the value ln this
, the natural logarithm of me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:NaturalLogarithm():ToText()
end
end
Negate()
Returns a Complex whose value is (-me). Returns NaN if either real or imaginary part of this Complex number is Double.NaN.
Return
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Negate():ToText()
end
end
RaiseToPower(Libraries.Compute.ComplexNumber x)
Returns of value of this complex number raised to the power of x. Implements the formula: y^x = exp(x*log(y)) where exp and log are NaturalExplonent and NaturalLogorithm, respectively. Returns Complex Not a number if either real or imaginary part of the input argument is not a number or infinite, or if y equals Complex#ZERO.
Parameters
- Libraries.Compute.ComplexNumber: exponent to which this ComplexNumber is to be raised.
Return
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber complex2
complex2:SetValue(2,2)
output complex:RaiseToPower(complex2):ToText()
end
end
RaiseToPower(number x)
Returns of value of this complex number raised to the power of x.
Parameters
- number x: exponent to which this Complex Number is to be raised.
Return
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:RaiseToPower(2):ToText()
end
end
Reciprocal()
SetValue(number real)
Create a complex number given the real part.
Parameters
- number real: Real part.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart)
complex = complex:RaiseToPower(2)
output complex:ToText()
end
end
SetValue(number real, number imaginary)
Create a complex number given the real and imaginary parts.
Parameters
- number real: Real part.
- number imaginary: Imaginary part.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:ToText()
end
end
Sine()
Compute the "http://mathworld.wolfram.com/Sine.html" sine of this complex number. Implements the formula: sin(a + bi) = sin(a)cosh(b) - cos(a)sinh(b)i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: sin(1 ± INFINITY i) = 1 ± INFINITY i sin(±INFINITY + i) = NaN + NaN i sin(±INFINITY ± INFINITY i) = NaN + NaN i
Return
Libraries.Compute.ComplexNumber: the sine of this complex number.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Sine():ToText()
end
end
SquareRoot()
Compute the "http://mathworld.wolfram.com/SquareRoot.html" square root of this complex number. Implements the following algorithm to compute sqrt(a + bi): Let t = sqrt((|a| + |a + bi|) / 2) if a ≥ 0 return t + (b/2t)i else return |b|/2t + sign(b)t i where |a| = FastMath#abs(a) |a + bi| = Complex#abs(a + bi) sign(b) = FastMath#copySign(double,double) copySign(1d, b) Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: sqrt(1 ± INFINITY i) = INFINITY + NaN i sqrt(INFINITY + i) = INFINITY + 0i sqrt(-INFINITY + i) = 0 + INFINITY i sqrt(INFINITY ± INFINITY i) = INFINITY + NaN i sqrt(-INFINITY ± INFINITY i) = NaN ± INFINITY i
Return
Libraries.Compute.ComplexNumber: the square root of me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 4
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:SquareRoot():ToText()
end
end
Subtract(number value)
Returns a Complex whose value is (me - subtrahend).
Parameters
- number value: subtrahend value to be subtracted from this Complex.
Return
Libraries.Compute.ComplexNumber: me - subtrahend.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Subtract(1):ToText()
end
end
Subtract(Libraries.Compute.ComplexNumber value)
Returns a Complex whose value is (me - subtrahend). Uses the definitional formula (a + bi) - (c + di) = (a-c) + (b-d)i If either me or subtrahend has a NaN value in either part, #NaN is returned; otherwise infinite and NaN values are returned in the parts of the result according to the rules for java.lang.Double arithmetic. Throws NullArgumentException if subtrahend is undefined.
Parameters
- Libraries.Compute.ComplexNumber: subtrahend value to be subtracted from this Complex.
Return
Libraries.Compute.ComplexNumber: me - subtrahend.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
ComplexNumber complex2
complex2:SetValue(1, 1)
output complex:Subtract(complex2):ToText()
end
end
Tangent()
Compute the "http://mathworld.wolfram.com/Tangent.html" tangent of this complex number. Implements the formula: tan(a + bi) = sin(2a)/(cos(2a)+cosh(2b)) + [sinh(2b)/(cos(2a)+cosh(2b))]i where the (real) functions on the right-hand side are FastMath#sin, FastMath#cos, FastMath#cosh and FastMath#sinh. Returns Complex#NaN if either real or imaginary part of the input argument is NaN. Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result. Examples: tan(a ± INFINITY i) = 0 ± i tan(±INFINITY + bi) = NaN + NaN i tan(±INFINITY ± INFINITY i) = NaN + NaN i tan(±π/2 + 0 i) = ±INFINITY + NaN i
Return
Libraries.Compute.ComplexNumber: the tangent of me.
Example
use Libraries.Compute.ComplexNumber
class Main
action Main
number realPart = 3
number imaginaryPart = 9
ComplexNumber complex
complex:SetValue(realPart, imaginaryPart)
output complex:Tangent():ToText()
end
end
ToText()
Outputs the complex number string.
Return
text: the complex number sentence.
On this page
Variables TableAction Documentation- AbsoluteValue()
- Add(Libraries.Compute.ComplexNumber value)
- Add(number value)
- Compare(Libraries.Language.Object object)
- Conjugate()
- Cosine()
- Divide(number divisor)
- Divide(Libraries.Compute.ComplexNumber divisor)
- Equals(Libraries.Language.Object object)
- Equals(Libraries.Compute.ComplexNumber other)
- GetHashCode()
- GetImaginary()
- GetImaginaryOneValue()
- GetNotANumberValue()
- GetOneValue()
- GetPositiveInfinityValue()
- GetReal()
- GetZeroValue()
- HyperbolicCosine()
- HyperbolicSine()
- HyperbolicTangent()
- InverseCosine()
- InverseSine()
- InverseTangent()
- IsInfinite()
- IsNotANumber()
- Multiply(Libraries.Compute.ComplexNumber multiplier)
- Multiply(number multiplier)
- NaturalExponent()
- NaturalLogarithm()
- Negate()
- RaiseToPower(Libraries.Compute.ComplexNumber x)
- RaiseToPower(number x)
- Reciprocal()
- SetValue(number real)
- SetValue(number real, number imaginary)
- Sine()
- SquareRoot()
- Subtract(number value)
- Subtract(Libraries.Compute.ComplexNumber value)
- Tangent()
- ToText()