chebyshevT is too slow

2 views (last 30 days)
htrh5
htrh5 on 6 Jan 2016
Edited: htrh5 on 6 Jan 2016
This function takes an eternity to compute. I have written a workaround that works about 75 times faster for me but I am curious why this is so. It is probable that many other special functions compute slower than they need to.
N=4096;
w=(-N/2:N/2-1)/sqrt(N);
n=8;
tic;x1=chebyshevT(n,w);toc;%2.720533
tic;
A=zeros(n+1,n+1);
for i = 1:n+1
for j = 1:n+1
A(i,j)= (i-1).^(j-1);
end
end
coefs = A\chebyshevT(n,(1:n+1)-1)';
x2 = polyval(flipud(coefs),w);
toc;%0.035399
sqrt( sum((x1-x2).^2)/sum(x1.^2) )
max( abs(x1-x2)/x1 )

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!