Ramanujan's Taxi, or a little torture test
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.forth Profile…
 Up
Ramanujan's Taxi, or a little torture test         


Author: Anton Ertl
Date: Dec 26, 2007 06:50

The latest Vierte Dimension has an article on Ramanujan numbers, i.e.,
natural number solutions of the equation

I^3+J^3 = K^3+L^3

This led to a discussion on de.comp.lang.forth:
<04062031113560@frunobulax.edu> ff. (for those who don't remember:
this is a Usenet Message-Id and can be used to find the message on
your local news server or on groups.google.com), with a number of
programs and versions being posted, some more correct than others. I
find one version especially interesting:

http://www.complang.tuwien.ac.at/forth/programs/taxi.fs

You probably need execute-parsing.fs from

http://www.complang.tuwien.ac.at/forth/compat.zip

to run it on most systems. The way you run it is, e.g.,

gforth-fast -m 1G -e "include compat/execute-parsing.fs 1290 include standard-taxi.fs cr bye"
bigforth -d 100M -e "include compat/execute-parsing.fs 1290 include taxi.fs cr bye"
pfe -k 100000 -e 'include ~/gforth/compat/execute-parsing.fs 1290 include taxi.fs bye'
iforth "include compat/execute-parsing.fs 1290 include taxi.fs cr bye"
vfxlin "include compat/execute-parsing.fs 1290 include taxi.fs cr bye"
Show full article (3.29Kb)
54 Comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Nickolai Leschov
Date: Dec 26, 2007 11:01

Anton, thank you very much for an interesting example. As a Forth
enthusiast I am happy to see more new and interesting examples of Forth
usage. Can you please include sp-Forth in your test?
http://spf.sourceforge.net/
To me it looks quite like a solid system: ANS compliant since 1994,
clean and documented code, open source since the beginning and now
released under modern GNU PL, etc.
As I read comp.lang.forth I get surprised by seemingly total oblivion of
this system by Forth community. I would like to see how it compares to
other systems.

That being said, in my opinion the Forth community, as well as the
programming community in general, is too much concerned with efficiency
in its narrowest sense - the runtime efficiency of code. I think that
switching from threaded to native code for a 2x - 3x gain in efficiency
discards one of the substantial advantages of Forth and often can be a
net lose. sp-Forth switched to subroutine threaded code early on,
unfortunately for me, but maybe not for benchmark results?

This of course can not diminish the usefullness of your benchmark - the
differences in score are great.
Show full article (1.17Kb)
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Anton Ertl
Date: Dec 26, 2007 11:17

Nickolai Leschov gmail.com> writes:
>Can you please include sp-Forth in your test?
>http://spf.sourceforge.net/

The only packages I see there are .exe files (obviously intended for
Windows and only unpackable there) and .rar files (which require a
proprietary unpacking tool); so I guess I won't install it soon.
>As I read comp.lang.forth I get surprised by seemingly total oblivion of
>this system by Forth community. I would like to see how it compares to
>other systems.

Stephen Pelc includes SP-Forth in his tests when he does proposals.
>That being said, in my opinion the Forth community, as well as the
>programming community in general, is too much concerned with efficiency
>in its narrowest sense - the runtime efficiency of code. I think that
>switching from threaded to native code for a 2x - 3x gain in efficiency
>discards one of the substantial advantages of Forth and often can be a
>net lose. sp-Forth switched to subroutine threaded code early on,
>unfortunately for me, but maybe not for benchmark results?
Show full article (1.83Kb)
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Aleksej Saushev
Date: Dec 26, 2007 12:20

Oh, please!

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> Nickolai Leschov gmail.com> writes:
>>Can you please include sp-Forth in your test?
>>http://spf.sourceforge.net/
> The only packages I see there are .exe files (obviously intended for
> Windows and only unpackable there)

Does that mean, you're incapable to use WINE?
> .rar files (which require a
> proprietary unpacking tool); so I guess I won't install it soon.

The same lie again.

2. The unRAR sources may be used in any software to handle RAR
archives without limitations free of charge, but cannot be used
to re-create the RAR compression algorithm, which is proprietary.

From unrar license.
>>That being said, in my opinion the Forth community, as well as the
>>programming community in general, is too much concerned with efficiency
>>in its narrowest sense - the runtime efficiency of code...
Show full article (2.12Kb)
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: helmwo
Date: Dec 26, 2007 12:27

On Dec 26, 3:50 pm, an...@mips.complang.tuwien.ac.at (Anton Ertl)
wrote:
> I^3+J^3 = K^3+L^3

Nice thing. But not very complex to optimize.
> 1290

It's allowed to cheat? I mean 1290 is obviously a cheat and I'm able
to reduce the comparations needed without abusing the dictionary as a
"hash" (I do think that usually Perl-people do this kind of abuse of
the language, while in Perl this is permitted).

One of the properties of X^3 is that with a Q(uestion) MOD 2^X usually
there are only N+1 values /per modulus/ are needed to crosscheck for a
sum, or if Q MOD 8 is zero, then it may be something "more arbitrary".
That's because one property of the modulus is that if you add two of
them they can tell you if that sum can be usable for a requested sum x
+ y == z. Amazingly with our case there are almost all Q MOD 2^X that
are even will be excluded (only those with Q MOD 8 == 0 will remain).
Did you try that?

-Helmar
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Nickolai Leschov
Date: Dec 26, 2007 13:04

Anton Ertl wrote:
> The only packages I see there are .exe files (obviously intended for
> Windows and only unpackable there) and .rar files (which require a
> proprietary unpacking tool); so I guess I won't install it soon.

Yes, as far as I know, sp-Forth is Windows only
I heard about Linux port but can't find it.
> Well, if you like threaded code, Gforth offers a whole range of
> threaded-code options

Yes, that's the approach I like.
I meant to say that Forths (including sp-Forth) usually have their code
model built in and this built-in and if there's no threaded code - there
won't be any.

Nickolai
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: helmwo
Date: Dec 26, 2007 13:22

Hi,
>> Well, if you like threaded code, Gforth offers a whole range of
>> threaded-code options
>
> Yes, that's the approach I like.
> I meant to say that Forths (including sp-Forth) usually have their code
> model built in and this built-in and if there's no threaded code - there
> won't be any.

I dont like really that model of explanation. That's like machines you
buy for kitchen - in advertise they do everything you want, in reality
you need place to store them and you never use them. Gforth...
Show full article (1.46Kb)
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Aleksej Saushev
Date: Dec 26, 2007 14:14

Nickolai Leschov gmail.com> writes:
> Anton Ertl wrote:
>
>> The only packages I see there are .exe files (obviously intended for
>> Windows and only unpackable there) and .rar files (which require a
>> proprietary unpacking tool); so I guess I won't install it soon.
>
> Yes, as far as I know, sp-Forth is Windows only
> I heard about Linux port but can't find it.

It is not supported, you can download experimental version of
approximatly 1 year (AFAIR) age from SourceForge site.
>> Well, if you like threaded code, Gforth offers a whole range of
>> threaded-code options
>
> Yes, that's the approach I like.
> I meant to say that Forths (including sp-Forth) usually have
> their code model built in and this built-in and if there's no
> threaded code - there won't be any.
Show full article (1.16Kb)
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Anton Ertl
Date: Dec 26, 2007 13:30

helmwo@gmail.com writes:
>On Dec 26, 3:50=A0pm, an...@mips.complang.tuwien.ac.at (Anton Ertl)
>wrote:
>
>> I^3+J^3 =3D K^3+L^3
>
>Nice thing. But not very complex to optimize.
>
>> 1290
>
>It's allowed to cheat? I mean 1290 is obviously a cheat

Really? Why do you think so?

What it actually does is set the limit of how far the program
searches. The limit 1290 guarantees that the sum of the cubes will
not exceed the 32-bit range (hmm, I think we could use 1291 as
parameter, because that means that the largest sum will be
1290^3+1289^3=4288389569, but I kept it at the same value that Marcel
used to keep the results comparable.
Show full article (2.33Kb)
no comments
Re: Ramanujan's Taxi, or a little torture test         


Author: Anton Ertl
Date: Dec 26, 2007 14:20

Aleksej Saushev writes:
>Oh, please!
>
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>
>> Nickolai Leschov gmail.com> writes:
>>>Can you please include sp-Forth in your test?
>>>http://spf.sourceforge.net/
>
>> The only packages I see there are .exe files (obviously intended for
>> Windows and only unpackable there)
>
>Does that mean, you're incapable to use WINE?

Unwilling.
Show full article (2.72Kb)
no comments
1 2 3 4 5 6