You're a 1 5 th century ballistics expert serving under the great Ottoman general Sultan Mehmed the Conqueror, tasked with ensuring a solid connection between cannon fire and the heavily fortified city walls of Constantinople.
You're setting up the cannon, which has a muzzle velocity of v 0 = 3 0 0 m / s , for a shot at a crucial encampment some 2 0 0 0 m away at the heart of the city when a few upstarts in your outfit start yelling at you, upset that you insist upon careful evaluation of the flight path of the cannonball, and urge you to take a more freewheeling approach. Historians will later note a band of Ottomans screaming at a dejected engineer, "just let it rip."
You hold steady and tell them to find something else to do.
Suppose you allowed the yahoos to have their way and ignored the effects of wind drag. By what margin ( in m ) would your cannon fire undershoot the encampment?
Assume that the force of wind resistance has the form F drag = − 2 1 ρ air C d A v 2 v ^ , where v ^ is a unit vector in the direction of the total velocity v , A is the cross-sectional area of the cannonball, and the constants are as defined in the code box below (in SI units). Moreover, the cannonball is a steel sphere of radius r and density ρ steel . To avoid collateral damage, you only choose launch angles θ ≥ 4 0 ° . For historical context, read on the Fall of Constantinople .
import math rho_air = 1.22 g = 10.0 rho_steel = 8050.0 v0 = 300.0 r = 0.08 theta = # Fill this in. drag = "Off" # Set this to "On" or "Off" to include drag, or not. C_d = (1 if drag is "On" else 0) (vx, vy) = (v0 * math.cos(theta * math.pi / 180), v0 * math.sin(theta * math.pi / 180)) (x, y) = (0, 0) dt = 0.001 while y >= 0: # Finish this code to step through the motion of the cannonball. (x, y) = (x + ..., y + ...) (vx, vy) = (vx + ..., vy + ...) print("The cannonball's range is {:.2f} meters.".format(x))
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
I am probably missing something quite simple, but... why is sin2(theta) = 2/9? where did that come from?
Log in to reply
Try v 0 = 3 0 0 and g = 1 0 in the stated equation for the range.
Log in to reply
I just never noticed an initial velocity stated in the original problem. but I am noticing it in the python script now.
I do object to the Ottoman invasion and the siege of Constantinople. If I could change history, I'd let the yahoos have their way and laugh at their lopping of projectiles on their own siegeworks. Or, I would take my place on the city wall and shoot at an angle of about 4 2 ∘ into the Ottoman invaders, which would give the proper range of 2000 m.
Note that in my simulation I use Δ x = 2 1 ( v old + v new ) d t . It is a very simple way to obtain more accuracy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
Output:
1 2 |
|
Your method gives v x x = = v x + a x × d t x + 2 1 ( o v x + v x ) d t = x + v x × d t + 2 1 a x × d t 2 v y y = = v y + a y × d t y + 2 1 ( o v y + v y ) d t = y + v y × d t + 2 1 a y × d t 2 which are my formulae (except that mine do not introduce o v x and o v y ). This method gives no greater accuracy.
Log in to reply
I noticed that. I was comparing with the more naive method, suggested by the template, which takes Δ x = v new Δ t .
The advantage of my method is that it avoid squaring d t (big whoop, of course, with how fast computers are today); and I like the intuition in Δ x = v average Δ t . However, any difference there is is mostly a matter of preference.
Yes, trap rule is both more accurate and more numerically stable than the explicit Euler. Although the implicit Euler is more stable than trap rule (but still less accurate).
Problem Loading...
Note Loading...
Set Loading...
If we were to ignore air resistance, we would aim the gun at an angle θ , where g v 0 2 sin 2 θ = 2 0 0 0 , and hence sin 2 θ = 9 2 . Since θ ≥ 4 0 ∘ , we deduce that θ = 8 3 . 5 8 0 2 ∘ .
With air resistance, the equation of motion of the cannon-ball is 3 4 π r 3 ρ steel r ¨ r ¨ = − 2 1 ρ air π r 2 ∣ r ˙ ∣ r ˙ − 3 4 π r 3 ρ steel g ( 1 0 ) = − 8 ρ steel r 3 ρ air ∣ r ˙ ∣ r ˙ − g ( 1 0 ) If we solve this equation numerically (I used d t = 0 . 0 0 0 1 for sufficient accuracy) with r ( 0 ) = ( 0 0 ) r ˙ ( 0 ) = 3 0 0 ( sin 8 3 . 5 8 0 2 ∘ cos 8 3 . 5 8 0 2 ∘ ) we deduce that the cannon-ball hits the ground at the point ( 0 4 1 0 . 9 7 ) which represents a range short-fall of 1 5 8 9 . 0 3 meters.
It is worth noting that the angle of projection needed to reach the target, taking air resistance into account, is roughly θ = 4 2 . 0 6 ∘ .