1 / 10

Proof of the Sum of Squares Formula and Recursive Algorithms

This article discusses the proof of the sum of squares formula using a formal proof approach, as well as the conversion of recursive functions into recursive algorithms. It also includes a bonus section on computing series using recursive algorithms.

janetp
Download Presentation

Proof of the Sum of Squares Formula and Recursive Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quiz 7 The way I expected it.

  2. How to do it! 1. Let P(n) be the statement that 12 + 22 + ... + n2= n(n + 1)(2n + 1)/6 for the positive integer n. Be sure to use the formal proof that includes the Basis Step

  3. State what you are trying to prove! Prove 12 + 22 + ... + n2= n(n + 1)(2n + 1)/6 for the positive integer n. Positive integer n means 1, 2, 3, …

  4. Basis Step Let P(n) be the statement that 12 + 22 + ... + n2= n(n + 1)(2n + 1)/6 for the positive integer n. (a) Basis Step: plugging in n = 1 we have that P(1) is the statement: (1)2= (1)((1) + 1)(2(1) + 1)/6 Expanding both sides we have: 1 = 1 * 2 * 3/6 = 1 Both sides of P(1) shown in part (a) equal 1. Here we are just plugging in the smallest positive integer and showing that both sides are equivalent.

  5. Inductive Hypotheses (b) Inductive Hypotheses: The inductive hypothesis is the statement that 12 + 22 + ... + k2= k(k + 1)(2k + 1)/6 Here we substitute k for n and restate what we are trying to prove.

  6. Inductive step (c) For the inductive step, we want to show for each k ≥ 1 that P(k) implies P(k + 1). In other words, we want to show that by assuming the inductive hypothesis we can prove (12 + 22 + ... + k2) + (k + 1)2 = (k + 1) ((k + 1) + 1)(2(k + 1) + 1)/6 We take the last k term on the left side , (k)2, add another similar term with the k value replaced by k + 1, and replace all k terms on the right-hand side by k + 1 terms.

  7. Substitution Proof (d) Replacing the quantity in brackets on the left-hand side of part(c) by what it equals by virtue of the inductive hypothesis k(k + 1)(2k + 1)/6+ (k + 1)2= (k + 1) ((k + 1) + 1)(2(k + 1) + 1)/6, we have k(k + 1)(2k + 1)/6+ (k + 1)2= (k + 1) ((k + 1) + 1)(2(k + 1) + 1)/6 k(k + 1)(2k + 1)/6+6 (k + 1)2/6 = (k + 1) ((k + 1) + 1)(2(k + 1) + 1)/6 (k(2k + 1)+ 6 (k + 1))/6 = (k + 2)(2k + 3)/6 {divide both sides by (k + 1)} (k(2k + 1)+ 6 (k + 1))= (k + 2)(2k + 3){multiply both sides by 6} 2k2 + k+ 6k + 6= (k + 2)(2k + 3){expand both sides} 2k2 + 7k + 6= 2k2 + 7k + 6{divide both sides by 2k2 + 7k + 6} 1 = 1{both sides equal} we have shown that both sides are equal as we desired. 

  8. N Factorial 2. Convert the following recursive function into a recursive algorithm (using the pseudo format specified in appendix A3): f(0) = 1 f(n + 1) = (n + 1) * f(n) procedure factorial(n:nonnegative integer) if n = 0 then return 1 else return n ∙ factorial(n − 1) {output is n!}

  9. A Recursive Algorithm for Computing nk=0 ak 3. Bonus: a. Give a recursive algorithm (in the pseudo format specified in appendix A3) for computing: nk=0 ak = a0 + a1 + a2 + … + an procedure series (a: list of nonzero real numbers, n:nonnegative integer) if n = 0 then return a0 else return an+ series(a, n − 1) {output is a0 + a1 + a2 + … + an}

  10. Bonus b. Using 3. above, show the value of ak generated at each step given a0= 1 and n= 4. (missing information a1 = 2, a2 = 3, a3 = 4, a4 = 5) Green is the values that missing info would have provided! Red is what you could have provided without missing info!

More Related