The following statements will compute the angle which minimizes the velocity necessary for a basketball shot from a height of 6 feet above the ground to reach a basket 10 feet high which is 15 feet from the shooter. This is problem 21 from the Chapter 16 review in Multivariable Calculus by McCallum, Hughes-Hallett, Gleason, et al.
Let v be the initial velocity of the ball and a be the angle at which it leaves the shooter's hand. The x coordinate of the ball at any given time, t, is:
> f:=(v,a,t)->v*cos(a)*t-15:
The y coordinate of the velocity vector of the ball is given by:
> g:=(v,a,t)->v*sin(a):
To find an expression for the y coordinate of the ball at any given time, we solve the following differential equation with initial conditions.
> eq:=diff(y(t),t,t)=-32:
> dq1:=dsolve({eq,y(0)=6,D(y)(0)=v*sin(a)},y(t)):
To ensure that the ball gets to the basket (goes through the point (0,10)), we need to solve the following equations simultaneously and minimize v.
> f1:=v*cos(a)*t-15=0:f2:=-16*t^2+v*sin(a)*t+6=10:
> f3:=solve(f1,t):
> f4:=subs(t=f3,f2):
> f5:=solve(f4,v):
> f6:=diff(f5[1],a):
> f7:=fsolve(f6,a=0..Pi/2):
> evalf(convert(f7,degrees)):
Therefore, the angle at which the ball should leave the shooter's hand is about 52 degrees with the horizontal. We now need to substitute to find the intial velocity.
> f8:=subs(a=f7,f4):
> v1:=solve(f8):
The position equations are now:
> px:=t->v1[2]*cos(f7)*t-15:py:=t->-16*t^2+v1[2]*sin(f7)*t+6:
The following sequence of commands will animate the flight of the ball.
> with(plots):
> p:=animate([px(n*t),py(n*t),t=0..15/15.39],n=0..1,color=red,thickness=2,frames=70):
> q:=plot(([px(t),py(t),t=0..15/15.39],color=blue),thickness=2):
> r:=plot([t,0,t=-17..0],color=white):
> s:=animate([px(n)+.5*cos(t),py(n)+.5*sin(t),t=0..2*Pi],n=0..15/15.39,color=green,frames=70):
> display({p,q,r,s},title=`Make a Basket with Minimum Velocity`,titlefont=[TIMES,BOLD,12]);
>