Lesson goal: Solve equations

Previous: Factor a polynomial | Home | Next: Take a derivative

Solving an equation means finding the value or values of the unknown variable that make the equality true. In CodeByMath, you can solve both single equations and simultaneous systems of linear equations using the solve() function. For a single equation, specify the equation and the variable to solve for: $$3x - 9 = 0 \implies x = 3$$ For a system of multiple linear equations, separate the equations with a comma and provide the comma-separated list of variables: $$\begin{cases} x + y = 10 \\ x - y = 2 \end{cases} \implies x = 6, y = 4$$
solve("3*x - 9 = 0", "x")solve("x + y = 10, x - y = 2", "x,y")
Move the mouse over a dotted box for more information.

The solution is returned as a set of relational equalities enclosed in braces, such as {x==3} or {x==6,y==4}.

Now you try. Try solving 5*x + 15 = 40 for x, and the system 2*x + y = 7, x - y = 2 for x,y.

Type your code here:


See your results here: