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[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:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

## Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

## 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

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License