logo for matrixlab-examples.com
leftimage for matrixlab-examples.com

Lucas Series - a code to find n elements


The French mathematician, Edouard Lucas (19th century), found a sequence of numbers (named the Lucas series) similar to the sequence found in the Fibonacci numbers.

The Fibonacci rule of adding the latest two integers to obtain the next number is kept, but here we start from 2 and 1, instead of 0 and 1 used for the Fibonacci series.


The series, also called the Lucas Numbers after him, is defined as follows: where we write its members as Ln, for Lucas: 

Ln = Ln-1 + Ln-2 for n > 2
L1 = 2
L2 = 1
 

Like the Fibonacci series, each Lucas number is defined to be the sum of its two immediate previous terms. The ratio between two consecutive Lucas numbers converges to the golden ratio. However, the first two Lucas numbers are L1 = 2 and L2 = 1 (instead of Fibonacci's F1 = 0 and F2 = 1), and the properties of Lucas numbers are therefore different from those of Fibonacci numbers.
 

We can generate a fast code to obtain the Lucas series (n is the input parameter and it’s the number of terms that we’ll calculate for the series).
 

function L = lucas_series(n)
% Define the first two elements
L(1) = 2;
L(2) = 1;
 

% Calculate as many numbers as needed
for i = 3 : n
    L(i) = L(i-1) + L(i-2);

end

 

Let’s test that function: 

clear, clc, format long
L = lucas_series(15) 

% Let's find the ratio of consecutive
% elements in the series

for i = 1 : length(L)-1
    list = [L(i) L(i+1) L(i+1)/L(i)]

end 

 

And we get the list of 15 terms and the ratio of consecutive numbers:
 

L = 2     1     3     4     7    11    18    29    47    76         123   199  322   521   843

list =  2.00000000000000   1.00000000000000   0.50000000000000
list =  1     3     3
list =  3.00000000000000   4.00000000000000   1.33333333333333
list =  4.00000000000000   7.00000000000000   1.75000000000000
list =  7.00000000000000  11.00000000000000   1.57142857142857
list = 11.00000000000000  18.00000000000000   1.63636363636364
list = 18.00000000000000  29.00000000000000   1.61111111111111
list = 29.00000000000000  47.00000000000000   1.62068965517241
list = 47.00000000000000  76.00000000000000   1.61702127659574
list = 1.0e+002 *
       0.76000000000000   1.23000000000000   0.01618421052632
list = 1.0e+002 *
       1.23000000000000   1.99000000000000   0.01617886178862
list = 1.0e+002 *
       1.99000000000000   3.22000000000000   0.01618090452261
list = 1.0e+002 *
       3.22000000000000   5.21000000000000   0.01618012422360
list = 1.0e+002 *
       5.21000000000000   8.43000000000000   0.01618042226488

 
We can see that, at the end, we end with a ratio that is an approximation to the so called golden ratio (1.6180...).
 

There are some interesting facts about the Lucas series and the Fibonacci numbers. You can look them here (opens new window).


 From 'Lucas Series' to home

 From 'Lucas Series' to Calculus Problems
   
Top

Fibonacci Series

Collatz Conjecture

Series and Sequences



footer for Lucas Series page