
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
%matplotlib inline
import numpy as np
from matplotlib import pyplot as plt
from math import sin, cos, exp, pi, sqrt
import math

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
i=1
2 =
n(n -1
2
འ
Σί
IM³
i=1
33
n°
2
12
-
+
n² n
ས
+
26
n
53
=
= (n(n − 1)) ² =
2
—
n4
4
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
n
i=1
ik
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

Knowledge Booster
Similar questions
- int funcB(int); int funcA(int n) { if (n 4) { return n* funcA(n - 5); } else { return n- funcB(n - 1); int main() { cout << funcA(13); return 0; What is the output of this program? Please show our work.arrow_forwardThis is needed in Java Given that an ArrayList of Strings named nameList has already been created and names have already been inserted, write the statement necessary to delete the name at index 15.arrow_forwardIn Java Assume code that has imported Scanner and instantiated it for keyboard input as stdln. Wtire a code fragment that does the following: 1. Uses a for loop to fill each array element with the square root of that elements index valuearrow_forward
- In Java using recursion, create a program with a GUI that will allow a user to enter five numbers. The program will provide the product of all five numbers using recursive methods.arrow_forward%matplotlib inlineimport mathimport numpy as npfrom matplotlib import pyplot as pltdef bad_poisson(lmd, k): return pow(lmd,k)*math.exp(-lmd)/math.factorial(k)# bad_poisson(1000,1000) # uncomment to see it breaksarrow_forwardJava Programming language Please help me with this. Thanks in advance.arrow_forward
- There is no difference between an array and an arraylist True Falsearrow_forwardBAGEL FILES import javax.swing.JFrame; public class Bagel{//-----------------------------------------------------------------// Creates and displays the controls for a bagel shop.//-----------------------------------------------------------------public static void main (String[] args){JFrame frame = new JFrame ("Bagel Shop");frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new BagelControls()); frame.pack();frame.setVisible(true);}} import java.awt.*;import java.awt.event.*; import javax.swing.*; public class BagelControls extends JPanel{private JComboBox bagelCombo;private JButton calcButton;private JLabel cost;private double bagelCost;public BagelControls(){String[] types = {"Make A Selection...", "Plain","Asiago Cheese", "Cranberry"};bagelCombo = new JComboBox(types);calcButton = new JButton("Calc");cost = new JLabel("Cost = " + bagelCost);setPreferredSize (new Dimension (400,…arrow_forwardMain difference between an array and an ArrayList is that an ArrayList can store more data types an ArrayList can store more elements an ArrayList executes faster for retrieval and insertion an ArrayList takes care of the memory management automatically an ArrayList uses positions and an array uses indicesarrow_forward
- Javaarrow_forward2. Problem 2: In this problem you will test our "in class" version of Gaussian elimination against the version in numpy. Use both codes to solve some randomly chosen linear systems of size N 10, 20, 40, 80, 160, 320, 640, 1280, 2560, and 5120. Depending on your computer, the last two may or may not work. If they don't, just say so in your report. If you computer can do N- 10240 then try this as well. Note that in cach case N 10 * 2k for k = 1,..., 10. That is, each time we are doubling the size of the matrix. abone Plot the results as two curves. Our code in red and numPy in bluc. (Or whatever colors you prefer). Can you guess the function which governs the runtime? Based on this guess, how long would it take to do N 40960 using numPy? N=81920?arrow_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