commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r653923 - in /commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences: EightPointsScheme.java FiniteDifferencesDifferentiator.java FourPointsScheme.java SixPointsScheme.java TwoPointsScheme.java
Date Tue, 06 May 2008 21:10:35 GMT
Author: luc
Date: Tue May  6 14:10:34 2008
New Revision: 653923

URL: http://svn.apache.org/viewvc?rev=653923&view=rev
Log:
added a way to retrieve the order of the first non-canceled derivative

Modified:
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FiniteDifferencesDifferentiator.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java
    commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java?rev=653923&r1=653922&r2=653923&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/EightPointsScheme.java
Tue May  6 14:10:34 2008
@@ -27,7 +27,7 @@
 public class EightPointsScheme extends FiniteDifferencesDifferentiator {
 
     /** Serializable UID. */
-    private static final long serialVersionUID = 39061646369246780L;
+    private static final long serialVersionUID = 3498050520014763473L;
 
     /** Scheme denominator. */
     private final double denominator;
@@ -36,7 +36,7 @@
      * @param h differences step size
      */
     public EightPointsScheme(final double h) {
-        super(h, -h * h * h * h * h * h * h * h / 630);
+        super(h, -h * h * h * h * h * h * h * h / 630, 9);
         denominator = 840 * h;
     }
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FiniteDifferencesDifferentiator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FiniteDifferencesDifferentiator.java?rev=653923&r1=653922&r2=653923&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FiniteDifferencesDifferentiator.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FiniteDifferencesDifferentiator.java
Tue May  6 14:10:34 2008
@@ -25,17 +25,24 @@
  * central test point according to a given h step.
  * For example a four points scheme would use a linear combination of points
  * <code>f(x-2h)</code>, <code>f(x-h)</code>, <code>f(x+h)</code>
and
- * <code>f(x+2h)</code> to compute the first differential <code>f'(x)</code>
- * (note that <code>f(x)</code> by itself is not used).
- * The computed differential is only an approximation, the error depends on
- * the value of the high order differentials of the function which were not
- * canceled by the linear combination, the number of points and the step.
+ * <code>f(x+2h)</code> to compute the first derivative <code>f'(x)</code>
+ * (note that <code>f(x)</code> by itself is not used for the evaluation of
+ * <code>f'(x)</code>, but is used to compute the value of the function
+ * <code>f(x)</code).</p>
+ * <p>The computed differential is only an approximation. The error depends on
+ * the value of the high order derivatives of the function which were not
+ * canceled by the linear combination, the number of points and the step size.
  * For example the four points scheme cancels the
  * <code>f<sup>(2)</sup></code>, <code>f<sup>(3)</sup></code>
and
- * <code>f<sup>(4)</sup></code> high order differentials but not
the
- * <code>f<sup>(5)</sup></code> and higher order terms. The error
model is
- * <code>-2h<sup>4</sup>/5 f<sup>(5)</sup>(x) + O(h<sup>6</sup>)</code>.
- * </p>
+ * <code>f<sup>(4)</sup></code> high order derivatives but not the
+ * <code>f<sup>(5)</sup></code> and higher order terms. The theoretical
error
+ * model for this scheme is <code>-2h<sup>4</sup>/5 f<sup>(5)</sup>(x)
+
+ * O(h<sup>6</sup>)</code>. This model doesn't take into account numerical
+ * cancellation which occur when the steps are too small.</p>
+ * <p>The general expression of the theoretical error model is
+ * <code>A f<sup>(k)</sup> + O(h<sup>k+1</sup>)</code>
where <code>A</code>
+ * is the value returned by {@link #getSignedErrorScaleFactor()} and
+ * <code>k</code> is the value returned by {@link #getOrderFirstNonCanceled()}.</p>
  */
 public abstract class FiniteDifferencesDifferentiator
     implements UnivariateDifferentiator, Serializable {
@@ -46,13 +53,20 @@
     /** Error scale factor. */
     private final double factor;
 
+    /** Order of the first non-canceled derivative. */
+    private final int order;
+
     /** Simple constructor.
      * @param stepSize step stepSize
      * @param factor error scale factor
+     * @param order order of the first non-canceled derivative
      */
-    protected FiniteDifferencesDifferentiator(final double stepSize, final double factor)
{
+    protected FiniteDifferencesDifferentiator(final double stepSize,
+                                              final double factor,
+                                              final int order) {
         this.stepSize = stepSize;
-        this.factor = factor;
+        this.factor   = factor;
+        this.order    = order;
     }
 
     /** Get the signed error scale factor for the finite differences scheme.
@@ -62,11 +76,25 @@
      * <code>-2h<sup>4</sup>/5 f<sup>(5)</sup>(x) + O(h<sup>6</sup>)</code>,
      * the signed error scale factor is <code>-2h<sup>4</sup>/5</code>.</p>
      * @return error signed scale factor
+     * @see #getOrderFirstNonCanceled()
      */
     public double getSignedErrorScaleFactor() {
         return factor;
     }
 
+    /** Get the order of the first non-canceled derivative.
+     * <p>The error model of the scheme depends on the first non-canceled
+     * high order differential of the function. For example since the error
+     * model for the four points scheme is <code>-2h<sup>4</sup>/5
+     * f<sup>(5)</sup>(x) + O(h<sup>6</sup>)</code>, the order
of the first
+     * non-canceled derivative is 5.
+     * @return order of the first non-canceled derivative
+     * @see #getSignedErrorScaleFactor()
+     */
+    public int getOrderFirstNonCanceled() {
+        return order;
+    }
+
     /** Get the step size.
      * @return step size
      */

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java?rev=653923&r1=653922&r2=653923&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/FourPointsScheme.java
Tue May  6 14:10:34 2008
@@ -27,7 +27,7 @@
 public class FourPointsScheme extends FiniteDifferencesDifferentiator {
 
     /** Serializable UID. */
-    private static final long serialVersionUID = -4303710033273686431L;
+    private static final long serialVersionUID = 3216911780962952859L;
 
     /** Scheme denominator. */
     private final double denominator;
@@ -36,7 +36,7 @@
      * @param h differences step size
      */
     public FourPointsScheme(final double h) {
-        super(h, -2 * h * h * h * h / 5);
+        super(h, -2 * h * h * h * h / 5, 5);
         denominator = 12 * h;
     }
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java?rev=653923&r1=653922&r2=653923&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/SixPointsScheme.java
Tue May  6 14:10:34 2008
@@ -27,7 +27,7 @@
 public class SixPointsScheme extends FiniteDifferencesDifferentiator {
 
     /** Serializable UID. */
-    private static final long serialVersionUID = -3054982833938680212L;
+    private static final long serialVersionUID = 7007473664353943364L;
 
     /** Scheme denominator. */
     private final double denominator;
@@ -36,7 +36,7 @@
      * @param h differences step size
      */
     public SixPointsScheme(final double h) {
-        super(h, h * h * h * h * h * h / 140);
+        super(h, h * h * h * h * h * h / 140, 7);
         denominator = 60 * h;
     }
 

Modified: commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java
URL: http://svn.apache.org/viewvc/commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java?rev=653923&r1=653922&r2=653923&view=diff
==============================================================================
--- commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java
(original)
+++ commons/sandbox/nabla/trunk/src/main/java/org/apache/commons/nabla/differences/TwoPointsScheme.java
Tue May  6 14:10:34 2008
@@ -27,7 +27,7 @@
 public class TwoPointsScheme extends FiniteDifferencesDifferentiator {
 
     /** Serializable UID. */
-    private static final long serialVersionUID = -3932881915416655202L;
+    private static final long serialVersionUID = -5824475098109485044L;
 
     /** Scheme denominator. */
     private final double denominator;
@@ -36,7 +36,7 @@
      * @param h differences step size
      */
     public TwoPointsScheme(final double h) {
-        super(h, h * h / 6);
+        super(h, h * h / 6, 3);
         denominator = 2 * h;
     }
 



Mime
View raw message