tags:

views:

589

answers:

7

I hate Physics, but I love software development. When I go back to school after Thanksgiving, I'll be taking two more quarters of Physics before I'm done with the horrid thing. I am currently reading postings on the F# units of measurement feature, but I've never used a language like F#. Would it be suitable to write applications so I can perhaps learn something about Physics while doing something I like?

I'm interested in command-line applications (even those that I can just execute and have spit out an answer without needing inputs) for things like kinematics, planar motion, Newton's Laws, gravitation, work, energy, momentum and impulse, systems of particles, rotational kinematics and dynamics, angular momentum, static equilibrium, oscillatory motion, wave motion, sound, physical optics, electrostatics, Gauss' law, electric field and potential, capacitance, resistance, DC circuits, magnetic field, Ampere's law, and inductance.

The reason I'm interested in F# is because of the units of measure functionality that the language provides.

A: 

Learning any computer language won't teach you physics, and you can learn physics by writing programs in any language.

Dimensional analysis is a rather handy tool for physics problems, it can steer you away from being "not even wrong".

I've always gained a certain perverse pleasure in getting an answer wrong by factors of 10^34 because I'd got my units wrong somewhere ;-)

Ian Hopkinson
+5  A: 

I rode the introduction of a book call "F# for scientists" (the intro is available for free), and it seems to be a good introduction to the field, since F# seems to be very well adapted to this kind of field.

You might want to have a look at the introduction.

http://www.ffconsultancy.com/products/fsharp_for_scientists/

(And no, I have no relationship with the author ;-)

Pascal T.
+1  A: 

Fsharp is one choice. If you want to learn a skill which may also be of more long-term benefit why not learn python. You'll also have numpy and scipy at your fingertips then too.

Simon
The reason I liked F# is because of the units of measure and because it would give me a good reason to go back to .NET programming.
Thomas Owens
+2  A: 

Yes (any language is) and No (learn what your future colleagues will use, like maybe they use python.). An interesting aside is Fortress.

dlamblin
+8  A: 

In my biased opinion, F# is ideal for physics. It has a feature called Units of Measure which does dimensional analysis for you, providing errors if you get it wrong. For example if you write:

let distance : float<meters> = gravity * 3.0<seconds>

That would yield a compile-error, since gravity is < meters/seconds^2 > and not < meters >. This prevents a great deal of physics-related programming errors.

For more information check out Andrew Kennedy's blog.

Chris Smith
That's why I'm asking specifically about F#. :) I'll ammend my question.
Thomas Owens
+1  A: 

About dimensional analysis : a fun calculus trick once given by one of my physics professors: given that it takes one hour to perfectly cook a one pound turkey in a given oven, how long would it take to cook a 2 pound turkey is the same oven ?

Well, dimensional analysis shows

(1) that the total amount of heat energy needed in order to cook the turkey is proportional to the mass of the turkey, which itself is proportional to its volume, which itself is proportional to the cube of it average "radius"
i.e
Cooking heat energy needed = k1 * (turkeyRadius" ^3) ==> unit : m^3 * k (where k1 unit is J / m^3)

(2) That the total amount of heat energy provided by the oven is proportional to the surface of the turkey multiplied by the amount of time you cook it,
i.e
Heat provided by the oven = k2 * time * (turkeyRadius ^ 2) (where k2 unit is J / s / m^2 )

Then by using (1) = (2) , you obtain
time = k1 / k2 * turkeyRadius ^ (3/2)

i.e
- the cooking time is proportionnal to the radius ^ 3/2
- given that turkeyRadius is proportionnal to the cubic root of the mass, we obtain
cooking time = k3 * sqrt(mass)

So, it will take sqrt(2) times longer to cook our 2 pounds turkey, and the result is obtained with no calculation at all - only dimensional analysis.

Pascal T.
+2  A: 

Yes, F# is a great way to build on functional programming, just as Chris Smith said in his response. I am working on building an extensive discussion about physics, engineering and biology using F#. I could certainly use input from a student like yourself. Programming without a real life problem in mind is one way of programming. The other way that is successful is to provide solutions that are only used by people using computers, certainly another way to go and one that builds wealth.

F# is made for knowledge domains like Physics.