Examples of derivative()


Examples of com.opengamma.analytics.math.function.DoubleFunction1D.derivative()

        polynomials[i] = Pair.of(getOne(), getZero());
      } else if (i == 1) {
        polynomials[i] = Pair.of(getX(), getOne());
      } else {
        p = (polynomials[i - 1].getFirst().multiply(getX()).multiply(2 * i - 1).subtract(polynomials[i - 2].getFirst().multiply(i - 1))).multiply(1. / i);
        dp = p.derivative();
        polynomials[i] = Pair.of(p, dp);
      }
    }
    return polynomials;
  }
View Full Code Here

Examples of com.opengamma.analytics.math.function.DoubleFunction1D.derivative()

  public Double getRoot(final Function1D<Double, Double> function, final Double x) {
    Validate.notNull(function, "function");
    Validate.notNull(x, "x");
    final DoubleFunction1D f = DoubleFunction1D.from(function);
    return getRoot(f, f.derivative(), x);
  }

  /**
   * Uses the {@link com.opengamma.analytics.math.function.DoubleFunction1D#derivative()} method. <i>x<sub>1</sub></i> and <i>x<sub>2</sub></i> do not have to be increasing.
   * @param function The function, not null
View Full Code Here

Examples of org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction.derivative()

                                .derivative());
                final DifferentiableUnivariateRealFunction latseg = smooth(
                        fLati.getSegmentFor(tmin), tmin, tmax, n);
                fBearing.addSegmentFunction(tmin, tmax, new BearingFunction(
                        smooth(fLongi.getSegmentFor(tmin), tmin, tmax, n)
                                .derivative(), latseg.derivative(), latseg));

                /* Calculate total ascent and total descent */
                List<Double> vpoints = getZeros(fVSpeed, time);
                vpoints.add(tmax);
                double z0 = fEle.value(tmin);
View Full Code Here

Examples of org.apache.commons.math3.analysis.function.Power.derivative()

        DifferentiableUnivariateFunction pow = new Power(2);
        Assert.assertEquals(108, FunctionUtils.compose(pow, pow).derivative().value(3), EPS);

        DifferentiableUnivariateFunction log = new Log();
        double a = 9876.54321;
        Assert.assertEquals(pow.derivative().value(a) / pow.value(a),
                            FunctionUtils.compose(log, pow).derivative().value(a), EPS);
    }

    @Test
    public void testAdd() {
View Full Code Here

Examples of org.apache.commons.math3.analysis.function.Sin.derivative()

        // 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);
        }

    }

    @Test
View Full Code Here

Examples of org.apache.commons.math3.analysis.function.Sin.derivative()

        // 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);
        }

    }

    @Test
View Full Code Here

Examples of org.apache.commons.math3.analysis.polynomials.PolynomialFunction.derivative()

            SparseGradient sgX = SparseGradient.createVariable(0, x);
            SparseGradient sgY1 = sgX.getField().getZero();
            for (int i = poly.degree(); i >= 0; --i) {
                sgY1 = sgY1.multiply(sgX).add(poly.getCoefficients()[i]);
            }
            SparseGradient sgY2 = sgX.compose(poly.value(x), poly.derivative().value(x));
            SparseGradient zero = sgY1.subtract(sgY2);
            checkF0F1(zero, 0.0, 0.0);
        }
    }
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution.derivative()

            D1 = log_H_S / stdDev + lambda * stdDev;
            D2 = D1 - 2.0 * lambda * stdDev;
            final CumulativeNormalDistribution f = new CumulativeNormalDistribution();
            cum_d1 = f.op(D1);
            cum_d2 = f.op(D2);
            n_d1 = f.derivative(D1);
            n_d2 = f.derivative(D2);
        } else {
            // TODO: not tested yet
            mu = Math.log(dividendDiscount / discount) / variance - 0.5;
            lambda = Math.sqrt( mu * mu - 2.0 * Math.log(discount) / variance);
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution.derivative()

            D2 = D1 - 2.0 * lambda * stdDev;
            final CumulativeNormalDistribution f = new CumulativeNormalDistribution();
            cum_d1 = f.op(D1);
            cum_d2 = f.op(D2);
            n_d1 = f.derivative(D1);
            n_d2 = f.derivative(D2);
        } else {
            // TODO: not tested yet
            mu = Math.log(dividendDiscount / discount) / variance - 0.5;
            lambda = Math.sqrt( mu * mu - 2.0 * Math.log(discount) / variance);
            if (log_H_S > 0) {
View Full Code Here

Examples of org.jquantlib.math.distributions.CumulativeNormalDistribution.derivative()

        strike = strike + displacement;
        final double d1 = Math.log(forward/strike)/stddev + .5*stddev;

        // TODO: code review
        final CumulativeNormalDistribution cdf = new CumulativeNormalDistribution();
        return discount * forward * cdf.derivative(d1);
    }

    // ---
    // ---
    // ---
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.