How can I integrate a multivariable function that includes Dirac delta?
조회 수: 5 (최근 30일)
이전 댓글 표시
I'm trying to integrate an expression that includes a Dirac delta function, but the "integral" function (as well as integral2 and integral3) isn't handling the Dirac delta correctly.
For example,
f = @(x) dirac(x);
q = integral(f,-100,100)
gives me an incorrect answer of 0, while
p = int(dirac(x),x,-100,100)
gives me a correct answer of 1.
Is this just a factor of the integral function using numerical integration? If so, any recommendations for how to integrate multivariable functions with a Dirac delta in MATLAB?
댓글 수: 0
채택된 답변
Walter Roberson
2016년 2월 14일
When you use integral() you need to add Waypoints corresponding to everywhere the dirac changes between zero and non-zero, because each dirac is a discontinuity.
댓글 수: 3
Walter Roberson
2020년 11월 14일
Good question, Rupsagar Chatterjee . I am seeing seemingly contradictory explanations of waypoints, and as I dig into the code, it does not look to me as if the function gets executed at the waypoints exactly.
Walter Roberson
2020년 11월 14일
Ah, the documentation says,
Do not use waypoints to specify singularities. Instead, split the interval and add the results of separate integrations with the singularities at the endpoints.
This would mean that in your example you should calculate
integral(f,-1,3) + integral(f,3,4) + value associated with f(3)
When I say value associated with f(3), I do not mean f(3) itself, since dirac(0) is classically infinity; you would need to know to use the value associated with the distribution dirac(0), which is to say 1, multiplied by any associated constant or function value...
This is, of course, a nuisance, and the value to be associated with the point is not always obvious.
My summary... integral() appears to be unable to integral dirac() properly in practice. :(
참고 항목
카테고리
Help Center 및 File Exchange에서 Special Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!