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.math4.legacy.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 */
045public class PegasusSolver extends BaseSecantSolver {
046
047    /** Construct a solver with default accuracy (1e-6). */
048    public PegasusSolver() {
049        super(DEFAULT_ABSOLUTE_ACCURACY, Method.PEGASUS);
050    }
051
052    /**
053     * Construct a solver.
054     *
055     * @param absoluteAccuracy Absolute accuracy.
056     */
057    public PegasusSolver(final double absoluteAccuracy) {
058        super(absoluteAccuracy, Method.PEGASUS);
059    }
060
061    /**
062     * Construct a solver.
063     *
064     * @param relativeAccuracy Relative accuracy.
065     * @param absoluteAccuracy Absolute accuracy.
066     */
067    public PegasusSolver(final double relativeAccuracy,
068                         final double absoluteAccuracy) {
069        super(relativeAccuracy, absoluteAccuracy, Method.PEGASUS);
070    }
071
072    /**
073     * Construct a solver.
074     *
075     * @param relativeAccuracy Relative accuracy.
076     * @param absoluteAccuracy Absolute accuracy.
077     * @param functionValueAccuracy Maximum function value error.
078     */
079    public PegasusSolver(final double relativeAccuracy,
080                         final double absoluteAccuracy,
081                         final double functionValueAccuracy) {
082        super(relativeAccuracy, absoluteAccuracy, functionValueAccuracy, Method.PEGASUS);
083    }
084}