Vi(D,i)=4/3*pi*((D+i)/2)^3-4/3*pi*((D+i-1)/2)^3
v(D,i)=Vi(D,i).expand().simplify().factor()
pretty_print('the volume of the i-th layer:')
P(D,G,N)=sum(v(D,i)*G/i,i,1,N)
pretty_print('the total gravity of N layers:')
pretty_print(P(D,G,N).factor())
from sage.plot.plot3d.shapes import Sphere
def display_shell(D,G,N):
g=Graphics(); s=Sphere(D,color='gray',frame=false)
layers=sum([Sphere(D+i,opacity=G/i) for i in [1..N]])
st='<center>D=%d, G=%.2f, N=%d => P=%f</center>'
pretty_print(html(st%(D,G,N,P(D,G,N))))
No comments:
Post a Comment