Evaluation-Interpolation using FFT algorithm
Ältere Kommentare anzeigen
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 Kommentar
chicken vector
am 22 Dez. 2020
Bearbeitet: chicken vector
am 22 Dez. 2020
Antworten (1)
Matt J
am 22 Dez. 2020
0 Stimmen
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 Kommentare
chicken vector
am 22 Dez. 2020
Bearbeitet: chicken vector
am 22 Dez. 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
am 22 Dez. 2020
Kategorien
Mehr zu Polynomials finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
