Starting from:

$30

CS6210-Assignment 5 Solved

Instructions 

1.   Simpson’s Rule, for integrating a function is given by

                                                                                                  𝑏                                        𝑁

∫ 𝑓(𝑥)𝑑𝑥 ≈ ∑ 𝑤𝑖𝑓(𝑥𝑖)

                                                                                                𝑎                                         𝑖=1

Implement or use the given  quadratic interpolant (composite Simpson formula) for 𝑁 =

17,33,65,129,257,513.  Test your code on the interval  [0,1]  with the functions   xp   p = 2,3,4,5,6 and 8 and show and explain the results.  

  

Calculate the integral for the function below.

(4𝑥) 𝑑𝑥

 3

 Report the results and create a convergence table  for Simpson’s Rule t for 𝑁 = 217,33,65,129,257,513 that shows how quickly the methods go to a common final value.

2.   Using the supplied QuadTX functions from the book calculate the integral defined by  

03(cos( ))x3 200dx  use tolerances 1.0e-7, 1.0e-8, ….. 1.0e-14 and compare the time spent and the number of functions calls of f(x) used.   

3.   Change your fixed grid code to estimate the overall error by repeating the calculation for the function in Question 4 and compare the performance of Quadtx with your fixed grid

Simpson’s  code  by showing how many steps quadtx takes to achieve a number of fixed grid cases. Note you may need many intervals for this difficult function. Explain your results.

4.   Solve the following problem that concerns a model of a coffee cup problem analytically for 5 minutes based upon Newton's law of cooling:            𝑑 𝑑𝑡𝑇𝑐 = −𝑟(𝑇𝑐 − 𝑇𝑠),  𝑇𝑠 = 19℃, 𝑇𝑐(0) = 84℃, 𝑟 = 0.025/𝑠𝑒𝑐𝑜𝑛𝑑.   

 

 Write a  program to solve the coffee cup problem using the Forward Euler Method calculate and compare your results to the analytical answer given by the provided function.  

  Plot the results for all algorithms using several different values for the step size ℎ (ℎ = 30𝑠, 15𝑠, 10𝑠, 5𝑠, 1𝑠, 0.5𝑠, 0.25𝑠)    

Using these results estimate the order of the error after the first step and at the end of the integration. Describe how the error changes with changes in ℎ.  

5.   Implement the ODE23 method described in the book Moler for the coffee cup problem .. For the standard equation dy/dt = f(t,y) the method is given by   

      S1 = f(tn,yn)  

      S2 = f(tn + h/2, yn+h/2 S1)        S3 = f(tn + 3h/4, yn+3h/4 S2)           tn+1 =  tn  + h         yn+1  = yn  + h/9  ( 2S1 + 3S2  + 4S3)  

        S4 = f(tn+1, yn+1)  

       Error(n+1)    = h/72  ( -5S1 + 6S2  + 8S3 -9 S4)  

6    Plot the results for this  algorithms using several different values for the step size ℎ (ℎ =

30𝑠, 15𝑠, 10𝑠, 5𝑠, 1𝑠, 0.5𝑠, 0.25𝑠) Using these results estimate the order of the error after the first step and at the end of the integration. Compare the actual error on the first timestep with the predicted error on the first step.  

7    Change the value of r in the problem being solved to r = 0.6. Does the error estimator blow up in the same way as the solution when the solution becomes unstable?   

8    Modify the Harmonic Oscillator code on the canvas page to include the Stormer Verlet method. Include code to measure the error in the Hamiltonian. Verify the class results for these methods.

9    Further modify the code to include the trapezoidal method and the Backward Euler method by using the inverse of a 2x2 matrix as was done in the class notes.  Are these methods area preserving as defined in the slides? Explain your results using  the approach adopted in the slides.

More products