关键词 > AMATH242/CS371

AMATH 242/ CS 371 (Spring 2022) Assignment 4

发布时间:2022-07-19

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

AMATH 242/ CS 371 (Spring 2022)

Assignment 4

Due:  Tuesday, July 26 by midnight

For this assignment, please submit pdfs/screenshots of your code along with the output/figures directly to Crowdmark.  Additionally, submit the raw code to LEARN. In all figures, label your axes.

I = \1 2 ^sin(x) + xdx

(a) By hand use the following numerical integration rules to approximate the integral.

Show your work.

(i) The composite Midpoint rule with n = 4 (ii) The composite Trapezoid rule with n = 4 (iii) The composite Simpson rule with n = 4

(b) An accurate value for the integral is I ≈ 1.56408. What are the relative errors for the

three approximations in (a)? Which of the three methods was the most accurate?

(c) Compute an error bound on each of the three rules in a.   (with n  = 4) for this function.

(d) Approximate I using Gaussian Integration (equation (6.17) in the course notes).

2. The Fresnel integrals,

S(t) = \0 t sin(x2 )dx

C(t) = \0 t cos(x2 )dx

have no closed form solutions. Let’s use numerical methods to approximate these integrals and generate an Euler spiral.

(a) Complete this function that uses the composite Simpson rule to approximate an

integral.

def  simpsonRule(f,a,b,n):

#  Input:

#     f  -  a  function  to  integrate

#      [a,  b]  -  interval  of  integration

#     n  -  number  of  sub - intervals  to  use  the  Simpson  rule  on I  =  0  #  replace  this  with  your  own  code

return  I

(b) Use your function with n = 40 to approximate S(t) and C(t) for t values

ts  = np .linspace(0,10,200).  Plot the curve (x,y) = ((t), (t)) for t ∈ [0, 10] using your results.