I’m trying to understand how to calculate the volume of a recursive function containing an integral. To be precise; it is the volume V[n,r] of an n-dimensional sphere with radius r expressed as an integral of the expression for an (n-1)-dimensional sphere with radius y, i.e. V[n-1,y]. My first attemt was simply the following:
But it only works for n =1 and n=2, and returns undefined for n=3. After some searching on the web I found out that the problem could be that the radius from differens steps in the recursion gets mixed up. A fix for that is to introduce a module, like this:
Now the problem is the speed, V[2,r] is calulated in a blink but V[3,r] takes several seconds despite my attemt to use memoization. Anyone who can explain how to get this to work?
Thanks Daniel, it´s a nice solution. I like the way you separate the integration variables without the using a module. Your solution is faster than my change of variables by hand. I guess one should leave that to Mathematica