Live data from Hacker News

Learn Physics by Programming in Haskell [pdf]

arxiv.org

1–10 of 56 posts

Re: Learn Physics by Programming in Haskell [pdf]

#2
If you're into physics I'd recommend solving some problems using whatever language, but especially functional languages (i.e. Lisps, Haskell, etc.) because you have some big "A-ha!" moments as to what the math really means. Like when you program an integral from scratch for a mechanics problem and you go "Oh that's why we use an integral here!" There are also many problems (i.e. n-body orbital dynamics) where brute-force computation is the only way to get to a solution. Finding the path Rosetta/Philae took to comet 67P comes to mind.

There's an older course that's a bit of a sequel to Structure and Interpretation of Computer Programs (SICP) called Structure and Interpretation of Classical Mechanics (SICM). I've never done it but always thought it looked like fun. (If you're into Scheme or Lisp)

course: http://ocw.mit.edu/courses/earth-atmospheric-and-planetary-s...

book: http://mitpress.mit.edu/sites/default/files/titles/content/s...

Re: Learn Physics by Programming in Haskell [pdf]

#3
post #2

If you're into physics I'd recommend solving some problems using whatever language, but especially functional languages (i.e. Lisps, Haskell, etc.) because you have some big "A-ha!" moments as to what the math really means. Like when you program an integral from scratch for a mechanics problem and you go "Oh that's why we use an integral here!" There are also many problems (i.e. n-body orbital dynamics) where brute-f…

That book absolutely blew me away the first time I worked through it. Great stuff!

Re: Learn Physics by Programming in Haskell [pdf]

#4
I am intrigued by this approach (I have Structure and Interpretation of Classical Mechanics on my lengthy to-read pile) but I do wonder whether expecting ~sophomores to be trying to pick up Haskell and the physics at the same time is a bit much.

The aspect of this that interests me most is related to a classic observation that, for most people learning physics, it's hard to separate difficulties with the physical content and difficulties with the mathematical content. The distinction between these is vague, but the separations like "set up the differential equation" vs. "solve the differential equation" that this functional style suggests seem like a good approximation to "physics" vs. "math."

Re: Learn Physics by Programming in Haskell [pdf]

#7
post #4

I am intrigued by this approach (I have Structure and Interpretation of Classical Mechanics on my lengthy to-read pile) but I do wonder whether expecting ~sophomores to be trying to pick up Haskell and the physics at the same time is a bit much. The aspect of this that interests me most is related to a classic observation that, for most people learning physics, it's hard to separate difficulties with the physical con…

If you're only dealing with pure maths, Haskell really isn't that hard to pick up, it's only once you start wanting to do I/O and deal with monads that it can be a bit of a burden.

For something like this, where you're probably just loading some pure functions into GHCi? No harder than Mathematica or something like it really.

Re: Learn Physics by Programming in Haskell [pdf]

#8
"One obvious use of types in physics that we have not explored in this work is the expression of physical dimensions (length, mass, time) and units (meter, kilogram, second).

...This is not trivial to do with Haskell’s type system because one wants multiplication to “multiply the units” as well as the numbers."

F# supports units: https://msdn.microsoft.com/en-us/library/dd233243.aspx

Re: Learn Physics by Programming in Haskell [pdf]

#9
I'm a physics sophomore, and I would be very glad to see more programming, especially FP, integrated to physics courses. During my studies, I've programmed some simulations related to the physics courses I've taken. My main purpose has been to gain a deeper, more practical insight on the subject which would've otherwise remained quite theoretical and distant.

For example, I made a little rollercoaster simulation to demonstrate the power of Lagrangian mechanics and generalized coordinates to myself. On the electrodynamics course I programmed a solver for Poisson's equation using the finite difference method to see a little more than the few simple geometries we calculated by hand. That kind of voluntary activities have greatly motivated me and helped me to understand various concepts.

On some courses we already have some simulation work and numerics in homework problems. Maybe deeper integration of programming into teaching requires time and, more importantly, a driving force and resources behind it. Then, of course, not everyone would be happy to see that kind of integration – I'm sure some would feel like they're forced to learn to program. And, as it has been seen on our entry level numerical physics course, learning programming, numerics and physics the same time is really quite hard.

Given those shortcomings, I still feel this is the way to go for future physics education. A gentle introduction and slowly teaching programming alongside physics would be the key, I think.

Post reply on HN