Evaluating integral numerically using quadgk

1 回表示 (過去 30 日間)
Niles Martinsen
Niles Martinsen 2012 年 8 月 14 日
Hi
I am trying to evaluate the following integral numerically in MatLAB: http://www.scribd.com/doc/100400549/mwe
However, the sqrt(x^2 + y^2) in the numerator has changed to x. Here is my attempt (based on this thread: http://mathworks.com/matlabcentral/answers/43929-evaluate-advanced-integral-numerically#answer_53917):
clc
clear all
myquad = @(fun,a,b,tol,trace,varargin)quadgk(@(x)fun(x,varargin{:}),a,b,'AbsTol',tol);
sigma = 1;
kappa = 1e4;
B = 1e6;
beta = 1.0;
f = 1e6;
fct = @(x,y,z,f) (...
(x)/sqrt(x.^2+y.^2+z.^2)).*(exp((-x.^2-y.^2-z.^2)/(2*sigma^2)))./ ((f - B*beta*sqrt(x.^2+y.^2+z.^2)).^2 + kappa^2/4 );
result = triplequad(@(x,y,z) fct(x,y,z,f), -Inf, Inf, -Inf, Inf, -Inf, Inf, 1e-16, myquad);
However this gives me a warning: "Rank deficient, rank = 0, tol = NaN.". I'm not sure what else to do here. Am I using triplequad correctly?
Best wishes, Niles.
  2 件のコメント
Niles Martinsen
Niles Martinsen 2012 年 8 月 14 日
I noticed that the warning only enters when the limits are from -infinity to infinity. If I change them to 0..infinity, then the warning disappears. Unfortunately the integrand is odd, so I have to use -inf..inf.
Teja Muppirala
Teja Muppirala 2012 年 8 月 14 日
If that changes to an x, then the integral is zero by symmetry.

サインインしてコメントする。

回答 (1 件)

Mike Hosea
Mike Hosea 2012 年 8 月 14 日
Make sure that you are using elementwise operations. See the first / in fct? It should be ./ instead. Check all the other multiplications and divisions. If it's only a scalar multiplication or division, then you don't need to change it, but in fact I find it easier just to use all .* and ./ rather than * or /.

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by