Could anybody please help me with my Intro to C++ programing homework? - by lizardfuel55
suliman on 20/9/2010 at 06:15
Numeric approximations and stuff, I guess? Physics with a computer is pretty much a whole branch of problems. You also have to know Matlab or something equivalent for all the lab stuff, so knowing C++ helps and in our uni they combine them into a single course. Physicists also have to take a little chemistry and infinitesimal calculus, biologists and chemists take classical mechanics and electrodynamics etc. There is some stuff in there that's useful to them(particularly to the chemists), but I think the idea is that you won't leave the university completely ignorant of anything outside your degree.
Mortal Monkey on 20/9/2010 at 08:55
Quote Posted by Thief13x
Edit - MM, have you ever tried programming in Haskell or any other functional languages?
Well, I did my Bachelor project in Racket (formerly known as <s>Prince</s> PLT-Scheme). If by similar you mean lots of deeply nested parenthesis, then yes.
Brian The Dog on 20/9/2010 at 13:52
Quote Posted by dethtoll
Why the fuck.....
What the fuck does one have to do with the other?
Most research positions now use physical models that are quite complicated, so need computer programs written to implement the model and analyse the quality of it against observations. Even for simple models, you're often dealing with thousands of data readings going through iterative processes.. You just can't do that level of stuff in Excel without problems. Off the top of my head, I can't think of any of my fellow PhD-ers in Physics who don't do at least some level of programming.
That's why my programs are functional and not particularly optimised, but are nicely scalable :)
If you mean "why C++?", they used to teach Fortran at my uni, but that's hardly used outside of academia, so for increased employability they switched to C++.
Quote Posted by suliman
You also have to know Matlab or something equivalent for all the lab stuff, so knowing C++ helps and in our uni they combine them into a single course. Physicists also have to take a little chemistry and infinitesimal calculus
Make that "a whole LOAD of calculus" - whenever my mathematician flatmates needed to differentiate something, they always got the Physicists to do it, we spent the first two years pretty much just doing calculus :sly: Yes, you need either Matlab/IDL or C++/Java to do the data analysis. MatLab is great for throwing together ideas for a paper, but if the problem gets really involved then you need something that's a bit more efficient.
demagogue on 20/9/2010 at 14:25
MM's program reminds me of how LISP works. You're nesting functions inside functions inside functions to incrementally build the program around the problem. It takes that idea he used and runs with it so that it's pretty much the only (or at least main) way to do anything. It just resolves functions as they come. And then trying to name some variables and do a simple, direct algorithm on them C++ style is what's odd in LISP. My C++ trained brain was skeptical at first, but it's actually a powerful way to do some kinds of things.
Vivian on 20/9/2010 at 15:04
Dethtoll, even I have to fuck around with C++ and Matlab every so often, and I'm technically a palaentologist (although not for long! hopefully. More of a biomechanist if I can get a grant I'm putting in funded).
Mortal Monkey on 20/9/2010 at 17:47
Quote Posted by demagogue
MM's program reminds me of how LISP works.
Lisp is the father of Scheme and grandfather of Racket, and also considered a functional language. I have no idea how they managed to program before bracket matching was invented, though.
Edit: By popular demand, here's a program that does the same thing in Racket:
Code:
#lang scheme
(define FUNCTIONS
(vector
(lambda (x) (+ x 5))
(lambda (x) (* x 2))
(lambda (x) (* x x))))
(define (get-number)
(printf "Please enter another number.~n")
(string->number (read-line)))
(apply printf "Results: ~a ~a ~a~n"
(for/list ((f (in-vector FUNCTIONS)))
(f (get-number))))
steo on 20/9/2010 at 18:52
You know, I think we scared lizardfuel off.
Sulphur on 20/9/2010 at 20:53
I had C and C++ programming as part of my Physics deg. too, plus a bit of microprocessor assembly programming when we were tackling electronics. A friend of mine who's doing his Ph.D and is currently on loan as a mathematician at a university in Germany does a fair bit of programming as part of his daily routine.
Quote Posted by Queue
So who gets the blowjob, then?
To be honest, brilliant as MM's code is, the offer'd still have to stand on account of how impressively unorthodox it also happens to be. I'm up for sloppy seconds, though! :thumb: