Is there some built-in routine, some easier method to change variables of integration, without/before solving the integral? Say I have

Integrate[expression1[x, y, z], x, y, z]

how to change it to

Integrate[expression2[r, theta, phi], r, theta, phi]

For the specific example of Cartesian -> Spherical transformation, you could use

TransformedField["Cartesian" -> "Spherical", expression1[x, y, z], {x,y,z} -> {r, theta, phi}] * 
  CoordinateTransformData["Spherical" -> "Cartesian", "MappingJacobianDeterminant"][{r, theta, phi}]

to get expression2[r, theta, phi]

Alternatively, you could use CoordinateChartData["Spherical", "VolumeFactor"][{r, theta, phi}] in the integral.

This functionality is new in version 9. In version 8, you'd have to do the calculations by hand:

mapping = {x, y, z} -> {r Cos[phi] Sin[theta], r Sin[phi] Sin[theta], r Cos[theta]}
jd = Simplify@Det@D[mapping[[2]], {{r, theta, phi}}]

expression1[x, y, z] jd /. Thread[mapping]
  • $\begingroup$ This looks nice, but anything for ver. 8? $\endgroup$ – Vladimir Mar 12 '13 at 17:48
  • $\begingroup$ Ok, I can get around with JacobianDeterminant for now. I was just hoping there are some bulit-in routines, and it's true for ver. 9. Thanks $\endgroup$ – Vladimir Mar 12 '13 at 17:52
  • $\begingroup$ @Vladimir I don't think there are builtins for v8, see my update $\endgroup$ – Szabolcs Mar 12 '13 at 17:55
  • $\begingroup$ @Szabolcs I see you were already talking about JacobianDeterminant, but I don't see it spelled out anywhere. So I added an answer containing that approach and a variation thereof. $\endgroup$ – Jens Mar 12 '13 at 18:06

For completeness, in version 8 (and version 9 too) you can load the VectorAnalysis package and do one of the following:


JacobianDeterminant[Spherical[r, θ, ϕ]]
(* ==> r^2 Sin[θ] *)

Times @@ ScaleFactors[Spherical[r, θ, ϕ]]
(* ==> r^2 Sin[θ] *)

So instead of invoking JacobianDeterminant, you can get the scale factors individually. The coordinates ($r$, $\theta$, $\phi$) in each case can be named as I did above - if you leave that out, it defaults to built-in capitalized standard names.

Putting this into an integral

To show that this leads to a syntax which is significantly more concise than the new version 9 syntax, see this specific integral. I define a function of Cartesian variables, then do the variable transformation in the integral, as was asked for in the question:

f[x_, y_, z_] := x + 2 y + z

 f @@ CoordinatesToCartesian[#, Spherical @@ #] JacobianDeterminant[
     Spherical @@ #] &@{r, θ, ϕ},
 r, θ, ϕ]

  -(1/8) r^4 (ϕ Cos[θ]^2 + θ (2 Cos[ϕ] - 
      Sin[ϕ]) + 
   Cos[θ] Sin[θ] (-2 Cos[ϕ] + Sin[ϕ]))

I honestly think this is much prettier than what you now have to write in version 9. But I also like the completely manual approach in Szabolcs' answer.

  • $\begingroup$ However, methods from "VectorAnalysis" are limited to 3D. This is why for ver. 8. I would even do explicit calculation, like Szabolcs. $\endgroup$ – Vladimir Mar 12 '13 at 18:24
  • 1
    $\begingroup$ Sure, but your example is also 3D. And the price you pay in version 9 is a much more lengthy syntax. I'll show the much more concise integration syntax for my approach in an edited answer. $\endgroup$ – Jens Mar 12 '13 at 18:31
  • $\begingroup$ I haven't used this package before. You're right that it is simpler than what v9 offers. Maybe new Mma functions are getting a bit more wordy than they should be ... $\endgroup$ – Szabolcs Mar 12 '13 at 18:48
  • $\begingroup$ @Jens Wow, these pure functions are powerful :) Yes, I see what you mean! $\endgroup$ – Vladimir Mar 12 '13 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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