Chapter 9: Problem 24
Make a calculus calculator class. Given a function \(f(x)\) defined on a domain \([a, b]\), the purpose of many mathematical exercises is to sketch the function curve \(y=f(x)\) compute the derivative \(f^{\prime}(x)\), find local and global extreme points, and compute the integral \(\int_{a}^{b} f(x) d x .\) Make a class CalculusCalculator which can perform all these actions for any function \(f(x)\) using numerical differentiation and integration, and the method explained in Exercise \(7.36\) or \(7.37\) for finding extrema. Here is an interactive session with the class where we analyze \(f(x)=\) \(x^{2} e^{-0.2 x} \sin (2 \pi x)\) on \([0,6]\) with a grid (set of \(x\) coordinates) of 700 points: Design the class such that the above session can be carried out. Hint: Use classes from the Diff and Integrator hierarchies (Chapters \(9.2\) and \(9.3\) ) for numerical differentiation and integration (with, e.g., Central2 and Trapezoidal as default methods for differentiation and integration). The method set_differentiation_method takes a subclass name in the Diff hierarchy as argument, and makes an attribute df that holds a subclass instance for computing derivatives. With set_integration_method we can similarily set the integration method as a subclass name in the Integrator hierarchy, and then compute the integral \(\int_{a}^{b} f(x) d x\) and store the value in the attribute integral. The extreme_points method performs a print on a MinMax instance, which is stored as an attribute in the calculator class. Name of program file: CalculusCalculator.py.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.