Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]
share|improve this question
up vote 8 down vote accepted

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]
share|improve this answer
This looks nice, but anything for ver. 8? – Vladimir Mar 12 '13 at 17:48
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 – Vladimir Mar 12 '13 at 17:52
@Vladimir I don't think there are builtins for v8, see my update – Szabolcs Mar 12 '13 at 17:55
@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. – 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.

share|improve this answer
However, methods from "VectorAnalysis" are limited to 3D. This is why for ver. 8. I would even do explicit calculation, like Szabolcs. – Vladimir Mar 12 '13 at 18:24
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. – Jens Mar 12 '13 at 18:31
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 ... – Szabolcs Mar 12 '13 at 18:48
@Jens Wow, these pure functions are powerful :) Yes, I see what you mean! – Vladimir Mar 12 '13 at 18:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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