Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

My first thought would be to switch your integral to polar coordinates so you don't need the max bit at all.

sage: r = 1.5
sage: var('rad,theta')
(rad, theta)
sage: var('a')
a
sage: integrate(integrate(a*(r - rad^2)*rad,theta,0, 2*pi),rad,0,sqrt(r))
1.125*pi*a
sage: solve(_==1,a)
[a == 8/9/pi]
sage: n(_[0].rhs())
0.282942121052258

I think I did the change of coordinates right - $r dr d\theta$, right?

Now, this doesn't answer the more general question of how to do this, where I would suggest using find_root - or just using Scipy in general, perhaps, since you are already using it, if you really do not need the symbolic capabilities; the syntax may end up more natural, who knows?

My first thought would be to switch your integral to polar coordinates so you don't need the max bit at all.

sage: r = 1.5
sage: var('rad,theta')
(rad, theta)
sage: var('a')
a
sage: integrate(integrate(a*(r - rad^2)*rad,theta,0, 2*pi),rad,0,sqrt(r))
1.125*pi*a
sage: solve(_==1,a)
[a == 8/9/pi]
sage: n(_[0].rhs())
0.282942121052258

I think I did the change of coordinates right - $r dr d\theta$, right?

Now, this doesn't answer the more general question of how to do this, this with a max and a double numerical integral, where I would suggest using find_root - or just using Scipy in general, perhaps, since you are already using it, if you really do not need the symbolic capabilities; the syntax may end up more natural, who knows?