Integrating with vector coefficients in Maple

543 Views Asked by At

I'm trying to use Maple to do something like this integral:

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

Where $a, b$ are vectors and $\mu$ is a scalar I'm integrating by. But I can't figure out to tell Maple to treat them like vectors, and specifically have it figure out how to distribute the dot products in the denominator (calculate the squared length of a vector by dotting it with itself).

Right now I'm solving this specific integral like this:

int((a*u-b)/sqrt(C*u^2-2*u*D+E)^3, u)

I've basically been multiplying out the denominator in to dot products, and treating the dot products as separate variables (eg: $a \cdot a = C, a \cdot b = D, b \cdot b = E$). But this adds a lot of bookkeeping and I'm tired of doing it like this. The equations I'm trying to integrate are becoming increasingly complex and I'd like the computer to handle more of the work.

What's the proper way to solve this integral in Maple?

Alternatively, is there a way to get Mathematica to do this integration?

2

There are 2 best solutions below

1
On

This seems more like a programming than a math issue, so it might be better placed on stackoverflow (or a forum like www.mapleprimes.com)

I suppose that you intend to map the integration action over each element of Vector a*mu-b, is that right?

I don't quite understand what is the difficulty about computing the denominator. Sure, you could use that expression involving several dot-products. Or you could just take the 2-norm.

It helps if you know something about mu and the entries of Vectors a and b, even if it's only that all are real-valued. Below, I use the assumption that all are positive (and thus implicitly real), with a pairwise relationship to mu.

restart:
N:=2: # or 3, 4...

a:=Vector(N,symbol=A):
b:=Vector(N,symbol=B):

with(LinearAlgebra): # to pick up LinearAlgebra:-Norm
myassumptions:=seq(mu*A[i]>B[i],i=1..N), positive: # up to you

sol1 := map(int,(a*mu-b)/(Norm(a*mu-b,2)^3),mu)
   assuming myassumptions;

sol2 := int~((a*mu-b)/(sqrt((a*mu-b).(a*mu-b))^3),mu) 
   assuming myassumptions;

sol3 := map(int,(a*mu-b)/(sqrt(a.a*mu^2-2*a.b*mu+b.b)^3),mu)
   assuming myassumptions;

sol4 := int~((a*mu-b)/(Norm(a*mu-b,2)^3),mu) 
   assuming myassumptions;

sol1-sol2;
sol1-sol3;
sol1-sol4;

The last variation above is using the relatively new syntax wherein the ~ symbol makes the int command act elementwise over the Vector a*mu-b.

What do you plan on doing with the results of this? Is going to be symbolic, or (floating-point) numeric?

2
On

If you want a numeric result, I think the following in Mathematica will get you close to where you want to be. a and b can be of arbitrary dimensions:

NIntegrate[(a u - b)/Norm[a u - b]^3, {u, lowerLimit, upperLimit}]

If you do not want the 2 Norm, then Norm[a,n] will give you the nth Norm.

In three dimensions, symbolically, Mathematica given

a = {a1, a2, a3}
b = {b1, b2, b3}

Integrate[(a u - b)/Sqrt[(a u - b)^2]^3, u]

produces,

{-(1/(a1 Sqrt[(b1-a1 u)^2])), -(1/(a2 Sqrt[(b2-a2 u)^2])), -(1/(a3 Sqrt[(b3-a3 u)^2]))}