Attached is a patch that will remove the firstDerivative and 
secondDerivative methods from UnivarateRealFunction,   this affects only 
the UnvariateRealFunction interface and the InterpolatorTest class.  (also 
affected is some Javadoc in the analysis test package).

  I choose not add a UnivariateRealDifferentiableFunction at this time, 
primary not to complicate matters while trying to get a 1.0 release 
compelte.  (my intent is to make a Differnetiator type of pattern similar 
to the Solver pattern)

   The reason I wish to remove the *Derivative() methods from the Function 
interface is that the class of differentiable functions is MUCH smaller 
than non-differentiable ones,  if we leave these in the interface it would 
enable the Solver (and other numerical methods) to take advantage of the 
derivative calculation that is not available in a large class of problems.


-- 
      Matt Cliff            
      Cliff Consulting
      303.757.4912
      720.280.6324 (c)


      The label said install Windows 98 or better so I installed Linux.
Index: src/java/org/apache/commons/math/analysis/CubicSplineFunction.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/math/src/java/org/apache/commons/math/analysis/CubicSplineFunction.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 CubicSplineFunction.java
--- src/java/org/apache/commons/math/analysis/CubicSplineFunction.java  1 Nov 2003 
16:04:12 -0000       1.1.1.1
+++ src/java/org/apache/commons/math/analysis/CubicSplineFunction.java  7 Nov 2003 
23:15:43 -0000
@@ -122,7 +122,6 @@
      * @param x the point for which the first derivative should be computed
      * @return the value
      * @throws MathException if the derivative couldn't be computed.
-     * @see UnivariateRealFunction#firstDerivative(double)
      */
     public double firstDerivative(double x) throws MathException {
         if (x < xval[0] || x > xval[xval.length - 1]) {
@@ -145,7 +144,6 @@
      * @param x the point for which the first derivative should be computed
      * @return the value
      * @throws MathException if the second derivative couldn't be computed.
-     * @see UnivariateRealFunction#secondDerivative(double)
      */
     public double secondDerivative(double x) throws MathException {
         if (x < xval[0] || x > xval[xval.length - 1]) {
Index: src/java/org/apache/commons/math/analysis/UnivariateRealFunction.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/math/src/java/org/apache/commons/math/analysis/UnivariateRealFunction.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 UnivariateRealFunction.java
--- src/java/org/apache/commons/math/analysis/UnivariateRealFunction.java       1 Nov 
2003 16:04:12 -0000       1.1.1.1
+++ src/java/org/apache/commons/math/analysis/UnivariateRealFunction.java       7 Nov 
2003 23:15:43 -0000
@@ -74,27 +74,4 @@
      */
     public double value(double x) throws MathException;
 
-    /**
-     * Compute the value for the first derivative of the function.
-     * It is recommended to provide this method only if the first derivative is
-     * analytical. Numerical derivatives may be acceptable in some cases.
-     * An implementation should throw an UnsupportedOperationException if
-     * this method is not implemented.
-     * @param x the point for which the first derivative should be computed
-     * @return the value
-     * @throws MathException if the derivative couldn't be computed.
-     */
-    public double firstDerivative(double x) throws MathException;
-
-    /**
-     * Compute the value for the second derivative of the function.
-     * It is recommended to provide this method only if the second derivative is
-     * analytical. Numerical derivatives may be acceptable in some cases.
-     * An implementation should throw an UnsupportedOperationException if
-     * this method is not implemented.
-     * @param x the point for which the first derivative should be computed
-     * @return the value
-     * @throws MathException if the second derivative couldn't be computed.
-     */
-    public double secondDerivative(double x) throws MathException;
 }
Index: src/test/org/apache/commons/math/analysis/InterpolatorTest.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/math/src/test/org/apache/commons/math/analysis/InterpolatorTest.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 InterpolatorTest.java
--- src/test/org/apache/commons/math/analysis/InterpolatorTest.java     1 Nov 2003 
16:04:12 -0000       1.1.1.1
+++ src/test/org/apache/commons/math/analysis/InterpolatorTest.java     7 Nov 2003 
23:15:43 -0000
@@ -89,31 +89,21 @@
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 0.5;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 1 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
     }
 
     public void testInterpolateLinearDegenerateThreeSegment()
@@ -129,61 +119,43 @@
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 0.5 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 0.5;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 1 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 1;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 1.5 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
     }
 
     public void testInterpolateLinear() throws MathException {
@@ -198,41 +170,28 @@
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 0.5 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 0.5;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 1 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
     }
 
     public void testInterpolateSin() throws MathException {
@@ -259,81 +218,57 @@
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = Math.PI / 6.0 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = Math.PI / 6.0 + 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = Math.PI / 2 - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = Math.PI / 2 + 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = Math.PI - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = Math.PI + 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         x = 2.0 * Math.PI - 1E-6;
         System.out.println(
             "x="
                 + x
                 + " y="
-                + f.value(x)
-                + " y'="
-                + f.firstDerivative(x)
-                + " y''="
-                + f.secondDerivative(x));
+                + f.value(x));
+
         //assertEquals(0.5,f.value(Math.PI/6.0),)
     }
 
Index: src/test/org/apache/commons/math/analysis/QuinticFunction.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/math/src/test/org/apache/commons/math/analysis/QuinticFunction.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 QuinticFunction.java
--- src/test/org/apache/commons/math/analysis/QuinticFunction.java      1 Nov 2003 
16:04:12 -0000       1.1.1.1
+++ src/test/org/apache/commons/math/analysis/QuinticFunction.java      7 Nov 2003 
23:15:43 -0000
@@ -70,18 +70,9 @@
     }
 
     /* First derivative of quintic.
-     * @see org.apache.commons.math.UnivariateRealFunction#firstDerivative(double)
      */
     public double firstDerivative(double x) throws MathException {
         return (5*x*x-3.75)*x*x+0.25;
-    }
-
-    /* Second order derivative of quintic.
-     * Unsupported.
-     * @see org.apache.commons.math.UnivariateRealFunction#secondDerivative(double)
-     */
-    public double secondDerivative(double x) throws MathException {
-        throw new UnsupportedOperationException();
     }
 
 }
Index: src/test/org/apache/commons/math/analysis/SinFunction.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/math/src/test/org/apache/commons/math/analysis/SinFunction.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 SinFunction.java
--- src/test/org/apache/commons/math/analysis/SinFunction.java  1 Nov 2003 16:04:12 
-0000       1.1.1.1
+++ src/test/org/apache/commons/math/analysis/SinFunction.java  7 Nov 2003 23:15:44 
-0000
@@ -75,18 +75,9 @@
     }
 
     /* First derivative of sinus function
-     * @see org.apache.commons.math.UnivariateRealFunction#firstDerivative(double)
      */
     public double firstDerivative(double x) throws MathException {
         return Math.cos(x);
-    }
-
-    /* Second derivative of sinus function.
-     * Unsupported.
-     * @see org.apache.commons.math.UnivariateRealFunction#secondDerivative(double)
-     */
-    public double secondDerivative(double x) throws MathException {
-        throw new UnsupportedOperationException();
     }
 
 }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to