# Talking Pi Calculator

#### Art

Joined Sep 10, 2007
806
Hi Guys,
Here's something a bit different I completed today.
Had a Pi calc routine working from a while back that I added a speech engine to.
I didn't write the Pi calc routine, it's some PD code I found.
Cheers, Art.

#### Dave

Joined Nov 17, 2003
6,970
Lol! Quite bizarre!

How many decimal places does it calculate the answer to? (I couldn't make it out from the opening screen).

Also how long does it take to calculate it?

Dave

#### recca02

Joined Apr 2, 2007
1,214
Also how long does it take to calculate it?

Dave
the video was 1.13 min,
and last digit was 9.

#### Art

Joined Sep 10, 2007
806
It begins calculating before printing any digits at all, and then there is a deliberate
delay so you see and hear the program's output, so it wouldn't really be fair to time it,
but it's printing 30000 digits. I can probably improve that a little.

The speed of the output can be faster and slower with button pushes,
I just went to maximum speed to keep the video short

to put together for a bit of fun.

#### Dave

Joined Nov 17, 2003
6,970
the video was 1.13 min,
and last digit was 9.
I thought it was speeded up. Plus my eyesight is rubbish, no chance of seeing that last 9 - if fact it could have been printing hieroglyphics!

It begins calculating before printing any digits at all, and then there is a deliberate
delay so you see and hear the program's output, so it wouldn't really be fair to time it,
but it's printing 30000 digits. I can probably improve that a little.

The speed of the output can be faster and slower with button pushes,
I just went to maximum speed to keep the video short

to put together for a bit of fun.
Its a good little exercise really. If it begins calculating before printing, how long does it take to do that?

Also care to share your algorithm? (I understand if you don't).

Dave

#### Art

Joined Sep 10, 2007
806
Hi,
I understand the algorithm, but that doesn't mean I could have written it of course
I only have the PSP source, and have lost the C source in it's generic format.

As for the time it takes to calculate 30000 digits, I don't know in computing time,
but Human time, about 17 seconds to start, but then every 5 digits is calculated
in real time as it is printing and speaking. The PSP unit is clocked at 2/3 it's max CPU speeds.
Art.

#### Dave

Joined Nov 17, 2003
6,970
Hi,
I understand the algorithm, but that doesn't mean I could have written it of course
I only have the PSP source, and have lost the C source in it's generic format.

As for the time it takes to calculate 30000 digits, I don't know in computing time,
but Human time, about 17 seconds to start, but then every 5 digits is calculated
in real time as it is printing and speaking. The PSP unit is clocked at 2/3 it's max CPU speeds.
Art.
Thanks for the info. I'm only really interested in the algorithm for calculating pi from a high-level (spending every waking hour with source code, I feel it wrong on me to go looking at it for pleasure!). I did write a golden ratio illustrator when I was at school, it came into its own when people got an interest in the golden ratio because of the Da Vinci Code.

Dave

#### Art

Joined Sep 10, 2007
806
Here is the PSP source. The algo is pretty much contained in a few functions still.
This is the main C source missing the speech samples and font graphics of course,
as they are large files.
I don't mind sharing a pi program, it's not the sort of thing I can put a nag screen on,
and distribute a shareware version

#### Dave

Joined Nov 17, 2003
6,970
Here is the PSP source. The algo is pretty much contained in a few functions still.
This is the main C source missing the speech samples and font graphics of course,
as they are large files.
I don't mind sharing a pi program, it's not the sort of thing I can put a nag screen on,
and distribute a shareware version
Did you intend to attach or link to some code?

Dave

#### Dave

Joined Nov 17, 2003
6,970
Thanks. I'll give it a whirl over the Christmas break and post back any comments.

Dave

#### Art

Joined Sep 10, 2007
806
Any further work I might do wouldn't be in the pi routine, but getting the numbers
to scroll smoothly allong the screen as if written on a continuous spool of tape.

#### Dave

Joined Nov 17, 2003
6,970
Any further work I might do wouldn't be in the pi routine, but getting the numbers
to scroll smoothly allong the screen as if written on a continuous spool of tape.
Do you realistically need to calculate the values each time? Couldn't you generate the answers and write them to an index; thereby you could run the two functions as mutually exclusive operations. It might not be what you intend to do, but it's a suggestion.

The pi calculation routine is what I am interested in.

Dave

#### Art

Joined Sep 10, 2007
806
It would be possible to complete the calculation first, and store the entire result,
but for some reason the algo calculates and prints on the fly.
The author must have assumed little memory.
The result for Pi is never stored in memory, just printed to the screen.
When the PSP prints any five digits, it has forgotten the last five.

I will try to locate the algo in it's more portable C form. I found it
through Google searches to begin with, so it may be possible to find again.

#### Dave

Joined Nov 17, 2003
6,970
The author must have assumed little memory.
The result for Pi is never stored in memory, just printed to the screen.
When the PSP prints any five digits, it has forgotten the last five.
Makes sense as an basic-resource implementation, one cannot assume 1GB of memory and several GBs on a disk. Maybe I am just getting greedy for speed! There is a case for a dual algorithm implementation; 1) on the fly as now, and 2) an indexed approach as I proposed before.

The advantage of an indexed approach is that you can perform search and seek on any section of the indexed value - therefore you could say print from the 150th decimal place and thereafter (obviously assuming you have indexed to that resolution).

Dave

#### Dave

Joined Nov 17, 2003
6,970
I will try to locate the algo in it's more portable C form. I found it
through Google searches to begin with, so it may be possible to find again.
Let me know if you find it. In the meantime I will have a play around with the files provided previously.

Dave