I have three complicated vectors u
, v
and w
as well as three simple prefactors a
, b
and c
, which actually give the volume element in spherical coordinates. With z = a*u + b*v + c*w
I want to compute Dot[z, Conjugate[z]]
and integrate over the variable φ
, which appears in the prefactors but not in the vectors.
If I just plug in everything, then Mathematica apparently gets confused by the lengthy expression and integration takes forever, although it's mathematically very simple. (I could do it with pen and paper if I wanted.) I presume that Mathematica wants to do some kind of simplification on the integrand and gets stuck there.
So my idea was to treat u
, v
and w
as formal variables, do the integration first and then plug in the actual expressions for u
, v
and w
after obtaining the integral. However, now Mathematica doesn't know anymore, how to treat the dot product since it doesn't know that a
, b
and c
are numbers, while u
, v
and w
are vectors.
I already tried to fumble around with replacement rules and made Mathematica split up the dot product into individual factors. Then, however I end up with terms like Sin[φ].Sin[φ]
, which don't get simplified to Sin[φ]^2
and therefore cannot be integrated. At this point I am stuck and don't know how to proceed. Usual tricks like testing for NumericQ
as proposed here don't work for me, since all expressions include functions themselves.
Any help or suggestions how to do it differently would be appreciated. Thanks!
Motivated by Marius' comment, a bit more clarification. With the definition z = Sin[φ]*{Exp[I x], Exp[I y], Exp[I x]*Exp[I y]}
I can integrate over φ
as expected:
z = Sin[φ]*{Exp[I x], Exp[I y], Exp[I x]*Exp[I y]}
$\left\{e^{i x} \sin (\varphi ),e^{i y} \sin (\varphi ),e^{i x+i y} \sin (\varphi )\right\}$
Dot[z, Conjugate[z]]
$\sin (\varphi ) e^{-i x^*-i y^*+i x+i y} \sin (\varphi )^*+e^{i x-i x^*} \sin (\varphi ) \sin (\varphi )^*+e^{i y-i y^*} \sin (\varphi ) \sin (\varphi )^*$
Integrate[%, {φ, 0, 2 Pi}]
$\pi e^{i \left(x-x^*\right)}+\pi e^{i \left(y-y^*\right)}+\pi e^{-2 \Im(x+y)}$
However, if I use the formally equivalent form z = Sin[φ]*v
(with v
being undefined at this point), then this is not possible.
z = Sin[φ]*v
$v \sin (\varphi )$
Dot[z, Conjugate[z]]
$(v \sin (\varphi )).(v \sin (\varphi ))^*$
Integrate[%, {φ, 0, 2 Pi}]
$\int_0^{2 \pi } (v \sin (\varphi )).(v \sin (\varphi ))^* \, d\varphi$
So how can I tell Mathematica to further evaluate the dot product?
Additon: My working code thanks to Simon's answer now looks like this.
e[θ_, φ_, φ0_, e1_, e2_, e3_] := Sin[θ] Cos[φ - φ0] e1 + Sin[θ] Sin[φ - φ0] e2 + Cos[θ] e3;
r1 = Dot[a_ + b_, c_] :> Dot[a, c] + Dot[b, c];
r2 = Dot[a_, b_ + c_] :> Dot[a, b] + Dot[a, c];
r3 = Conjugate[a_ + b_] :> Conjugate[a] + Conjugate[b];
r4 = Conjugate[a_ b_] :> Conjugate[a] Conjugate[b];
i[θ_, φ_, φ0_, ep_, es_, ez_] = Dot[e[θ, φ, φ0, e1, e2, e3], Conjugate[e[θ, φ, φ0, e1, e2, e3]]] //. {r1, r2, r3, r4};
r1 = Dot[a___, d_ b_ /; FreeQ[d, e1], c___] :> d Dot[a, b, c];
r2 = Dot[a___, d_ b_ /; FreeQ[d, e2], c___] :> d Dot[a, b, c];
r3 = Dot[a___, d_ b_ /; FreeQ[d, e3], c___] :> d Dot[a, b, c];
Integrate[Simplify[i[θ, φ, φ0, e1, e2, e3], θ ∈ Reals && φ ∈ Reals && φ0 ∈ Reals] //. {r1, r2, r3}, {φ, 0, 2 Pi}]
$\pi \left(\sin ^2(\theta ) \left(\text{e1}.\text{e1}^*+\text{e2}.\text{e2}^*\right)+2\, \text{e3}.\text{e3}^* \cos ^2(\theta )\right)$
However, if I define the function i
with SetDelayed
instead of Set
, integration is again not carried out. What could be the reason for that?
u,v,w
that shows your problem more concretely? $\endgroup$Exp
orSqrt
, but also including numerical values like natural constants. All the functions depend on several variables. The prefactors look pretty much likeSin[φ]
orCos[φ]
. If you want something for testing, a case likeSin[φ] * {Exp[x], Exp[y], Exp[x]*Exp[y]}
should be fine. $\endgroup$z
is a complex function, but then your examplez = Sin[φ]*{Exp[x], Exp[y], Exp[x] Exp[y]}
is a bit confusing. $\endgroup$Exp[I x]
would have been better, indeed. But it doesn't change much about the problem I run into. $\endgroup$