Live data from Hacker News

Learn Physics by Programming in Haskell [pdf]

arxiv.org

21–30 of 56 posts

Re: Learn Physics by Programming in Haskell [pdf]

#21

At Georgia Tech, the labs associated with Physics I and II have a large programming portion. They had us use VPython [1], which is a strange package which includes a version of python and a graphics library. It worked pretty well, and I got a good kick out of it. They had us model gravitation of planets (using discrete time steps). In Physics II one of the assignments was to create vector field displaying a magnetic…

Note that this is only for modern physics 1 and 2, which I think roughly half of the students take, the rest taking the classical physics 1 and 2.

Yes. Though they are pretty "hush hush" about the differences between the two classes, in fact, the course numbers are the same, it's just common knowledge that one professor teaches "Modern" physics, and one teaches "Classical" though, those are kind of informal, the differences are not in the material, but mainly in the teaching style.

Re: Learn Physics by Programming in Haskell [pdf]

#23
post #17

Man, do I feel old. Back in undergraduate school, we were taught to learn programming (FORTRAN) through physics, not the other way around. The idea that the process could be turned around really hammers home how much things have changed due to the access to computers at a young age that most kids have nowadays.

Eh, I think the approach we (as in, that's how I learned programming, too) learned with is the correct one, really. Computational physics is less about programming and more about the constant tension between the demands of efficiency and accuracy and the inherent imperfections of the methods (e.g. difference models) and underlying machine representation of numbers.

Physics isn't just about punching numbers into a computer or solving math problems, and I think a shift toward more programming centered learning of physics needs to be heavily tempered with that understanding.

Re: Learn Physics by Programming in Haskell [pdf]

#24
post #17

Man, do I feel old. Back in undergraduate school, we were taught to learn programming (FORTRAN) through physics, not the other way around. The idea that the process could be turned around really hammers home how much things have changed due to the access to computers at a young age that most kids have nowadays.

I learned programming independently, but I've done a Master's in physics.

I really think that you want the curriculum to go in this order: (1) teach a high-schooler to program via games; (2) leverage that programming knowledge to build up some abstract mathematics and love of patterns; (3) start into Newton's equations with a programming background.

Haskell is actually a pretty good choice for this process because it is functional. I wouldn't tell the student that it's a "functional language" but rather that it is "based on a simpler model of computation". You start with the idea of "expressions reduce", the naming of things, and backslash-function literals. Once you understand that, then there are data structures and pattern matching -- you expand slowly outwards this way.

The syntax is surprisingly simple if you explain it top-down, but is often "lighter" than Lisp's parentheses. Curried functions and operator sections let you easily speak about high-level functions really early on without a mess of syntax. Haskell guards and pattern matching really embodies the SICP value that "every good program starts with a case dispatch." And, you can still do SICP's trick of implementing a Scheme dialect in Haskell pretty easily (in the context of games this allows them to be "scriptable").

The value that you get is that in the mathematics courses, you are sneakily starting a student off in a proof-centric environment; you can start calculus with the discrete calculus

    delta list@(x : xs) = x : zipWith (-) xs list
    sigma = scanl1 (+)
...and you swiftly get an inductive proof that sigma and delta are inverse functions.

Because computers are stupid, you really break every idea down to the lowest common denominator, which makes it really easy to incrementally learn.

Re: Learn Physics by Programming in Haskell [pdf]

#25
post #3

Earlier quoted context omitted.

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

I've yet to finish my way through. But it is amazingly precise and thorough. There are a few mistakes that the reader catches easily if they've been paying attention. The authors are really onto something with programming as a means to learn other subjects. I know there is a very recent book on differential geometry topics from them also! Would you happen to have proof of property d of exercise 1.33 lying around? (Th…

The authors are really onto something with programming as a means to learn other subjects.

I think this is because of the precision that programming demands. You have to really nail down every edge case, and think about things down to their essence.

This is one reason why programmers can succeed in jumping the fence to work in their customer's jobs, even when it's an unrelated field. (I've seen many programmers make swaps from fields as diverse as brand management, telecom customer support and bond trading)

Re: Learn Physics by Programming in Haskell [pdf]

#26
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…

Interestingly, the second edition of the book will be published next Friday.

Re: Learn Physics by Programming in Haskell [pdf]

#27

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 d…

Have a look at the Matter & Interactions textbook by Chabay and Sherwood. It's a really cool concept for a first-year physics course, and it incorporates a lot of programming (and even just programming-inspired perspectives). (The authors use the "VPython" programming package for easy creation of 3D simulations.)

Re: Learn Physics by Programming in Haskell [pdf]

#28
post #26
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…

Interestingly, the second edition of the book will be published next Friday.

Do you know if it has changed enough to deviate from the course or not? I just found out about this and it sounds really interesting, and I'd like to get the newer book if I can.

Re: Learn Physics by Programming in Haskell [pdf]

#29
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…

One thing that somewhat turned me away about SICM is that it relies almost entirely on a specific Scheme implementation and Emacs setup.

Re: Learn Physics by Programming in Haskell [pdf]

#30

Earlier quoted context omitted.

I've yet to finish my way through. But it is amazingly precise and thorough. There are a few mistakes that the reader catches easily if they've been paying attention. The authors are really onto something with programming as a means to learn other subjects. I know there is a very recent book on differential geometry topics from them also! Would you happen to have proof of property d of exercise 1.33 lying around? (Th…

The authors are really onto something with programming as a means to learn other subjects. I think this is because of the precision that programming demands. You have to really nail down every edge case, and think about things down to their essence. This is one reason why programmers can succeed in jumping the fence to work in their customer's jobs, even when it's an unrelated field. (I've seen many programmers make…

I think it's actually as much to do with having to turn syntax and abstraction into something actionable that describes the solution.

That is, in programming you learn a small set of abstractions (programming language syntax), and the actual coursework in applying that is in how they combine, how to fit them to problems.

In math, you learn a large number of abstractions (notation), that can vary and have new ones across different domains, and which doesn't tell you what it is doing unless you learn all the abstractions.

The latter you can kinda get, if you think about it, but forcing you to actually turn it into something expressed in the former means it is synthesized into something applicable, rather than just abstraction that may or may not be.

That is,

http://upload.wikimedia.org/math/d/f/1/df17b3410e58ac4c285bc...

is harder to understand when you come across it than

  total = 0;
  for(i = 0; i
or

  sum([1..100])
You have to convert the first from a symbol that does not describe its action, to an action; the code describes the action. That extra translation step leads to additional cognitive load when learning, at least for me.
Post reply on HN