Math 242B

18 February 2019

First, verify Catalan’s Identity

Module to compute (Subscript[F, n]), the nth Fibonacci number:

computeFib[n_]:=Module[{acc0=0,acc1=1,next},
Do[
next=acc0+acc1;  (* compute the next value *)
acc0=acc1;               (* shift down *)
acc1=next,
{k,1,n}
];
acc0         (* return value *)
]

Make a big list of Fibonacci numbers:

max=9;
r=5;
fibs=computeFib/@Range[max+r]

Make lists to verify the identity:

fibsSquared=(fibs[[r+1;;max]])^2

fibA=fibs[[1;;max-r]]

fibB=fibs[[2r+1;;max+r]]

rightside=Table[(-1)^(n-r)fibs[[r]]^2,{n,r+1,max}]

Now verify the identity:

fibsSquared-fibA*fibB==rightside

Idea: make the code more modular

We could make a module to encapsulate this code:

verifyCatalan[r_,quantity_]:=Module[{},
(* paste here the code from above *)



(* return true or false *)
fibsSquared-fibA*fibB==rightside
]

Then we could verify the identity for r=5 and 100 values of n like this: verifyCatalan[5,100].

Pell Identities

First we will define a Module that generates recursive sequences.

generateSequences[n_, val0_, val1_]:=Module[{seq={val0, val1}, acc0=val0, acc1=val1,next, m=2},
If[n ≤ 1, Return[seq]];
Do[
next=m*acc1+acc0;            (* compute the next value *)
seq=Append[seq,next];     (* append to the sequence *)
acc0=acc1;     (* shift *)
acc1=next;      (* shift *)
,{i,2,n}];
seq                           (* return the sequence *)
]

Generate the Pell sequence to term (Subscript[P, 10]):

generateSequences[10,0,1]

Generate the Lucas sequence to term (Subscript[Q, 10]):

generateSequences[10,2,2]

Write some code to conveniently produce Pell numbers

Generate a long list of Pell numbers:

pellSeq=generateSequences[1000,0,1];

Take a peek at the first 6 :

pellSeq[[;;6]]

Looks good.

Make a function to easily access the Pell number (Subscript[P, n]):

P[n_]:=pellSeq[[n+1]]

P[0]

P[1]

P[4]

Let' s find an identity

Produce some subsets of Pell numbers and their cubes:

P/@Range[0,15,3] (* every third Pell number *)
(P/@Range[0,5])^3
P/@Range[0,5]

Here is a pattern:

0==8*0+3*0
5==8*1-3*1
70==8*8+3*2
985==8*125-3*5
13860==8*1728+3*12

Questions:

How could we have found this pattern?

If we thought there was a pattern like (Subscript[P, 3n])=((a((Subscript[P, n])))^3)+b (Subscript[P, n]), how would we find the coefficients a and b?