How does Wolfram Alpha find polynomial equation of given roots?

232 Views Asked by At

I am experimenting with a method which will converge hopefully to a real number, for which I suspect, that it is the root of a polynomial equation. How does Wolfram Alpha find its guess?

How does WA find the polynomial $$34 x^5 - 25 x^4 + 220 x^3 - 3 x^2 - 98 x - 72$$ which has a given root $x$ near $$x = 0.896955≈0.89695468574315102364$$?

Is it possible to do this also in Sagemath?

1

There are 1 best solutions below

0
On

I will answer my question for Sagemath, which is based on what @HansLundmark wrote.

It uses the PSLQ algorithm:

def find_approximate_poly_given_root(z,max_degree=10,tol=10**-15,dps=50):
    # https://mpmath.org/doc/1.1.0/identification.html#algebraic-identification
    # https://math.stackexchange.com/questions/4464671/how-does-wolfram-alpha-find-polynomial-equation-of-given-roots
    from mpmath import mp, findpoly
    mp.dps = dps
    l = findpoly(z,n=max_degree,tol=tol)
    if l is None:
        return None
    d = len(l)
    var("x")
    f = sum([x**(d-i-1)*l[i] for i in range(d)])
    return f

f = find_approximate_poly_given_root(0.896954685743151,max_degree=10,tol=10**-15,dps=15)
print(f)
print(f.roots(ring=CC))