BigInt

Announcements of available shared folders

BigInt

Postby oliver » Fri Jun 04, 2010 5:37 pm

The entire BigInt extension and the beginning of a few tools to toy with it.

For something fun, type 400 and run fibtriangle. Then view the resulting image by eval'ing it (or tapping ->screen (->LCD)).
The function mirrors what's done here: http://mathworld.wolfram.com/FibonacciNumber.html

You'll find more explanation in the FibTriangle tutorial.

The BigInt type is discussed in
Reference: Custom Data Types http://naivedesign.com/ND1/ND1_Reference__Custom_Types.html.

See Working with BigInts http://naivedesign.com/ND1/BigInts.html for a BigInt-related tutorial.
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

v1.1

Postby oliver » Sun Oct 24, 2010 1:06 pm

An updated version of BigInt has been released.

A new function, fibtr_JS, has been added. This is a pure JavaScript implementation of fibtriangle, using the BigNum data type. It's much faster than the naive RPL implementation which was compact but called "fib" for each Fibonacci number.
Conversely, this function calculates each Fibonacci number using the previous one. As the RPL function, it appends it as a padded hexadecimal number string to the image data pointer, which is fed row by row.

To built an image of the first 400 Fibonacci numbers takes just a second now on an iPhone 3GS.

For the technically inclined, here's the entire loop:
Code: Select all
for (var i=0; i<maxNum; i++) {
      var val = BigNum["+"](a, b);
      a = b; b = val;
      data += STR.pad(STR.toString(BigNum.toString(BigNum.toHex(val)).slice(2)), padWidth, padChar).slice(1, -1); // convert number to hex, string, slice off 0x, pad w/ zeroes, and concatenate with data string
   }

This is preceded by five lines of init code, and one line of code to turn the data into an image and display it.
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

v1.5

Postby oliver » Mon May 23, 2011 3:57 pm

Version 1.5 of this extension has been posted.

.injection is up-to-date with ND1 v1.3.8.

fibtriangle now uses optimized RPL+ code to draw the triangle in under a second.

fibtr_rpl is that same RPL+ code with timing code added

fibtr_JS is a slightly faster JavaScript version

fib_last is a new entry which shows the last 6 digits of the Fibonacci number. This function uses the new modfib function which works with huge integers. Try 1e40 fib_last, for example. Internally, this works with optimized modular matrix exponentiation code.
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm


Return to Downloadable Folders / Shared Data

Who is online

Users browsing this forum: No registered users and 2 guests

cron