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 . A residual is the value f(candidate), which should be close to zero for a numerical candidate.
The exact roots are -1, 0 and 1. One numerical search need not reveal all three.
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.
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 ?
Write a prediction (optional)
Numerical roots with original residual checks
Select Run Python with the code unchanged.
Your saved draft is open. To use the published code, select Restore example in Tools. Use Recover draft to bring back your code.
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.
Execution error
Technical error details
Your result
Python text output
Compare with the worked example
Executed from the published Python during the site build. Your own run appears above. Build environment ↗
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.
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?
Need a hint?
Hint 1
Identify what information the call actually searched.
Hint 2
Check the original residual and domain.