---
author: Nathan Carter (ncarter@bentley.edu)
---

This answer assumes you have imported SymPy as follows.


```python
from sympy import *                   # load all math functions
init_printing( use_latex='mathjax' )  # use pretty math output
```

Let's say we want to write the equation $x^2+y^2=2$.
We must first define $x$ and $y$ as mathematical variables,
then use SymPy's `Eq` function to build an equation.
This helps SymPy distinguish a mathematical equation
from a Python assignment statement.


```python
var( 'x y' )
Eq( x**2 + y**2, 2 )    # Two parameters: left and right sides of equation
```




$\displaystyle x^{2} + y^{2} = 2$



You can make a system of equations just by placing several equations in a Python list.


```python
system = [
    Eq( x + 2*y, 1 ),
    Eq( x - 9*y, 5 )
]
system
```




$\displaystyle \left[ x + 2 y = 1, \  x - 9 y = 5\right]$



fc7acd4c5d5c528b22927dff0293227d936585ca
ipynb
Jupyter Notebook
database/tasks/How to write symbolic equations/Python, using SymPy.ipynb
nathancarter/how2data
7d4f2838661f7ce98deb1b8081470cec5671b03a
MIT
database/tasks/How to write symbolic equations/Python, using SymPy.ipynb
nathancarter/how2data
7d4f2838661f7ce98deb1b8081470cec5671b03a
MIT
database/tasks/How to write symbolic equations/Python, using SymPy.ipynb
nathancarter/how2data
7d4f2838661f7ce98deb1b8081470cec5671b03a
MIT
2021-07-18T19:01:29.000Z
2022-03-29T06:47:11.000Z
Qwen/Qwen-72B
1. YES
2. YES