Section 3.1 Solving Equations
The
solve
function algebraically solves an equation or system of equations. We will begin by focusing on solving a single equation. By default, Sage assumes the expression is equal to \(0\text{.}\)
Let’s solve for \(x\) in the equation \(8 + x = 0\text{.}\)
Let’s solve for \(x\) in the equation \(8 + x = 5\text{.}\)
We can store the equation in a new variable and perform operations on it. Recall the single equal sign (
=
) is the assignment operator, while the double equal sign (==
) is the equality operator.Observe that the solution of a equation is given between square brackets, indicating that the data type is a
list
. We can access the solutions in the list
with square brackets. Notice that after accessing the solution, the brackets are no longer present.In this case the
list
has only one element. However, other equations may have multiple solutions and therefore multiple elements in the list
.We can also access each side of the equation. Here is the right-hand side of the equation.
Here is the left-hand side of the equation.
To use a variable other than
x
, we need to create a symbolic variable object with the var()
function. Otherwise, Sage will not recognize the variable as a symbolic variable.