Package org.apache.commons.math3.analysis.function

Examples of org.apache.commons.math3.analysis.function.Sin


        Assert.assertEquals(4 - 2, FunctionUtils.add(c, FunctionUtils.compose(m, id)).value(2), EPS);
    }

    @Test
    public void testAddDifferentiable() {
        UnivariateDifferentiableFunction sin = new Sin();
        UnivariateDifferentiableFunction c = new Constant(4);
        UnivariateDifferentiableFunction m = new Minus();
        UnivariateDifferentiableFunction inv = new Inverse();

        final double a = 123.456;
View Full Code Here


    }

    @Test
    public void testSinc() {
        BivariateFunction div = new Divide();
        UnivariateFunction sin = new Sin();
        UnivariateFunction id = new Identity();
        UnivariateFunction sinc1 = FunctionUtils.combine(div, sin, id);
        UnivariateFunction sinc2 = new Sinc();

        for (int i = 0; i < 10; i++) {
View Full Code Here

        }
    }

    @Test(expected = NumberIsTooLargeException.class)
    public void testSampleWrongBounds(){
        FunctionUtils.sample(new Sin(), FastMath.PI, 0.0, 10);
    }
View Full Code Here

        FunctionUtils.sample(new Sin(), FastMath.PI, 0.0, 10);
    }

    @Test(expected = NotStrictlyPositiveException.class)
    public void testSampleNegativeNumberOfPoints(){
        FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, -1);
    }
View Full Code Here

        FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, -1);
    }

    @Test(expected = NotStrictlyPositiveException.class)
    public void testSampleNullNumberOfPoints(){
        FunctionUtils.sample(new Sin(), 0.0, FastMath.PI, 0);
    }
View Full Code Here

    @Test
    public void testSample() {
        final int n = 11;
        final double min = 0.0;
        final double max = FastMath.PI;
        final double[] actual = FunctionUtils.sample(new Sin(), min, max, n);
        for (int i = 0; i < n; i++) {
            final double x = min + (max - min) / n * i;
            Assert.assertEquals("x = " + x, FastMath.sin(x), actual[i], 0.0);
        }
    }
View Full Code Here

    @Test
    @Deprecated
    public void testToDifferentiableUnivariateFunction() {

        // Sin implements both UnivariateDifferentiableFunction and DifferentiableUnivariateFunction
        Sin sin = new Sin();
        DifferentiableUnivariateFunction converted = FunctionUtils.toDifferentiableUnivariateFunction(sin);
        for (double x = 0.1; x < 0.5; x += 0.01) {
            Assert.assertEquals(sin.value(x), converted.value(x), 1.0e-10);
            Assert.assertEquals(sin.derivative().value(x), converted.derivative().value(x), 1.0e-10);
        }

    }
View Full Code Here

    @Test
    @Deprecated
    public void testToUnivariateDifferential() {

        // Sin implements both UnivariateDifferentiableFunction and DifferentiableUnivariateFunction
        Sin sin = new Sin();
        UnivariateDifferentiableFunction converted = FunctionUtils.toUnivariateDifferential(sin);
        for (double x = 0.1; x < 0.5; x += 0.01) {
            DerivativeStructure t = new DerivativeStructure(2, 1, x, 1.0, 2.0);
            Assert.assertEquals(sin.value(t).getValue(), converted.value(t).getValue(), 1.0e-10);
            Assert.assertEquals(sin.value(t).getPartialDerivative(1, 0),
                                converted.value(t).getPartialDerivative(1, 0),
                                1.0e-10);
            Assert.assertEquals(sin.value(t).getPartialDerivative(0, 1),
                                converted.value(t).getPartialDerivative(0, 1),
                                1.0e-10);
        }

    }
View Full Code Here

    @Override
    protected UnivariateFunction[] createFunctions() {
        return new UnivariateFunction[] {
            new Power(2.0), new Exp(), new Expm1(),
            new Log1p(), new Cosh(), new Sinh(), new Tanh(), new Cos(),
            new Sin(), new Tan(), new Acos(), new Asin(), new Atan(),
            new Abs(), new Sqrt(), new Cbrt(), new Ceil(),
            new Floor(), new Rint(), new Signum()
        };
    }
View Full Code Here

    /**
     * Test of integrator for the sine function.
     */
    @Test
    public void testSinFunction() {
        UnivariateFunction f = new Sin();
        UnivariateIntegrator integrator = new MidPointIntegrator();
       
        double min = 0;
        double max = FastMath.PI;
        double expected = 2;
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.analysis.function.Sin

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.