How to integrate a functional of integrals numerically?
2 views (last 30 days)
Show older comments
Greetings, Trying to numerically integrate the following http://www.scribd.com/doc/221721132/Numerical-Integration expression> using MATLAB. The answer should be a table of phi as a function of j (rows) and x (columns) as indicated on the attached file. Any help is appreciated. Thanks Naeem
Accepted Answer
Star Strider
on 3 May 2014
Edited: Star Strider
on 3 May 2014
The integrals in the numerator and denominator of φ(z,j) are actually double integrals of ψ w.r.t. x and y, so I calculated them that way in the loop, substituting in the required values for z, and then computed φ(z,j) from them and beta. (The entire calculation required about 214 seconds on my machine.)
This code:
zv = 0.1:0.1:1;
jv = 0:31;
fpsixyz = @(x,y,z) exp(-(((x-y).*z).^2)/4)./(1+y.^2); % Function to integrate
B = @(j) 1E-5 * 2.^j; % Beta
for k1 = 1:size(jv,2)
for k2 = 1:size(zv,2)
z = zv(k2);
psiz = integral2(@(x,y) fpsixyz(x,y,z), 0, Inf, -Inf, Inf); % Integrate over [x,y]
j = jv(k1);
phizj(k1,k2) = psiz ./ (B(j) + psiz); % Compute phi(z,j)
end
end
figure(1)
surfc(phizj)
xlabel('\itz\rm')
ylabel('\itj\rm')
zlabel('\phi(\itz, j\rm)')
set(gca, 'XTick', 1:2:10, 'XTickLabel', zv(1:2:end))
axis([xlim 0 31 0 1])
produces:
4 Comments
Star Strider
on 3 May 2014
What I definitely intended to say is that φ(z,j) is the RHS of the top equation. That is what I coded. The LHS of that is clearly not the original equation. They are definitely not equal in that situation because beta never appears in an integral.
I believe the original system was written as it was to emphasize that z had to be incorporated into the integral for ψ.
The last two statements there I agree with, but they seem irrelevant.
More Answers (2)
Naeem
on 3 May 2014
1 Comment
Star Strider
on 3 May 2014
I can’t get that one to integrate in MATLAB because the integral of a function of two variables integrated with respect to only one will not return the result as a function of the other variable. I tried it with a much simpler function, and when I attempted to integrate it with respect to only x, it gave an undefined variable error for y. It is obviously not a double integral problem in the usual sense.
I suggest you search the literature to see if it is possible to integrate expressions such as this, or perhaps for expressions of the integrated variables themselves. You might also consider a 2- or 3 term Taylor expansion (linearisation) of ψ, since that might make φ(z,j) easier to calculate.
Otherwise, you could write your own multiple-integration routine specifically for this problem. Numerically integrate it with the trapezoid rule or some such.
Naeem
on 3 May 2014
3 Comments
Star Strider
on 3 May 2014
My pleasure! I always learn from Answering Questions here.
I wish we could have integrated your second equation, but it is sufficiently difficult that it would require several days — if not a few weeks — to code the integrals. It is necessary to integrate two integrals over four variables, not a simple task under any circumstances.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!