Talking Pi Calculator

Discussion in 'Math' started by Art, Dec 16, 2007.

  1. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    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.
    http://au.youtube.com/watch?v=y7Bv3yszDNg
    I didn't write the Pi calc routine, it's some PD code I found.
    Cheers, Art.
     
  2. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  3. recca02

    Senior Member

    Apr 2, 2007
    1,211
    0
    the video was 1.13 min,
    and last digit was 9:D.
     
  4. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    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 :)

    No real point to the program, but I already had the various pieces of it ready
    to put together for a bit of fun.
     
  5. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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! :p

    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
     
  6. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Hi,
    I understand the algorithm, but that doesn't mean I could have written it of course :)
    Yes, I'll be happy to send you a copy of the source code if you pm me your email address.
    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.
     
  7. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
  8. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  9. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    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 ;)
     
  10. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    Did you intend to attach or link to some code?

    Dave
     
  11. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
  12. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
  13. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    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.
     
  14. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  15. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    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.
     
  16. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  17. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    Let me know if you find it. In the meantime I will have a play around with the files provided previously.

    Dave
     
Loading...