Evaluation-Interpolation using FFT algorithm
이전 댓글 표시
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
chicken vector
2020년 12월 22일
편집: chicken vector
2020년 12월 22일
답변 (1개)
Matt J
2020년 12월 22일
0 개 추천
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
chicken vector
2020년 12월 22일
편집: chicken vector
2020년 12월 22일
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
2020년 12월 22일
카테고리
도움말 센터 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
