Evaluation-Interpolation using FFT algorithm
Mostrar comentarios más antiguos
I'm trying to develop a FFT algorithm for evaluation-interpolation of polynomials.
I tried the simple function
where the coefficients are expressed as
but only the DFT seems to work. I've spent quite some time on this and I can't make it work. Any suggestions?
but only the DFT seems to work. I've spent quite some time on this and I can't make it work. Any suggestions?f = @(x) x^3;
Pf = [1 , 0 , 0 , 0];
yf = FFT(Pf,1);
y = FFT(yf,2)
function y = FFT(P,k)
% k = 1 -> DFT
% k = 2 -> IDFT
N = length(P);
omega = exp(2*pi*1i/N);
if k == 1
l = 1;
p = 1;
elseif k == 2
l = 1/N;
p = -1;
end
if N == 1
y = P;
else
n = N/2;
P_e = P(2:2:end);
P_o = P(1:2:end);
y_e = FFT(P_e,k);
y_o = FFT(P_o,k);
y = zeros(N,1);
for j = 1 : N/2
y(j) = y_e(j) + (l*omega^(p*(j-1)))*y_o(j);
y(j+n) = y_e(j) - (l*omega^(p*(j-1)))*y_o(j);
end
end
end
1 comentario
chicken vector
el 22 de Dic. de 2020
Editada: chicken vector
el 22 de Dic. de 2020
Respuestas (1)
Matt J
el 22 de Dic. de 2020
0 votos
A highly impractical thing to do. If you know the coefficients of the polynomial, you should just use polyval().
However, if you must use FFT interpolation, then interpft() will readily do it,
3 comentarios
chicken vector
el 22 de Dic. de 2020
Editada: chicken vector
el 22 de Dic. de 2020
Finding the roots of a 15th order polynomial can be highly unstable numerically, e.g.,
rTrue=sort((rand(1,15))*5);
coeffsTrue=poly(rTrue), %true coefficients
coeffs=coeffsTrue+[0,randn(1,15)]*1e-6*max(coeffsTrue), %add small errors to coefficients
rTrue, %true roots
r=sort(real( roots(coeffs) )).' %calculated roots
chicken vector
el 22 de Dic. de 2020
Categorías
Más información sobre Polynomials en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
