
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
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](https://content.bartleby.com/qna-images/question/f97c0725-689e-40d7-87a0-46553d65cfc3/b89c2040-5b80-4ecf-99aa-386c084d6221/2zoai1p_thumbnail.png)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 2 images

Knowledge Booster
Similar questions
- Optimization: make the input as big or as small as possible in Python using Newton and Bisection methods. The second picture below is another example from other problems we did. Please show your codes.arrow_forwardPythonarrow_forwardWrite a java code for the following . Write a Java program to print the unique elements along with their frequency in the given (3x 3) integer matrix. ex. java sample outputarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education