You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by br...@apache.org on 2004/04/26 22:47:07 UTC

cvs commit: jakarta-commons/math/xdocs/userguide analysis.xml utilities.xml

brentworden    2004/04/26 13:47:07

  Modified:    math/src/java/org/apache/commons/math/util
                        ContinuedFraction.java
               math/xdocs/userguide analysis.xml utilities.xml
  Log:
  Added user guide entry for continued fractions.
  
  Revision  Changes    Path
  1.12      +4 -1      jakarta-commons/math/src/java/org/apache/commons/math/util/ContinuedFraction.java
  
  Index: ContinuedFraction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/util/ContinuedFraction.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ContinuedFraction.java	21 Feb 2004 21:35:16 -0000	1.11
  +++ ContinuedFraction.java	26 Apr 2004 20:47:07 -0000	1.12
  @@ -24,11 +24,14 @@
    * Provides a generic means to evaluate continued fractions.  Subclasses simply
    * provided the a and b coefficients to evaluate the continued fraction.
    * 
  + * <p>
    * References:
    * <ul>
    * <li><a href="http://mathworld.wolfram.com/ContinuedFraction.html">
    * Continued Fraction</a></li>
    * </ul>
  + * </p>
  + * 
    * @version $Revision$ $Date$
    */
   public abstract class ContinuedFraction implements Serializable {
  
  
  
  1.9       +2 -1      jakarta-commons/math/xdocs/userguide/analysis.xml
  
  Index: analysis.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/xdocs/userguide/analysis.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- analysis.xml	29 Feb 2004 18:50:10 -0000	1.8
  +++ analysis.xml	26 Apr 2004 20:47:07 -0000	1.9
  @@ -92,6 +92,7 @@
               <tr><th>Solver</th><th>Factory Method</th><th>Notes on Use</th></tr>
               <tr><td>Bisection</td><td>newBisectionSolver</td><td><div>Root must be bracketted.</div><div>Linear, guaranteed convergence</div></td></tr>
               <tr><td>Brent</td><td>newBrentSolver</td><td><div>Root must be bracketted.</div><div>Super-linear, guaranteed convergence</div></td></tr>
  +            <tr><td>Newton</td><td>newNewtonSolver</td><td><div>Uses single value for initialization.</div><div>Super-linear, non-guaranteed convergence</div><div>Function must be differentiable</div></td></tr>
               <tr><td>Secant</td><td>newSecantSolver</td><td><div>Root must be bracketted.</div><div>Super-linear, non-guaranteed convergence</div></td></tr>
             </table>
           </p>
  
  
  
  1.7       +66 -4     jakarta-commons/math/xdocs/userguide/utilities.xml
  
  Index: utilities.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/xdocs/userguide/utilities.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- utilities.xml	29 Feb 2004 18:50:10 -0000	1.6
  +++ utilities.xml	26 Apr 2004 20:47:07 -0000	1.7
  @@ -41,9 +41,71 @@
   </subsection>
   
   <subsection name="6.3 Continued Fractions" href="continued_fractions">
  -    <p>
  -    This is yet to be written. Any contributions will be gratefully accepted!
  -    </p>
  +  <p>
  +    The <a href="../apidocs/org/apache/commons/math/util/ContinuedFraction.html">
  +    org.apache.commons.math.util.ContinuedFraction</a> class provides a generic
  +    way to create and evaluate continued fractions.  The easiest way to create a
  +    continued fraction is to subclass <code>ContinuedFraction</code> and
  +    override the <code>getA</code> and <code>getB</code> methods which return
  +    the continued fraction terms.  The precise definition of these terms is
  +    explained in <a href="http://mathworld.wolfram.com/ContinuedFraction.html">
  +    Continued Fraction, equation (1)</a> from MathWorld.
  +  </p>
  +  <p>
  +    As an example, the constant Pi could be computed using the continued fraction
  +    defined at <a href="http://functions.wolfram.com/Constants/Pi/10/0002/">
  +    http://functions.wolfram.com/Constants/Pi/10/0002/</a>.  The following
  +    anonymous class provides the implementation:
  +    <source>ContinuedFraction c = new ContinuedFraction() {
  +    public double getA(int n, double x) {
  +        switch(n) {
  +            case 0: return 3.0;
  +            default: return 6.0;
  +        }
  +    }
  +    
  +    public double getB(int n, double x) {
  +        double y = (2.0 * n) - 1.0;
  +        return y * y;
  +    }
  +}</source>
  +  </p>
  +  <p>
  +    Then, to evalute Pi, simply call any of the <code>evalute</code> methods
  +    (Note, the point of evalution in this example is meaningless since Pi is a
  +    constant).
  +  </p>
  +  <p>
  +    For a more practical use of continued fractions, consider the exponential
  +    function with the continued fraction definition of
  +    <a href="http://functions.wolfram.com/ElementaryFunctions/Exp/10/">
  +    http://functions.wolfram.com/ElementaryFunctions/Exp/10/</a>.  The
  +    following anonymous class provides its implementation:
  +    <source>ContinuedFraction c = new ContinuedFraction() {
  +    public double getA(int n, double x) {
  +        if (n % 2 == 0) {
  +            switch(n) {
  +                case 0: return 1.0;
  +                default: return 2.0;
  +            }
  +        } else {
  +            return n;
  +        }
  +    }
  +    
  +    public double getB(int n, double x) {
  +        if (n % 2 == 0) {
  +            return -x;
  +        } else {
  +            return x;
  +        }
  +    }
  +}</source>
  +  </p>
  +  <p>
  +    Then, to evalute <i>e</i><sup>x</sup> for any value x, simply call any of the
  +    <code>evalute</code> methods.
  +  </p>
   </subsection>
   
   <subsection name="6.4 binomial coefficients, factorials and other common math functions" href="math_utils">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org