001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.math3.analysis.solvers;
019
020/**
021 * Implements the <em>Pegasus</em> method for root-finding (approximating
022 * a zero of a univariate real function). It is a modified
023 * {@link RegulaFalsiSolver <em>Regula Falsi</em>} method.
024 *
025 * <p>Like the <em>Regula Falsi</em> method, convergence is guaranteed by
026 * maintaining a bracketed solution. The <em>Pegasus</em> method however,
027 * should converge much faster than the original <em>Regula Falsi</em>
028 * method. Furthermore, this implementation of the <em>Pegasus</em> method
029 * should not suffer from the same implementation issues as the <em>Regula
030 * Falsi</em> method, which may fail to convergence in certain cases. Also,
031 * the <em>Pegasus</em> method should converge faster than the
032 * {@link IllinoisSolver <em>Illinois</em>} method, another <em>Regula
033 * Falsi</em>-based method.</p>
034 *
035 * <p>The <em>Pegasus</em> method assumes that the function is continuous,
036 * but not necessarily smooth.</p>
037 *
038 * <p>Implementation based on the following article: M. Dowell and P. Jarratt,
039 * <em>The "Pegasus" method for computing the root of an equation</em>,
040 * BIT Numerical Mathematics, volume 12, number 4, pages 503-508, Springer,
041 * 1972.</p>
042 *
043 * @since 3.0
044 * @version $Id: PegasusSolver.java 1364387 2012-07-22 18:14:11Z tn $
045 */
046public class PegasusSolver extends BaseSecantSolver {
047
048    /** Construct a solver with default accuracy (1e-6). */
049    public PegasusSolver() {
050        super(DEFAULT_ABSOLUTE_ACCURACY, Method.PEGASUS);
051    }
052
053    /**
054     * Construct a solver.
055     *
056     * @param absoluteAccuracy Absolute accuracy.
057     */
058    public PegasusSolver(final double absoluteAccuracy) {
059        super(absoluteAccuracy, Method.PEGASUS);
060    }
061
062    /**
063     * Construct a solver.
064     *
065     * @param relativeAccuracy Relative accuracy.
066     * @param absoluteAccuracy Absolute accuracy.
067     */
068    public PegasusSolver(final double relativeAccuracy,
069                         final double absoluteAccuracy) {
070        super(relativeAccuracy, absoluteAccuracy, Method.PEGASUS);
071    }
072
073    /**
074     * Construct a solver.
075     *
076     * @param relativeAccuracy Relative accuracy.
077     * @param absoluteAccuracy Absolute accuracy.
078     * @param functionValueAccuracy Maximum function value error.
079     */
080    public PegasusSolver(final double relativeAccuracy,
081                         final double absoluteAccuracy,
082                         final double functionValueAccuracy) {
083        super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, Method.PEGASUS);
084    }
085}