org.apache.commons.math.analysis.polynomials
Class PolynomialFunctionTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.math.analysis.polynomials.PolynomialFunctionTest
All Implemented Interfaces:
junit.framework.Test

public final class PolynomialFunctionTest
extends junit.framework.TestCase

Tests the PolynomialFunction implementation of a UnivariateRealFunction.

Version:
$Revision: 799857 $
Author:
Matt Cliff

Field Summary
protected  double tolerance
          Error tolerance for tests
 
Constructor Summary
PolynomialFunctionTest()
           
 
Method Summary
 void checkPolynomial(org.apache.commons.math.analysis.polynomials.PolynomialFunction p, String reference)
           
 void testAddition()
           
 void testConstants()
          tests the value of a constant polynomial.
 void testfirstDerivativeComparison()
          tests the firstDerivative function by comparison
 void testLinear()
          tests the value of a linear polynomial.
 void testMultiplication()
           
 void testQuadratic()
          Tests a second order polynomial.
 void testQuintic()
          This will test the quintic function f(x) = x^2(x-5)(x+3)(x-1) = x^5 - 3x^4 -13x^3 + 15x^2
 void testSerial()
           
 void testString()
           
 void testSubtraction()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tolerance

protected double tolerance
Error tolerance for tests

Constructor Detail

PolynomialFunctionTest

public PolynomialFunctionTest()
Method Detail

testConstants

public void testConstants()
                   throws org.apache.commons.math.MathException
tests the value of a constant polynomial.

value of this is 2.5 everywhere.

Throws:
org.apache.commons.math.MathException

testLinear

public void testLinear()
                throws org.apache.commons.math.MathException
tests the value of a linear polynomial.

This will test the function f(x) = 3*x - 1.5

This will have the values f(0.0) = -1.5, f(-1.0) = -4.5, f(-2.5) = -9.0, f(0.5) = 0.0, f(1.5) = 3.0 and f(3.0) = 7.5

Throws:
org.apache.commons.math.MathException

testQuadratic

public void testQuadratic()
Tests a second order polynomial.

This will test the function f(x) = 2x^2 - 3x -2 = (2x+1)(x-2)


testQuintic

public void testQuintic()
This will test the quintic function f(x) = x^2(x-5)(x+3)(x-1) = x^5 - 3x^4 -13x^3 + 15x^2


testfirstDerivativeComparison

public void testfirstDerivativeComparison()
                                   throws org.apache.commons.math.MathException
tests the firstDerivative function by comparison

This will test the functions f(x) = x^3 - 2x^2 + 6x + 3, g(x) = 3x^2 - 4x + 6 and h(x) = 6x - 4

Throws:
org.apache.commons.math.MathException

testString

public void testString()

testAddition

public void testAddition()

testSubtraction

public void testSubtraction()

testMultiplication

public void testMultiplication()

testSerial

public void testSerial()

checkPolynomial

public void checkPolynomial(org.apache.commons.math.analysis.polynomials.PolynomialFunction p,
                            String reference)


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.