Live data from Hacker News

Learn Physics by Programming in Haskell [pdf]

arxiv.org

11–20 of 56 posts

Re: Learn Physics by Programming in Haskell [pdf]

#11

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…

Your activities sound useful and worthwhile. A comment on this:

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.

Yeah. My feeling is that the numerical side of things is a lock to get short shrift in this type of course. In my own education, there were certainly lots of nods at numerical work, but they really undersold the subtle difficulties of doing numerics well.

Re: Learn Physics by Programming in Haskell [pdf]

#12
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 field, and then animate a magnet around the field in a circle.

I think the programming might have been a little too complex for some, as some people took physics first or second semester before having a programming class, and it became difficult for the TA's to help people with their code as they taught how to accomplish things, not accomplish it in a clean manner.

Overall though, I think it added a good bit of value to the course.

[1] : http://vpython.org/

Re: Learn Physics by Programming in Haskell [pdf]

#13
post #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

And note that there is no way to resolve this without some fundamental changes as Haskell requires that the two operands and the resultant type share a type. (Otherwise you could do some tricks with recursive types to accomplish this)

Re: Learn Physics by Programming in Haskell [pdf]

#14
post #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

There is also a haskell package for it:

https://hackage.haskell.org/package/units

and the corresponding definitions for types:

https://hackage.haskell.org/package/units-defs

Though I haven't used them.

Re: Learn Physics by Programming in Haskell [pdf]

#15
post #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

There are several options for physical units of that sort in Haskell: https://wiki.haskell.org/Physical_units. I remember being fairly satisfied with unittyped: https://bitbucket.org/xnyhps/haskell-unittyped/. Though, enabled by GHC 7.8, units may now be nicer: https://github.com/goldfirere/units

Re: Learn Physics by Programming in Haskell [pdf]

#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.

Re: Learn Physics by Programming in Haskell [pdf]

#18

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.

Re: Learn Physics by Programming in Haskell [pdf]

#19
post #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!

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? (The one on the Euler-Lagrange operator of a composition of Lagrangian-like functions)

Re: Learn Physics by Programming in Haskell [pdf]

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

Additionally by Sussman is Functional Differential Geometry. This builds on work from SICM and delves into ideas of Relativity.
Post reply on HN