I asked this same question in Mathematics, and it was suggested I might try here. I'm more comfortable with Maple, but if I can get Mathematica to do what I'm after, so much the better.

Basically I'm trying to symbolically integrate something like this:

$\displaystyle\int \frac{a\mu-b}{||a\mu-b||^3} \mathrm{d}\mu$

where $a,b$ are vectors and $\mu$ is a scalar. The denominator is the cube of the 2-norm of the vector, and can be found by taking the dot product of a vector with itself, and raising it to the power of $\frac{3}{2}$.

Right now in Maple I'm explicitly multiplying out the denominator and making substitutions so that the denominator, at least, is only in terms of scalars ($a \cdot a = C$, etc. ), but I hate doing it this way, because it adds a lot of bookkeeping. Basically I'd like the computer to understand that $a * (b \cdot a)$ is not the same thing as $b * a^2$, but that $a \cdot b * c \cdot d = c \cdot d * a \cdot b$.

What's the most kosher way to do this integration in Mathematica?


This is the full integral I'm trying to do. I'm not sure it even has an answer, but the first integral is similar to what I have above. So I was hoping I could take any techniques that work on the simpler one above and apply them to the full problem below.

Let: $\vec{f} = (a - c) \mu_1 + (b - c) \upsilon_1 - (x - z) \mu_2 - (y-z) \upsilon_2 - (z - c) $

where $a, b, c, x, y, z$ are vectors representing positions, and $\mu_1, \nu_1, \mu_2, \nu_2$ are scalars.

I want to find:

$\vec{F_G} = \displaystyle\int_0^1 \int_0^{1-v_2} \int_0^{1} \int_0^{1-v_1} \! \frac{f}{||{f}||^3} \, \mathrm{d} \mu_1 \mathrm{d} \upsilon_1 \mathrm{d} \mu_2 \mathrm{d} \upsilon_2 $

  • $\begingroup$ Did you check the packages mentioned here mathematica.stackexchange.com/q/297/193 ? $\endgroup$ Commented Apr 9, 2012 at 14:28
  • $\begingroup$ Using a tensor plugin is an interesting idea. I'll explore it a bit and see if I can get what I'm after. $\endgroup$
    – Jay Lemmon
    Commented Apr 10, 2012 at 16:38
  • $\begingroup$ Atlas 2 seems capable of what I'm after (digi-area.com/Maple/atlas). It's a plugin for either Maple or Maya. Not sure I want to spend the cash on it, though. There seems to be a few other free plugins for Mathematica that might work, too. I'll give them a try. $\endgroup$
    – Jay Lemmon
    Commented Apr 12, 2012 at 22:37
  • $\begingroup$ Don't forget to post an answer if you solve it. Good luck! $\endgroup$ Commented Apr 13, 2012 at 1:29
  • $\begingroup$ Atlas 2 is add-on for Maple and Mathematica, not for Maple or Maya. ;) Maya is 3D animation editor (usa.autodesk.com/maya) $\endgroup$
    – helen
    Commented May 7, 2012 at 6:04

2 Answers 2


It helps to do a little analysis to simplify the problem. This expression is integrating over a line through $\mathbf{b}$ in the direction of $\mathbf{a}$. By choosing a suitable coordinate system you can arrange for $\mathbf{a} = (x,0,0)$ where, to assure a unit Jacobian, $x = \|\mathbf{a}\|$ (and you can even make $\mathbf{b} = (0,b,0)$ if you like, but let's just stop here and generically take $\mathbf{b} = (a,b,c)$). Brute force now succeeds:

ClearAll[x, a, b, c];
Integrate[{x, 0, 0} μ / Norm[{x, 0, 0} μ - {a, b, c}]^3, 
  {μ, -Infinity, Infinity}, 
  Assumptions -> Im[a] == 0 && Im[b] == 0 && Im[c] == 0 && Im[x] == 0 && a b c != 0]

The output, after 5 seconds, is

{ConditionalExpression[(2 a Abs[x])/((b^2 + c^2) x^2), x != 0], 0, 0}

Change back to the original coordinates to obtain the general answer.

The key is to specify the assumptions implicit in the question: namely, that these are real vectors and that the line does not pass through the origin (where the integral diverges).

  • 1
    $\begingroup$ The same result can be achieved by assuming that {a, b, c, x} \[Element] Reals instead of specifying that their imaginary parts are zero. $\endgroup$
    – rcollyer
    Commented Apr 9, 2012 at 2:01
  • $\begingroup$ It's an interesting approach, but the actual problems I'm interested in (specifically integrating across two triangles' barycentric coordinates (so forming a quadruple integral)) could be difficult to set up with all the coordinate transformations. Unless there's a reasonable way to automate those, also? $\endgroup$
    – Jay Lemmon
    Commented Apr 9, 2012 at 2:56
  • $\begingroup$ Jay, there probably is a simple way to set up the transformations. Consider posing the problem you want answered, rather than a simplified version. @rcollyer: Thank you for the tip! $\endgroup$
    – whuber
    Commented Apr 9, 2012 at 14:27
  • $\begingroup$ @whuber I've updated the problem. Don't know if you have any further insights/ideas? $\endgroup$
    – Jay Lemmon
    Commented Apr 10, 2012 at 16:33

If I understood ...

av = Table[Subscript[a, i], {i, 3}];
bv = Table[Subscript[b, i], {i, 3}];
i = Integrate[(av mu - bv)/Dot[av mu - bv, av mu - bv]^(3/2), mu]
k = i /. {x_ __, x_ __, x_ __} -> x;

And then your integral is k * j


$k =\frac{1}{\left(a_1^2 \left(b_2^2+b_3^2\right)-2 a_3 a_1 b_1 b_3+a_3^2 \left(b_1^2+b_2^2\right)-2 a_2 b_2 \left(a_1 b_1+a_3 b_3\right)+a_2^2 \left(b_1^2+b_3^2\right)\right) \sqrt{-2 a_1 b_1 \mu -2 a_2 b_2 \mu -2 a_3 b_3 \mu +a_1^2 \mu ^2+a_2^2 \mu ^2+a_3^2 \mu ^2+b_1^2+b_2^2+b_3^2}}$


$ j = \frac{i}{k}$

  • $\begingroup$ Thanks, but I'm specifically trying to prevent it from breaking the vectors in to their components. It makes the resultant equation messy to put back together. (For instance, you have $b_1^2+b_2^2+b_3^2$, when I'd want it to just be $||b||^2$ or even $b \cdot b$) $\endgroup$
    – Jay Lemmon
    Commented Apr 9, 2012 at 6:46
  • $\begingroup$ @belisarius Is the i /. {x_ __, x_ __, x_ __} -> x used to extract a common factor of the vector? $\endgroup$
    – tkott
    Commented Apr 9, 2012 at 14:09
  • $\begingroup$ @tkott yep. Surely there is a safer way, but in this case it works OK $\endgroup$ Commented Apr 9, 2012 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.