Take you same derivate function from last week and let’s make it more general by passing in f(x), and x You derivative function will now look something like this my_der_calc(f,x,N,eps, option) eps is a tolerance for determining the accuracy of your derivatives. We will use this later To test, let’s use our function from last laboratory class, x(1-x) The output argument, df, should be the numerical derivatives computed for xaccording to the method defined by the input argument, option Remember, the forward difference method “loses” the last point, the backward difference method loses the first point, and the central difference method loses the first and last points. So you have use some interpolation to get these points. Try linear By obtaining the derivative at the first and last point, you will have the exact same number of values for both df and x. Although, you could set them to same value as well, however, your plot will only be linear for the interior points Plot df .vs x, notice the functional form of your plot. Compare with the actual form with the derivative of the given function, if the calculated derivative is not within 1×〖10〗^(-3) of the given function derivative add more points until the calculated derivative is less than or equal to 1×〖10〗^(-3) of the given function’s derivative Next, add to you derivative function the capability to check for accuracy by comparing maximum errors between successive calculations of the derivative. You will need a while loop that checks when the maximum error is ≤eps.  To find the maximum array create a numpy array in your derivative function.  Call it ”maxe” where each element of the array would contain |〖df〗^(j+1) (x_i )-〖df〗^j (x_i )|. j+1 refers to the finer grid where the j+1 grid would use twice as many points as the j grid. For example, j=1 (the starting grid) would have N=10 points, and the j+1 grid would use 2N=20 points, the j+2 grid would use 40 points and so on. Now for the 1st pass through the while-loop you cannot converge you haven’t started the comparison. So construct you code to avoid this situation.

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
  • Take you same derivate function from last week and let’s make it more general by passing in f(x), and x
  • You derivative function will now look something like this my_der_calc(f,x,N,eps, option)
  • eps is a tolerance for determining the accuracy of your derivatives. We will use this later
  • To test, let’s use our function from last laboratory class, x(1-x)
  • The output argument, df, should be the numerical derivatives computed for xaccording to the method defined by the input argument, option
  • Remember, the forward difference method “loses” the last point, the backward difference method loses the first point, and the central difference method loses the first and last points. So you have use some interpolation to get these points. Try linear
  • By obtaining the derivative at the first and last point, you will have the exact same number of values for both df and x. Although, you could set them to same value as well, however, your plot will only be linear for the interior points
  • Plot df .vs x, notice the functional form of your plot.
  • Compare with the actual form with the derivative of the given function, if the calculated derivative is not within 1×〖10〗^(-3) of the given function derivative add more points until the calculated derivative is less than or equal to 1×〖10〗^(-3) of the given function’s derivative
  • Next, add to you derivative function the capability to check for accuracy by comparing maximum errors between successive calculations of the derivative. You will need a while loop that checks when the maximum error is ≤eps.  To find the maximum array create a numpy array in your derivative function.  Call it ”maxe” where each element of the array would contain |〖df〗^(j+1) (x_i )-〖df〗^j (x_i )|.
  • j+1 refers to the finer grid where the j+1 grid would use twice as many points as the j grid. For example, j=1 (the starting grid) would have N=10 points, and the j+1 grid would use 2N=20 points, the j+2 grid would use 40 points and so on.
  • Now for the 1st pass through the while-loop you cannot converge you haven’t started the comparison. So construct you code to avoid this situation.
  •  
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Recurrence Relation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
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