Class Solvers

java.lang.Object
org.sunflow.math.Solvers

public final class Solvers extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final double[]
    solveQuadric(double a, double b, double c)
    Solves the equation ax^2+bx+c=0.
    static double[]
    solveQuartic(double a, double b, double c, double d, double e)
    Solve a quartic equation of the form ax^4+bx^3+cx^2+cx^1+d=0.

    Methods inherited from class java.lang.Object

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

    • Solvers

      public Solvers()
  • Method Details

    • solveQuadric

      public static final double[] solveQuadric(double a, double b, double c)
      Solves the equation ax^2+bx+c=0. Solutions are returned in a sorted array if they exist.
      Parameters:
      a - coefficient of x^2
      b - coefficient of x^1
      c - coefficient of x^0
      Returns:
      an array containing the two real roots, or null if no real solutions exist
    • solveQuartic

      public static double[] solveQuartic(double a, double b, double c, double d, double e)
      Solve a quartic equation of the form ax^4+bx^3+cx^2+cx^1+d=0. The roots are returned in a sorted array of doubles in increasing order.
      Parameters:
      a - coefficient of x^4
      b - coefficient of x^3
      c - coefficient of x^2
      d - coefficient of x^1
      e - coefficient of x^0
      Returns:
      a sorted array of roots, or null if no solutions exist