This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Sequences of Numbers

Fibonacci Numbers

The Fibonacci numbers are a sequence of integers. The following recursion formula defines the nth Fibonacci number:

To compute the Fibonacci numbers, use the numlib::fibonacci function. For example, the first 10 Fibonacci numbers are:

numlib::fibonacci(n) $ n = 0..9

Mersenne Primes

The Mersenne numbers are the prime numbers 2p - 1. Here p is also a prime. The numlib::mersenne function returns the list that contains the following currently known Mersenne numbers:


Continued Fractions

The continued fraction approximation of a real number r is an expansion of the following form:

Here a1 is the integer floor(r), and a2, a3, ... are positive integers.

To create a continued fraction approximation of a real number, use the numlib::contfrac function. For example, approximate the number 123456/123456789 by a continued fraction:


Alternatively, you can use the more general contfrac function. This function belongs to the standard library. While numlib::contfrac accept only real numbers as parameters, contfrac also accepts symbolic expressions. When working with real numbers, contfrac internally calls numlib::contfrac, and returns the result of the domain type numlib::contfrac:

a := contfrac(123456/123456789);

Since contfrac internally calls numlib::contfrac, calling the numlib::contfrac directly can speed up your computations.

Was this topic helpful?