DGS Studio

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

Graph preview of newton(x^3-x-2,x,1.5)
A static sample of this expression. The studio draws the full interactive result.

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

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

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.

Edit and generate

Solve Equation opens the studio homepage and runs this field. Open in DGS Studio loads the same text and waits for you to generate it. The equation is sent once, as a query parameter.

Related examples