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 BackwardDifferenceDerivative extends AbstractDifferenceDerivative { 29 30 33 public BackwardDifferenceDerivative(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) - f.value(x - h)) / h; 44 } 45 46 49 public static UnivariateRealFunction decorate(UnivariateRealFunction function, double h) { 50 return new BackwardDifferenceDerivative(function, h); 51 } 52 } 53 | Popular Tags |