2
votes

I have a Matlab function that evaluates a polynomial in one point in a non-explicit way (i.e., I do not have access to its coefficients )

y = @(t) P(t)   

Is there a way I can compute its coefficients (by interpolation , or other means ) so as I can find it roots using the Matlab roots function.

There is a way to do it with symbolic variables but I'd like to know if there is a solution without using symbolic computing :

 syms y ; 
 coefficients=sym2poly(feval(P,y));  

Thanks

1
do you know the degree of the polynom?Shai
@Shai I know that it's at most 20Yacine E.Faris

1 Answers

2
votes

You can use polyfit to fit the polynomial.

Suppose your polynom is of degree less or equal to d, then you need at most d+1 points to estimate the coefficients:

P = @(t) 4*t.^2-2.*t+1;  # an example of deg2 poly
d = 5;  # we estimate P to of at most deg 5
x = 0:d; 
y = P(x); 
coeff = polyfit(x,y,d)

coeff =
-0.0000    0.0000   -0.0000    4.0000   -2.0000    1.0000

As you can see, when we over-estimated the degree, the high order coeff are zero.