Page 1 of 1

Homework 7, due November 2, 2016.

Posted: Fri Oct 28, 2016 5:33 pm
by goodwine
Reading: sections 12.1-12.3 of the course text. Also, if you have not read it, section 1.6 has background information including Matlab examples.

Exercises: For all problems, be sure to run the program multiple times with a different time step sizes to ensure that your approximate answer has converged to the correct answer, i.e., keep reducing dt until the answer does not change significantly. Also, unless otherwise indicated, you must use a compiled language, such as FORTRAN, C, or C++.
  1. 12.1 (number 3 only and be sure to notice the paragraph at the end of the problem)
  2. Choose your favorite ordinary differential equation for which you can find the exact solution. If you are working with others, you must choose a different equation than they do. The only other condition is that it must be of the form x'(t) = f(x,t) and f must depend on BOTH x and t. It can be a single first order equation, or a higher-order equation converted to a system of first order equations. Write a program (or separate programs) that use a) Euler's method, 2) 2nd order R-K and iii) 4th order R-K and plot the error versus different time steps. Indicate whether the error is decreasing in a manner consistent with the order of the method.
  3. Consider the differential equation, which does not look all that bad:

    x' = 40 x (1 - x)

    where

    x(-1) = 1/(1 + exp(40)).

    Note that the initial condition is at t=-1. Use matlab and ode45() to solve this. Compare it to the exact answer, which is

    x(t) = 1/(1 + exp(-40 t))

    by plotting the two on the same graph. Verify the given exact answer really is the answer by substituting it into the differential equation. On a different graph, plot the error. Does matlab give a good solution?

    Write a program using 4th order Runge-Kutta to determine the solution. Plot the error versus different sized time steps.

    Main point: can you always trust matlab to give a good answer? Look at the original equation. Does it look suspicious in any way that would lead you to believe that it is problematics? (My answer is no, unless you ponder it for a long time).
  4. Do the first stage of the project, as described on the project page.

Re: Homework 7, due November 2, 2016.

Posted: Mon Oct 31, 2016 8:28 pm
by rlema
When we are comparing the exact and approximate solutions in problem 1, is the exact going to have the same time step as the approximation? or can we use a small time-step for the exact and compare how the approximation converges at a given point?

Re: Homework 7, due November 2, 2016.

Posted: Tue Nov 01, 2016 5:40 am
by goodwine
rlema wrote:When we are comparing the exact and approximate solutions in problem 1, is the exact going to have the same time step as the approximation? or can we use a small time-step for the exact and compare how the approximation converges at a given point?
Compare the exact and numerical solutions at the same point(s). If you choose to evaluate the exact solution at other times, that's ok.

Re: Homework 7, due November 2, 2016.

Posted: Tue Nov 01, 2016 1:11 pm
by Kelly Pacifico
To clarify for number 2 on homework 7, it says "plot the error versus different time steps. Indicate whether the error is decreasing in a manner consistent with the order of the method." do you want us to have three separate graphs (one for Eulers, second order, and fourth order) that have error versus t for various dt?

Re: Homework 7, due November 2, 2016.

Posted: Tue Nov 01, 2016 1:47 pm
by goodwine
Kelly Pacifico wrote:To clarify for number 2 on homework 7, it says "plot the error versus different time steps. Indicate whether the error is decreasing in a manner consistent with the order of the method." do you want us to have three separate graphs (one for Eulers, second order, and fourth order) that have error versus t for various dt?
Whatever method of plotting them that most clearly communicates the nature of the relationship among the time steps and methods is what I want you to submit.

Re: Homework 7, due November 2, 2016.

Posted: Tue Nov 01, 2016 6:45 pm
by jscholz
just to be clear, in question 3 is the differential equation 40 times (1-x) or is it 40 times x times (1-x)?

Re: Homework 7, due November 2, 2016.

Posted: Tue Nov 01, 2016 7:01 pm
by goodwine
jscholz wrote:just to be clear, in question 3 is the differential equation 40 times (1-x) or is it 40 times x times (1-x)?
It is the latter:

x' = 40*x(t)*(1 - x(t))

Re: Homework 7, due November 2, 2016.

Posted: Thu Nov 03, 2016 10:13 pm
by pkrog2
How should we present the answers for 1; do you want the code, graph, an analysis of the problem based on the results from our code, or some combination of those?

Re: Homework 7, due November 2, 2016.

Posted: Fri Nov 04, 2016 5:44 am
by goodwine
pkrog2 wrote:How should we present the answers for 1; do you want the code, graph, an analysis of the problem based on the results from our code, or some combination of those?
Submit all codes except 1) simple matlab plot commands and 2) if all you did was change something like dt you don't have to submit the code for each time for those. The analysis should be your attempt to most clearly communicate the nature of the relationship among the method, time step size and error.