# Python | sympy.simplify() method

With the help of sympy.simplify() method, we can simplify any mathematical expression.

Syntax: simplify(expression)

Parameters:
expression – It is the mathematical expression which needs to be simplified.

Returns: Returns a simplified mathematical expression corresponding to the input expression.

Example #1:
In this example we can see that by using sympy.lambdify() method, we can simplify any mathematical expression.

 `# import sympy ` `from` `sympy ``import` `*`  ` `  `x ``=` `symbols(``'x'``) ` `expr ``=` `sin(x)``*``*``2` `+` `cos(x)``*``*``2` ` `  `print``(``"Before Simplification : {}"``.``format``(expr)) ` `   `  `# Use sympy.simplify() method ` `smpl ``=` `simplify(expr)  ` `   `  `print``(``"After Simplification : {}"``.``format``(smpl))  `

Output:

```Before Simplification : sin(x)**2 + cos(x)**2
After Simplification : 1
```

Example #2:

 `# import sympy ` `from` `sympy ``import` `*`  ` `  `x ``=` `symbols(``'x'``) ` `expr ``=` `(x``*``*``3` `+` `x``*``*``2` `-` `x ``-` `1``)``/``(x``*``*``2` `+` `2` `*` `x ``+` `1``) ` ` `  `print``(``"Before Simplification : {}"``.``format``(expr)) ` `   `  `# Use sympy.simplify() method ` `smpl ``=` `simplify(expr)  ` `   `  `print``(``"After Simplification : {}"``.``format``(smpl))  `

Output:

```Before Simplification : (x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)
After Simplification : After Simplification : x - 1
```

My Personal Notes arrow_drop_up Coder Machine Learner Social Activist Vocalist

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.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.