Numerical Methods
Numerical Methods
Approximate a root with newton(f, x, x0), bisection(f, x, a, b), or secant(f, x, x0, x1). The table lists every iteration, and a failed run is not called a root.
Solve Equation runs newton(x^3-x-2,x,1.5) with the iteration x - f(x)/f'(x). The derivative 3*x^2-1 comes from the existing differentiation routine. The approximate root is 1.5213797068. newton(cos(x)-x,x,0.5) returns the approximate root 0.7390851332. Each row of the table lists the estimate, the function value, the derivative, and the step error.
bisection(x^3-x-2,x,1,2) and bisection(x^2-2,x,1,2) keep a bracket whose endpoint values have opposite signs and report the approximate roots 1.5213797068 and 1.4142135624. secant(x^3-x-2,x,1,2) returns 1.5213797068, and secant(exp(x)-3,x,1,2) returns 1.0986122887. A zero derivative, a zero secant denominator, a same-sign interval, a discontinuity, or an iteration limit is reported as a failed approximation rather than a root.
Equation
newton(x^3-x-2,x,1.5)
Graph preview
How a numerical root is checked
Newton's method replaces the graph by its tangent line. The next estimate is x - f(x)/f'(x), and the derivative comes from the existing differentiation routine. The secant method uses the same idea with the chord through two estimates instead of a tangent. Bisection keeps an interval whose endpoint values have opposite signs and replaces it by the half that still changes sign. A reported value is an approximate numerical root, checked by the residual |f(x)|.
The iteration stops for a settled step, a zero derivative, a zero secant denominator, a discontinuity, an empty or same-sign interval, divergence, stagnation, or the iteration limit. A failed run shows the last estimate and does not call it a root. Bisection claims a root exists only when continuity on the closed interval was checked and the endpoint values have opposite signs. That still does not claim the root is unique. A line that would cross a detected discontinuity is omitted.
Reading the input
newton(x^3-x-2,x,1.5)— This is a command. The name selects the routine, and the items inside the parentheses are its arguments.
Other versions of this example
These stay on this page so each version keeps the same explanation. Choose Try example to run a version in its Studio workflow, or copy it into the editable field below.
Newton cubic
The approximate root is 1.5213797068.
newton(x^3-x-2,x,1.5)
Newton cosine
The approximate root is 0.7390851332.
newton(cos(x)-x,x,0.5)
Bisection cubic
The approximate root is 1.5213797068.
bisection(x^3-x-2,x,1,2)
Bisection square root
The approximate root is 1.4142135624.
bisection(x^2-2,x,1,2)
Secant cubic
The approximate root is 1.5213797068.
secant(x^3-x-2,x,1,2)
Secant exponential
The approximate root is 1.0986122887.
secant(exp(x)-3,x,1,2)
Try a change
- Move the iteration slider after Generate Graph. Earlier tangents, intervals, or secant lines return, and the readout shows that step's estimate and error.
- Try bisection with two endpoints of the same sign, such as bisection(x^2-2,x,2,3). The result explains why no root is reported.
Solve Equation shows the iteration formula, the derivative when Newton is used, the tolerance, and a table of every step. A value is labeled an approximate root only after the residual |f(x)| meets the tolerance. A failed status is not presented as a root.