Integration using Green's function in MatLab

19 次查看(过去 30 天)
I have an integration
phi(r)= int_0^{inf} (r'^2 * dr' * G(r,r') * S(r'))
where G(r,r') = 1/(2*m*r*r')*(exp(-m*(r-r')) - exp(-m*(r+r'))) and S(r') is a known dataset at each r' and m is also known.
How to deal with this integration to find phi(r). Could you please help me on this?

采纳的回答

Shubh Pareek
Shubh Pareek 2023-6-12
From what i have understood you want to integrate phi function from 0 to infinity , may be this code can help
also since I didn't know what your dataset function S is so i specified it to be rprime itself.
m = 1; % Some constant value
r = 0.5; % Value of r to evaluate
% Define the function handles for G and S
G = @(r, rprime) 1./(2.*m.*r.*rprime).* (exp(-m.*(abs(r-rprime))) - exp(-m.*(r+rprime)));
S = @(rprime) rprime;% Define your dataset function here
% Define the integrand function
integrand = @(rprime) (rprime.^2) .* G(r, rprime) .* S(rprime);
% Evaluate the integral using MATLAB's integral function
phi_r = integral(integrand, 0, Inf)
phi_r = 2.0739
If you want to know more about integration with multiple variable or how integral function works here are some resources .
  2 个评论
Torsten
Torsten 2023-6-12
I think a function of r for phi is more adequate here:
m = 1; % Some constant value
% Define the function handles for G and S
G = @(r, rprime) 1./(2.*m.*r.*rprime).* (exp(-m.*(abs(r-rprime))) - exp(-m.*(r+rprime)));
S = @(rprime) rprime;% Define your dataset function here
% Define the integrand function
integrand = @(r, rprime) (rprime.^2) .* G(r, rprime) .* S(rprime);
% Evaluate the integral using MATLAB's integral function
phi_r = @(r) integral(@(rprime)integrand(r, rprime), 0, Inf);
phi_r(0.5)
ans = 2.0739
pritha
pritha 2023-6-12
Thanks for your reply @Shubh. I was not taking the abs(r-rprime). That's why I couldn't able to solve it. Thanks for helping me out. Thanks @Torsten for your reply. I am getting the result properly now.

请先登录,再进行评论。

更多回答(0 个)

类别

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