# Integrating expressions with several terms and delta functions

So I want to integrate an expression that looks something like this:

Integrate[f[x]+DiracDelta[x-y]g[x],{x,-Infinity,Infinity}]


With some more terms added with delta functions after g[x]. Even after expanding and simplifying Mathematica won't break up the expression and evaluate the delta function, it just leaves it in exactly the form I have above. How do I make Mathematica evaluate the integral term by term?

Cheers :)

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. Apr 20, 2015 at 2:23

I would try to see if you can use Distribute for this:

Distribute@
Integrate[f[x] + DiracDelta[x - y] g[x], {x, -Infinity, Infinity}]


Unlike Map, Distribute is especially (though not exclusively) intended for use with sums.

• Perfect. My only problem with that is some of my terms should actually be integrated over a different dummy variable. Apart from that it looks great. Apr 20, 2015 at 7:09
• Actually, nevermind - you're a life saver :) Apr 21, 2015 at 6:40

One approach, admittedly not elegant, is

Map[Integrate[#, {x, -∞, ∞}] &, f[x] + DiracDelta[x - y] g[x]]
(* ConditionalExpression[g[y] + Integrate[f[x], {x, -∞, ∞}], Element[y, Reals]] *)


Incidentally, the code in the Question can be rewritten as

Integrate[#, {x, -∞, ∞}] & @ (f[x] + DiracDelta[x - y] g[x])


and the code at the beginning of this Answer as

Integrate[#, {x, -∞, ∞}] & /@ (f[x] + DiracDelta[x - y] g[x])


From this perspective the change needed to integrate DiracDelta is small.

In response to the OP's Comment below, if the integral in the Question is designated int (for instance), then
int = Integrate[f[x]+DiracDelta[x-y]g[x],{x,-∞, ∞}];