SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function.polynomial.root
Class Linear

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.polynomial.root.Linear
All Implemented Interfaces:
Solver

public class Linear
extends java.lang.Object
implements Solver

This is a linear equation solver.

A linear equation is an algebraic equation in which each term is either a constant or the product of a constant and (the first power of) a single variable. That is, it has this form

ax + b = 0

The solution is simply

x = -b/a

See Also:
Wikipedia: Linear equation

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.polynomial.root.Solver
Solver.RootFindingException, Solver.Type
 
Constructor Summary
Linear()
           
 
Method Summary
 NumberList solve(Polynomial polynomial)
          Solve ax + b = 0
 Solver.Type type()
          Get the type of the solver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Linear

public Linear()
Method Detail

type

public Solver.Type type()
Description copied from interface: Solver
Get the type of the solver.

Specified by:
type in interface Solver
Returns:
the solver type

solve

public NumberList solve(Polynomial polynomial)
Solve
ax + b = 0

Specified by:
solve in interface Solver
Parameters:
polynomial - the linear polynomial to solve
Returns:
a list of all roots in Number
Throws:
java.lang.IllegalArgumentException - if the polynomial degree is not 1

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.