

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for students in a university-level mathematics course to find acceleration and position from velocity data using various methods. The methods include using an o(∆t2) accurate scheme, fitting a spline, and finding the least-squares curve. Students are also asked to integrate velocity data to find position using a trapezoidal rule and a spline. Additionally, students are asked to solve the van der pol differential equation using ode45 and other integration methods, and to investigate the relationship between the average step-size and error tolerance.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Homework 3: Autumn 2008
DUE: Thursday, November 6 at 3 a.m.
I Download the file velocity.dat from the class webpage. This file will be located next to 301hw3.pdf. This data contains the velocity (meters/second) as a function of time (sec- onds). Find the acceleration as a function of time. To do this, you will need to differentiate the data as a function of time. Do this in the following ways: (a) Use an O(∆t^2 ) accurate scheme on the raw data. ANSWER: Should be written out as a row vector A1.dat (b) Fit a spline through the data with t = 0 : 0.01 : 30 and find the O(∆t^2 ) and O(∆t^4 ) results. (At boundaries use O(∆t^2 ) accurate forward- and backward-difference scheme.) ANSWER: Should be written out as row vectors A2.dat and A3.dat (c) Fit the least-squares curve (AGAIN, YOUR INITIAL GUESS IS CRITICAL! So try using the initial guesses for A, B, C and D being 3, π/ 4 , 2 /3 and 32 respectively.)
f (t) = A cos(Bt) + Ct + D (1)
through the data points and differentiate the resulting best fit with an O(∆t^2 ) accurate scheme using t = 0 : 0.01 : 30. ANSWERS: Curve and derivative are row vectors A4.dat and A5.dat respectively
II Download the file velocity.dat from the class webpage. This file will be located next to 301hw3.pdf. This data contains the velocity (meters/second) as a function of time (seconds). Find the position as a function of time. To do this, you will need to integrate the data as a function of time. Do this in the following ways: (a) Use a trapezoidal rule (CUMTRAPZ) on the data. ANSWER: Should be written out as column vector A6.dat (b) Use a spline with t = 0 : 0.01 : 30 and a trapezoidal rule to evaluate the integral. ANSWER: Should be written out as column vector A7.dat (c) Fit the least-squares curve f (t) = A cos(Bt) + Ct + D as with the previous homework using the initial guesses for A, B, C and D being 3, π/ 4 , 2 /3 and 32 respectively. Integrate with the QUAD and INLINE command and give the results for the cumulative integral for t = 0 : 0.1 : 30. ANSWER: Should be written out as column vector A8.dat
III Consider the Van der Pol differential equation (use ode45)
y′′^ + (y^2 − 1)y′^ + y = 0
which has the nonlinear damping term (y^2 − 1)y′. (a) With = 0.1, solve the equation for t ∈ [0 : 0.5 : 30] for initial conditions y(0) = 0.1 and y′(0) = −1. Repeat with = 1 and = 20. ANSWER: Should be written out as two column matrices A9.dat–A11.dat for = 0. 1 , 1 and 20 respectively.
(b) With = 1, t ∈ [0, 30] (let MATLAB pick step-size) and initial conditions y(0) = 5 and y′(0) = 0, solve the equation with the four different integration methods: ode45, ode23, ode113, and ode15s. For each method, use the diff and mean command to calculate the average step-size ∆t taken to solve the problem over t ∈ [0, 30] for a given tolerance. Control the error tolerance, TOL, in the ode solvers with
TOL=1e-4; OPTIONS = odeset(’RelTol’,TOL,’AbsTol’,TOL); [T,Y] = ODE45(’F’,TSPAN,Y0,OPTIONS);
Use the following tolerance values: 10−^4 , 10 −^5 , 10 −^6 , 10 −^7 , 10 −^8 , 10 −^9 , 10 −^10. Plot on a log- log scale the average step-size (x-axis) versus the tolerance (y-axis) for the given tolerance values. Calculate the slopes of these lines with the polyval command. Note that the local error should be O(∆t^5 ) and O(∆t^3 ) for ode45 and ode23 respectively. What are the local errors for ode113 and ode15s?
ANSWER: Slopes should be written out as a row vector with four components A12.dat whose components are slopes of ode 45 , ode 23 , ode113 and ode 15 s respectively.