Solving Nonlinear Systems Of Equations

Description

Sage can be used to solve nonlinear systems of equations. We will be solving the system

(1)
\begin{align} p + q &= 9\\ qy + px &= -6\\ qy^2 +px^2 &= 24\\ p &= 1\\ \end{align}

Sage Cell

Code

var('p q y')
eq1 = p+q == 9
eq2 = q*y + p*x == -6
eq3 = q*y^2 + p*x^2 == 24
eq4 = p == 1
solve( [eq1, eq2, eq3, eq4], p, q, x, y )

Options

Option

Separating the solutions

Sage stores the solutions in an array. By assigning that array to a variable, you can display specific elements in the array. Note that an array index of size n starts at 0 and ends at n - 1. Here, we store the solutions in an array called answer and use answer to display the first solution in the array. To get the other solution, try replacing answer with answer.

Code

var('p q y')
eq1 = p+q == 9
eq2 = q*y + p*x == -6
eq3 = q*y^2 + p*x^2 == 24
eq4 = p == 1
answer = solve( [eq1, eq2, eq3, eq4], p, q, x, y )

Tags

Primary Tags—Precalculus: Systems of equations and inequalities

Secondary Tags—Systems of equations and inequalities: Nonlinear systems