Solve Equations#
The Python package SymPy can symbolically solve equations, differential equations, linear equations, nonlinear equations, matrix problems, inequalities, Diophantine equations, and evaluate integrals. SymPy can also solve numerically.
Learn how to use SymPy computer algebra system to:
Description |
Example |
Solution |
---|---|---|
\(x^2 = y\) |
\(x \in \{-\sqrt{y},\sqrt{y}\}\) |
|
\(x^2 + y = 2, x - y = 4\) |
\(\{(x = -3, y = -7), (x = 2, y = 2)\}\) |
|
\(\cos(x) = x \) |
\( x \approx 0.739085133215161\) |
|
\(y''(x) + 9y(x)=0 \) |
\( y(x)=C_{1} \sin(3x)+ C_{2} \cos(3x)\) |
|
\(x + y = 2, x - y = 0 \) |
\( x = 1, y = 1\) |
|
\(x^2 + y^3 = 1, x^3 - y^2 = 0 \) |
\( x = 1, y = 0\) |
|
\( \left[\begin{array}{cc} 1 & 1\\1 & -1\end{array}\right] \left[\begin{array}{cc} x\\y\end{array}\right] = \left[\begin{array}{cc} 2\\0\end{array}\right] \) |
\( \left[\begin{array}{cc} x\\y\end{array}\right] = \left[\begin{array}{cc} 1\\1\end{array}\right]\) |
|
\( x^2 < 4 \) |
\( -2 < x < 2 \) |
|
\( x^2 < 4, x > 0 \) |
\( 0 < x < 2 \) |
|
\( x^2 - x = 0 \) |
\( x \in \{0, 1\} \) |
|
Solve a Diophantine equation (find integer solutions to a polynomial equation) algebraically |
\(x^2 - 4xy + 8y^2 - 3x + 7y - 5 = 0 \) |
\( \{(x = 2, y = 1), (x = 5, y = 1)\}\) |
Note: SymPy has a function called solve()
which is designed to find the roots of an equation or system of equations.
SymPy solve()
may or may not be what you need for a particular problem,
so we recommend you use the links on this page to learn how to “solve” your problem.
And while a common, colloquial expression is, for example, “solve an integral”,
in SymPy’s terminology it would be “evaluate an integral.”