Evaluation-Interpolation using FFT algorithm
Mostra commenti meno recenti
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 Commento
chicken vector
il 22 Dic 2020
Modificato: chicken vector
il 22 Dic 2020
Risposte (1)
Matt J
il 22 Dic 2020
0 voti
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 Commenti
chicken vector
il 22 Dic 2020
Modificato: chicken vector
il 22 Dic 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
il 22 Dic 2020
Categorie
Scopri di più su Polynomials in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
