PI routines

new topic     » topic index » view thread      » older message » newer message

--=====================_859198120==_

        I've just begun to explore Euphoria, and thought it would be fun to
transfer a
QBasic PI calculation engine to Euphoria.  Needless to say, the Euphoria
engine is faster than the QBasic version.  See Table 1 for results of my
comparisons.
        However, there is a *minor* bug in the Euphoria version that I
cannot quite figure out.  It seems that it does not want to properly
calculate the last two (2 :) ) digits of PI.  ie, when calculating to 50
digits,  PI.EX responds with:


but PI.BAS returns:


        I have included both PI.EX and PI.BAS for those who would like to
see the source, and for those who have had more experience with Euphoria
than I have (about 1 week).  Hopefully, someone will be able to find what
I'm doing wrong.  Also, there is a *severe* lack of documentation on the PI
routine itself.  This is due in part to the lazyness of the original author,
and in part to the fact that I only understand WHAT the program does, not
the underlying math theory.  Again, maybe someone can enlighten me. :)

TABLE 1
                                          Approximate Execution Time (seconds)
|---------------------------------------------------------------------------
----------------
|Language & Ver  |   100  digits   |   200  digits   |   300  digits   |
400  digits   |
|---------------------------------------------------------------------------
----------------
|  Euphoria 1.5     |        1.65       |       6.71         |        15.05
|        26.81     |
|  QBasic 1.1        |        5.72       |     22.63         |        50.92
|        90.52     |
|  QuickBasic 4.5 |        3.13       |     12.47         |        28.18
|        49.93     |
|---------------------------------------------------------------------------
----------------
|  QuickBasic 4.5 |                      |                       |
|                      |
|  (compiled exe)  |        0.72       |       2.64         |          5.98
|        10.66     |
----------------------------------------------------------------------------
---------------
NOTE:  I did not think it fair to actually include the compiled PI.BAS along
with the interpreted versions, thus the seperate section.  (notice that
QB4.5 interpreted the file nearly 2x as fast as QBasic 1.1 did?)
As you can see, however, QB4.5's ability to compile to semi-pure .exe is a
definate speed advantage.  (Binding the program with EX, to the best of my
knowledge, just results in an internal version of the program getting
attached to the EX binary, which doesnt actually produce a truely compiled
program.  Therefore,  no catagory was made for an exe form of PI.EX, since
the times stated for the interpreted version would be the same).
        That brings me to an obvious question which I won't ask, since I am
sure it has been asked by every Euphoria programmer.  (And I know the answer
goes something like <insert nasty RTFM response here>.  ;)  ).

--=====================_859198120==_
 x-mac-type="705A4950"; x-mac-creator="705A4950"

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu