# Python | sympy.div() method

The function `div()` provides division of polynomials with remainder. That is, for polynomials f and g, it computes q and r, such that `f= g*q+r` and `deg(r) <q.`

```Syntax:`sympy.div(f, g, domain='QQ')`
Return: division of polynomials with remainder
```

Example #1:

 `# import sympy  ` `from` `sympy ``import` `*`  ` `  `f ``=` `5` `*` `x``*``*``2` `+` `10` `*` `x ``+` `3` `g ``=` `2` `*` `x ``+` `2` ` `  `# Using sympy.div() method  ` `q, r ``=` `div(f, g, domain ``=``'QQ'``) ` ` `  `print``(q) ` `print``(r) `

Output:

```5*x/2 + 5/2
-2
```

Example #2:

 `# import sympy  ` `from` `sympy ``import` `*`  ` `  `f ``=` `5` `*` `x``*``*``2` `+` `10` `*` `x ``+` `3` `g ``=` `2` `*` `x``*``*``2` `+` `2` ` `  `# Using sympy.div() method  ` `q, r ``=` `div(f, g, domain ``=``'QQ'``) ` ` `  `print``(q) ` `print``(r) `

Output:

```5/2
10*x - 2
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

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.