Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn Mysql The Easy Way A Beginner Friendly Guide

Authors: Kiet Huynh

1st Edition

B0CNY7143T, 979-8869761545

More Books

Students also viewed these Databases questions

Question

2-12. How do countries know if their economic systems are working?

Answered: 1 week ago

Question

4. Label problematic uses of language and their remedies

Answered: 1 week ago