I have a certain class of integrals that I have to calculate quite often. The special thing about them is that they all contain an absolute value function (with a real argument). Here is an example:
function = Sin[m*r1]*Sin[n*r2]*Exp[I*k*Abs[r1 - r2]]
fullIntegral = Integrate[Integrate[function, {r2, 0, R}], {r1, 0, R}]
(* Returns unevaluated integral expression *)
The problem is that Mathematica is not able to simplify the absolute value. I have tried teaching it to do so by using assumptions and simplify etc (following Simplifying the derivative of $|x|$, Numerical Integration with absolute value and http://www.walkingrandomly.com/?p=2283), but I can't seem to get it to work for this type of integral.
I do have a way to do it with Mathematica, by evaluating the integral in domains by hand
function2 = Sin[m*r1]*Sin[n*r2]*Exp[I*k*(r1 - r2)];
function3 = Sin[m*r1]*Sin[n*r2]*Exp[I*k*(r2 - r1)];
fullIntegral2 = Simplify[Integrate[Integrate[function2, {r2, 0, r1}], {r1, 0, R}] + Integrate[Integrate[function3, {r2, r1, R}], {r1, 0, R}]]
(* evaluates correctly, returning a nice algebraic expression *)
I have been doing these kinds of integrals like that for a while now, except it is starting to get tedious with multiply domains and dimensions. Mathematica can clearly perform these integrals, so my question is how to do it using the input function
instead of function1, function2
and the corresponding domains.