Solving equations and inequalities

SymPy offers several ways to solve linear and nonlinear equations and systems of equations. Of course, these functions do not always succeed in finding closed-form exact solutions. In this case, we can fall back to numerical solvers and obtain approximate solutions.

How to do it...

  1. Let's define a few symbols:
    >>> from sympy import *
        init_printing()
    >>> var('x y z a')
    How to do it...
  2. We use the solve() function to solve equations (the right-hand side is 0 by default):
    >>> solve(x**2 - a, x)
    How to do it...
  3. We can also solve inequalities. Here, we need ...

Get IPython Interactive Computing and Visualization Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.