Solve and checkLesson 16 of 48 · 7 min
Solve a nonlinear system
Keep all branches of a nonlinear system and verify complete candidate pairs.
Maths refresher: Intersections of curves
A common solution of two curve equations is a point lying on both curves.
Substituting gives . The points are and .
Nonlinear equations can have several isolated solutions or larger families. nonlinsolve returns sets of tuples so those joint branches remain visible. Do not select a convenient branch before stating which extra conditions justify the selection.
Intersect a circle with a line. Substituting the line relationship into the circle creates a quadratic, so two intersection points are plausible. The example checks both returned pairs against both original residuals.
A physical interpretation may require positive coordinates or a bounded region, but those are extra constraints. Include them explicitly and explain any excluded branch. General nonlinear systems can be much harder, and solver output may contain parameters or unresolved conditions.
Should a solver return only the intersection with positive coordinates when no sign constraint was supplied?
Write a prediction (optional)
Exact symbolic investigation
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
Intersection points: {(-1, -2), (2, 1)}
Original checks: [(0, 0), (0, 0)]
Read the starter result
Intersection points gives full coordinate pairs. Each pair has two zero residuals in Original checks. A later model restriction could exclude one pair.
Edit and compare
In the residuals line, replace x**2+y**2-5 with x**2+y**2-1. Select Run Python. Compare Intersection points with the first run, then read Original checks for both revised coordinate pairs.
Scope. This system has finite elementary solutions. General nonlinear solving can return parametric or incomplete symbolic descriptions.
Try a fresh case
A nonlinear solver finds two valid branches. A model permits only positive x. What next?
Need a hint?
Hint 1
Separate the equations from extra admissibility conditions.
Hint 2
Check each candidate against the explicit condition.