07-17-2014, 03:01 PM

I am reading the new book Practical Numerical Methods For Chemical Engineers by Richard A. Davis. This book uses a lot of Excel VBA code and has fantastic library of numerical routines. In the chapter about nonlinear equations, Davis lists the following formula for modifying Newtons method when f(x) has a very small slope near the root. This new formula can also help solve equations like f(x)=x^2 (where f(x) does not cross the x-axis) and f(x)=x^3:

x = x - f(x) f'(x)/([f'(x)]^2 + delta)

Where f'(x) is the first derivative of f(x) and delta is a small value (like 1e-7). I find the above equation to be a clever variant since the denominator calculates the square of the slope (making sure the result is always zero or greater) and adds a positive number. The result is a denominator that always has positive value. Placing the derivative in the numerator assures that the sign of that derivative is not lost and the value of the derivative is not mutilated by squaring the slope in the denominator. The above equation is a clever variant of the following simpler and very vulnerable version:

x = x - f(x) / (f'(x) + delta)

The first equation works BUT IS SLOW. The slow convergence sure beats NO SOLUTION AT ALL.

MAKE SURE THAT YOU CALCULATE THE DERIVATIVE USING A CENTRAL DIFFERENCE FORMULA LIKE:

f'(x) = (f(x+h) - f(x-h)) / 2h

Where h is something like h = 0.01*(1+|x|). Using the following forward difference approximation SLOWS CONVERGENCE EVEN MORE:

f'(x) = (f(x+h) - f(x)) / h

Have fun!

Namir

x = x - f(x) f'(x)/([f'(x)]^2 + delta)

Where f'(x) is the first derivative of f(x) and delta is a small value (like 1e-7). I find the above equation to be a clever variant since the denominator calculates the square of the slope (making sure the result is always zero or greater) and adds a positive number. The result is a denominator that always has positive value. Placing the derivative in the numerator assures that the sign of that derivative is not lost and the value of the derivative is not mutilated by squaring the slope in the denominator. The above equation is a clever variant of the following simpler and very vulnerable version:

x = x - f(x) / (f'(x) + delta)

The first equation works BUT IS SLOW. The slow convergence sure beats NO SOLUTION AT ALL.

MAKE SURE THAT YOU CALCULATE THE DERIVATIVE USING A CENTRAL DIFFERENCE FORMULA LIKE:

f'(x) = (f(x+h) - f(x-h)) / 2h

Where h is something like h = 0.01*(1+|x|). Using the following forward difference approximation SLOWS CONVERGENCE EVEN MORE:

f'(x) = (f(x+h) - f(x)) / h

Have fun!

Namir