Gauss-Chebyshev quadrature を使用して積分を計算するコードを matlab で作成しましたが、機能しません。
function int = chebquad('-1i*exp(x+3)',1e-8,-1,1);
f=inline('-1i*exp(x+3)','x')
old_int = inf;
for n=1:1000
x = cos(((2*(1:n) - 1)/(2*n))*pi);
w = pi/n;
fx = f(x);
int = sum(w.*fx);
if abs(int_old-int) < tol
break
end
old_int = int;
end
助言がありますか?
ありがとう!!