  # Python | sympy.apart () method Using the sympy.apart () method, we can decompose a partial fraction into a rational mathematical expression.

Syntax: apart ( expression)

Parameters:
expression - It is a rational mathematical expression.

Returns: Returns an expression after the partial decomposition.

Example # 1:
In this example, we can see that using the sympy.apart () method , we can get the partial fractional part of the given mathematical expression.

 ` # import sympy ` ` from ` ` sympy ` ` import ` ` * `   ` x ` = ` symbols (` ` `x` ` `) ` ` expr ` ` = ` ` (` ` 4 ` ` * ` ` x ` ` * ` ` * ` ` 3 ` ` + ` ` 21 ` ` * ` ` x ` ` * ` ` * ` ` 2 ` ` + ` ` 10 ` ` * ` ` x ` ` + ` ` 12 ` `) ` ` / ` ` (x ` ` * ` ` * ` ` 4 ` ` + ` 5 ` * ` ` x ` ` * * 3 + 5 * x * * 2 + 4 * x) ``    print ( "Mathematical expression: {}" . format (expr))    # Use the sympy.apart () method pd = apart (expr)    print ( "After Partial Decomposition: {}" . format (pd)) `

Exit :

` Mathematical expression: (4 * x ** 3 + 21 * x ** 2 + 10 * x + 12) / (x ** 4 + 5 * x ** 3 + 5 * x ** 2 + 4 * x) After Partial Decomposition: (2 * x - 1) / (x ** 2 + x + 1) - 1 / (x + 4) + 3 / x `

Example # 2:

 ` # import sympy ` ` from ` ` sympy ` ` import ` ` * `    ` x ` ` = ` ` symbols (< / code> `x` ) `` expr = 1 / (x + 3 ) (x + 2 )    print ( "Mathematical expression: { } " . format (expr))   # Use the sympy.factor_list () method pd = apart (expr)    print ( "After Partial Decomposition: {}" . format (pd)) `

Exit :

` Mathematical expression: 1 / ((x + 2) * (x + 3)) After Partial Decomposition: -1 / ( x + 3) + 1 / (x + 2) `