Course 1.1Lesson 5 of 5
A project that uses the whole chapter: a ball is thrown at 20 metres per second at several angles, and arrays give the time of flight, the range and the greatest height for every angle with one formula each. The range is v squared times sin of 2 theta over g, the time of flight is 2 v sin theta over g, and the height is the square of v sin theta over twice g. np.deg2rad changes the angles to radians, argmax finds the angle of the longest range, which is 45 degrees, and a mask finds the angles that give a range above a limit. A column of angles with a row of values of g gives a whole table by broadcasting, and the same angle gives a range six times longer on the Moon than on Earth.
Try the code and the simulations beside the lesson.
After this lesson you can
zip,argmax, andA ball is thrown at a speed at an angle above the ground. If we forget the air, the ball is a projectile. From physics, we know three formulas.
Here . The questions are: how far does the ball go for each angle, and which angle is best? Before you read on, make a guess. Many people say 45 degrees. Let us see.
Predict first. At which angle will the range be the longest? Then run it.
Notice also the last column. The ball reaches a greater height at the steeper angle, but it does not go as far. A high throw stays in the air longer (3.94 s at 75 degrees), but most of its speed is used to go up.
The same ball is thrown on Mars or on the Moon. The gravity is different. What happens? Now we have two quantities: the angle and the gravity.
distance.max(axis=0) is the best range of each column, the best for each planet: 40.8 m on Earth, 108.1 m on Mars, and 250.0 m on the Moon. On the Moon, the same throw goes about six times as far, because the gravity is about six times less. The best angle is the same on all of them: 45 degrees.
The hollow dot is the angle 90° − θ. It always sits at the same height as the full dot: the two throws land in the same place.
A good scientist always checks. Three ways to check a result like this one:
np.deg2rad. The numbers look strange, and the longest range is not at 45 degrees.math.sin on an array. It gives a TypeError. Use np.sin.sin(2 * theta) for sin(theta) ** 2.** Read the formula again.Start with two quick questions. Each New numbers gives you a fresh one, so you can practise as long as you like.
Then the labs and the problems:
np.deg2rad before you use np.sin.zip goes through several arrays together. argmax gives the place of the biggest number.Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
np.deg2rad?Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.