May I know the formula for pi?
James, what program language did you write it in?
If so may I have look at your source?
Hal
erm ... I used an Excel spreadsheet.
It's not necessary to use anything else, but it did fall over
when I tried to expand it to 30000 terms.
However, [he says grabbing an envelope]
Thanks James M & L,
What's the maximum of floating points it can hold. Anyone tried
anything Perl?
By the way, what programming language is the best to (or designed
from ground up) to handle mathematical calculations/programming?
Preferably open source language.
Thanks James, I thought that the code
would look something like that. I was also looking for a more all
singing all dancing pi calculating program, but that's
great.
Hal,
Perl is a really cool programming language, or so I've been told.
Your program would say "I want you to go through this list and
take out all thw ones which are something like this ... yep
that's perfect" and I believe it's quite fast. Perl is usually
used on *nix systems. I don't know any Perl whatsoever, but I
suspect there will be someone around who does.
If you're looking for pure speed then you need a compiled
language like C/C++ as opposed to an interpreted one like BASIC,
which is slower even after it's compiled. I like C/C++,
but I only know the basics, and I grew up with BASIC, admittedly
I haven't done any/much for a long time, but it's what I know.
BASIC is of course a beginners language and interpreted, which
makes it easy to use, but slow.
If you're looking for a really quick and easy way of making lots
of calculations, then use an Excel spreadsheet as I did, which is
more than sufficient.
There are also more mathematical packages such as Maple and stuff
which will solve stuff for you, which may require you to learn
something, but can be very useful.
I'll come back to open source after my lectures.
James
Yep, I am into Open Source stuff. I used to program in
ColdFusion, but gave it up to learn languages that are Open
Source and non-proprietary.
Perl is indeed a good language, you can do so many things in so
many different ways. If you don't use Linux/Unix you can still do
Perl, go to ActivePerl.com or .org I thing, there is a Win32
version if it, but you also neee Pws (personal web server) i
think. I use it in Linux mainly to experient, but still consider
my self to me a beginner. I guess I would need couple o years of
hacking away at Perl to call me self a proper Perl hacker.
I too learned BASIC, but it was a long time ago.... on the old
BBC MICRO's, anyone remember them???? That got me hooked onto
computing and maths I guess.
Is Nrich run on apache/linux of something from MS?
[Apache/linux. - The Editor]
Have you tried and assembly languages? I learned a bit of
emulation in Z80 before , but only a little though. I might
return to that once I feel comfortable and mastered linux and its
zillions of FREE apps.
That's pretty much what I was going to
say.
Open Source:
Linux comes with hundreds of open source apps including C/C++
compilers, Perl stuff, Pascal stuff, anything you could care to
name, and if it's not on the distribution CDs then there's some
ftp server where you can find it.
Another advantage of Perl is that you can interface it directly
with gnuplot and stuff like that, or so I've heard, for a
graphical output ActivePerl is, as Hal says, available free and
for Win32. I have a copy, but I'm too lazy and I've too much
important stuff to do to play with it, and Linux, which I haven't
installed yet either. Perl is very useful to learn, because it's
so easy to hack code together once you've learnt the basics, as
long as you've the O'Reilly book to hand.
It doesn't need to be open source of course; freeware is just as
good and much more widely availible. There are a selection
first-class resources including TUCOWS , or UK Mirror Service
.
However, you can get a students license for Microsoft Visual
Studio if you prefer that, which will not cost you anywhere near
as much as a normal one.
Programming Languages:
I learnt GWBASIC, which progressed to QBASIC, then QuickBASIC,
and so now I can do some VB. I never liked BBCs, but we had a PC
at home from about 1988/9 or so and so I started using BASIC.
Since I've done tiny bits of Assembly Language, back in the days
when Pentiums couldn't divide, and a little C/C++, which I'm
trying to resurrect, and wean myself off BASIC, so I can do stuff
in Linux too.
Assembly Language is about as low level as you can get. This
makes it completely unsuitable for writing code to do
mathematical stuff. And hence, noone uses it anymore, unless
they're programming PICs or other similar processors. I think
that the priority for anyone wanting to learn computer languages
is to learn C/C++, because the code is so much more efficient and
better structured and prettier. So that's my advice for anyone
intending to start. It's also difficult learning a new language
when you know one which will suffice.
CATAM (Computer Aided Teaching of All Mathematics) used to be
done in Pascal, but it's now in C++. This shows just how powerful
it is.
Servers:
I'd be surprised if Nrich isn't on a UNIX server, as it's part of
the Maths faculty here at Cambridge, and that's the kind of thing
that happens here. There are also a selection of free web servers
for Windows and Linux etc availible also from TUCOWS , or
UK Mirror
Service .
James
Hal, the precision of James' program is roughly 17 significant figures at best, because it uses the 64 bit "double" type in C++. The 32 bit "float" type given about 7 or 8 sig figs. You can download free libraries on the internet to do arbitary precision maths (APM), or if you're using Java you can use the "BigDecimal" package. In fact, you might be able to do this using just JavaScript and your browser, anyone know if you can?
Here is a link to an arbitrary precision C library: http://spanky.triumf.ca/www/fractint/arb-prec.html
Thanks Dan. I'll keep that under my bookmarks, and will use after I learn a bit more C.