## Solving polynomial equations in python:

In this section, we'll discuss the polynomial equations in python. How to solve the polynomial equations in python. Here we discuss in detail polynomial equations in python and the way to solve poly1d and polyder.

Now take a look at first Poly1D and then switch to polyder. In this, we also cover the program to take the polynomial coefficients from the keyboard and show the equation.

numpy.poly1d () in Python

numpy.poly1d (arr, root, var): It defines a polynomial function.

This function makes it easier to implement "natural operations" on polynomials.

Also read, Date and time function in Python

Parameters used :
array: [array_like] polynomial coefficients are given in decreasing order of powers. If the second parameter (root) is set to true then the array values are the roots of the polynomial equation.

For example-

poly1d (5, 2, 3) = 5x2 + 2x + 3
Poly 1 D ([1, 2, 3], True) = (x-1) (x-2) (x-3) = x3 - 6x2 + 11x -6

root: [bool, optional] true means polynomial roots. The default is false.

var: Variables such as x, y, z and we need in the polynomial are [default is x].

Also read, Date and time function in Python

Numpy.polyder () in Python

The numpy.polyder (p, m):  The method that evaluates the derivative of a polynomial equation.

Parameter used:

p: [array_like or poly1d]
Here, polynomial coefficients are given in decreasing order of powers. If the second parameter is about to true, the range values are the roots of the polynomial equation.

For example: poly1d (7, 2, 4) = 7x2 + 2x + 4

M: A sequence of [int, optional] differentiation

### The polynomial equation by using poly1d and polyder

```import numpy as np
a = [3,4,6,8,1,3]
p = np.poly1d(a)
print('the Polynomial equation is:')
print(p)
p2=np.polyder(p)
print('the dervative of the given polynomial equation is:')
print(p2)```
`Output:`
```the Polynomial equation is:
5     4     3     2
3 x + 4 x + 6 x + 8 x + 1 x + 3```
```
the dervative of the given polynomial equation is:
4      3      2
15 x + 16 x + 18 x + 16 x + 1
```

### Write a Program that takes coefficients of the polynomial from the keyboard and shows the equation:

```import numpy as np
n = int(input('enter a number of cofficients for polynomial equation'))
a =[]
while(n>=1):
b = int(input('enter cofficients for degree'+str(n-1)))
a.append(b)
n = n-1print('the entered polynomial equation')
print(a)
p = np.poly1d(a)
print(p)```
`Output:`
```enter a number of cofficients for polynomial equation 6
enter cofficients for degree5 3
enter cofficients for degree4 4
enter cofficients for degree3 6
enter cofficients for degree2 7
enter cofficients for degree1 3
enter cofficients for degree0 5
the entered polynomial equation
[3, 4, 6, 7, 3, 5]
5     4     3     2
3 x + 4 x + 6 x + 7 x + 3 x + 5
```

Summary:  During this section, we first discuss the polynomial equation by using poly1D and polyder. Discuss the syntax used in poly1D and polyder, and write code in Python for both. In the next section discuss a program that takes coefficients of polynomial form with output.