Class NumberTheory

Buy me a cup of coffee via donation

Did you find the software useful? Please consider donation

or support me purchasing the license via ORDER Page , or INFIMA online store


INFIMA online store
java.lang.Object
org.mariuszgromada.math.mxparser.mathcollection.NumberTheory

public final class NumberTheory extends Object
NumberTheory - summation / products etc...
Version:
5.2.0
Author:
Mariusz Gromada
MathParser.org - mXparser project page
mXparser on GitHub
INFIMA place to purchase a commercial MathParser.org-mXparser software license
info@mathparser.org
ScalarMath.org - a powerful math engine and math scripting language
Scalar Lite
Scalar Pro
MathSpace.pl

Buy me a cup of coffee via donation

Did you find the software useful? Please consider donation

or support me purchasing the license via ORDER Page , or INFIMA online store


INFIMA online store
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    argmax(double... numbers)
    Arg-Max function.
    static double
    argmin(double... numbers)
    Arg-Min function.
    static String
    convDecimal2OthBase(double decimalNumber, int numeralSystemBase)
    Decimal number to other numeral system conversion with base between 1 and 36.
    static String
    convDecimal2OthBase(double decimalNumber, int numeralSystemBase, int format)
    Decimal number to other numeral system conversion with base between 1 and 36.
    static double
    convOthBase2Decimal(double[] baseAndDigits)
    Other base to decimal conversion.
    static double
    convOthBase2Decimal(double numeralSystemBase, double... digits)
    Other base to decimal conversion.
    static double
    convOthBase2Decimal(int[] baseAndDigits)
    Other base to decimal conversion.
    static double
    convOthBase2Decimal(int numeralSystemBase, int... digits)
    Other base to decimal conversion.
    static double
    convOthBase2Decimal(String numberLiteral)
    Other base (base between 1 and 36) number literal conversion to decimal number.
    static double
    convOthBase2Decimal(String numberLiteral, int numeralSystemBase)
    Other base (base between 1 and 36) number literal conversion to decimal number.
    static double
    digitAtPosition(double number, double position)
    Digit at position - numeral system with base 10
    static double
    digitAtPosition(double number, double position, double numeralSystemBase)
    Digit at position - numeral system with given base
    static int
    digitAtPosition(long number, int position)
    Digit at position - numeral system with base 10
    static int
    digitAtPosition(long number, int position, int numeralSystemBase)
    Digit at position - numeral system with given base
    static char
    digitChar(int digitIndex)
    Character representing digit for numeral systems with base between 1 and 36.
    static int
    digitIndex(char digitChar)
    Digit index based on digit character for numeral systems with base between 1 and 36.
    static String
    fractionToString(double[] fraction)
    Converts array representing fraction to fraction string representation.
    static double
    gcd(double... numbers)
    Greatest common divisor (GCD)
    static double
    gcd(double a, double b)
    Greatest common divisor (GCD)
    static long
    gcd(long... numbers)
    Greatest common divisor (GCD)
    static long
    gcd(long a, long b)
    Greatest common divisor (GCD)
    static double[][]
    getDistValues(double[] array, boolean returnOrderByDescFreqAndAscOrigPos)
    Returns list of distinct values found in a given array.
    static int
    Recognition of numeral system base in which number literal represents number.
    static long
    Gets initial search size used by the toFraction method
    static double
    lcm(double... numbers)
    Latest common multiply (LCM)
    static double
    lcm(double a, double b)
    Latest common multiply (LCM)
    static long
    lcm(long... numbers)
    Latest common multiply (LCM)
    static long
    lcm(long a, long b)
    Latest common multiply (LCM)
    static double
    max(double... numbers)
    Maximum function.
    static double
    max(double a, double b)
    Maximum function.
    static double
    max(Expression f, Argument index, double from, double to, double delta)
    Maximum value - iterative operator.
    static double
    min(double... numbers)
    Minimum function.
    static double
    min(double a, double b)
    Minimum function.
    static double
    min(Expression f, Argument index, double from, double to, double delta)
    Minimum value - iterative operator.
    static double
    numberOfDigits(double number)
    Number of digits needed to represent given number in base 10 numeral system.
    static double
    numberOfDigits(double number, double numeralSystemBase)
    Number of digits needed to represent given number (its integer part) in numeral system with given base.
    static int
    numberOfDigits(long number)
    Number of digits needed to represent given number in base 10 numeral system.
    static long
    numberOfDigits(long number, long numeralSystemBase)
    Number of digits needed to represent given number in numeral system with given base.
    static double
    numberOfDistValues(double... numbers)
    Returns number of unique values found the list of numbers
    static double
    numberOfPrimeFactors(double number)
    Prime decomposition (prime factorization) - returns number of distinct prime factors
    static double
    piProduct(Expression f, Argument index, double from, double to, double delta)
    Product operator
    static double
    primeCount(double n)
    Prime counting function
    static long
    primeCount(long n)
    Prime counting function
    static double
    primeFactorExponent(double number, double id)
    Prime decomposition (prime factorization) - returns prime factor exponent
    static double[]
    primeFactors(double number)
    Prime decomposition (prime factorization)
    static long[]
    primeFactors(long number)
    Prime decomposition (prime factorization)
    static double
    primeFactorValue(double number, double id)
    Prime decomposition (prime factorization) - returns prime factor value
    static double
    primeTest(double n)
    Prime test
    static boolean
    primeTest(long n)
    Prime test
    static double
    prod(double... numbers)
    Numbers multiplication.
    static void
    Sets initial search size for the toFraction method
    static double
    sigmaSummation(Expression f, Argument index, double from, double to, double delta)
    Summation operator (SIGMA FROM i = a, to b, f(i) by delta
    static int[]
    sortAsc(double[] array)
    Array sort - ascending - quick sort algorithm.
    static double
    sum(double... numbers)
    Adding numbers.
    static double[]
    toFraction(double value)
    Converts double value to its fraction representation.
    static String
    toFractionString(double value)
    Converts number to its fraction string representation.
    static double[]
    toMixedFraction(double value)
    Converts double value to its mixed fraction representation.
    static String
    toMixedFractionString(double value)
    Converts number to its mixed fraction string representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_TO_FRACTION_INIT_SEARCH_SIZE

      public static final long DEFAULT_TO_FRACTION_INIT_SEARCH_SIZE
      See Also:
  • Constructor Details

    • NumberTheory

      public NumberTheory()
  • Method Details

    • setToFractionInitSearchSize

      public static void setToFractionInitSearchSize(long n)
      Sets initial search size for the toFraction method
      Parameters:
      n - initial search size, has to be non-zero positive.
      See Also:
    • getToFractionInitSearchSize

      public static long getToFractionInitSearchSize()
      Gets initial search size used by the toFraction method
      Returns:
      initial search size used by the toFraction method
      See Also:
    • min

      public static double min(double a, double b)
      Minimum function.
      Parameters:
      a - the a function parameter
      b - the b function parameter
      Returns:
      if a,b <> Double.NaN returns Math.min(a, b), otherwise returns Double.NaN.
    • min

      public static double min(double... numbers)
      Minimum function.
      Parameters:
      numbers - the a function parameter
      Returns:
      if each number form numbers <> Double.NaN returns the smallest number, otherwise returns Double.NaN.
    • argmin

      public static double argmin(double... numbers)
      Arg-Min function.
      Parameters:
      numbers - the a function parameter
      Returns:
      Returns the index of the first smallest number, otherwise returns Double.NaN.
    • max

      public static double max(double a, double b)
      Maximum function.
      Parameters:
      a - the a function parameter
      b - the b function parameter
      Returns:
      if a,b <> Double.NaN returns Math.max(a, b), otherwise returns Double.NaN.
    • max

      public static double max(double... numbers)
      Maximum function.
      Parameters:
      numbers - the a function parameter
      Returns:
      if each number form numbers <> Double.NaN returns the highest number, otherwise returns Double.NaN.
    • argmax

      public static double argmax(double... numbers)
      Arg-Max function.
      Parameters:
      numbers - the a function parameter
      Returns:
      Returns the index of the first biggest number, otherwise returns Double.NaN.
    • sortAsc

      public static int[] sortAsc(double[] array)
      Array sort - ascending - quick sort algorithm.
      Parameters:
      array - Array to be sorted
      Returns:
      Sorts array and additionally returns initial ordering swapped according to sort order.
    • getDistValues

      public static double[][] getDistValues(double[] array, boolean returnOrderByDescFreqAndAscOrigPos)
      Returns list of distinct values found in a given array.
      Parameters:
      array - The array
      returnOrderByDescFreqAndAscOrigPos - Indicator whether to apply final ordering based on descending value frequency and ascending initial position.
      Returns:
      List of values in the form of: first index - value index, second index: 0 - value, 1 - value count, 2 - minimal value position in original array
    • numberOfDistValues

      public static double numberOfDistValues(double... numbers)
      Returns number of unique values found the list of numbers
      Parameters:
      numbers - The list of numbers
      Returns:
      Number of unique values. If list is null or any Double.NaN is found then Double.NaN is returned.
    • gcd

      public static long gcd(long a, long b)
      Greatest common divisor (GCD)
      Parameters:
      a - the a function parameter
      b - the b function parameter
      Returns:
      GCD(a,b)
    • gcd

      public static double gcd(double a, double b)
      Greatest common divisor (GCD)
      Parameters:
      a - the a function parameter
      b - the b function parameter
      Returns:
      if a, b <> Double.NaN returns gcd( (int)Math.round(a),(int)Math.round(b) ), otherwise returns Double.NaN.
    • gcd

      public static long gcd(long... numbers)
      Greatest common divisor (GCD)
      Parameters:
      numbers - the numbers
      Returns:
      GCD(a_1,...,a_n) a_1,...,a_n in numbers
    • gcd

      public static double gcd(double... numbers)
      Greatest common divisor (GCD)
      Parameters:
      numbers - the numbers
      Returns:
      if each number form numbers <> Double.NaN returns GCD(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
    • lcm

      public static long lcm(long a, long b)
      Latest common multiply (LCM)
      Parameters:
      a - the a function parameter
      b - the b function parameter
      Returns:
      LCM(a,b)
    • lcm

      public static double lcm(double a, double b)
      Latest common multiply (LCM)
      Parameters:
      a - the a function parameter
      b - the b function parameter
      Returns:
      if a, b <> Double.NaN returns lcm( (int)Math.round(a), (int)Math.round(b) ), otherwise returns Double.NaN.
    • lcm

      public static long lcm(long... numbers)
      Latest common multiply (LCM)
      Parameters:
      numbers - the numbers
      Returns:
      LCM(a_1,...,a_n) a_1,...,a_n in numbers
    • lcm

      public static double lcm(double... numbers)
      Latest common multiply (LCM)
      Parameters:
      numbers - the numbers
      Returns:
      if each number form numbers <> Double.NaN returns LCM(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
    • sum

      public static double sum(double... numbers)
      Adding numbers.
      Parameters:
      numbers - the numbers
      Returns:
      if each number from numbers <> Double.NaN returns sum(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
    • prod

      public static double prod(double... numbers)
      Numbers multiplication.
      Parameters:
      numbers - the numbers
      Returns:
      if each number from numbers <> Double.NaN returns prod(a_1,...,a_n) a_1,...,a_n in numbers, otherwise returns Double.NaN.
    • primeTest

      public static boolean primeTest(long n)
      Prime test
      Parameters:
      n - The number to be tested.
      Returns:
      true if number is prime, otherwise false
    • primeTest

      public static double primeTest(double n)
      Prime test
      Parameters:
      n - The number to be tested.
      Returns:
      true if number is prime, otherwise false
    • primeCount

      public static long primeCount(long n)
      Prime counting function
      Parameters:
      n - number
      Returns:
      Number of primes below or equal x
    • primeCount

      public static double primeCount(double n)
      Prime counting function
      Parameters:
      n - number
      Returns:
      Number of primes below or equal x
    • sigmaSummation

      public static double sigmaSummation(Expression f, Argument index, double from, double to, double delta)
      Summation operator (SIGMA FROM i = a, to b, f(i) by delta
      Parameters:
      f - the expression
      index - the name of index argument
      from - FROM index = form
      to - TO index = to
      delta - BY delta
      Returns:
      summation operation (for empty summation operations returns 0).
    • piProduct

      public static double piProduct(Expression f, Argument index, double from, double to, double delta)
      Product operator
      Parameters:
      f - the expression
      index - the name of index argument
      from - FROM index = form
      to - TO index = to
      delta - BY delta
      Returns:
      product operation (for empty product operations returns 1).
      See Also:
    • min

      public static double min(Expression f, Argument index, double from, double to, double delta)
      Minimum value - iterative operator.
      Parameters:
      f - the expression
      index - the name of index argument
      from - FROM index = form
      to - TO index = to
      delta - BY delta
      Returns:
      product operation (for empty product operations returns 1).
      See Also:
    • max

      public static double max(Expression f, Argument index, double from, double to, double delta)
      Maximum value - iterative operator.
      Parameters:
      f - the expression
      index - the name of index argument
      from - FROM index = form
      to - TO index = to
      delta - BY delta
      Returns:
      product operation (for empty product operations returns 1).
      See Also:
    • digitIndex

      public static int digitIndex(char digitChar)
      Digit index based on digit character for numeral systems with base between 1 and 36.
      Parameters:
      digitChar - Digit character (lower or upper case) representing digit in numeral systems with base between 1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
      Returns:
      Returns digit index if digit char was recognized, otherwise returns -1.
    • digitChar

      public static char digitChar(int digitIndex)
      Character representing digit for numeral systems with base between 1 and 36.
      Parameters:
      digitIndex - Digit index between 0 and 35
      Returns:
      Digit character representing digit for numeral systems with base between 1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z. If digit index is put of range '?' is returned.
    • getNumeralSystemBase

      public static int getNumeralSystemBase(String numberLiteral)
      Recognition of numeral system base in which number literal represents number. Examples: 2 for b2.1001 or b.1001, 1 for b1.111, 23 for b23.123afg 16 for b16.123acdf or h.123acdf.
      Parameters:
      numberLiteral - Number literal string. Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12. b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26. b27. b28. b29. b30. b31. b32. b33. b34. b35. b36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
      Returns:
      If number literal fits numeral system definition then numeral system base is returned (base between 1 and 36), otherwise -1 is returned.
    • convOthBase2Decimal

      public static double convOthBase2Decimal(String numberLiteral, int numeralSystemBase)
      Other base (base between 1 and 36) number literal conversion to decimal number.
      Parameters:
      numberLiteral - Number literal in given numeral system with base between 1 and 36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
      numeralSystemBase - Numeral system base, between 1 and 36
      Returns:
      Decimal number after conversion. If conversion was not possible the Double.NaN is returned.
    • convOthBase2Decimal

      public static double convOthBase2Decimal(String numberLiteral)
      Other base (base between 1 and 36) number literal conversion to decimal number. Base specification included in number literal. Examples: 2 for b2.1001 or b.1001, 1 for b1.111, 23 for b23.123afg 16 for b16.123acdf or h.123acdf.
      Parameters:
      numberLiteral - Number literal string. Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12. b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26. b27. b28. b29. b30. b31. b32. b33. b34. b35. b36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z
      Returns:
      Decimal number after conversion. If conversion was not possible the Double.NaN is returned.
    • convOthBase2Decimal

      public static double convOthBase2Decimal(int numeralSystemBase, int... digits)
      Other base to decimal conversion.
      Parameters:
      numeralSystemBase - Numeral system base has to be above 0.
      digits - List of digits
      Returns:
      Number after conversion. If conversion is not possible then Double.NaN is returned.
    • convOthBase2Decimal

      public static double convOthBase2Decimal(double numeralSystemBase, double... digits)
      Other base to decimal conversion.
      Parameters:
      numeralSystemBase - Numeral system base has to be above 0.
      digits - List of digits
      Returns:
      Number after conversion. If conversion is not possible then Double.NaN is returned.
    • convOthBase2Decimal

      public static double convOthBase2Decimal(int[] baseAndDigits)
      Other base to decimal conversion.
      Parameters:
      baseAndDigits - Numeral system base and digits specification. Numeral system base is placed at index 0, rest of array is interpreted as digits. Numeral system base has to be above 0.
      Returns:
      Number after conversion. If conversion is not possible then Double.NaN is returned.
    • convOthBase2Decimal

      public static double convOthBase2Decimal(double[] baseAndDigits)
      Other base to decimal conversion.
      Parameters:
      baseAndDigits - Numeral system base and digits specification. Numeral system base is placed at index 0, rest of array is interpreted as digits. Numeral system base has to be above 0.
      Returns:
      Number after conversion. If conversion is not possible then Double.NaN is returned.
    • convDecimal2OthBase

      public static String convDecimal2OthBase(double decimalNumber, int numeralSystemBase)
      Decimal number to other numeral system conversion with base between 1 and 36.
      Parameters:
      decimalNumber - Decimal number
      numeralSystemBase - Numeral system base between 1 and 36
      Returns:
      Number literal representing decimal number in given numeral system. Digits 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z. If conversion was not possible the "NaN" string is returned.
    • convDecimal2OthBase

      public static String convDecimal2OthBase(double decimalNumber, int numeralSystemBase, int format)
      Decimal number to other numeral system conversion with base between 1 and 36.
      Parameters:
      decimalNumber - Decimal number
      numeralSystemBase - Numeral system base between 1 and 36
      format - If 1 then always bxx. is used, i.e. b1. or b16. If 2 then for binary b. is used, for octal o. is used, for hexadecimal h. is used, otherwise bxx. is used where xx is the numeral system base specification.
      Returns:
      Number literal representing decimal number in given numeral system. Base format: b1. b2. b. b3. b4. b5. b6. b7. b8. o. b9. b10. b11. b12. b13. b14. b15. b16. h. b17. b18. b19. b20. b21. b22. b23. b24. b25. b26. b27. b28. b29. b30. b31. b32. b33. b34. b35. b36. Digits: 0:0, 1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8, 9:9, 10:A, 11:B, 12:C, 13:D, 14:E, 15:F, 16:G, 17:H, 18:I, 19:J, 20:K, 21:L, 22:M, 23:N, 24:O, 25:P, 26:Q, 27:R, 28:S, 29:T, 30:U, 31:V, 32:W, 33:X, 34:Y, 35:Z If conversion was not possible the "NaN" string is returned.
    • numberOfDigits

      public static int numberOfDigits(long number)
      Number of digits needed to represent given number in base 10 numeral system.
      Parameters:
      number - The number
      Returns:
      Number of digits needed to represent given number in base 10 numeral system.
    • numberOfDigits

      public static double numberOfDigits(double number)
      Number of digits needed to represent given number in base 10 numeral system.
      Parameters:
      number - The number
      Returns:
      Number of digits needed to represent given number in base 10 numeral system. If number is NaN the NaN is returned. If number is infinite then Double.POSITIVE_INFINITY is returned.
    • numberOfDigits

      public static long numberOfDigits(long number, long numeralSystemBase)
      Number of digits needed to represent given number in numeral system with given base.
      Parameters:
      number - The number
      numeralSystemBase - Numeral system base above 0
      Returns:
      Returns number of digits. In case when numeralSystemBase is lower than 1 then -1 is returned.
    • numberOfDigits

      public static double numberOfDigits(double number, double numeralSystemBase)
      Number of digits needed to represent given number (its integer part) in numeral system with given base.
      Parameters:
      number - The number
      numeralSystemBase - Numeral system base above 0
      Returns:
      Returns number of digits. In case when numeralSystemBase is lower than 1 then Double.NaN is returned. If number or numeralSystemBase is Double.NaN then Double.NaN is returned. If numeralSystemBase is infinite then Double.NaN is returned.
    • digitAtPosition

      public static int digitAtPosition(long number, int position, int numeralSystemBase)
      Digit at position - numeral system with given base
      Parameters:
      number - The number
      position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
      numeralSystemBase - Base of numeral system - above 0
      Returns:
      Return digit at given position. If digit finding was not possible then -1 is returned.
    • digitAtPosition

      public static int digitAtPosition(long number, int position)
      Digit at position - numeral system with base 10
      Parameters:
      number - The number
      position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
      Returns:
      Return digit at given position. If digit finding was not possible then -1 is returned.
    • digitAtPosition

      public static double digitAtPosition(double number, double position, double numeralSystemBase)
      Digit at position - numeral system with given base
      Parameters:
      number - The number
      position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
      numeralSystemBase - Base of numeral system - above 0
      Returns:
      Return digit at given position. If digit finding was not possible then Double.NaN is returned.
    • digitAtPosition

      public static double digitAtPosition(double number, double position)
      Digit at position - numeral system with base 10
      Parameters:
      number - The number
      position - Position from 1 ... n (left to right) or from 0 ... -(n-1) (right to left).
      Returns:
      Return digit at given position. If digit finding was not possible then Double.NaN is returned.
    • primeFactors

      public static long[] primeFactors(long number)
      Prime decomposition (prime factorization)
      Parameters:
      number - Number to be decomposed
      Returns:
      List of prime factors (non-distinct)
    • primeFactors

      public static double[] primeFactors(double number)
      Prime decomposition (prime factorization)
      Parameters:
      number - Number to be decomposed
      Returns:
      List of prime factors (non-distinct)
    • numberOfPrimeFactors

      public static double numberOfPrimeFactors(double number)
      Prime decomposition (prime factorization) - returns number of distinct prime factors
      Parameters:
      number - Number to be decomposed
      Returns:
      Number of distinct prime factors
    • primeFactorValue

      public static double primeFactorValue(double number, double id)
      Prime decomposition (prime factorization) - returns prime factor value
      Parameters:
      number - Number to be decomposed
      id - Factor id
      Returns:
      Factor value if factor id between 1 and numberOfPrimeFactors, otherwise 1 is returned. For NaN of infinite parameters Double NaN is returned. For number eq 0 Double.NaN is returned.
    • primeFactorExponent

      public static double primeFactorExponent(double number, double id)
      Prime decomposition (prime factorization) - returns prime factor exponent
      Parameters:
      number - Number to be decomposed
      id - Factor id
      Returns:
      Factor exponent if factor id between 1 and numberOfPrimeFactors, otherwise 0 is returned. For NaN of infinite parameters Double NaN is returned. For number eq 0 Double.NaN is returned.
    • toFraction

      public static double[] toFraction(double value)
      Converts double value to its fraction representation.
      Parameters:
      value - Value to be converted
      Returns:
      Array representing fraction. Sign at index 0, numerator at index 1, denominator at index 2. If conversion is not possible then Double.NaN is assigned to all the fields.
    • toMixedFraction

      public static double[] toMixedFraction(double value)
      Converts double value to its mixed fraction representation.
      Parameters:
      value - Value to be converted
      Returns:
      Array representing fraction. Sign at index 0, whole number at index 1, numerator at index 2, denominator at index 3. If conversion is not possible then Double.NaN is assigned to both numerator and denominator.
    • fractionToString

      public static String fractionToString(double[] fraction)
      Converts array representing fraction to fraction string representation.
      Parameters:
      fraction - Array representing fraction (including mix fractions)
      Returns:
      String representation of fraction.
      See Also:
    • toFractionString

      public static String toFractionString(double value)
      Converts number to its fraction string representation.
      Parameters:
      value - Given number
      Returns:
      String representation of fraction.
      See Also:
    • toMixedFractionString

      public static String toMixedFractionString(double value)
      Converts number to its mixed fraction string representation.
      Parameters:
      value - Given number
      Returns:
      String representation of fraction.
      See Also: