user1907354
user1907354

Reputation: 19

increasing the precision of finding roots of a polynomial in matlab

I have a polynomial depends on x and y in matlab, when I find its roots for different x, sometimes substitution of the roots in the polynomial is not an almost zero value, what is the problem?

Upvotes: 1

Views: 642

Answers (1)

Shai
Shai

Reputation: 114906

Numerical issues may arise when x and y are poorly scaled. If, for example, your root (x,y) has very large values, machine precision might prevent you from getting the precise root. Try scale your function to a compact domain around (0,0) (usually [-1,1]x[-1,1] is a good starting point).

%// let mx and my be upper bounds to |x| and |y| respectively
nx = x / mx; %// change of variables
ny = y / my;
%// express your polynom in nx and ny and solve for them
%// let nrx and nry be a root of the polynom in the new changed variables, then:
rx = nrx * mx; %// root in original varialbes
ry = nry * my;
%// if you want to verify that the roots indeed brings your polynom to zero, you should try it in the scaled domain with rnx, rny.

Upvotes: 1

Related Questions