Python | sympy.solve() method
With the help of sympy.solve(expression) method, we can solve the mathematical equations easily and it will return the roots of the equation that is provided as parameter using sympy.solve() method.
Syntax :
sympy.solve(expression)
Return : Return the roots of the equation.
Example #1 :
In this example we can see that by using sympy.solve() method, we can solve the mathematical expressions and this will return the roots of that equation.
# import sympy from sympy import * x, y = symbols('x y') gfg_exp = x**2 - 4 print("Before Integration : {}".format(gfg_exp)) # Use sympy.integrate() method intr = solve(gfg_exp, x) print("After Integration : {}".format(intr)) |
Output :
Before Integration : x**2 – 4
After Integration : [-2, 2]
Example #2 :
# import sympy from sympy import * x, y = symbols('x y') gfg_exp = x**2 + 36 print("Before Integration : {}".format(gfg_exp)) # Use sympy.integrate() method intr = solve(gfg_exp, x) print("After Integration : {}".format(intr)) |
Output :
Before Integration : x**2 + 36
After Integration : [-6*I, 6*I]
Recommended Posts:
- class method vs static method in Python
- Python | set() method
- Python | os.dup() method
- Python | next() method
- Python | os.times() method
- Python | sympy.cot() method
- Python | os.fstat() method
- Python | os.unlink() method
- Python PIL | Image.new() method
- Python | os.fdatasync() method
- Python | sympy.crt() method
- Python | os.WIFEXITED() method
- Python | os.waitid() method
- Python | os.open() method
- Python | sympy.csc() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



