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

AMATH 301

Homework 7: Autumn 2021

 

I  Consider the following temperature data taken over a 24-hour (military time) cycle:

75 at 1, 77 at 2, 76 at 3, 73 at 4, 69 at 5, 68 at 6, 63 at 7, 59 at 8, 57 at 9, 55 at 10, 54 at 11, 52 at 12, 50 at 13, 50 at 14, 49 at 15, 49 at 16, 49 at 17, 50 at 18, 54 at 19, 56 at 20, 59 at 21, 63 at 22, 67 at 23, 72 at 24.

(a) Fit the data with the parabolic fit

f (x) = Ax2 + Bx + C                                                    (1)

and calculate the E2 error as A1. Use POLYFIT and POLYVAL to get your results. Evaluate the curve f (x) for x = 1 : 0.01 : 24 and save this in a column vector A2.

ANSWER: The error and curve should be written out as A1 and A2 respectively

(b) Use the INTERP1 and SPLINE command to generate an interpolated approximation to the data for x = 1 : 0.01 : 24. Save these two results as column vectors.

ANSWER: Should be written out as A3 and A4

(c) Develop a Least-Squares algorithm and calculate E2  for:

y = A cos Bx + C                                                       (2)

(Hint:  use the FMINSEARCH  (matlab) or FMIN  (python) command to help.   YOUR INITIAL GUESS IS CRITICAL! So be sure to plot your results to see if they look right!)

Evaluate the curve for x = 1 : 0.01 : 24 and save this in a column vector.          ANSWER: Error and curve should be written out as A5 and A6 respectively

II  Consider the data of the velocity (meters/second) as a function of time (seconds):

v = [30, 35, 33, 32, 34, 37, 39, 38, 36, 36, 37, 39, 42, 45, 45, 41, 40, 39, 42, 44, 47, 49, 50, 49, 46, 48, 50, 53, 55, 54, 53]

where time goes from 0 to 30 seconds in steps of one second.

(a) Fit the least-squares curve (AGAIN, YOUR INITIAL GUESS IS CRITICAL!)

f (t) = A cos(Bt) + Ct + D                                                (3)

through the data points using the initial guesses for A, B, C and D being 3, π/4, 2/3 and 32

respectively. Generate the least-square curve for t = 0 : 0.01 : 30

ANSWERS: The curve should be the row vector A7