I know it can be silly but I can not find how to do it. I want to know how I can calculate the opposite polynomial created in Numpy regardless of its degree .
Example that does not work for me:
import numpy as np
p0 = np.poly1d([2., 0., 0., -100., 2., -1.])
p1 = np.polyder(p0, 1)
p2 = -1. @ (np.polydiv(p0, p1))[1]
p3 = -1. @ np.polydiv(p1, p2[1])[1]
p4 = -1. @ np.polydiv(p2[1], p3[1])[1]
print(p0)
print(p1)
print(p2[1])
print(p3[1])
print(p4[1])
The output is as follows:
Traceback (most recent call last) <ipython-input-9-9aab292f9c1e> in <module>()
1 p0 = np.poly1d([2., 0., 0., -100., 2., -1.])
2 p1 = np.polyder(p0, 1)
----> 3 p2 = -1. @ (np.polydiv(p0, p1))[1]
4 p3 = -1. @ np.polydiv(p1, p2[1])[1]
5 p4 = -1. @ np.polydiv(p2[1], p3[1])[1]
TypeError: unsupported operand type(s) for @: 'float' and 'poly1d'