Linux On iPod Forum Index
 FAQ  •  Search  •  Memberlist  •  Usergroups  •  Profile  •  Log in to check your private messages  •  Log in
 PiCalc - Calculate digits of pi on your iPod View next topic
View previous topic
Post new topicReply to topic
Author Message
Keripo
Contributor


Joined: 26 Jul 2007


PostPosted: Mon Feb 18, 2008 10:22 pm Reply with quoteBack to top

As the title hints, this podzilla2 module uses a cross-compiled pi-agm binary to calculates digits of pi. It uses the terminal module to allow for input.

Due to a bug in the terminal module, backspacing will not work (I would link to a trac ticket if trac wasn't down - if you have the time to fix it, a patch would be greatly welcomed). If you make an input mistake, just exit and re-enter the window and re-input things carefully. Once the calculations are done, pi-agm will exit and the calculated values will be saved in a text file located where-ever your current working directory is (e.g. mine saved to "/pi8k.txt").

Here's the readme:

ReadMe from Keripo.txt wrote:
Last updated: Feb 18, 2008
~Keripo

Calculates digits of pi via pi-agm. Uses the terminal module for input.
Saves output to working directory (most likely root "/pi##.txt").
Was able to calculate 8192 digits in 37 seconds (used "8k", "2", "-1").

pi-agm is written by Carey Bloodworth.
http://web.archive.org/web/20030803090725/http://www.bloodworth.org/
Source code downloaded from myownlittleworld.com
http://myownlittleworld.com/miscellaneous/computers/files/pi-programs/source/pi-agm.tgz

To compile pi-agm, extract the original source code, replace the
"${LD} ${LDFLAGS} ${OUT_FILE} .o ${MATH_LIBS}" line of your intended
target in src/Makefile with "${CC} ${LDFLAGS} -o ${OUT_FILE} .o ${MATH_LIBS}"
and compile with "make fft-hartley CC=arm-elf-gcc LDFLAGS=-elf2flt"
(you can replace fft-hartley with whichever type you want). This will give
an unoptimized pi-agm binary that you can run on iPodLinux. I may port this
as a proper podzilla2 module later when I have time.

(Note that when I say "when I have time", it doesn't necessarily mean anytime soon ; P

Download:
http://ipodlinux.org/Image:Picalc-1.0.tar.gz

Knock yourselves out Wink

~Keripo

_________________
Project ZeroSlackr
http://sourceforge.net/projects/zeroslackr/

Me = Keripo, Keripo Test Account = Me
010/001/111
View user's profileSend private message
zowki



Joined: 17 Sep 2006

Location: /mnt/zowki

PostPosted: Tue Mar 18, 2008 8:21 am Reply with quoteBack to top

Wouldnt it just be easier to make the ipod calculate 22 divide by 7 and tell it when to stop?

_________________
My ipods:
iPod Nano 1G 2GB
iPod Video 5g 60GB
View user's profileSend private messageSend e-mailMSN Messenger
joeyjwc
Moderator


Joined: 30 Oct 2005


PostPosted: Tue Mar 18, 2008 10:01 am Reply with quoteBack to top

zowki wrote:
Wouldnt it just be easier to make the ipod calculate 22 divide by 7 and tell it when to stop?


22/7 is not pi. It's an approximation of pi.

_________________
JWC
http://jwcxz.com/
http://blog.jwcxz.com/
View user's profileSend private messageVisit poster's website
zowki



Joined: 17 Sep 2006

Location: /mnt/zowki

PostPosted: Tue Mar 18, 2008 12:04 pm Reply with quoteBack to top

joeyjwc wrote:
zowki wrote:
Wouldnt it just be easier to make the ipod calculate 22 divide by 7 and tell it when to stop?


22/7 is not pi. It's an approximation of pi.

Wow, I never knew that! I always thought it was! So what equation actually does calculate pi?

Edit: According to wikipedia:
Quote:
it cannot be expressed as a fraction m/n, where m and n are integers. Consequently its decimal representation never ends or repeats. Beyond being irrational, it is a transcendental number, which means that no finite sequence of algebraic operations on integers (powers, roots, sums, etc.) could ever produce it.


Its impossible to have an equation for it... So how can it be calculated to be more exact?

_________________
My ipods:
iPod Nano 1G 2GB
iPod Video 5g 60GB
View user's profileSend private messageSend e-mailMSN Messenger
Keripo Test Account
Contributor


Joined: 11 Apr 2006

Location: Ontario, Canada

PostPosted: Tue Mar 18, 2008 2:46 pm Reply with quoteBack to top

Look at the pi-agm source code and you'll find various different algorithms ; ) Hartley's FFT is the fastest in pi-agm but theres also instructions on how to create your own algorithm/pi-agm build in the source code (my build is the recommended fft-hartley target though you can also build the other targets - haven't tried any other though and all of them are optimized for Intels I think so performance may vary on the iPod)

_________________
Project ZeroSlackr
http://sourceforge.net/projects/zeroslackr/
http://ipodlinux.org/forums/viewtopic.php?t=29636
View user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressMSN Messenger
zowki



Joined: 17 Sep 2006

Location: /mnt/zowki

PostPosted: Tue Mar 18, 2008 2:52 pm Reply with quoteBack to top

Looked at agm.c and this is what I found:
Code:

/*
**      The AGM itself
**
** A[0]=1 B[0]=1/sqrt(2) Sum=1
**
** n=1..inf
** A[n] = (A[n-1] + B[n-1])/2
** B[n] = Sqrt(A[n-1]*B[n-1])
** C[n] = (A[n-1]-B[n-1])/2    or:
** C[n]^2 = A[n]^2 - B[n]^2    or:
** C[n]^2 = 4A[n+1]*C[n+1]
** Sum  = Sum - C[n]^2*(2^(n+1))
** PI[n] = 4A[n+1]^2 / Sum
**
** However, it's not implemented that way.  We can save a full
** sized multiplication (with two numbers) by rearranging it,
** and keeping the squares of the A and B.  Also, we can do the
** first pass a little differently since A and A^2 will both be 1.
**
** A[0]=1           A[0]^2=1
** B[0]=1/sqrt(2)   B[0]^2=0.5
**
** First pass:
**
** A[1]     = (A[0] + B[0])/2
** B[1]^2   = A[0]*B[0]  ; Since A[0]==1, B[1]^2=B[0]
** C[1]^2   = ((A[0]^2+B[0]^2)/2-B[1]^2)/2
**
** Remainging passes:
**
** C[n]     = (A[n-1]-B[n-1])/2; C[n] is actually temp usage of C[n]^2
** A[n]     = A[n-1] - C[n]
** C[n]^2   = C[n]*C[n]
** B[n]^2   = (A[n-1]^2+B[n-1]^2-4C[n]^2)/2
**
** Then the rest of the formula is done the same:
**
** A[n]^2   = C[n]^2 + B[n]^2
** B[n]     = sqrt(B[n]^2)
** Sum      = Sum - C[n]^2*(2^(n+1))
**
** It is an unusual arrangment, but they are all derived directly
** from the standard AGM formulas as given by Salamin.
**
*/


That is really confusing! I'm only in grade 8 maths!

_________________
My ipods:
iPod Nano 1G 2GB
iPod Video 5g 60GB
View user's profileSend private messageSend e-mailMSN Messenger
Keripo Test Account
Contributor


Joined: 11 Apr 2006

Location: Ontario, Canada

PostPosted: Tue Mar 18, 2008 2:56 pm Reply with quoteBack to top

Read more books then. Or, you know, google more Wink
I myself haven't even looked at any of the algorithms and doubt I'd be able to fully understand them myself. And theres really no need to other than out of curiousity. If you're really all that curious, try asking your math teacher (though s/he probably won't have an answer). No need to post your every question here ; P

_________________
Project ZeroSlackr
http://sourceforge.net/projects/zeroslackr/
http://ipodlinux.org/forums/viewtopic.php?t=29636
View user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressMSN Messenger
megabyte



Joined: 02 Nov 2005

Location: /dev/null

PostPosted: Sun Mar 23, 2008 6:46 pm Reply with quoteBack to top

Wasn't there a chain fraction to calculate it?

_________________
The 2.5 booter - Gentoo from Stage3 + Ubuntu 7.10 + Mac OS X 10.5.1.
View user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressMSN Messenger
zowki



Joined: 17 Sep 2006

Location: /mnt/zowki

PostPosted: Mon Mar 24, 2008 3:25 am Reply with quoteBack to top

megabyte wrote:
Wasn't there a chain fraction to calculate it?

According to wikipedia Pi can not be represented in a fraction as it would still be continuous.

Like this:
Image

Or the Gregory-Leibniz series:
Image

But it seems as if wikipedia is contradicting itself because I looked under Computing Pi and I found it actually can be written as a formula. Here are two famous ones:
Image
Image

_________________
My ipods:
iPod Nano 1G 2GB
iPod Video 5g 60GB
View user's profileSend private messageSend e-mailMSN Messenger
joeyjwc
Moderator


Joined: 30 Oct 2005


PostPosted: Mon Mar 24, 2008 5:06 am Reply with quoteBack to top

This makes much more sense if you have studied series. @zowki: Wikipedia is not contradicting itself. The "formula" you found is just an infinite series where you sum each term. That's what that big sigma means.

_________________
JWC
http://jwcxz.com/
http://blog.jwcxz.com/
View user's profileSend private messageVisit poster's website
megabyte



Joined: 02 Nov 2005

Location: /dev/null

PostPosted: Mon Mar 24, 2008 11:36 pm Reply with quoteBack to top

(for those less mathematical: a sigma = a sum of iterations. Under it you state the iteration variable, in this case K, and what value does it start with, in this case 0. Over the sigma is the maximum of iterations, in this case infinity. After the sigma you will find what to do with K in each iteration, thus what to sum up)

_________________
The 2.5 booter - Gentoo from Stage3 + Ubuntu 7.10 + Mac OS X 10.5.1.
View user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressMSN Messenger
Display posts from previous:      
Post new topicReply to topic


 Jump to:   



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme :: All times are GMT