How can I integrate a multivariable function that includes Dirac delta?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rebecca
el 14 de Feb. de 2016
Comentada: Walter Roberson
el 14 de Nov. de 2020
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 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Feb. de 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 comentarios
Walter Roberson
el 14 de Nov. de 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
el 14 de Nov. de 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. :(
Ver también
Categorías
Más información sobre Special Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!