Solving polynomial equations (quadratic, cubic etc.)
Code: "equa_apache.py". Programming language: Python
DMelt Version 1. Last modified: 09/15/2015. License: Pro
https://datamelt.org/code/cache/equa_apache_2676.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from org.apache.commons.math3 import *
from org.apache.commons.math3.analysis.polynomials import *
from org.apache.commons.math3.analysis.solvers import *
coeff=[1, -2, 8] # 1-2*x+8x^2=0
sol=LaguerreSolver(1e-5)
result=sol.solveAllComplex(coeff,0.0)
print result.tolist()
coeff=[1, -2, 8, 1] # 1-2x+8x^2+x^3=0
result=sol.solveAllComplex(coeff,0.0)
print result.tolist()
coeff=[1, -2, 8, -1, 4] # 1-2x+8x^2-x^3+4x^4
result=sol.solveAllComplex(coeff,0.0)
print result.tolist()
You see the box below because you did not login.