Added "derivative".

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1185184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2011-10-17 14:05:53 +00:00
parent 5aaf1adc15
commit 9227754177
1 changed files with 15 additions and 1 deletions

View File

@ -18,6 +18,7 @@
package org.apache.commons.math.analysis.function;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.util.FastMath;
/**
@ -26,9 +27,22 @@ import org.apache.commons.math.util.FastMath;
* @version $Id$
* @since 3.0
*/
public class Log10 implements UnivariateRealFunction {
public class Log10 implements DifferentiableUnivariateRealFunction {
/** ln(10) = {@value}.*/
private static final double LN_10 = FastMath.log(10);
/** {@inheritDoc} */
public double value(double x) {
return FastMath.log10(x);
}
/** {@inheritDoc} */
public UnivariateRealFunction derivative() {
return new UnivariateRealFunction() {
/** {@inheritDoc} */
public double value(double x) {
return 1 / (x * LN_10);
}
};
}
}