Numerical integration with two parameters

조회 수: 9 (최근 30일)
Dimitar
Dimitar 2022년 8월 22일
댓글: Dimitar 2022년 8월 22일
So I want to integrate the following integral fun = @(t, x, y) (y-t*x+t^2)/(sqrt((x-2*t)^2+(y-t^2)^2)^3). I tried using the quad function (@t from -inf to inf) because the parameters are 'vectors' ie. x=-inf:inf and y=-inf:inf but I don't get an answer. Am I using the correct function or should I do something else, I really can't figure it out. Any answer would be helpful, thanks in advance.
  댓글 수: 2
Torsten
Torsten 2022년 8월 22일
편집: Torsten 2022년 8월 22일
I tried using the quad function (@t from -inf to inf) because the parameters are 'vectors' ie. x=-inf:inf and y=-inf:inf
So you are trying to calculate the 3d integral for x=-Inf:Inf and for y=-Inf:Inf and for t=-Inf:Inf of the above function ?
Or is it a one-dimensional integral with fixed values for x and y ?
Dimitar
Dimitar 2022년 8월 22일
Not really, I want to get one more 'vector' of answer with different values of x and y, for example x=0, y=0 the next one being x=0,y=1 etc. And after I get all the answers I want to plot them on a graph Sorry, I don't know how to explain better, I hope you can understand now.

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

답변 (1개)

Torsten
Torsten 2022년 8월 22일
편집: Torsten 2022년 8월 22일
You should check whether the integral exists when y = x^2/4. In this case, the denominator of fun is 0, and I think you'll have a pole of order 1 at t = x/2. This would mean the integral does not exist.
fun = @(t,x,y)(y-t*x+t.^2)./(sqrt((x-2*t).^2+(y-t.^2).^2).^3);
% Case where y ~= x^2/4
x = 2;
y = 4;
value = integral(@(t)fun(t,x,y),-Inf,Inf)
value = 0.7966
% Case where y = x^2/4
x = 2;
y = 1;
value = integral(@(t)fun(t,x,y),-Inf,Inf)
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.3e-02. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
value = 1.8403
  댓글 수: 1
Dimitar
Dimitar 2022년 8월 22일
I actually succeeded getting results and plotting them, by taking the values of x and y as such: [x, y] = ndgrid(-10:10,-10:10) and adding 'ArrayValued' to the integral function. I just have to figure out how to exclude ie set to 0, the values of the integral where it doesn't exist. Thank you so much!!

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by