calculus - Fast integration technique in matlab? -
so have following function need code:
lm = 1/d integral[exp(-i(a(x)t+mkx)) dx (from 0 d)
what have right is:
l = (1/period) * int(exp(- 1i*(ax*t+(m*k*x))),x,0,period); subs(l,[t,m],[beta0,tt]);
where symbolic. takes long time if ax challenging (sin(x)). figure out way simplify this. have array a_x(xi) , have been referred colleagues quad
function, far not sure how use that.
thanks
if integrand doesn't change (variables not function of x
) see no reason why couldn't take output of symbolic integration , use numerically without performing integration:
kmp = k.*m.*period/2 l = exp(-1i*(ax.*t+kmp)).*sin(kmp)./kmp
otherwise, yes, should matlab's quadrature integration methods – work vary similary sym/int
, numerical values , functions. in newer versions of matab try integral
or use quadgk
. this:
fun = @(x)exp(-1i*(ax*t+(m*k*x))); l = (1/period)*integral(fun,0,period);
note highly oscillatory functions, quadrature methods have difficulty. should check results correct in such cases. if matlab's built-in quadrature routines have trouble, levin integration schemes or maybe this.
Comments
Post a Comment