From 9227754177ba240cd51ad15517f3edc72a0641b3 Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Mon, 17 Oct 2011 14:05:53 +0000 Subject: [PATCH] Added "derivative". git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1185184 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/math/analysis/function/Log10.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/math/analysis/function/Log10.java b/src/main/java/org/apache/commons/math/analysis/function/Log10.java index f0464515b..a5af75996 100644 --- a/src/main/java/org/apache/commons/math/analysis/function/Log10.java +++ b/src/main/java/org/apache/commons/math/analysis/function/Log10.java @@ -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); + } + }; + } }