Solve and checkLesson 18 of 48 · 8 min

A numerical root needs a check

Use nsolve with a starting value and report its local numerical scope.

Maths refresher: Roots and residuals

A root makes f(x)=0f(x)=0. A residual is the value f(candidate), which should be close to zero for a numerical candidate.

f(x)=x3−x=x(x−1)(x+1)f(x)=x^3-x=x(x-1)(x+1)
Worked example

The exact roots are -1, 0 and 1. One numerical search need not reveal all three.

Maths prerequisite map ↗

Some equations do not have a convenient elementary solution. nsolve approximates a root numerically from a starting value or suitable bracket. A returned root is not automatically a catalogue of all roots.

See the mathematics
-1.5-0.7500.751.5-2-1012xy
-1.5-0.7500.751.5-2-1012xy
x3−x=x(x−1)(x+1)x^3-x=x(x-1)(x+1)
Starter reference. This teaching cubic has three crossings. Finding one numerically does not establish that all have been found.

The residual measures how nearly the original equation is satisfied at the computed value. A small residual is useful evidence, but its relationship to root accuracy depends on sensitivity and conditioning. Verify denominator restrictions and real-world admissibility as well.

The cubic below has three simple roots, so several starting guesses expose the local nature of the calculation. In harder problems, nearby guesses can converge to the same root, fail or encounter singularities. Report the equation, precision, guesses and verification rather than claiming completeness from one run.

Will one starting guess necessarily find every root of x3−xx^3-x?

Write a prediction (optional)

Numerical roots with original residual checks

Select Run Python with the code unchanged.

Tools
About Python

Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗

Ctrl+Enter or ⌘+Enter runs Python.

Compare with the worked example

Executed from the published Python during the site build. Your own run appears above. Build environment ↗

Starting guesses
[−1.2, 0.1, 1.2]\left[ -1.2, \ 0.1, \ 1.2\right]
Numerical roots
[−1.0, 0, 1.0]\left[ -1.0, \ 0, \ 1.0\right]
Residuals
[1.0⋅10−126, 0, 1.0⋅10−126]\left[ 1.0 \cdot 10^{-126}, \ 0, \ 1.0 \cdot 10^{-126}\right]
Worked text output
Starting guesses: [-1.2, 0.1, 1.2]
Numerical roots: [-1.0000000000000000000000000000000000, 0, 1.0000000000000000000000000000000000]
Residuals: [0.e-126, 0, 0.e-126]

Read the starter result

Match Starting guesses and Numerical roots by position. Then read Residuals to check the original equation at those roots. The guesses find different roots in this starter. A numerical search can miss roots in other examples.

Edit and compare

Replace expression = x**3-x with expression = sp.cos(x)-x and guesses = [-1.2,.1,1.2] with guesses = [1]. Set prec=35 to prec=50 in the nsolve call and select Run Python. Use Numerical roots and Residuals to check the candidate for the revised equation.

Return to the editor

Scope. A small residual alone is not a universal root-error bound, and one successful search does not establish completeness.

Try a fresh case

A single nsolve call finds a root. Which claim is justified?

Choose an answer
Need a hint?
Hint 1

Identify what information the call actually searched.

Hint 2

Check the original residual and domain.

Your notesNotes save in this browser when storage is available.