The Grey Labyrinth is a collection of puzzles, riddles, mind games, paradoxes and other intellectually challenging diversions. Related topics: puzzle games, logic puzzles, lateral thinking puzzles, philosophy, mind benders, brain teasers, word problems, conundrums, 3d puzzles, spatial reasoning, intelligence tests, mathematical diversions, paradoxes, physics problems, reasoning, math, science.

   
The Grey Labyrinth Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    RegisterRegister  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Programming question(s)
Goto page 1, 2  Next
 
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture
View previous topic :: View next topic  
Author Message
mith
Pitbull of Truth



PostPosted: Mon May 09, 2005 6:04 pm    Post subject: 1 Reply with quote

1. What's a good language for mathematical programming?

I am specifically looking for something that can handle vectors better. I am currently using Perl (dumb idea) because I already knew enough of it to get by and it was easy to get running, but it's not designed for math at all. I also have access to Maple, but I don't particularly like it and I don't know how to do any actual programming bits in it. Something I can download freely and you know pretty well is preferable, so that I can ask questions later if I decide to learn it.

2. In my program, I am currently using basically the same subroutine about six different times because each time it's called it needs to run on a different variable (function, really). Is there any (easy) way (in whatever language you recommend for 1) to set it up so the function is passed to the subroutine, rather than having to have six different subs doing the same thing? (If it helps, it's a method of false position algorithm, finding where the acceleration, velocity, and distance is zero (two different functions for that, depending on the variable), and where the velocity equals the initial velocity.)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Antrax
ESL Student



PostPosted: Mon May 09, 2005 6:30 pm    Post subject: 2 Reply with quote

1. Matlab or Mathematica, I guess. I think Matlab is better, but the help system is really shitty, so get a good book and some patience. Neither is free in the traditional sense, though. However, I'm sure your university can provide you with a licence.
2. I know how to do it in C/C++, but neither is especially suited for your purpose. What you're looking for is function pointers, but I seriously doubt mathematical languages support them.
Oh, you might want to look into Python, too. It's free, very clever, and my programing languages professor insists it's a mathematical language, even though I never understood why. Maybe you will.
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mith
Pitbull of Truth



PostPosted: Mon May 09, 2005 6:42 pm    Post subject: 3 Reply with quote

It's not a question of whether they could, but whether they would. Revenge most foul! I suppose I could check, but I'll probably just get asked "why not use Maple?", and I need a better reply than "because it sucks."

I'll have a look at python again sometime. I used it once to do the initialization work for some chemistry package, but it was very specific and I don't remember anything I did anyway. Revenge most foul!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Antrax
ESL Student



PostPosted: Mon May 09, 2005 6:54 pm    Post subject: 4 Reply with quote

Why wouldn't they? Licences for these things are usually pretty cheap for academic institutions. Besides, you can also use Maple, most likely, it just sucks Felicitous
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
i_h8_evil_stuff
Daedalian Member



PostPosted: Mon May 09, 2005 7:17 pm    Post subject: 5 Reply with quote

"Maple sucks" is a valid point in any argument. At least, at RPI it is.

"I believe that abortion is wrong, because it kills innocent babies!"
"I disagree with you, on the basis that Maple sucks."
"Wow. You're right. *puts down protest sign* You want to go get lunch?"

Alright, maybe I exaggerated on that one a little bit. But this next one actually happened.

"Professor, can I have an extension on my project?"
"For what reason?"
"Well, my Calculus TA has assigned some homework, and Maple sucks."
"Oh, yes, sure. When's the Calc homework due?"
"Tuesday."
"Alright, you have until Friday."
"Thanks, Professor!"
_________________
Space for sale. PM i_h8_evil_stuff for details.
Back to top
View user's profile Send private message Send e-mail AIM Address
old grey mare
Guest



PostPosted: Tue May 10, 2005 5:41 am    Post subject: 6 Reply with quote

It seems like you want something that does a lot of number crunching and then just spits out an answer. I always do that kind of stuff with C/C++ (usually C). I love that language. You can make vectors of vectors, vectors of functions, functions of vectors, etc. You can do floating-point or integer computations, and you can always define the bit widths of the values you use. The standard math library has the basic functions like sin(x), ln(x), erf(x), etc. I've done a lot of wackydoodle stuff over the years and C hasn't let me down.

C is an old language thats not good for graphs and user interface stuff. But on the other hand you can always export your computations to files for viewing or whatever. It is well documented. It's like one level of abstraction above assembly language. Gives you lots of control, but also lets you be dangerous. You do have to keep your eye out for computation overflows and buffer overruns and such. But if you're careful and use good programming practices you'll have no problems. I know you're already a mathematical-type guy mith; if you also want to become a software-type guy you may appreciate C.

Here's a good free DOS compiler I like using:
http://www.delorie.com/djgpp/
Back to top
Antrax
ESL Student



PostPosted: Tue May 10, 2005 5:53 am    Post subject: 7 Reply with quote

Re: C Compiler - only gcc. There is no reason to use anything else, ever.
Also, I have to disagree with your sales pitch. First of all, "old" is not a factor you consider when choosing a programming language. C is as standard as standard gets, and it's pretty damn well convenient. However, both C and C++ strongly lack in the imaging department, so I don't think they're the best option. Oh, and the "shooting yourself in the leg with C" routine is really old by now. If you can't code, don't use a programming language. As simple as that.
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
old grey mare
Guest



PostPosted: Tue May 10, 2005 12:50 pm    Post subject: 8 Reply with quote

I'm not sure what you're disagreeing with.

For one, that delorie compiler is a gcc compiler.
And C/C++ does indeed lack in the imaging department, mostly because it is old. That was exactly my point. Other than that it is convenient. I didn't see anything in mith's problem description that suggested he needed pictures.

And yes, people who don't have the mental discipline to code shouldn't bother. But mith always seemed like a smart guy so I gave him the benefit of the doubt that he'd be a good coder. That's why I recommended C. If he doesn't like it that's his choice.
Back to top
mith
Pitbull of Truth



PostPosted: Tue May 10, 2005 1:45 pm    Post subject: 9 Reply with quote

For the record, I've used C before (had a uni course on it... 5 years ago, now? and then various little programs for solving puzzles and game problems and such). The main reason I started programming in perl was that I had used it more recently, and it's easier to read. But that was probably a mistake. Revenge most foul!

As for graphics... well, perl certainly isn't made for that either. I've just been taking my results files and sticking them in excel. One of these days I'll get around to (re)learning Java and make sexy 3D interactive graphs, but until then, I'm not too bothered.

How does C handle vectors? Are they just arrays? The problem I'm having with vectors is not defining them, but doing math on them. Rather than something like:

W = aU + bV;

I have to do:

(wx, wy, wz) = vadd(a, ux, uy, uz, b, vx, vy, vz);

with vadd a user defined function. It gets the job done, but it's messy, and kinda cancels out the readability.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
old grey mare
Guest



PostPosted: Tue May 10, 2005 2:09 pm    Post subject: 10 Reply with quote

Yeah I was basically thinking of vectors as either arrays or structures. Also you can define N-dimensional arrays of arrays or structures. The trick is using typedefs. As for scaling or adding vectors, I'd just write a generic routine that you pass in a pointer to a vector that would get changed. Then call that routine wherever you need it.

If you want to go to C++ you can define a vector object, along with its contents and operations you can perform on it. For example you can do "operator overloading". In other words, you can redefine the '+' symbol for vector objects, so that in your code you can start writing one liners like:

W = U + V; // Where W, U, and V are vector objects.
Back to top
mith
Pitbull of Truth



PostPosted: Tue May 10, 2005 2:12 pm    Post subject: 11 Reply with quote

See, that would be nice. But I hate object oriented programming. Dispirited
Back to top
View user's profile Send private message Send e-mail Visit poster's website
old grey mare
Guest



PostPosted: Tue May 10, 2005 2:20 pm    Post subject: 12 Reply with quote

Suck it up soldier!
Wink

Seriously though, it may be worth your while to get comfortable with it. Or try Python instead, I don't know.
Back to top
Antrax
ESL Student



PostPosted: Tue May 10, 2005 8:29 pm    Post subject: 13 Reply with quote

Quote:
For one, that delorie compiler is a gcc compiler.
~blinks~
Since when is gcc a DOS compiler? I know Gnu's not Unix, but still. AFAIK you need Cygwin to run gcc -> not DOS.
Quote:
I didn't see anything in mith's problem description that suggested he needed pictures.
Plotting is a common use of mathematical applications.
Quote:
But mith always seemed like a smart guy
So why do you think he'll shoot himself in the leg with C? (I just hate this arugment. It's used way too often for such a weak argument).
Quote:
See, that would be nice. But I hate object oriented programming
You might as well hate integrating. OOP is here to stay. You might as well learn how to utilise it, it's a good idea.
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mith
Pitbull of Truth



PostPosted: Tue May 10, 2005 9:01 pm    Post subject: 14 Reply with quote

Well, I suppose part of the reason I hate it is that I never found any use for it. So maybe now...

No, it just sucks. Like Maple. Cannibal
Back to top
View user's profile Send private message Send e-mail Visit poster's website
old grey mare
Guest



PostPosted: Tue May 10, 2005 9:34 pm    Post subject: 15 Reply with quote

That compiler I pointed to (DJGPP) is a port of the GNU compiler over to a DOS platform. It makes programs that run on regular DOS, or on a Windows that has a DOS emulator. When you use Windows it has to go through the DPMI (DOS Protected Mode Interface), so I don't think anyone is shooting themselves in the leg.

I guess if you have Cygwin on your Windows you can use the regular gcc too. Whatever.

Curiously, I just tried that web link I posted and it appears down at the moment. It was up yesterday. Confused

Well, I guess you'll have to do your math with pencil and paper, mith.
(Oh, wait.. those are objects. Never mind. Razz )
Back to top
Antrax
ESL Student



PostPosted: Tue May 10, 2005 9:38 pm    Post subject: 16 Reply with quote

OGM, where were you last year? I hate Cygwin with all my heart, but I couldn't find any other way to run gcc on my winodws machine Dispirited
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Leptonn
Guest



PostPosted: Tue May 10, 2005 9:58 pm    Post subject: 17 Reply with quote

I use Octave, which is a Gnu version of MatLab. It is quite well-documented, uses most of the standard C-style commands, and is free. It handles vectors well. I'm using it right now for a couple shorter routines.

I'm not sure what you have against Maple. It isn't designed to perform heavy algorithms, certainly. For those who are willing to give Maple a fair shot, be sure to use a version on the order of 5, rather than the bloated and slow newer releases (9). You won't lose much functionality with 5.
Back to top
Antrax
ESL Student



PostPosted: Wed May 11, 2005 4:09 am    Post subject: 18 Reply with quote

You answered yourself. My school always gets the newest versions, so I was exposed to 9. It sucks Felicitous
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Leptonn
Guest



PostPosted: Wed May 11, 2005 2:29 pm    Post subject: 19 Reply with quote

I'm not sure that your logic is as clear-cut as I have come to expect, Antrax. It is as if you said that microwave ovens suck because they don't toast bread very well.
Back to top
Antrax
ESL Student



PostPosted: Wed May 11, 2005 2:49 pm    Post subject: 20 Reply with quote

I think they suck because everything tastes like shit if you heat it in the microwave. If to go back to the original question, it does its job not as well as other programs -> sucks.
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Leptonn
Guest



PostPosted: Wed May 11, 2005 6:27 pm    Post subject: 21 Reply with quote

In my opinion, Maple V is just as effective, more intuitive, and of comparable power and efficiency when used to run short scripts, play around with functions, etc. I use Maple when I can't do something on my TI-83 but don't want to deal with the more cumbersome MatLab.
Back to top
Antrax
ESL Student



PostPosted: Wed May 11, 2005 7:20 pm    Post subject: 22 Reply with quote

...what part of "I've never seen Maple 5" wasn't clear enough?
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Leptonn
Guest



PostPosted: Wed May 11, 2005 8:34 pm    Post subject: 23 Reply with quote

I just didn't want to appear as if I had lost the argument.

/concedes

Felicitous
Back to top
Internet Stranger
Paragon of Mafia Hunters



PostPosted: Wed May 11, 2005 8:40 pm    Post subject: 24 Reply with quote

Oh hey! Maple! Yea, it sucks.
_________________
"I didn't know she was your sister I swear!"
www.InternetStranger.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
old grey mare
Guest



PostPosted: Wed May 11, 2005 9:09 pm    Post subject: 25 Reply with quote

How is Mathematica these days? Anyone know?

Last time I used it was like 14 years ago. I remember programming it to make some nice 3D gain plots for a phased array I was doing at the time. I don't remember it being difficult. Of course this was 14 years ago so I'm sure its had a ton of revisions since then. Maybe it sucks now. At the time I was working in the DOD so the government paid for the package. When I stopped working there I looked into buying Mathematica for myself and found it ridiculously expensive, so that was the end of that.
Back to top
Antrax
ESL Student



PostPosted: Wed May 11, 2005 9:10 pm    Post subject: 26 Reply with quote

I use an old version, and am very happy with it. I know dave10000 is big on it.
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bicho the Inhaler
Daedalian Member



PostPosted: Wed May 11, 2005 10:56 pm    Post subject: 27 Reply with quote

I use Mathematica 4.1 regularly. It's pretty handy, although I can usually find things to annoy me (e.g., the graphing functions aren't general enough and their warning/error messages print too slowly, and the sound generation leaves a lot to be desired).
Back to top
View user's profile Send private message
Antrax
ESL Student



PostPosted: Thu May 12, 2005 6:39 am    Post subject: 28 Reply with quote

Bicho, did you know you can turn off that extremely loud ringing sound you get whenever you start the program? I was so thrilled the day I found where to disable it Felicitous
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Bicho the Inhaler
Daedalian Member



PostPosted: Thu May 12, 2005 7:37 am    Post subject: 29 Reply with quote

Yes, I did know that. That was one of the first things I learned about it. Revenge most foul! That sound is awful.
Back to top
View user's profile Send private message
Internet Stranger
Paragon of Mafia Hunters



PostPosted: Thu May 12, 2005 3:30 pm    Post subject: 30 Reply with quote

Oh hey! Mathematica! Yea, it sucks.
_________________
"I didn't know she was your sister I swear!"
www.InternetStranger.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Samadhi
+1



PostPosted: Thu May 12, 2005 5:26 pm    Post subject: 31 Reply with quote

I remember Borodog once telling me that fortran was full of "number crunchy goodness"

I don't know anything about it, or if it's even applicable though.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
extro...
Guest



PostPosted: Thu May 12, 2005 7:18 pm    Post subject: 32 Reply with quote

try APL.
Back to top
Doc Borodog
Guest



PostPosted: Thu May 12, 2005 8:39 pm    Post subject: 33 Reply with quote

Mmm . . . FORTRAN.

FORTRAN good. FORTRAN simple. FORTRAN easy.
Back to top
mithy
Guest



PostPosted: Fri May 13, 2005 9:49 am    Post subject: 34 Reply with quote

I've used Fortran before too. I don't particularly like it.
Back to top
Doc Borodog
Guest



PostPosted: Fri May 13, 2005 2:09 pm    Post subject: 35 Reply with quote

Burn the infidel.
Back to top
CB
Guest



PostPosted: Mon May 16, 2005 11:27 am    Post subject: 36 Reply with quote

mithy, if you were given a ready-made class for vectors (i'm so sure i have one within all those projects i had made for school), would you use OOP? I don't really see anything that would make too big a difference over the regular C...

And if not, you can always do it all yourself, like this:
Code:
typedef void (*userdef) (double a, double ux, ..., double vz, double &wx, double &wy, double &wz);

void do_it(userdef vadd, [...results...]) {
 vadd(a, ux, uy, uz, b, vx, vy, vz, wx, wy, wz);
}

void my_func1 (double a, double ux, ..., double vz, double &wx, double &wy, double &wz) {
 ...
}

void my_func2 (double a, double ux, ..., double vz, double &wx, double &wy, double &wz) {
 ...
}

...

{
 ...
 do_it(my_func1, [...results...]);
 do_it(my_func2, [...results...]);
 ...
}
instead of leting the Vector class work its magic...
Code:
typedef Vector& (*userdef) (double a, Vector u, double b, Vector v);

void do_it(userdef vadd, [...results...]) {
 w = vadd(a, u, b, v);
}

Vector& my_func1 (double a, Vector u, double b, Vector v) {
 ...
}

Vector& my_func2 (double a, Vector u, double b, Vector v) {
 ...
}

...

{
 ...
 do_it(my_func1, [...results...]);
 do_it(my_func2, [...results...]);
 ...
}
Sorry if this isn't the layout that needs to be used, but i'm a bit rusty on function pointers. Embarassed I could always check it out myself if you want me to, but i'm too lazy ATM.
Back to top
MacSulach
Guest



PostPosted: Wed Jun 01, 2005 1:03 pm    Post subject: 37 Reply with quote

Fortran77 ah yes, the good old dyas when all programming languages were brown.
Back to top
Adrith
Daedalian Member



PostPosted: Thu Jun 02, 2005 1:06 pm    Post subject: 38 Reply with quote

Instead of trying FORTRAN, I would definitely go with something like Matlab. IIRC, Matlab is a descendant of RSI's IDL, which is heavily based off of FORTRAN. I think Matlab supports Object Oriented stuff too, but it's pretty kludgy.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
MacSulach
Guest



PostPosted: Thu Jun 02, 2005 1:09 pm    Post subject: 39 Reply with quote

(Turbo) Pascal is good

Then again all round all purpose fast prog language C or C++ is hard to beat.
Back to top
L'lanmal
Daedalian Member



PostPosted: Thu Jun 02, 2005 8:45 pm    Post subject: 40 Reply with quote

1. What's a good language for mathematical programming?
-----------------------------------
I'm not familiar with it, but the traditional answer is Mathematica, especially if you want to create and compile your own libraries for it. Work at it enough, and it can do just about anything. (For instance, if you wanted to do a simulation of the three-body problem complete with graphics and the ability to set initial conditions by dragging the bodies with your mouse, Mathematica is the one that could probably get it done.)

In short:

Mathematica: Supposedly most powerful, but I never learned how to use it. I get the impression it is not great for quick results, but the best to use if you are doing something involved. I'm not sure how accurate that is.

Maple: Adaptable and approachable, but often annoying to try to find exactly the right command or library to do what you want. Frequent compatibility issues and syntex changes between different releases. The GUIs tend to be quirky as well. Decent for programming if you stick to the command-line interface and compiler, but your programs may be incompatible with future releases.

Matlab: Was built for Matrix/Linear Algebra. If you want to do anything unrelated to this, you are probably better off with Mathematica or Maple. If all you are doing is vector addition, projections, dot products, etc., it could work for you. It also had the least "pretty" output (though this may have changed in recent releases).

MathCAD: It's either Maple or Mathematica (I forget which) with an interface on top. Use it if when using MS Office, you find yourself wishing it knew how to integrate or how to do ANOVA. (I haven't seen it in 7-8 years, actually.)

Non-math-exclusive languages:
LISP is the traditional language of AI, but on the other hand... good luck!
C++ seems to be all but replaced by Java, but still can be a good choice, especially if you have a program you'll want to add stuff onto later. Not blazingly fast on the calculations, but often good enough.
If you are thinking of using FORTRAN 90(?), use C++ or Java instead. Those that have used FORTRAN around here have converted over their programs to C++, and it would be easier to do so from the start. I do not speak from personal experience.
I have little experience with PASCAL. It seemed a decent sort from what I've seen.
I have no experience with Java. It all looks like C++ to me.
I have no experience with modern scripting languages.

2. In my program, I am currently using basically the same subroutine about six different times because each time it's called it needs to run on a different variable (function, really). Is there any (easy) way (in whatever language you recommend for 1) to set it up so the function is passed to the subroutine, rather than having to have six different subs doing the same thing?
--------------------------------
I would hope so for each. **shrug**


3. How does C handle vectors?
---------------------------------
Find a good library or write your own... traditional C/C++ built-ins aren't that great.


4. The problem I'm having with vectors is not defining them, but doing math on them. Rather than something like: <snip>
---------------------------------
From this, it sounds like you want to be using Maple. It comes the closest to typing in "W=aU+bV;" and having it work for you, implicit declaration and all.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous: by   
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Site Design by Wx3