From: Francois on
hi, I am working on a project for which I need to evaluate chebychev polynomials of several variables, i.e. expressions of the form

F(X,Y) = sum(sum(sum( c_i_j_k*Ti(x)*Tj(Y)*Tj(Z))))

where the sum is over the indexes i and j and k, c_i_j_k is a scalar (so c is a 3-d array), and
Ti and Tj and Tak are the chebychev polynomials of degrees i and j and k resp.

I need to evaluate this repeatedly, so I want to have a function which accepts X and Y and Z as arrays as argument if possible.

Here's what I've done so far, any suggestion to speed up is appreciated. Do you think using the recursive formula for chebychev is better?

res = 0 ;
for i=1:ncheb
temp3 = cos((i-1)*acos(X)) ;
for j=1:ncheb2
temp4 = cos((j-1)'*acos(Y)) ;
for k=1:ncheb3
temp5 = cos((k-1)'*acos(Z)) ;
res = res + coeffs(i,j,k)*temp3.*temp4.*temp5 ;
end
end
end

Thanks a lot!