## Code Examples of QuinticFunction

• org.apache.commons.math.analysis.QuinticFunction
```
@Test
public void testQuinticMin() throws MathException {
// The quintic function has zeros at 0, +-0.5 and +-1.
// The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
UnivariateRealFunction f = new QuinticFunction();
UnivariateRealOptimizer underlying = new BrentOptimizer();
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(4312000053l);
MultiStartUnivariateRealOptimizer minimizer =
new MultiStartUnivariateRealOptimizer(underlying, 5, g);
minimizer.setAbsoluteAccuracy(10 * minimizer.getAbsoluteAccuracy());
minimizer.setRelativeAccuracy(10 * minimizer.getRelativeAccuracy());

try {
minimizer.getOptima();
fail("an exception should have been thrown");
} catch (IllegalStateException ise) {
// expected
} catch (Exception e) {
fail("wrong exception caught");
}
try {
minimizer.getOptimaValues();
fail("an exception should have been thrown");
} catch (IllegalStateException ise) {
// expected
} catch (Exception e) {
fail("wrong exception caught");
}

assertEquals(-0.27195612846834, minimizer.optimize(f, GoalType.MINIMIZE, -0.3, -0.2), 1.0e-13);
assertEquals(-0.27194301946870, minimizer.getResult(), 1.0e-13);
assertEquals(-0.04433426940878, minimizer.getFunctionValue(), 1.0e-13);

double[] optima = minimizer.getOptima();
double[] optimaValues = minimizer.getOptimaValues();
for (int i = 0; i < optima.length; ++i) {
assertEquals(f.value(optima[i]), optimaValues[i], 1.0e-10);
}

assertTrue(minimizer.getEvaluations()    >= 510);
assertTrue(minimizer.getEvaluations()    <= 530);
assertTrue(minimizer.getIterationCount() >= 150);
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```        // of zero a 0.
// The other roots are less well to find, in particular the root at 1, because
// the function grows fast for x>1.
// The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
// intervals containing these values are harder for the solvers.
UnivariateRealFunction f = new QuinticFunction();
double result;
// Brent-Dekker solver.
UnivariateRealSolver solver = new BrentSolver();
// Symmetric bracket around 0. Test whether solvers can handle hitting
// the root in the first iteration.
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```    /**
* Test deprecated APIs.
*/
@Deprecated
public void testDeprecated2() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
MullerSolver solver = new MullerSolver(f);
double min, max, expected, result, tolerance;

min = -0.4; max = 0.2; expected = 0.0;
tolerance = Math.max(solver.getAbsoluteAccuracy(),
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```
/**
* Test of solver for the quintic function.
*/
public void testQuinticFunction() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
double min, max, expected, result, tolerance;

min = -0.4; max = 0.2; expected = 0.0;
tolerance = Math.max(solver.getAbsoluteAccuracy(),
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```        result = solver.solve(f, 1, 4);
assertEquals(result, Math.PI, solver.getAbsoluteAccuracy());
}

public void testQuinticZero() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
double result;

UnivariateRealSolver solver = new BisectionSolver();
result = solver.solve(f, -0.2, 0.2);
assertEquals(result, 0, solver.getAbsoluteAccuracy());
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```
/**
* Test of integrator for the quintic function.
*/
public void testQuinticFunction() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new TrapezoidIntegrator();
double min, max, expected, result, tolerance;

min = 0; max = 1; expected = -1.0/48;
tolerance = Math.abs(expected * integrator.getRelativeAccuracy());
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```        result = integrator.integrate(f, min, max);
assertEquals(expected, result, tolerance);
}

public void testQuinticFunction() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new LegendreGaussIntegrator(3, 64);
double min, max, expected, result;

min = 0; max = 1; expected = -1.0/48;
result = integrator.integrate(f, min, max);
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```
/**
* Test of integrator for the quintic function.
*/
public void testQuinticFunction() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new RombergIntegrator();
double min, max, expected, result, tolerance;

min = 0; max = 1; expected = -1.0/48;
tolerance = Math.abs(expected * integrator.getRelativeAccuracy());
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```
/**
* Test of integrator for the quintic function.
*/
public void testQuinticFunction() throws MathException {
UnivariateRealFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new SimpsonIntegrator();
double min, max, expected, result, tolerance;

min = 0; max = 1; expected = -1.0/48;
tolerance = Math.abs(expected * integrator.getRelativeAccuracy());
```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```
@Test
public void testQuinticMin() throws MathException {
// The quintic function has zeros at 0, +-0.5 and +-1.
// The function has extrema (first derivative is zero) at 0.27195613 and 0.82221643,
UnivariateRealFunction f = new QuinticFunction();
UnivariateRealOptimizer minimizer = new BrentOptimizer();
assertEquals(-0.27195613, minimizer.optimize(f, GoalType.MINIMIZE, -0.3, -0.2), 1.0e-8);
assertEquals( 0.82221643, minimizer.optimize(f, GoalType.MINIMIZE,  0.3,  0.9), 1.0e-8);
assertTrue(minimizer.getIterationCount() <= 50);

```

View Full Code Here

• org.apache.commons.math.analysis.QuinticFunction
```
/**
*
*/
public void testQuinticZero() throws MathException {
DifferentiableUnivariateRealFunction f = new QuinticFunction();
double result;

UnivariateRealSolver solver = new NewtonSolver();
result = solver.solve(f, -0.2, 0.2);
assertEquals(result, 0, solver.getAbsoluteAccuracy());
```

View Full Code Here

TOP

TOP