Project Euler 317
Project Euler 317
题目
Firecracker
A firecracker explodes at a height of $100 \text{m}$ above level ground. It breaks into a large number of very small fragments, which move in every direction; all of them have the same initial velocity of $20 \text{m/s}$.
We assume that the fragments move without air resistance, in a uniform gravitational field with $g=9.81 \text{m/s}^2$.
Find the volume (in $\text{m}^3$) of the region through which the fragments move before reaching the ground.
Give your answer rounded to four decimal places.
解决方案
可以发现,所要求解的物体是一个绕$y$轴旋转体。
假设抛出的物体的方向和$x$轴正方向的夹角为$\theta$,并且当前时间为$t$。那么可以列出如下$(x,y)$关于$(\theta,t)$的参数方程:
将$y$固定,在此约束下$t$和$\theta$要取适当的值使得$x$取到最大值,这个过程用拉格朗日乘数法解决。
因此,可以写出
计算得到:
令$\dfrac{\partial \mathcal{L}}{\partial t}=0,\dfrac{\partial \mathcal{L}}{\partial \theta}=0$,那么得到式子$v=gt\sin\theta$。然后联立$x=vt\cos\theta,y=h+vt\sin\theta-\dfrac{1}{2}gt^2$,那么得到最终的曲线的方程:
当物体从竖直向上抛出时,能够达到的高度最高,为$H=h+\dfrac{v^2}{2g}$。
因此,答案为
代码
1 | from math import pi |