Math 2250-002 Second Software (Matlab) Assignment

advertisement
Math 2250 - 002
Matlab
Project #2
Due: 9/20/11
Math 2250-002
Second Software (Matlab) Assignment
Numerical Approximation for Solutions to Differential Equations
If you choose to do this project using Matlab, it may be helpful to start with the m-file at the
following URL:
Start File:
http://www.math.utah.edu/~camacho/teaching/fall2011/Start_File.m
Copy the text into a new m-file and save it. This file provides a good demonstration for how to
run a simple numerical algorithm in Matlab. You will need to make several modifications to the
code in order answer the questions this assignment.
You may find the following two Matlab introductory files to be useful. The first one describes
how to get started in Matlab and some of the basic features, while the second one covers many of
the more advanced commands in Matlab that you'll the list of commands you might find helpful
for this course.
Introduction: http://www.math.utah.edu/~camacho/teaching/fall2011/Matlab_Intro.pdf
Commands: http://www.math.utah.edu/~camacho/teaching/fall2011/Matlab_Commands.pdf
In this project it will be necessary to use some "for loops" and "if loops" to do the iterations in
these numerical algorithms. In the Matlab Commands1 file referred to above, you will find a
great explanation of "for loops" and "if loops". You can also see how each of these types of
loops are implemented in the Start File2, referred to above. For additional help you can look in
Matlab's help file, ask your professor, ask your TA, or ask for help at the Math Tutoring Center.
You will be using the Euler and Runge-Kutta numerical algorithms. Sections 2.4 and 2.6 contain
pseudocode3 for these algorithms. There are Matlab and TI-85 implementations at the ends of
these sections.
You will create at least two Matlab m-files to carry out the tasks you are asked about in the
questions below. One m-file should be used to answer questions pertaining to the Euler method,
while the other should be used to answer questions pertaining to the Runga-Kutta method. Your
code should be commented clearly enough for the grader to understand what each part of your
code is doing. You will record your answers to each question on a separate paper, either hand
written or typed.
1
http://www.math.utah.edu/~camacho/teaching/fall2011/Matlab_Commands.pdf
http://www.math.utah.edu/~camacho/teaching/fall2011/Project_2.m
3
Psuedocode is an organized way to describe a computer program or algorithm using words rather than actual
code. You are essentially describing what your code is doing in the order that the algorithm is carried out.
2
Math 2250 - 002
Matlab
Project #2
Due: 9/20/11
Important directions for submission for Math 2250-2: When handing in your work, you will
be including several items in your project report.
1. The first two pages of your report should be the third and fourth page of this document
which list the questions you are answering. Be sure to write your name in the space
provided.
2. The answers to each of the questions with any relevant explanations, equations,
functions, graphs, or tables. This part of the report may either be handwritten or typed.
3. A printout of the Matlab code you used to generate your answers to the questions
below. You will need to print out the code in two different m-files. One which solves
the IVP using Euler's method, and the other which uses the Runga-Kutta method.
Staple all of these items together, in the order listed above and hand in your work at the
beginning of class on Tuesday, September 20th. You may turn the assignment in early if you
would like.
Math 2250 - 002
Matlab
Project #2
Due: 9/20/11
Name:______________________
Consider the IVP
.
You solved this IVP in the first Maple project - the solution is
This problem and its solution could be modeling a linear drag problem for a parachutist who
drops out of a helicopter at time
and immediately pulls his ripcord. In this model we
measure positive distance in the downwards direction; the acceleration of gravity is
, and
the drag of the parachute adds the deceleration term
out what percentage of the terminal velocity of
. In the first project you figured
is obtained after
and
seconds.
1.
Use Euler's method to approximate the solution to the IVP on the interval
follows:
, as
(a) Use step size
. Write your "for" loop so that Matlab only outputs the approximate
values at
. What is the relative error of your numerical estimates as compared to the exact
solution values, at
? (Recall that relative error is the error divided by the exact value,
expressed as a percentage)
(b) Now use step size
, display at the same
about the relative error as in part (a)
values and answer the same questions
(c) Now use step size
and display at the same
about the relative error as in parts (a) and (b).
2.
values and answer the same questions
Use the Runga-Kutta method to approximate the solution to the IVP on the interval
. Have Matlab output only the approximate values at
. Use step size
and
calculate the relative error of your numerical estimates. How does the accuracy of Runge-Kutta
with step size
compare to the accuracy of Euler's Method with the three step sizes you
used in question 1?
Math 2250 - 002
Matlab
Project #2
Due: 9/20/11
3.
The wind resistance provided by a parachute is not really a linear deceleration. Suppose
that for a certain type of parachute and for a person of the same mass as in the original model,
the acceleration equation is more effectively modeled by
(a) What is the terminal velocity in this model? [You will have difficulty solving this
algebraically, it will be helpful to use Matlab's numerical solver. For instructions in how to use
Matlab's numerical solver see the Matlab Commands4 file]
(b) This is differential equation does NOT have an elementary solution. Use Runge-Kutta with
step sizes
and
to estimate the solution values at
and
seconds. Based on a
comparison of the estimated values at these two values, how confident are you that either one
of them provides a good estimate for the actual values
and
? Explain your reasoning.
(c) Based on your work in part (b), what percent of the terminal velocity is attained at
seconds and at
seconds?
4
http://www.math.utah.edu/~camacho/teaching/fall2011/Matlab_Commands.pdf
Download