Write a function my_der_calc(f,a,b,N,option), with the output as [df,X],where  f(x) is a function that equals x(1-x), a and b are a scalars that represent the 1st and last point of your grid respectively, and Nis an integer that represents the number of grid points, and optionis the string that can take on the text forward, backward or central differencing.  Thus, you are writing a function that can perform forward, backward or central differencing, the choice is determined by the input option Let xbe an array starting at a, ending at b, containing Nevenly spaced elements, and let y be the array f(x) The output argument, df, should be the numerical derivatives computed for xaccording to the method defined by the input argument, option The output argument Xshould be an array that is the same size as df containing the points in xfor which df is valid 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 to use forward or backward differences depending on whether it is the 1st or last point. 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 Write a derivative function that doesn’t use numpy arrays

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 17PE
icon
Related questions
Question
  • Write a function my_der_calc(f,a,b,N,option), with the output as [df,X],where  f(x)
    is a function that equals x(1-x), a and b are a scalars that represent the 1st and last point of your grid respectively, and Nis an integer that represents the number of grid points, and optionis the string that can take on the text forward, backward or central differencing.  Thus, you are writing a function that can perform forward, backward or central differencing, the choice is determined by the input option
  • Let xbe an array starting at a, ending at b, containing Nevenly spaced elements, and let y be the array f(x)
  • The output argument, df, should be the numerical derivatives computed for xaccording to the method defined by the input argument, option
  • The output argument Xshould be an array that is the same size as df containing the
    points in xfor which df is valid
  • 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 to use forward or backward differences depending on whether it is the 1st or last point.
  • 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
  • Write a derivative function that doesn’t use numpy arrays
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
Function Arguments
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr