# Formulas or Code? It’s All Numbers When It Comes to Physics – My programming school

Everyone already makes use of computer systems in physics. At the very least, college students use handheld calculators (I doubt anybody is nonetheless utilizing a slide-rule calculator). Also, it is turning into more widespread to have college students remedy physics downside by creating and coding their very own packages— and I think that is a good thing. If you are not acquainted with these numerical calculations (one other title for computational physics), the essential concept is to take an issue and break it into many smaller and easier issues. These smaller issues are simpler to remedy, however you get so many calculations that you simply principally have to write a pc program to full them (however you technically do not have to use a pc).

But as numerical strategies develop into more widespread, we even have to focus on the position of those strategies in phrases of the character of science. I typically see quotes like this: “Computational methods expand our tool set in physics. We now have three parts of science: experiment, theory, and computations.”

However, this simply is not true. You cannot break science into three completely different elements. Computational strategies and principle are actually simply two variations of a calculation—and they actually aren’t that completely different. I’m going to present you the way these are the identical, however first let me be clear in regards to the nature of science. Science is all in regards to the constructing and testing of fashions. We create fashions about the best way the universe works, and then we take a look at these fashions with experimental proof. These fashions might be an precise bodily mannequin (like a globe), a conceptual mannequin, an equation—or even a pc program. So, each “theory” and “computation” are each fashions.

Let’s begin with a mass linked to a spring. I’ll be trustworthy, we physicists LOVE this state of affairs. It’s simple sufficient to remedy however sophisticated sufficient that we are able to approximate many different issues as only a mass on a spring. For instance, when a block sits on a desk, the contact drive may be modeled as a spring. Even the interplay between atoms in a stable may be approximated as a spring drive. Really, this downside is in every single place. But right here it is in its most simple kind.

I’m going to remedy this downside two methods. First, I’ll remedy it numerically by breaking it into small items (and utilizing some Python code). After that, I’ll find an analytical answer—an answer that is a closed kind perform (like in phrases of cosine) in an effort to put in no matter numbers and parameters you need to get a bunch of options. But in the top, I’ll present you that these two strategies aren’t actually that completely different.

Numerical Solution

In order to construct a numerical mannequin for a mass linked to a spring, we’d like an expression for the drive a spring exerts. If you’re taking a spring and pull it, it pulls again with some drive. The more you stretch it, the tougher it pulls. Suppose the place of a mass is given by the variable x such that this is additionally the stretch of the spring. In that case, the spring drive (in one dimension) could be:

https://media.wired.com/photographs/5f9c261806e9afd2b38e204d/191:100/w_1280,c_limit/Science_computationalphysics_1145833006.jpg