View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.math3.analysis.solvers;
19  
20  /**
21   * Implements the <em>Pegasus</em> method for root-finding (approximating
22   * a zero of a univariate real function). It is a modified
23   * {@link RegulaFalsiSolver <em>Regula Falsi</em>} method.
24   *
25   * <p>Like the <em>Regula Falsi</em> method, convergence is guaranteed by
26   * maintaining a bracketed solution. The <em>Pegasus</em> method however,
27   * should converge much faster than the original <em>Regula Falsi</em>
28   * method. Furthermore, this implementation of the <em>Pegasus</em> method
29   * should not suffer from the same implementation issues as the <em>Regula
30   * Falsi</em> method, which may fail to convergence in certain cases. Also,
31   * the <em>Pegasus</em> method should converge faster than the
32   * {@link IllinoisSolver <em>Illinois</em>} method, another <em>Regula
33   * Falsi</em>-based method.</p>
34   *
35   * <p>The <em>Pegasus</em> method assumes that the function is continuous,
36   * but not necessarily smooth.</p>
37   *
38   * <p>Implementation based on the following article: M. Dowell and P. Jarratt,
39   * <em>The "Pegasus" method for computing the root of an equation</em>,
40   * BIT Numerical Mathematics, volume 12, number 4, pages 503-508, Springer,
41   * 1972.</p>
42   *
43   * @since 3.0
44   * @version $Id: PegasusSolver.java 1364387 2012-07-22 18:14:11Z tn $
45   */
46  public class PegasusSolver extends BaseSecantSolver {
47  
48      /** Construct a solver with default accuracy (1e-6). */
49      public PegasusSolver() {
50          super(DEFAULT_ABSOLUTE_ACCURACY, Method.PEGASUS);
51      }
52  
53      /**
54       * Construct a solver.
55       *
56       * @param absoluteAccuracy Absolute accuracy.
57       */
58      public PegasusSolver(final double absoluteAccuracy) {
59          super(absoluteAccuracy, Method.PEGASUS);
60      }
61  
62      /**
63       * Construct a solver.
64       *
65       * @param relativeAccuracy Relative accuracy.
66       * @param absoluteAccuracy Absolute accuracy.
67       */
68      public PegasusSolver(final double relativeAccuracy,
69                           final double absoluteAccuracy) {
70          super(relativeAccuracy, absoluteAccuracy, Method.PEGASUS);
71      }
72  
73      /**
74       * Construct a solver.
75       *
76       * @param relativeAccuracy Relative accuracy.
77       * @param absoluteAccuracy Absolute accuracy.
78       * @param functionValueAccuracy Maximum function value error.
79       */
80      public PegasusSolver(final double relativeAccuracy,
81                           final double absoluteAccuracy,
82                           final double functionValueAccuracy) {
83          super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, Method.PEGASUS);
84      }
85  }