Description
Sage can be used to solve nonlinear systems of equations. We will be solving the system
(1)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[0] to display the first solution in the array. To get the other solution, try replacing answer[0] with answer[1].
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 )
answer[0]
Tags
Primary Tags—Precalculus: Systems of equations and inequalities
Secondary Tags—Systems of equations and inequalities: Nonlinear systems
Related Cells
- Solving Equations. The solve function solves equations.
- Solving Linear Systems of Equations. The solve function can also solve linear systems of equations.
- Solving Equations for One Variable in Terms of Others. Solving equations for one variable in terms of others.
Attribute
Permalink:
Author: Gregory V. Bard. Sage for Undergraduates. American Mathematical Society, Providence, RI, 2015. Available at http://www.gregorybard.com/Sage.html.
Date: 25 Feb 2019 20:38
Submitted by: Zane Corbiere