triple integral of parametrized function

조회 수: 3 (최근 30일)
Bill Francois
Bill Francois 2015년 5월 6일
답변: Mike Hosea 2015년 5월 7일
Hi
I would like to numerically compute the integral of a parametrized function to use it as a function of the parameter. Is this possible? (I know it works with a simple integral, but in the Help folder of integral3, they assign a value to the parameter BEFORE computing the integral so they do not get a function of the parameter in the end).
My function is the following one:
fun1 = @(k,e,x,y,z)((e.*psf(x,y,z)).^k).*exp(-e.*psf(x,y,z))/factorial(k)
Where psf is a function of x, y , z: @(x,y,z)exp(-2*(x.^2+y.^2)-2*z.^2) (a 3D Gaussian)
I would like to get the triple integral of fun1 between the limits -100 and 100 for x,yamd z (for example; the best woul be for me to be able to tune the limits of the integral) and use it as a function of k (which is a natural integer), to plot it for various values of e.
Thanks in advance
Bill

채택된 답변

Mike Hosea
Mike Hosea 2015년 5월 7일
Something like this?
psf = @(x,y,z)exp(-2*(x.^2+y.^2)-2*z.^2);
fun1 = @(k,e,x,y,z)((e.*psf(x,y,z)).^k).*exp(-e.*psf(x,y,z))/factorial(k);
% Make a function that takes a scalar k and a scalar e and returns the
% integral. Can use -100,100 limits (faster), or expressions involving k.
% Can use different tolerances.
scalar_k_scalar_e_fun = @(k,e)integral3(@(x,y,z)fun1(k,e,x,y,z),-inf,inf,-inf,inf,-inf,inf,'Abstol',1e-4,'RelTol',1e-3);
% Make the latter function work with an array input for e, to facilitate
% plotting.
scalar_k_array_e_fun = @(k,e)arrayfun(@(e)scalar_k_scalar_e_fun(k,e),e);
e = 0:0.1:1;
k = 3:5;
q = zeros(length(k),length(e));
for i = 1:length(k)
q(i,:) = scalar_k_array_e_fun(k(i),e);
end
hold on
for i = 1:length(k)
plot(e,q(i,:));
end
hold off

추가 답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 6일
No, you cannot do that numerically. There is a possibility that you could do it symbolically, but it would be common that no closed-form integral existed.
At the time you do numeric integration, all variables must be assigned particular values, with the particular x, y, z to integrate at being the only free variables. There is no way to produce a formula out of numeric integration. And that's what you seem to be wanting to do, produce a formula that has k as a free variable. If you want a formula output, then you need symbolic integration.
  댓글 수: 1
Bill Francois
Bill Francois 2015년 5월 7일
Thanks for the answer however, I do not want a general formula of the function defined by the integral. What I would like would be to is to be able to compute the value of the integral, numerically, for various values of the parameter, and plot them. How can i do that?
The best would be for me to have a function of k, e and l, (l being the integration limit), that returns the numerical value of the integral when I give it the values of k, e, and l. Is there a way I can do this?
It is possible to do it with a single integral but I find no way of doing it with a triple integral.

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

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by