Question: USING SCHEME CODE (a) The Pell numbers are an infinite sequence of integers which correspond to the denominators of the closest rational approximations of p

USING SCHEME CODE

(a) The Pell numbers are an infinite sequence of integers which correspond to the denominators of the closest rational approximations of p 2. The Pell numbers are defined by the following recurrence relation (which looks very similar to the Fibonnacci sequence): Pn = 0 if n = 0 1 if n = 1 2Pn1 + Pn2 otherwise Use this recurrence relation to write a recursive function, pell, which takes one parameter, n, and returns the n t h Pell number.

(b) Write a separate function, named (find-pell n), which uses your Pell function to find the largest Pell number which is less than n. You can try testing it by finding the largest Pell number less than 100.

(c) The numerator for the rational approximation of p 2 corresponding to a particular Pell number is half of the corresponding number in the sequence referred to as the companion Pell numbers (or Pell-Lucas numbers). The companion Pell numbers are defined by the recurrence relation: Qn = 2 if n = 0 2 if n = 1 2Qn1 +Qn2 otherwise Use this recurrence relation to write a function, named (comp-pell n), which returns the n t h companion Pell number.

(d) Finally write a function that uses the Pell number and companion Pell number functions, as described in Part a, to write a SCHEME function, named (sqrt-2-approx n), to compute the n t h approximation for p 2. You can test your new function to compute the approximation for p 2 using the sixth Pell and companion Pell numbers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!