Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BigNum

Immutable, arbitrary precision, higher dimensional numbers. A BigNum consists of a real part and imaginary part(s) stored as Component objects. A MathContext object is used to specify the number of decimal places (not significant figures) the user wants and what rounding algorithm should be used. Every operation is carried out by an intermediate result which is then rounded to the preferred number of decimal places using the preferred rounding algorithm.

The BigNum objects follow the Cayley-Dickson construction algebra for multiplication. They can be mathematically expressed as

\[ x = \sum_{i=0}^{N-1} x_ie_i \]

where \( N \) represents the number of dimensions the number exists in and \( e_i \) are the orthogonal units. The components are stored using a real first convention. Therefore, by convention \( e_0 = 1 \), the real unit. The others are the imaginary units. The \( e_1 \) is our familiar \( \imath \) for the complex numbers. Again, \( e_2=\jmath \) and \( e_3=k \) are the Hamilton's units for quaternions.

Notation:

In the documentation for the methods below, unless otherwise stated, the following notation is used.

Let \( x = a + v \) where \( a \) is the real part and \( v \) is the "vector" part or the purely imaginary part. Define \( \hat{v} = \frac{v}{\lvert v \rvert} \) and \( \theta = \lvert v \rvert \) such that \( x = a + \hat{v} \theta \).

Hierarchy

Index

Constructors

constructor

Properties

components

components: Component[]

The components of the number represented by this object. The first one (at index 0) is the real component and the rest are the components of the imaginary units.

dim

dim: number

The dimension in which this number belongs. The dimension must always be a power of 2.

Accessors

classRef

conj

imag

neg

real

Methods

add

  • Adds two BigNum instances. Addition is defined component-wise. That is, for two numbers \( a \) and \( b \), their addition is defined as

    \[ a + b = \sum_i a_i + b_i \]

    The result is rounded according to mathenv.mode.

    Parameters

    • that: BigNum

      The number to add this with.

    Returns BigNum

    this + that.

  • Adds two BigNum instances. Addition is defined component-wise. That is, for two numbers \( a \) and \( b \), their addition is defined as

    \[ a + b = \sum_i a_i + b_i \]

    The result is rounded according to the given context settings.

    Parameters

    • that: BigNum

      The number to add this with.

    • context: MathContext

      The context settings to use.

    Returns BigNum

    this + that.

div

  • Divides one BigNum instance by another. This method assumes right division. That is, the inverse of that is multiplied on the right. The result is rounded according to mathenv.mode.

    Parameters

    • that: BigNum

      Number to divide by.

    Returns BigNum

  • Divides one BigNum instance by another. This method assumes right division. That is, the inverse of that is multiplied on the right. The result is rounded according to the given context settings.

    Parameters

    • that: BigNum

      Number to divide by.

    • context: MathContext

      The context settings to use.

    Returns BigNum

  • Divides one BigNum instance by another. This method multiplies the inverse of that on the given "side" of this. The result is rounded according to mathenv.mode.

    Parameters

    • that: BigNum

      Number to divide by.

    • side: "left" | "right"

      Side on which to divide from.

    Returns BigNum

  • Divides one BigNum instance by another. This method multiplies the inverse of that on the given "side" of this. The result is rounded according to the given context settings.

    Parameters

    • that: BigNum

      Number to divide by.

    • side: "left" | "right"

      Side on which to divide from.

    • context: MathContext

      The context settings to use.

    Returns BigNum

equals

  • Checks whether this and that are equal numbers. Equality is defined component wise. That is, two numbers \( a \) and \( b \) are equal if and only if

    \[ a_i = b_i \quad \forall i \]

    The equality is checked only up to the number of decimal places specified by mathenv.mode.

    Parameters

    • that: BigNum

      The number to check against.

    Returns boolean

  • Checks whether this and that are equal numbers. Equality is defined component wise. That is, two numbers \( a \) and \( b \) are equal if and only if

    \[ a_i = b_i \quad \forall i \]

    The equality is checked only up to the number of decimal places specified by the given context settings.

    Parameters

    • that: BigNum

      The number to check against.

    • context: MathContext

      The context settings to use.

    Returns boolean

getDefinition

  • getDefinition(methodName: string): "instance" | "static" | "undefined"
  • Checks whether a method exists on the object or as a static member of the class.

    Parameters

    • methodName: string

      Name of the method.

    Returns "instance" | "static" | "undefined"

inv

mul

norm

  • Evaluates the norm of this number. Since this is not necessarily a real number, the norm is defined as \[ \text{norm } a = a^* a \] where \( a^* \) is the conjugate of \( a \).

    The norm is calculated with rounding according to mathenv.mode.

    Returns BigNum

  • Evaluates the norm of this number. Since this is not necessarily a real number, the norm is defined as \[ \text{norm } a = a^* a \] where \( a^* \) is the conjugate of \( a \).

    The norm is calculated with rounding according to the given context.

    Parameters

    Returns BigNum

sub

  • Subtracts one BigNum instance from another. Subtraction is defined component-wise. That is, for two numbers \( a \) and \( b \), their difference is defined as

    \[ a - b = \sum_i a_i - b_i \]

    The result is rounded according to mathenv.mode.

    Parameters

    • that: BigNum

      The number to add this with.

    Returns BigNum

    this - that.

  • Subtracts one BigNum instance from another. Subtraction is defined component-wise. That is, for two numbers \( a \) and \( b \), their difference is defined as

    \[ a - b = \sum_i a_i - b_i \]

    The result is rounded according to the given context settings.

    Parameters

    Returns BigNum

    this - that.

Static abs

Static absSq

Static acos

  • Calculates the inverse trigonometric cosine of a given value with rounding according to mathenv.mode.

    Method:

    \[ \cos^{-1} (a + v) = \cos^{-1} \left( \frac{\alpha(a, \theta) - \beta(a, \theta)}{2} \right) - \hat{v} \cosh^{-1} \left( \frac{\alpha(a, \theta) + \beta(a, \theta)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    Notation

    see

    alpha_beta

    Parameters

    Returns BigNum

  • Calculates the inverse trigonometric cosine of a given value with rounding according to the given context settings.

    Method:

    \[ \cos^{-1} (a + v) = \cos^{-1} \left( \frac{\alpha(a, \theta) - \beta(a, \theta)}{2} \right) - \hat{v} \cosh^{-1} \left( \frac{\alpha(a, \theta) + \beta(a, \theta)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    Notation

    see

    alpha_beta

    Parameters

    Returns BigNum

Static acosh

  • Calculates the inverse hyperbolic cosine of a given value with rounding according to mathenv.mode.

    Method:

    \[ \cosh^{-1} (a + v) = \cosh^{-1} \left( \frac{\alpha(\theta, a) + \beta(\theta, a)}{2} \right) + \hat{v} \cos^{-1} \left( \frac{\alpha(\theta, a) - \beta(\theta, a)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    alpha_beta

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the inverse hyperbolic cosine of a given value with rounding according to the given context settings.

    Method:

    \[ \cosh^{-1} (a + v) = \cosh^{-1} \left( \frac{\alpha(\theta, a) + \beta(\theta, a)}{2} \right) + \hat{v} \cos^{-1} \left( \frac{\alpha(\theta, a) - \beta(\theta, a)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    alpha_beta

    see

    Notation

    Parameters

    Returns BigNum

Static asin

  • Calculates the inverse trigonometric sine of a given value with rounding according to mathenv.mode.

    Method:

    \[ \sin^{-1} (a + v) = \sin^{-1} \left( \frac{\alpha(a, \theta) - \beta(a, \theta)}{2} \right) + \hat{v} \cosh^{-1} \left( \frac{\alpha(a, \theta) + \beta(a, \theta)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    Notation

    see

    alpha_beta

    Parameters

    Returns BigNum

  • Calculates the inverse trigonometric sine of a given value with rounding according to the given context settings.

    Method:

    \[ \sin^{-1} (a + v) = \sin^{-1} \left( \frac{\alpha(a, \theta) - \beta(a, \theta)}{2} \right) + \hat{v} \cosh^{-1} \left( \frac{\alpha(a, \theta) + \beta(a, \theta)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    Notation

    see

    alpha_beta

    Parameters

    Returns BigNum

Static asinh

  • Calculates the inverse hyperbolic sine of a given value with rounding according to mathenv.mode.

    Method:

    \[ \sinh^{-1} (a + v) = \cosh^{-1} \left( \frac{\alpha(\theta, a) + \beta(\theta, a)}{2} \right) + \hat{v} \sin^{-1} \left( \frac{\alpha(\theta, a) - \beta(\theta, a)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    Notation

    see

    alpha_beta

    Parameters

    Returns BigNum

  • Calculates the inverse hyperbolic sine of a given value with rounding according to the given context settings.

    Method:

    \[ \sinh^{-1} (a + v) = \cosh^{-1} \left( \frac{\alpha(\theta, a) + \beta(\theta, a)}{2} \right) + \hat{v} \sin^{-1} \left( \frac{\alpha(\theta, a) - \beta(\theta, a)}{2} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta.

    see

    Notation

    see

    alpha_beta

    Parameters

    Returns BigNum

Static atan

  • Calculates the inverse trigonometric tangent of a given value with rounding according to mathenv.mode.

    Method:

    \[ \tan^{-1}(a+v) = \frac{1}{2} \tan^{-1} \left( \frac{2a}{1 - \lVert a+v \rVert} \right) + \hat{v} \frac{1}{4} \ln \left( \frac{\alpha^2(\theta, a)}{\beta^2(\theta, a)} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta and \( \lVert a+v \rVert \) is the norm of the argument.

    see

    alpha_beta

    see

    norm

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the inverse trigonometric tangent of a given value with rounding according to the given context settings.

    Method:

    \[ \tan^{-1}(a+v) = \frac{1}{2} \tan^{-1} \left( \frac{2a}{1 - \lVert a+v \rVert} \right) + \hat{v} \frac{1}{4} \ln \left( \frac{\alpha^2(\theta, a)}{\beta^2(\theta, a)} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta and \( \lVert a+v \rVert \) is the norm of the argument.

    see

    alpha_beta

    see

    norm

    see

    Notation

    Parameters

    Returns BigNum

Static atanh

  • Calculates the inverse hyperbolic tangent of a given value with rounding according to mathenv.mode.

    Method:

    \[ \tanh^{-1} (a + v) = \frac{1}{4} \ln \left( \frac{\alpha^2(a, \theta)}{\beta^2(a, \theta)} \right) +\hat{v} \frac{1}{2} \tan^{-1} \left( \frac{2\theta}{1 - \lVert a+v \rVert} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta and \( \lVert a+v \rVert \) is the norm of the argument.

    see

    alpha_beta

    see

    norm

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the inverse hyperbolic tangent of a given value with rounding according to the given context settings.

    Method:

    \[ \tanh^{-1} (a + v) = \frac{1}{4} \ln \left( \frac{\alpha^2(a, \theta)}{\beta^2(a, \theta)} \right) +\hat{v} \frac{1}{2} \tan^{-1} \left( \frac{2\theta}{1 - \lVert a+v \rVert} \right) \]

    where \( \alpha(x, y) \) and \( \beta(x, y) \) are defined by the function alpha_beta and \( \lVert a+v \rVert \) is the norm of the argument.

    see

    alpha_beta

    see

    norm

    see

    Notation

    Parameters

    Returns BigNum

Static ceil

Static complex

  • complex(real: number, imag: number): BigNum
  • complex(real: string, imag: string): BigNum
  • Creates a BigNum instance of a complex number from the decimal representations of the real and imaginary part. This instance will store the exact binary floating point value of the number. Even though it uses the toString() method to convert number to string it might be unpredictable at times.

    The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Parameters

    • real: number

      The real part of the number.

    • imag: number

      The imaginary part of the number.

    Returns BigNum

  • Creates a BigNum instance from the string representations of the real and imaginary parts.

    The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Parameters

    • real: string

      The real part of the number.

    • imag: string

      The imaginary part of the number.

    Returns BigNum

Static cos

  • Calculates the trigonometric cosine of a given number with rounding according to mathenv.mode.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \cos (a + v) = \cos a \cosh \theta - \hat{v} \sin a \sinh \theta \]

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the trigonometric cosine of a given number with rounding according to the given context settings.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \cos (a + v) = \cos a \cosh \theta - \hat{v} \sin a \sinh \theta \]

    see

    Notation

    Parameters

    Returns BigNum

Static cosh

  • Calculates the hyperbolic cosine of a given value with rounding according to mathenv.mode.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \cosh (a + v) = \cosh a \cos \theta + \hat{v} \sinh a \sin \theta \]

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the hyperbolic cosine of a given value with rounding according to the given context settings.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \cosh (a + v) = \cosh a \cos \theta + \hat{v} \sinh a \sin \theta \]

    see

    Notation

    Parameters

    Returns BigNum

Static e

  • Returns a single unit corresponding to a given index. The indexing starts from 0. With \( e_0 = 1 \) defined as the real unit and the rest (for \( i>0 \)) are the orthogonal imaginary units.

    Parameters

    • i: number

      The index.

    Returns BigNum

Static exp

Static floor

Static hyper

  • hyper(...comps: number[]): BigNum
  • hyper(comps: number[]): BigNum
  • hyper(...comps: string[]): BigNum
  • hyper(comps: string[]): BigNum
  • Creates a BigNum instance from the components of a hyper-complex number that follow the Cayley-Dickson construction. This instance will use the exact binary floating point representations of the components. Even though it uses the toString() method to convert numbers to strings it might be unpredictable at times.

    The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Parameters

    • Rest ...comps: number[]

      The components of the number.

    Returns BigNum

  • Creates a BigNum instance from the components of a hyper-complex number that follow the Cayley-Dickson construction. This instance will use the exact binary floating point representations of the components. Even though it uses the toString() method to convert numbers to strings it might be unpredictable at times.

    The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Parameters

    • comps: number[]

      The components of the number.

    Returns BigNum

  • Creates a BigNum instance from the components of a hyper-complex number that follow the Cayley-Dickson construction.

    Parameters

    • Rest ...comps: string[]

      The components of the number.

      The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Returns BigNum

  • Creates a BigNum instance from the components of a hyper-complex number that follow the Cayley-Dickson construction.

    Parameters

    • comps: string[]

      The components of the number.

      The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Returns BigNum

Static ln

  • Calculates the natural logarithm (to the base \( e \)) of a given number with rounding according to mathenv.mode.

    Method:

    Let \( r \) be the absolute value of \( x \). Therefore, \( r = \lvert a + \hat{v} \theta \rvert \).

    \[ \ln \left(a+\hat{v}\theta \right) = \ln r + \hat{v} \phi \]

    where \( \phi \) is such that

    \[ \begin{align} a &= r \cos \phi \\ \theta &= r \sin \phi \end{align} \]

    that is,

    \[ \phi = \operatorname{atan2} \left(\theta, a \right) \]

    see

    atan2

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the natural logarithm (to the base \( e \)) of a given number with rounding according to the given context settings.

    Method:

    Let \( r \) be the absolute value of \( x \). Therefore, \( r = \lvert a + \hat{v} \theta \rvert \).

    \[ \ln \left(a+\hat{v}\theta \right) = \ln r + \hat{v} \phi \]

    where \( \phi \) is such that

    \[ \begin{align} a &= r \cos \phi \\ \theta &= r \sin \phi \end{align} \]

    that is,

    \[ \phi = \mathrm{atan2} \left(\theta, a \right) \]

    see

    atan2

    see

    Notation

    Parameters

    Returns BigNum

Static real

  • Creates a BigNum instance from the string representation of a real number.

    The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Parameters

    • num: string

      The string representation of a real number in decimal system.

    Returns BigNum

  • Creates a BigNum instance from the decimal representation of a real number. This instance created will store the exact binary floating point value of the number. Even though it uses the toString() method to convert the number to a string it might be unpredictable at times.

    The use of this function to create a new BigNum instance is recommended over using the constructor for the same. The constructor may not always be predictable is called directly.

    Parameters

    • num: number

      A numeric expression.

    Returns BigNum

Static round

Static sin

  • Calculates the trigonometric sine of a given number with rounding according to mathenv.mode.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \sin (a + v) = \sin a \cosh \theta + \hat{v} \cos a \sinh \theta \]

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the trigonometric sine of a given number with rounding according to the given context settings.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \sin (a + v) = \sin a \cosh \theta + \hat{v} \cos a \sinh \theta \]

    see

    Notation

    Parameters

    Returns BigNum

Static sinh

  • Calculates the hyperbolic sine of a given value with rounding according to mathenv.mode.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \sinh (a + v) = \sinh a \cos \theta + \hat{v} \cosh a \sin \theta \]

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the hyperbolic sine of a given value with rounding according to the given context settings.

    Method:

    The sum formula works for higher dimensional numbers too. Therefore,

    \[ \sinh (a + v) = \sinh a \cos \theta + \hat{v} \cosh a \sin \theta \]

    see

    Notation

    Parameters

    Returns BigNum

Static tan

Static tanh

  • Calculates the hyperbolic tangent of a given value with rounding according to mathenv.mode.

    Method:

    The easiest way to calculate \( \tanh x \) is to use

    \[ \tanh (a+v) = \frac{\sinh (a+v)}{\cosh (a+v)} \]

    Upon simplifying,

    \[ \tanh (a + v) = \frac{\sinh 2a}{\cosh 2a + \cos 2\theta} + \hat{v} \frac{\sin 2\theta}{\cosh 2a + \cos 2\theta} \]

    see

    Notation

    Parameters

    Returns BigNum

  • Calculates the hyperbolic tangent of a given value with rounding according to the given context settings.

    Method:

    The easiest way to calculate \( \tanh x \) is to use

    \[ \tanh (a+v) = \frac{\sinh (a+v)}{\cosh (a+v)} \]

    Upon simplifying,

    \[ \tanh (a + v) = \frac{\sinh 2a}{\cosh 2a + \cos 2\theta} + \hat{v} \frac{\sin 2\theta}{\cosh 2a + \cos 2\theta} \]

    see

    Notation

    Parameters

    Returns BigNum

Generated using TypeDoc