fib

From DavinciWiki
Jump to: navigation, search

Description

Fibonacci numbers.

Arguments and Return Values

Arguments: One numeric array (not necessarily just integers; this function uses the generalized Binet formula to extend the Fibonacci numbers to all real numbers)

Return Value: An array of Fibonacci numbers corresponding to each element in the input array

Output format:

int, if input is byte, short, or int with all elements between -31 and 31 (inclusive)

float or double, if input is float or double (respectively)

double, if maximum of absolute value of input is greater than 31

The function returns the simplest format that can accurately represent the output value(s).

If no arguments are input, fib() prints its description, as shown below.

Usage

Syntax: fib(x)

'x' - a numeric array (any format)

Examples

dv> fib()

Fibonacci numbers
fib(n) returns nth Fibonacci number
Uses generalized version of Binet's formula
The generalized version extends the sequence to all numbers
Works for arrays
S.Marshall 02-17-2008

0
dv> fib(create(11))
11x1x1 array of int, bsq format [44 bytes]
0       1       1       2       3       5       8       13      21      34      55
dv> fib(-1.//-0.5//0.//0.5//1.)
5x1x1 array of float, bsq format [20 bytes]
1.00000 0.351578        0.00000 0.568864        1.00000
dv> fib(31)
1346269
dv> fib(32)
2.17831e+06

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Recent Library Changes

Created On: 12-07-2007
Modified On: 02-22-2008

Personal tools