Skip to content
Browse files

- Modified compute() method, use first initial guess as validateEqFun…

…ction() guess value as default to meet change request #14927.

- Reformatted code


git-svn-id: http://svn.php.net/repository/pear/packages/Math_Numerical_RootFinding/trunk@268681 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 9b5c4ff commit 9e68bdd09bd68647c68d58727dbc4c16fb6bc608 Firman Wandayandi committed Nov 10, 2008
View
101 Math/Numerical/RootFinding/Bisection.php
@@ -11,54 +11,31 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
// {{{ Dependencies
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
@@ -68,14 +45,14 @@
/**
* Bisection/Binary Chopping/Interval Halving/Bolzano method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_Bisection
extends Math_Numerical_RootFinding_Common
@@ -85,10 +62,10 @@ class Math_Numerical_RootFinding_Bisection
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_Bisection($options = null)
{
@@ -127,21 +104,21 @@ function infoCompute()
/**
* Bisection/Binary Chopping/Interval Halving/Bolzano method.
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param float $xL Lower guess.
- * @param float $xU Upper guess.
+ * @param callback $fxFunction Callback f(x) equation function or
+ * object/method tuple.
+ * @param float $xL Lower guess.
+ * @param float $xU Upper guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding::validateEqFunction()
- * @see Math_Numerical_RootFinding::getEqResult()
- * @see Math_Numerical_RootFinding_Falseposition::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding::validateEqFunction()
+ * @see Math_Numerical_RootFinding::getEqResult()
+ * @see Math_Numerical_RootFinding_Falseposition::compute()
*/
function compute($fxFunction, $xL, $xU)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xL);
if (PEAR::isError($err)) {
return $err;
}
@@ -150,7 +127,7 @@ function compute($fxFunction, $xL, $xU)
$xR = ($xU + $xL) / 2;
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR);
if (PEAR::isError($err)) {
return $err;
}
View
99 Math/Numerical/RootFinding/FalsePosition.php
@@ -10,54 +10,31 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
// {{{ Dependencies
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
@@ -67,14 +44,14 @@
/**
* False Position/Regula Falsi method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_FalsePosition
extends Math_Numerical_RootFinding_Common
@@ -84,10 +61,10 @@ class Math_Numerical_RootFinding_FalsePosition
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_FalsePosition($options = null)
{
@@ -126,21 +103,21 @@ function infoCompute()
/**
* False Position/Regula Falsi method.
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param float $xL Lower guess.
- * @param float $xU Upper guess.
+ * @param callback $fxFunction Callback f(x) equation function or
+ * object/method tuple.
+ * @param float $xL Lower guess.
+ * @param float $xU Upper guess.
*
- * @return float|PEAR_Error root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Bisection::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Bisection::compute()
*/
function compute($fxFunction, $xL, $xU)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xL);
if (PEAR::isError($err)) {
return $err;
}
View
97 Math/Numerical/RootFinding/FixedPoint.php
@@ -10,54 +10,31 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
// {{{ Dependencies
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
@@ -67,14 +44,14 @@
/**
* Fixed Point method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_FixedPoint
extends Math_Numerical_RootFinding_Common
@@ -84,10 +61,10 @@ class Math_Numerical_RootFinding_FixedPoint
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_FixedPoint($options = null)
{
@@ -126,20 +103,20 @@ function infoCompute()
*
* This method using g(x) (the modification of f(x), which g(x) = x).
*
- * @param callback $gxFunction Callback g(x) equation function or
- * object/method tuple.
- * @param float $xR Initial guess.
+ * @param callback $gxFunction Callback g(x) equation function or
+ * object/method tuple.
+ * @param float $xR Initial guess.
*
- * @return float|PEAR_Error root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
*/
function compute($gxFunction, $xR)
{
// Validate g(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($gxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($gxFunction, $xR);
if (PEAR::isError($err)) {
return $err;
}
View
106 Math/Numerical/RootFinding/NewtonRaphson.php
@@ -10,54 +10,31 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
// {{{ Dependencies
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
@@ -67,14 +44,14 @@
/**
* Newton-Raphson method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_NewtonRaphson
extends Math_Numerical_RootFinding_Common
@@ -84,10 +61,10 @@ class Math_Numerical_RootFinding_NewtonRaphson
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_NewtonRaphson($options = null)
{
@@ -128,29 +105,28 @@ function infoCompute()
/**
* Netwon-Raphson method.
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param callback $dfxFunction Callback f'(x) equation function or
- * object/method tuple.
- * @param float $xR Initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or
+ * object/method tuple.
+ * @param callback $dfxFunction Callback f'(x) equation function or
+ * object/method tuple.
+ * @param float $xR Initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on
- * failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Newtonraphson2::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Newtonraphson2::compute()
*/
function compute($fxFunction, $dfxFunction, $xR) {
// evaluate f(x) equation function before begin anything
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR);
if (PEAR::isError($err)) {
return $err;
}
// evaluate df(x) equation function before begin anything
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfxFunction, $xR);
if (PEAR::isError($err)) {
return $err;
}
View
108 Math/Numerical/RootFinding/NewtonRaphson2.php
@@ -10,54 +10,31 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
// {{{ Dependencies
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
@@ -67,14 +44,14 @@
/**
* Newton-Raphson 2 method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_NewtonRaphson2
extends Math_Numerical_RootFinding_Common
@@ -84,10 +61,10 @@ class Math_Numerical_RootFinding_NewtonRaphson2
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_NewtonRaphson2($options = null)
{
@@ -130,37 +107,34 @@ function infoCompute()
/**
* Newton-Raphson method for calculate double root (twin root).
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param callback $dfx1Function Callback f'(x) equation function or
- * object/method tuple.
- * @param callback $dfx2Function Callback f''(x) equation function or
- * object/method tuple.
- * @param float $xR Initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method tuple.
+ * @param callback $dfx1Function Callback f'(x) equation function or object/method tuple.
+ * @param callback $dfx2Function Callback f''(x) equation function or object/method tuple.
+ * @param float $xR Initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Newtonraphson::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Newtonraphson::compute()
*/
function compute($fxFunction, $dfx1Function, $dfx2Function, $xR)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR);
if (PEAR::isError($err)) {
return $err;
}
// Validate f'(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfx1Function);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfx1Function, $xR);
if (PEAR::isError($err)) {
return $err;
}
// Validate f''(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfx2Function);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($dfx2Function, $xR);
if (PEAR::isError($err)) {
return $err;
}
View
103 Math/Numerical/RootFinding/RalstonRabinowitz.php
@@ -10,47 +10,24 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
@@ -67,14 +44,14 @@
/**
* Ralston and Rabinowitz method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_RalstonRabinowitz
extends Math_Numerical_RootFinding_Common
@@ -84,10 +61,10 @@ class Math_Numerical_RootFinding_RalstonRabinowitz
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_RalstonRabinowitz($options = null)
{
@@ -129,30 +106,28 @@ function infoCompute()
/**
* Ralston and Rabinowitz method for calculate double root (twin root).
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param callback $dxFunction Callback f'(x) equation function or
- * object/method tuple.
- * @param float $xR0 First initial guess.
- * @param float $xR1 Second initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method tuple.
+ * @param callback $dxFunction Callback f'(x) equation function or object/method tuple.
+ * @param float $xR0 First initial guess.
+ * @param float $xR1 Second initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Secant::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Secant::compute()
*/
function compute($fxFunction, $dxFunction, $xR0, $xR1)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR0);
if (PEAR::isError($err)) {
return $err;
}
// Validate f'(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($dxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($dxFunction, $xR0);
if (PEAR::isError($err)) {
return $err;
}
View
100 Math/Numerical/RootFinding/Secant.php
@@ -10,54 +10,31 @@
* PHP versions 4 and 5
*
* LICENSE:
+ * Copyright (c) 2008 Firman Wandayandi <firman@php.net>
*
- * BSD License
+ * This source file is subject to the BSD License license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://www.opensource.org/licenses/bsd-license.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to pear-dev@list.php.net so we can send you a copy immediately.
*
- * Copyright (c) 2004-2006 Firman Wandayandi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * 3. Neither the name of Firman Wandayandi nor the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version CVS: $Id$
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version CVS: $Id$
*/
// }}}
// {{{ Dependencies
/**
- * Load Math_Numerical_RootFinding_Common as base class.
+ * Math_Numerical_RootFinding_Common
*/
require_once 'Math/Numerical/RootFinding/Common.php';
@@ -67,14 +44,14 @@
/**
* Secant method class.
*
- * @category Math
- * @package Math_Numerical_RootFinding
- * @subpackage Methods
- * @author Firman Wandayandi <firman@php.net>
- * @copyright Copyright (c) 2004-2006 Firman Wandayandi
- * @license http://www.opensource.org/licenses/bsd-license.php
- * BSD License
- * @version Release: @package_version@
+ * @category Math
+ * @package Math_Numerical_RootFinding
+ * @subpackage Methods
+ * @author Firman Wandayandi <firman@php.net>
+ * @copyright Copyright (c) 2004-2008 Firman Wandayandi
+ * @license http://www.opensource.org/licenses/bsd-license.php
+ * BSD License
+ * @version Release: @package_version@
*/
class Math_Numerical_RootFinding_Secant
extends Math_Numerical_RootFinding_Common
@@ -84,10 +61,10 @@ class Math_Numerical_RootFinding_Secant
/**
* Constructor.
*
- * @param array $options (optional) Options.
+ * @param array $options (optional) Options.
*
- * @access public
- * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::Math_Numerical_RootFinding_Common()
*/
function Math_Numerical_RootFinding_Secant($options = null)
{
@@ -126,22 +103,21 @@ function infoCompute()
/**
* Secant method.
*
- * @param callback $fxFunction Callback f(x) equation function or
- * object/method tuple.
- * @param float $xR0 First initial guess.
- * @param float $xR1 Second initial guess.
+ * @param callback $fxFunction Callback f(x) equation function or object/method tuple.
+ * @param float $xR0 First initial guess.
+ * @param float $xR1 Second initial guess.
*
- * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
- * @access public
- * @see Math_Numerical_RootFinding_Common::validateEqFunction()
- * @see Math_Numerical_RootFinding_Common::getEqResult()
- * @see Math_Numerical_RootFinding_Common::isDivergentRow()
- * @see Math_Numerical_RootFinding_Ralstonrabinowitz::compute()
+ * @return float|PEAR_Error Root value on success or PEAR_Error on failure.
+ * @access public
+ * @see Math_Numerical_RootFinding_Common::validateEqFunction()
+ * @see Math_Numerical_RootFinding_Common::getEqResult()
+ * @see Math_Numerical_RootFinding_Common::isDivergentRow()
+ * @see Math_Numerical_RootFinding_Ralstonrabinowitz::compute()
*/
function compute($fxFunction, $xR0, $xR1)
{
// Validate f(x) equation function.
- $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction);
+ $err = Math_Numerical_RootFinding_Common::validateEqFunction($fxFunction, $xR0);
if (PEAR::isError($err)) {
return $err;
}

0 comments on commit 9e68bdd

Please sign in to comment.
Something went wrong with that request. Please try again.