How can I integrate a multivariable function that includes Dirac delta?

3 vues (au cours des 30 derniers jours)
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 14 Fév 2016
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 commentaires
Walter Roberson
Walter Roberson le 14 Nov 2020
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
Walter Roberson le 14 Nov 2020
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. :(

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 14 Fév 2016
Modifié(e) : Matt J le 14 Fév 2016
So you want to do symbolic double and triple integrals, etc...? If so, can't you apply int() several times in succession?

Catégories

En savoir plus sur Special Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by