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.math4.legacy.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   */
45  public class PegasusSolver extends BaseSecantSolver {
46  
47      /** Construct a solver with default accuracy (1e-6). */
48      public PegasusSolver() {
49          super(DEFAULT_ABSOLUTE_ACCURACY, Method.PEGASUS);
50      }
51  
52      /**
53       * Construct a solver.
54       *
55       * @param absoluteAccuracy Absolute accuracy.
56       */
57      public PegasusSolver(final double absoluteAccuracy) {
58          super(absoluteAccuracy, Method.PEGASUS);
59      }
60  
61      /**
62       * Construct a solver.
63       *
64       * @param relativeAccuracy Relative accuracy.
65       * @param absoluteAccuracy Absolute accuracy.
66       */
67      public PegasusSolver(final double relativeAccuracy,
68                           final double absoluteAccuracy) {
69          super(relativeAccuracy, absoluteAccuracy, Method.PEGASUS);
70      }
71  
72      /**
73       * Construct a solver.
74       *
75       * @param relativeAccuracy Relative accuracy.
76       * @param absoluteAccuracy Absolute accuracy.
77       * @param functionValueAccuracy Maximum function value error.
78       */
79      public PegasusSolver(final double relativeAccuracy,
80                           final double absoluteAccuracy,
81                           final double functionValueAccuracy) {
82          super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, Method.PEGASUS);
83      }
84  }