1 18 19 package org.apache.commons.math.analysis.derivative; 20 21 import org.apache.commons.math.MathException; 22 import org.apache.commons.math.analysis.UnivariateRealFunction; 23 24 28 public class ForwardDifferenceDerivative extends AbstractDifferenceDerivative { 29 30 33 public ForwardDifferenceDerivative(UnivariateRealFunction function, double h) { 34 super(function, h); 35 } 36 37 40 public double value(double x) throws MathException { 41 UnivariateRealFunction f = getFunction(); 42 double h = getDelta(); 43 return (f.value(x + h) - f.value(x)) / h; 44 } 45 46 49 public static UnivariateRealFunction decorate(UnivariateRealFunction function, double h) { 50 return new ForwardDifferenceDerivative(function, h); 51 } 52 } 53 | Popular Tags |