Consider the following algorithm. This algorithm is used to compute a familiar mathematical quantity. It does so by repeatedly computing the sequence defined by the recurrence relation for some input number a. We do this until the difference n+1 In is smaller than some €. The algorithm outputs the final value of x after this threshold is reached. Here's a more formal description of this algorithm in pseudocode: Algorithm 1 Inputs: nonnegative real number a, small positive real number € > 0. 1. Initialize x = a + 1, A = 2€. 2. While A> €: Xnew ← 1/1/²(x + 1). ← |¤new − x|. oxnew. 3. Return x. Part A Notes: a Xn+1 + = 1/² (²+ = -) n 2 Xn Write a function in Python or Java that implements Algorithm 1. The user should be able to specify the values of a and €. • It is possible but not required (or easier) to do this with a recursive function. • Set the default value of € at 10-¹6. In Python this can be done by writing epsilon = 1e-16 in the appropriate location. • It's fun, though not required, to print the value of x at each iteration. Part B What familiar mathematical quantity does this function approximately compute? You don't have to reason about this function mathematically - just try a few values of a and make an informed guess. Note: proving the answer to this question, and describing how well the function approximates its target, is a classical question in numerical analysis.
Consider the following algorithm. This algorithm is used to compute a familiar mathematical quantity. It does so by repeatedly computing the sequence defined by the recurrence relation for some input number a. We do this until the difference n+1 In is smaller than some €. The algorithm outputs the final value of x after this threshold is reached. Here's a more formal description of this algorithm in pseudocode: Algorithm 1 Inputs: nonnegative real number a, small positive real number € > 0. 1. Initialize x = a + 1, A = 2€. 2. While A> €: Xnew ← 1/1/²(x + 1). ← |¤new − x|. oxnew. 3. Return x. Part A Notes: a Xn+1 + = 1/² (²+ = -) n 2 Xn Write a function in Python or Java that implements Algorithm 1. The user should be able to specify the values of a and €. • It is possible but not required (or easier) to do this with a recursive function. • Set the default value of € at 10-¹6. In Python this can be done by writing epsilon = 1e-16 in the appropriate location. • It's fun, though not required, to print the value of x at each iteration. Part B What familiar mathematical quantity does this function approximately compute? You don't have to reason about this function mathematically - just try a few values of a and make an informed guess. Note: proving the answer to this question, and describing how well the function approximates its target, is a classical question in numerical analysis.
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
Related questions
Question
100%
Please help me solve Part A of this problem
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
Recommended textbooks for you
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
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