Package org.apache.commons.math.analysis

Examples of org.apache.commons.math.analysis.SinFunction


    /**
     * Test of solver for the sine function.
     */
    public void testSinFunction() throws MathException {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealSolver solver = new MullerSolver();
        double min, max, expected, result, tolerance;

        min = 3.0; max = 4.0; expected = FastMath.PI;
        tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
View Full Code Here


    /**
     * Test of solver for the sine function using solve2().
     */
    public void testSinFunction2() throws MathException {
        UnivariateRealFunction f = new SinFunction();
        MullerSolver solver = new MullerSolver();
        double min, max, expected, result, tolerance;

        min = 3.0; max = 4.0; expected = FastMath.PI;
        tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
View Full Code Here

    /**
     * Test of parameters for the solver.
     */
    public void testParameters() throws Exception {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealSolver solver = new MullerSolver();

        try {
            // bad interval
            solver.solve(f, 1, -1);
View Full Code Here

*/
public final class NewtonSolverTest extends TestCase {

    @Deprecated
    public void testDeprecated() throws MathException {
        DifferentiableUnivariateRealFunction f = new SinFunction();
        double result;

        UnivariateRealSolver solver = new NewtonSolver(f);
        result = solver.solve(3, 4);
        assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
View Full Code Here

    /**
    *
    */
   public void testSinZero() throws MathException {
       DifferentiableUnivariateRealFunction f = new SinFunction();
       double result;

       UnivariateRealSolver solver = new NewtonSolver();
       result = solver.solve(f, 3, 4);
       assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy());
View Full Code Here

public class MultiStartUnivariateRealOptimizerTest {

    @Test
    public void testSinMin() throws MathException {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealOptimizer underlying = new BrentOptimizer();
        JDKRandomGenerator g = new JDKRandomGenerator();
        g.setSeed(44428400075l);
        MultiStartUnivariateRealOptimizer minimizer =
            new MultiStartUnivariateRealOptimizer(underlying, 10, g);
        minimizer.optimize(f, GoalType.MINIMIZE, -100.0, 100.0);
        double[] optima = minimizer.getOptima();
        double[] optimaValues = minimizer.getOptimaValues();
        for (int i = 1; i < optima.length; ++i) {
            double d = (optima[i] - optima[i-1]) / (2 * FastMath.PI);
            assertTrue (FastMath.abs(d - FastMath.rint(d)) < 1.0e-8);
            assertEquals(-1.0, f.value(optima[i]), 1.0e-10);
            assertEquals(f.value(optima[i]), optimaValues[i], 1.0e-10);
        }
        assertTrue(minimizer.getEvaluations() > 150);
        assertTrue(minimizer.getEvaluations() < 250);
    }
View Full Code Here

    /**
     * Test of integrator for the sine function.
     */
    public void testSinFunction() throws MathException {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealIntegrator integrator = new SimpsonIntegrator();
        double min, max, expected, result, tolerance;

        min = 0; max = FastMath.PI; expected = 2;
        tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
 
View Full Code Here

    /**
     * Test of parameters for the integrator.
     */
    public void testParameters() throws Exception {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealIntegrator integrator = new SimpsonIntegrator();

        try {
            // bad interval
            integrator.integrate(f, 1, -1);
View Full Code Here

    /**
     * Test of integrator for the sine function.
     */
    public void testSinFunction() throws MathException {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealIntegrator integrator = new RombergIntegrator();
        double min, max, expected, result, tolerance;

        min = 0; max = FastMath.PI; expected = 2;
        tolerance = FastMath.abs(expected * integrator.getRelativeAccuracy());
 
View Full Code Here

    /**
     * Test of parameters for the integrator.
     */
    public void testParameters() throws Exception {
        UnivariateRealFunction f = new SinFunction();
        UnivariateRealIntegrator integrator = new RombergIntegrator();

        try {
            // bad interval
            integrator.integrate(f, 1, -1);
View Full Code Here

TOP

Related Classes of org.apache.commons.math.analysis.SinFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.