% secant method it=0; xb=startl(1); fb=f(xb); xc=startr(1); fc=f(xc); while abs(xc-xb)tol it=it+1; xa=xb; fa=fb; xb=xc; fb=fc; xc=xb-fb.(xb-xa)/(fb-fa); fc=f(xc);% print progress%fprintf(’ n =%i Computed Solution =%20.15e Cauchy Error =%e ’,it,xc,abs(xc-xb)); end; xs=xc;% print results fprintf(’ Computed Solution =%e ’,xs).
Secant Method M File Download
Original file (SVG file, nominally 351 × 315 pixels, file size: 6 KB)
|Description||Illustration of the secant method. Created by Jitse Niesen using Xfig.|
|Date||(original upload date)|
|Source||No machine-readable source provided. Own work assumed (based on copyright claims).|
|Author||No machine-readable author provided. Jitse Niesen assumed (based on copyright claims).|
|I, the copyright holder of this work, release this work into the public domain. This applies worldwide.|
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
Derivative works of this file: Secant method 2.svg
Click on a date/time to view the file as it appeared at that time.
|current||11:58, 19 June 2006||351 × 315 (6 KB)||Jitse Niesen||Illustration of the w:secant method. Created by ~~~ using Xfig.|
Global file usage
The following other wikis use this file:
Matlab Secant Method M File
- Usage on ca.wikipedia.org
- Usage on cs.wikipedia.org
- Usage on en.wikibooks.org
- Usage on es.wikipedia.org
- Usage on fa.wikipedia.org
- Usage on fi.wikipedia.org
- Usage on fr.wikipedia.org
- Usage on he.wikipedia.org
- Usage on hu.wikipedia.org
- Usage on id.wikipedia.org
- Usage on it.wikipedia.org
- Usage on ko.wikipedia.org
- Usage on pt.wikipedia.org
- Usage on sl.wikipedia.org
- Usage on sr.wikipedia.org
- Usage on sv.wikipedia.org
- Usage on zh.wikipedia.org
Secant MethodThe secant method is an iterative procedure to estimate a root of an equation f(x) = 0 where the user gives two initial estimates and a tolerance. One of the two initial estimates is regarded as being older than the other, the procedure then calculates a new estimate and discards the oldest estimate until the distance between the two estimates is less than the preassigned tolerance. If xi-1 and xi are the two estimates with xi-1 being older than xi, the new estimate xi+1 is that point on the x-axis which is the intersection of the x-axis and the line joining the points ( xi-1, f(xi-1) ) and ( xi, f(xi) ) on the curve y = f(x)
Newton Secant Method. The subsequent estimate then uses the points ( xi, f(xi) ) and ( xi+1, f(xi+1) ) to estimate xi+1.
It is best to avoid using the secant method if there are local extrema near the root. The convergence of the secant method depends on the initial estimates. It is generally better if the two initial conditions are close so that the secant is approximately equal to the tangent.
- double Secant_Method( double (*f)(double), double a, double b, double tolerance, int max_iteration_count, int *err)
Find a root of f(x) in near a and b. The procedure terminates when the absolute difference of the return value and the actual root is less than tolerance, where tolerance is a user specified number specifying the desired accuracy of the result. The input argument max_iteration_count allows the user to control the maximum number of iterations to attempt. The method returns an err of 0 if the iteration was successful, -1 if the number of iterations exceed the maximum allowable number of iterations as specified by the user, and -2 if an attempt was made to divide by zero, which is indicative of a local minimum or a local maximum. Even if the an err return of 0 occurs, it is possible that the result is erroneous, especially if there is a local minimum or local maximum near the root. For this reason, if it is not known whether there is a local extremum in a small neighborhood of the root, the result should be checked for its validity.
C Source Code
- The file, secant_method.c, contains the version of Secant_Method( ) written in C.