Question: Python for Rapid Engineering Solutions Homework # 2 There are two parts to this homework, both worth 5 0 points. Use scipy.integrate.quad for both parts!

Python for Rapid Engineering Solutions
Homework #2
There are two parts to this homework, both worth 50 points.
Use scipy.integrate.quad for both parts!
Part 1
Compute the value of the integral:
0r(ax2+bx+c)dx
where r ranges from 0 to S in steps of 0.01, and a,b, and c are the constants 2,3, and 4,
respectively. Place the results on a plot using matplotlib. Then change the constants so that a,
b, and c are 2,1, and 1, respectively. Use these results to add another curve to your plat.
NOTE- You must use the same function for performing both integrals! That is, one function that
computes the value of ax2+bx+c. Therefore, you must pass the values of a,b, and c as
arguments to the function!
To be clear, there will be two curves on your plot. Remember to properly label the axis and add
a title. And don't forget the legend!
Name your script hw/2_poly.py.
Part 2
Compute the value of the integral:
0dx(1+x)x2=
using the substituion method. (You might be able to find a package that will integrate this
without substitution, but the point of this execise is to learn to do the substitution. Therefore,
unless you do the substitution methad, your work will nat be counted!)
Note that this is a known integral whose answer is, in fact, .
Use the substitution method taught in lecture and discussed in the Newman text.
Print out your result to a precision of 8 digits past the decimal point. Then subtract your answer
from numpy.pi and print the difference to 15 digits pas the decimal point.
NOTE: Be sure to use np.sqrt() to compute any square roots required.
Name your script hw/2_pi.py.
Your output must match this format:
Pi is 3.14159265
Difference from numpy.pi is: -0.000000000000099
 Python for Rapid Engineering Solutions Homework #2 There are two parts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!