DGS Studio

Numerical Methods

Numerical Root Finding

Plot newton(f, x, x0), bisection(f, x, a, b), or secant(f, x, x0, x1). Tangents, shrinking intervals, or secant lines replay with the iteration slider.

Generate Graph plots newton(x^3-x-2,x,1.5) with the curve, the horizontal axis, and the approximate root 1.5213797068. Each accepted step draws the tangent from the current point to the next estimate on the axis. The iteration slider replays those tangents and shows the estimate and the numerical error for the selected step.

The same card draws newton(cos(x)-x,x,0.5), whose approximate root is 0.7390851332, the bisection brackets for x^3-x-2 and x^2-2, whose approximate roots are 1.5213797068 and 1.4142135624, and the secant lines for x^3-x-2 and exp(x)-3, whose approximate root is 1.0986122887. Bisection shows the shrinking interval and the midpoint. A chord that would cross a detected discontinuity is left undrawn. Zoom, pan, and the existing graph export stay on this board.

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. Each step draws the tangent.

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. The interval halves at every step.

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. Each step draws the secant.

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

Generate Graph plots the original function, the horizontal axis, and the approximate root when one was verified. Newton draws each tangent, bisection shows the shrinking interval and midpoint, and secant draws each chord. The iteration slider replays the steps and shows the current estimate and error. Zoom, pan, and export stay on the board. A line is omitted when it would cross a detected discontinuity.

Edit and generate

Generate Graph 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