✓ 6 Sum of ik Intro In discrete math we learn that the sum of integer from 1...n is given by and and As you may notice, one can actually show that ¿ has is a polynomial of degree k + 1. i=1 n n(n - 1) n² n 2 2 2 i=1 n i=1 3 n² + n 2 6 n 'n(n 2 Σ³ ³ = ((n − 1))' *+.... ² = 2 i=1 To calculate the sum if we use for loop and calculate the left hand side it will be O(n). But if we use the right hand side we can calculate it in O(1). So, calculating it with a closed form is a much better approach. But as you recall getting the close formed formula is quite difficult to do by hands. In this problem we will use legendre polynomial to find it. Problem Use what you learn about Legendre Method and write a function that takes in n and k and calculate in O(k) (NOT O(n)). Warning: don't try to sum up too far as it can cause integer overflow. 1 [ ] i=1 IM- Python

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

given

%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
from math import sin, cos, exp, pi, sqrt
import math
 
answer in python
✓ 6 Sum of ik
Intro
In discrete math we learn that the sum of integer from 1...n is given by
and
and
As you may notice, one can actually show that
¿ has is a polynomial of degree k + 1.
i=1
n
n(n - 1)
n²
n
2
2 2
i=1
n
i=1
3
n²
+
n
2 6
n
'n(n
2
Σ³ ³ = ((n − 1))' *+....
² =
2
i=1
To calculate the sum if we use for loop and calculate the left hand side it will be O(n). But if we use the right hand side we can calculate it in O(1). So, calculating it with a closed form is a much better approach.
But as you recall getting the close formed formula is quite difficult to do by hands. In this problem we will use legendre polynomial to find it.
Problem
Use what you learn about Legendre Method and write a function that takes in n and k and calculate
in O(k) (NOT O(n)).
Warning: don't try to sum up too far as it can cause integer overflow.
1
[ ]
i=1
IM-
Python
Transcribed Image Text:✓ 6 Sum of ik Intro In discrete math we learn that the sum of integer from 1...n is given by and and As you may notice, one can actually show that ¿ has is a polynomial of degree k + 1. i=1 n n(n - 1) n² n 2 2 2 i=1 n i=1 3 n² + n 2 6 n 'n(n 2 Σ³ ³ = ((n − 1))' *+.... ² = 2 i=1 To calculate the sum if we use for loop and calculate the left hand side it will be O(n). But if we use the right hand side we can calculate it in O(1). So, calculating it with a closed form is a much better approach. But as you recall getting the close formed formula is quite difficult to do by hands. In this problem we will use legendre polynomial to find it. Problem Use what you learn about Legendre Method and write a function that takes in n and k and calculate in O(k) (NOT O(n)). Warning: don't try to sum up too far as it can cause integer overflow. 1 [ ] i=1 IM- Python
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education