# can I find a solution for this integral?

1 view (last 30 days)
Shreen El-Sapa on 3 Aug 2021
Commented: Shreen El-Sapa on 4 Aug 2021
r=sqrt(x.^2+y.^2);
theta=atan2(y,x);
ab1=1;xi=2;n=10;
h=@(t) (t.*(exp(-xi.*(r.*cos(theta)+ab1))-exp(-t.*(r.*cos(theta)+ab1))).*((-1).^(n-1).*exp(-ab1.*t)./factorial( n )).*t.*besselj(1,t.*r.*sin(theta)));
integral(h, 0, inf)
Shreen El-Sapa on 4 Aug 2021
in this case it excuted but i wanted to use the values in the lines 17 and 18 it failed
syms t real
L=.4;
c =-a/L;
b =a/L;
m =a*200; % NUMBER OF INTERVALS
[x,y]=meshgrid([c:(b-c)/m:b],[c:(b-c)/m:b]');
[I J]=find(sqrt(x.^2+y.^2)<(a-.1));
if ~isempty(I)
x(I,J) = 0;
y(I,J) = 0;
end
r = sqrt(x.^2+y.^2);
theta = atan2(y,x);
ab1=1; xi=2; n=10; k=2;
% I want to use the following green lines instead of above values of ab1=1; xi=2; n=10; k=2;
%chi=1;alpha=1;ab1=1;
%k=sqrt(chi.^2+alpha.^2);xi=sqrt(t.^2+k.^2);
h=@(t)(t-xi).^(-1).* (t.*(exp(-xi.*(r.*cos(theta)+ab1))-exp(-t.*(r.*cos(theta)+ab1))).*(((-1).^(n-1).*t.^(n-1).*exp(-ab1.*t)./factorial( n ))+((-1).^(n).*sqrt(pi.*k./2./t.^2).*exp(-ab1.*xi).*gegenbauerC(n,-1./2, xi./k))).*t.*besselj(1,t.*r.*sin(theta)));
hint = integral(h, 0, inf, 'ArrayValued', true)

Dave B on 3 Aug 2021
When I run this code with scalar x,y it works fine:
x=2;y=2;
r=sqrt(x.^2+y.^2);
theta=atan2(y,x);
ab1=1;xi=2;n=10;
h=@(t) (t.*(exp(-xi.*(r.*cos(theta)+ab1))-exp(-t.*(r.*cos(theta)+ab1))).*((-1).^(n-1).*exp(-ab1.*t)./factorial( n )).*t.*besselj(1,t.*r.*sin(theta)));
integral(h, 0, inf)
When I run this code with vector x and y it fails:
x=[1 2];y=[1 2];
r=sqrt(x.^2+y.^2);
theta=atan2(y,x);
ab1=1;xi=2;n=10;
h=@(t) (t.*(exp(-xi.*(r.*cos(theta)+ab1))-exp(-t.*(r.*cos(theta)+ab1))).*((-1).^(n-1).*exp(-ab1.*t)./factorial( n )).*t.*besselj(1,t.*r.*sin(theta)));
integral(h, 0, inf)
"For scalar-valued problems, the function y = fun(x) must accept a vector argument, x, and return a vector result, y. This generally means that fun must use array operators instead of matrix operators. For example, use .* (times) rather than * (mtimes). If you set the 'ArrayValued' option to true, then fun must accept a scalar and return an array of fixed size."
Here, your function accepts a scalar argument (t) and returns an array:
size(h(0)) == size(r); % for all scalar h, for all size(r) (at least that I tested)
"Set this flag to true or 1 to indicate that fun is a function that accepts a scalar input and returns a vector, matrix, or N-D array output."
Thus, if x and y are arrays, do you want the following?
integral(h, 0, inf, 'ArrayValued', true)
##### 2 CommentsShowHide 1 older comment
Shreen El-Sapa on 4 Aug 2021
in this case it excuted but i wanted to use the values in the lines 17 and 18 it failed
syms t real
L=.4;
c =-a/L;
b =a/L;
m =a*200; % NUMBER OF INTERVALS
[x,y]=meshgrid([c:(b-c)/m:b],[c:(b-c)/m:b]');
[I J]=find(sqrt(x.^2+y.^2)<(a-.1));
if ~isempty(I)
x(I,J) = 0;
y(I,J) = 0;
end
r = sqrt(x.^2+y.^2);
theta = atan2(y,x);
ab1=1; xi=2; n=10; k=2;
% I want to use the following green lines instead of above values of ab1=1; xi=2; n=10; k=2;
%chi=1;alpha=1;ab1=1;
%k=sqrt(chi.^2+alpha.^2);xi=sqrt(t.^2+k.^2);
h=@(t)(t-xi).^(-1).* (t.*(exp(-xi.*(r.*cos(theta)+ab1))-exp(-t.*(r.*cos(theta)+ab1))).*(((-1).^(n-1).*t.^(n-1).*exp(-ab1.*t)./factorial( n ))+((-1).^(n).*sqrt(pi.*k./2./t.^2).*exp(-ab1.*xi).*gegenbauerC(n,-1./2, xi./k))).*t.*besselj(1,t.*r.*sin(theta)));
hint = integral(h, 0, inf, 'ArrayValued', true)