Computers and Technology
Computers and Technology, 11.02.2020 20:49, L3Zenith

Young Jeanie knows she has two parents, four grandparents, eight great grandparents, and so on. (a) Write a recursive function to compute the number of Jeanieā€™s ancestors in the nth previous generation. The number of ancestors in each generation back produces a sequence that may look familiar: 2,4,8,16,... For each generation back, there are twice the number of ancestors than in the previous generation back. That is, an = 2anāˆ’1. Of course, Jeanie knows she has two ancestors, her parents, one generation back. (b) ā€™. Speciļ¬cally, (num-ancestors n) should return: 2 + 4 + 8 +Ā·Ā·Ā·+ an Use your function in part (a) as a "helper" function in the deļ¬nition of (num-ancestors n)1. 2. Perhaps you remember learning at some point that 22 7 is an approximation for Ļ€, which is an irrational number. In fact, in number theory, there is a ļ¬eld of study named Diophantine approximation, which deals with rational approximation of irrational numbers. (a) In 1910, Srinivasa Ramanujan, an Indian mathematician discovered several inļ¬nite series that rapidly converge to Ļ€. The series Ramanujan discovered form the basis for the fastest modern algorithms used to calculate Ļ€. One such series is
1 Ļ€
=
2āˆš2 9801
[infinity] X k=0
(4k)!(1103 + 26390k) (k!)43964k
This series computes an additional eight decimal places of Ļ€ for each term in the series. Write a Scheme function to calculate Ļ€ using this series. Your function, (pi-approx k), should take k as a parameter and produce the approximation of Ļ€ produced by the ļ¬rst k terms in the series. You may use the following skeleton to complete your solution. All you will need to add is the helper function to compute the summation deļ¬ned above: (define (pi-approx k) ;Recall the definition of factorial from the lecture slides (define (factorial k) (if (= k 0) 1 1Of course, we can use the closed-form solution for the geometric progression to compute num-ancestors (ancestors(n) = 2n+1 āˆ’ 2) but that doesnā€™t give us any experience with recursive functions. However, this is a useful fact we can use when testing our functions to ensure they are correct.
1
(* k (factorial (- k 1
;Define a helper function to compute the summation of the terms in the series (define (pi-aux k) ;Take care with the base case, k=0 is a term in the series
)
;Body of the pi-approx function (/ 1 (* (/ (* 2 (sqrt 2)) 9801) (pi-aux (- k 1
)
(b) The Pell numbers are an inļ¬nite sequence of integers which correspond to the denominators of the closest rational approximations of āˆš2. The Pell numbers are deļ¬ned by the following recurrence relation (which looks very similar to the Fibonnacci sequence): Pn =ļ£± ļ£² ļ£³ 0 if n = 0 1 if n = 1 2Pnāˆ’1 + Pnāˆ’2 otherwise Use this recurrence relation to write a recursive function, pell-num, which takes one parameter, n, and returns the nth Pell number. The numerator for the rational approximation of āˆš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 deļ¬ned by the recurrence relation: Qn =ļ£± ļ£² ļ£³ 2 if n = 0 2 if n = 1 2Qnāˆ’1 + Qnāˆ’2 otherwise (c) Use this recurrence relation to write a function, named comp-pell-num, which returns the nth companion Pell number. (d) Finally write a function that uses the Pell number and companion Pell number functions to compute the nth approximation forāˆš2. Use your new function to compute the approximation forāˆš2 for the sixth Pell and companion Pell numbers. 3. It is an interesting fact the the square-root of any number may be expressed as a continued fraction. For example, āˆšx = 1 + xāˆ’1 2 + xāˆ’1 2 + xāˆ’1 ... Write a Scheme function called new-sqrt which takes two formal parameters x and n, where x is the number we wish to ļ¬nd the square root of and n is the number of continued fractions to compute recursively. Demonstrate that for large n, new-sqrt is very close to the builtin sqrt function.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, babyface1686
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
image
Computers and Technology, 23.06.2019 10:00, uwunuzzles
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
image
Computers and Technology, 24.06.2019 00:30, sethhdoty
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
image
Computers and Technology, 24.06.2019 01:00, summerjoiner
Verify each identity[tex] \frac{csc}{cot \: x \: + \: tan \: x} = cos \: x[/tex]
Answers: 1
Do you know the correct answer?
Young Jeanie knows she has two parents, four grandparents, eight great grandparents, and so on. (a)...

Questions in other subjects: