I made a function that uses the np.roots() to calculate the roots of a cubic function after I solved for coefficients p1,p2, and p3. I'm trying to make it return multiple roots.
Here is my code:
def Q():
.
.
.
coeff = [1,p1, p2, p3]
roots = np.roots(coeff)
#prints out the real positive root
for i in range(0, len(roots)):
if np.isreal(roots[i]):
return np.real(roots[i])
return
root = Q(T1,P1,Tc,Pc)
print(root)
output:
root 1
what I want:
root 1
root 2
.
.
.
root n