Homework 8, due November 3, 2011.
Posted: Fri Oct 28, 2011 10:58 am
Reading: Chapter 12, Sections 1-5.
Note: for the exercises, if you are asked to write a computer program, you must use a compiled language, such as FORTRAN, C, C++, etc. You may only use matlab to plot your answers or if the problem explicitly says for you to use ode45.
Exercises: 12.1 (number 3 only -- be sure to read the paragraph at the END of the problem), 12.2 (number 6 only), 12.5,12.6 and 12.7.
Also, consider the differential equation
x' = 40 x (1 - x)
where
x(-1) = 1/(1 + exp(40))
Note the initial condition is at t=-1. Use matlab and ode45 to solve this. Compare it with 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. Also, on a different graph, plot the error. Does Matlab give a good solution?
Write your own program to use 4th order R-K to solve it. Plot your solution along with the exact solution. Keep reducing the step size until the answer is accurate (it may need to be very small!). Be sure to use double precision if necessary. Note that exp(40) and exp(-40) are huge and tiny numbers, respectively, so be sure your program is able to compute them and not give you Nan or Inf for the former and zero for the latter.
Main point: can you always trust matlab to give the right answer? Look at the original differential equation. Does it look suspicious in any way that would lead you to believe it's problematic? (Answer, no). If you study it further, what is it about the equation that messes stuff up?
Note: for the exercises, if you are asked to write a computer program, you must use a compiled language, such as FORTRAN, C, C++, etc. You may only use matlab to plot your answers or if the problem explicitly says for you to use ode45.
Exercises: 12.1 (number 3 only -- be sure to read the paragraph at the END of the problem), 12.2 (number 6 only), 12.5,12.6 and 12.7.
Also, consider the differential equation
x' = 40 x (1 - x)
where
x(-1) = 1/(1 + exp(40))
Note the initial condition is at t=-1. Use matlab and ode45 to solve this. Compare it with 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. Also, on a different graph, plot the error. Does Matlab give a good solution?
Write your own program to use 4th order R-K to solve it. Plot your solution along with the exact solution. Keep reducing the step size until the answer is accurate (it may need to be very small!). Be sure to use double precision if necessary. Note that exp(40) and exp(-40) are huge and tiny numbers, respectively, so be sure your program is able to compute them and not give you Nan or Inf for the former and zero for the latter.
Main point: can you always trust matlab to give the right answer? Look at the original differential equation. Does it look suspicious in any way that would lead you to believe it's problematic? (Answer, no). If you study it further, what is it about the equation that messes stuff up?