Solving Equations

In this lesson, we will learn about solving different types of equations numerically and symbolically.

SymPy has equation solvers that can handle linear and non-linear algebraic equations as well as linear and non-linear multivariate equations. Depending upon the input equation, the answer returned can be symbolic or numeric. The most commonly used one is solve(). It uses the following syntax:

solve(f(x), x)

The output type of solve() varies with input, sometimes it returns a Python list and sometimes a Python dictionary. Usually, for single variable equations, it returns a list and for multivariable equations, it returns a dictionary.

Let’s explore different cases in the examples below:

Solving for a single variable

Single solution

Let’s solve the following equation that has a single solution:

2x+3=02x+3=0

Get hands-on with 1200+ tech skills courses.