Question: 16.3.1 Exercise: integrate a function 1. Using scipy's quad function, write a program that solves the following integral numerically: I = So ' cos(27x)dx. 2.

16.3.1 Exercise: integrate a function 1. Using scipy's quad function, write a program that solves the following integral numerically: I = So ' cos(27x)dx. 2. Find the analytical integral and compare it with the numerical solution. 3. Why is it important to have an estimate of the accuracy (or the error) of the numerical integral? 16.3.2 Exercise: plot before you integrate It is good practice to plot the integrand function to check whether it is "well behaved" before you attempt to integrate. Singularities (i.e. x values where the f(x) tends towards minus or plus infinity) or other irregular behaviour (such as f(x) = sin(1) close to x = 0 are difficult to handle numerically. 1. Write a function with name plotquad which takes the same arguments as the quad command (i.e. f, a and b) and which . (i) creates a plot of the integrand f(x) and (ii) computes the integral numerically using the quad function. The return values should be as for the quad function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
