Can someone please help me in doing numerical integration on the following function, I want to do double numerical integration with respect to y and x, such that the final answer will be a function of z only. Also the limit of integration is not a constant, it is basically something like (x-y, x+y), not sure if there exist a way to do this, can someone please advise me on how to proceed?
Thank you

댓글 수: 10

Please write out precisely the integral with limits of integration you want to compute.
Thank you for responding;
I'll split the integral into two integrations such that
the integration limits of the first one is as follows:
dx > z-y to z+y ; dy > 0 to z
and the integration limit of the second one is:
dx > y-z to z+y ; dy > z to infinity
The final answer should be the summation of both integration.
Hope that is clear,
Thank you
John D'Errico
John D'Errico 2022년 9월 3일
편집: John D'Errico 2022년 9월 3일
Are lamdas and lamdab known? If they are not, you can do nothing, since this would not be a numerical integration.
Regardless, since z lies internal to the kernel, you cannot solve for the integral in any form, unless you also know the value of z.
A numerical integration requires that all variables you will not be integrating out are known constants.
Yes lamdab and lambdas are known, both are constant.
As for z, I'll integrate it as well after finishing the double integration, or should I make it a triple integration to include z?
Thank you,
Again, you CANNOT do a numerical integration where z (or ANY variable) is an unknown parameter to the problem. If the end goal is to integrate over z also, then you do indeed need to perform a triple integration.
numeric integration can never be done on expressions that involve unresolved variables.
Consider for example that a numeric integration routine would not know whether z has a very small absolute value (such as 1e-200) that makes no difference to the integration... or if z will have a large enough absolute value that it overwhelms the x y contributions making the overall term very small.
Thank you for clarifying, in case I wish to perform triple numerical integration is this correct?
fun = @(x,y,z) 4.*pi.*lambda1.*lambda2.*z.*exp(-pi.*(lambda2.*x.^2+lambda1.*y.^2))./(sqrt(1-((x.^2+y.^2-z.^2)/2.*x.*y).^2));
q = integral3(fun,d-y,d+y,0,d,-inf,inf);
Your sqrt expression becomes negative if you integrate from -Inf to +Inf in the z-direction.
Is it a special geometrical object you try to integrate over ?
And
fun = @(x,y,z) 4.*pi.*lambda1.*lambda2.*z.*exp(-pi.*(lambda2.*x.^2+lambda1.*y.^2))./sqrt(1-((x.^2+y.^2-z.^2)/(2.*x.*y)).^2);
instead of
fun = @(x,y,z) 4.*pi.*lambda1.*lambda2.*z.*exp(-pi.*(lambda2.*x.^2+lambda1.*y.^2))./(sqrt(1-((x.^2+y.^2-z.^2)/2.*x.*y).^2));
The integral (once it is correctly written) could be considered as a function of z. Then numerical integration can be carried out.
z is always positive, I made a mistake when I wrote -inf, was just trying to understand the implementation of it.
I found 'vpaintegral' and it looks promising but it is very slow to compute.
Thank you for your help

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2022년 9월 6일
편집: Matt J 2022년 9월 6일
I'll demonstrate for a simpler function. The technique is the same regardless of what function we're integrating.
F=@(x,y,z) x.^2+y.^2+z.^2; %The input function to be integrated
Iyz=@(y,z)integral( vect(@(q)F(q,y,z)), z-y,z+y); %partial integral w.r.t. x
Iz=@(z) integral( vect(@(q)Iyz(q,z)) , 0,z); %partial integral w.r.t. y
Iz(1)
ans = 2.6667
function fun=vect(fun)
%vectorize a non-vectorized function
fun=@(x) arrayfun(fun,x);
end

댓글 수: 6

If F() is vectorized with respect to x, as it is in this case, then we don't actually need vect() for the innermost integral.
F=@(x,y,z) x.^2+y.^2+z.^2;
Iyz=@(y,z)integral( @(q)F(q,y,z), z-y,z+y);
Iz=@(z) integral( vect(@(q)Iyz(q,z)) , 0,z);
Iz(1)
ans = 2.6667
Thank you for your help, I'll try it out
You're welcome, but if you find it works for you, please Accept-click the answer.
Thank you for your help,
I still couldn't do it with my function, I think it might require the use of Mathmatica.
Torsten
Torsten 2022년 9월 8일
편집: Torsten 2022년 9월 8일
Yes, the square root in the denominator is quite ambitious ... When it gives real values and when it is different from 0 ... To take care of it in the integration limits for x,y and z won't be easy - be it with or without Mathematica.
Right, I'll hopefully look more into it to figure it out.
Thanks again!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by