Package org.opentrafficsim.core.math
Class Solver
java.lang.Object
org.opentrafficsim.core.math.Solver
public final class Solver
extends java.lang.Object
Solvers for simple equations.
 
 Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. 
 BSD-style license. See OpenTrafficSim License.
 
- Version:
 - $Revision$, $LastChangedDate$, by $Author$, initial version Dec 10, 2015 
 - Author:
 - Alexander Verbraeck, Peter Knoppers
 
- 
Method Summary
Modifier and Type Method Description static doublefirstSolutionAfter(double lowerBound, double a, double b, double c)Solve a quadratic or linear equation and return the solution that is closest (but not less than) a boundary.static double[]solve(double a, double b)Solve linear equation ax+b=0 for x.static double[]solve(double a, double b, double c)Solve quadratic equation ax2+bx+c=0 for x. 
- 
Method Details
- 
solve
public static double[] solve(double a, double b, double c)Solve quadratic equation ax2+bx+c=0 for x. Degenerate case a == 0 is allowed.- Parameters:
 a- double; the coefficient of x2b- double; the coefficient of xc- double;- Returns:
 - double[]; array with zero, one, or two elements (depending on the number of solutions of the equation)
 
 - 
firstSolutionAfter
public static double firstSolutionAfter(double lowerBound, double a, double b, double c) throws ValueRuntimeExceptionSolve a quadratic or linear equation and return the solution that is closest (but not less than) a boundary.- Parameters:
 lowerBound- double; minimum value of good solutiona- double; quadratic coefficientb- double; linear coefficientc- double; value of the quadratic function for x==0- Returns:
 - double; the solution that is closest (but not less than) a boundary
 - Throws:
 ValueRuntimeException- if there is no acceptable solution
 - 
solve
public static double[] solve(double a, double b)Solve linear equation ax+b=0 for x.- Parameters:
 a- double; the coefficient of xb- double;- Returns:
 - double[]; array with one or zero elements (depending on the number of solutions of the equation). The case where both a and b are zero returns an array of length 0.
 
 
 -