Mathematics and Python#
Science often begins with observation, but it becomes more powerful when we can describe those observations quantitatively. Mathematics gives us a way to express relationships clearly. It helps us compare sizes, estimate timescales, test whether an idea is reasonable, and predict what should happen under different conditions.
In this book, mathematics is used as a tool for reasoning. The goal is not to memorize equations or perform long calculations for their own sake. The goal is to connect an idea to a measurable quantity. A short calculation can often reveal whether a claim is plausible, whether two effects are comparable, or whether a number is too large or too small to ignore.
Python is used for the same reason. A computer program can repeat a calculation quickly, change input values, make a graph, or test a pattern. This is especially useful in science because real systems often involve many numbers, repeated calculations, or relationships that are easier to see visually.
The Python examples in this book are not meant to replace the mathematics. Instead, they usually follow the same reasoning as the written solution. First, we identify the physical idea. Then we write the mathematical relationship. Finally, we use Python to check the result, explore the pattern, or visualize what the calculation means.
How to approach the math and Python
When you see a calculation or Python example in this book, focus on three questions:
What scientific idea is being represented?
What quantities are being compared or calculated?
How does the result help us understand the original question?
You do not need to memorize the code. You should understand what each variable represents and how the calculation connects to the scientific idea.
For example, suppose we want to estimate how long sunlight takes to reach Saturn. We can start with a known value: sunlight takes about \(8.2\ {\rm min}\) to travel from the Sun to Earth. Earth’s average distance from the Sun is \(1\ {\rm AU}\), while Saturn’s average distance from the Sun is about \(9.5\ {\rm AU}\).
Because light travels at a constant speed, the travel time scales directly with distance. Saturn is about \(9.5\) times farther from the Sun than Earth, so the light travel time is also about \(9.5\) times longer.
This means sunlight takes about \(78\ {\rm min}\), or about \(1.3\ {\rm hr}\), to reach Saturn. The Python version repeats the same scaling calculation.
# Light travel time from the Sun to Earth in minutes
earth_light_time = 8.2
# Average orbital distances in AU
earth_distance = 1.0
saturn_distance = 9.5
# Scale the Earth light travel time by the distance ratio
saturn_light_time = (saturn_distance / earth_distance) * earth_light_time
# Convert the light travel time from minutes to hours
saturn_light_time_hours = saturn_light_time / 60
print(f"Sunlight takes about {saturn_light_time:.1f} minutes to reach Saturn.")
print(f"This is about {saturn_light_time_hours:.1f} hours.")
Sunlight takes about 77.9 minutes to reach Saturn.
This is about 1.3 hours.
The important idea is the scaling. Once we know the light travel time for \(1\ {\rm AU}\), we can estimate the light travel time to another planet by multiplying by that planet’s distance in AU.