Page 1 of 1

Homework 8, due November 3, 2011.

Posted: Fri Oct 28, 2011 10:58 am
by goodwine
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?

Re: Homework 8, due November 3, 2011.

Posted: Mon Oct 31, 2011 8:11 pm
by Jessie
For 12.7 part 2, should each of the graphs have the 4 different methods at one time step, or 1 method at the different time steps?

Re: Homework 8, due November 3, 2011.

Posted: Mon Oct 31, 2011 9:13 pm
by astumpf
Prof., for 12.6 #6, can you give us a hint on how to solve this equation. It's not exact which technically means it's not seperable which means we need an integrating factor. I know in the last paragraph it said IF there is an exact solution etc... so i guess my question is, is there an exact solution? and if so can you give any hints or tricks? thanks!

Re: Homework 8, due November 3, 2011.

Posted: Mon Oct 31, 2011 10:12 pm
by espinell
Professor,

Could you post the Fortran work you did in class today? As well as the work you did in class on Friday?

Re: Homework 8, due November 3, 2011.

Posted: Mon Oct 31, 2011 10:42 pm
by astewar9
astumpf wrote:Prof., for 12.6 #6, can you give us a hint on how to solve this equation. It's not exact which technically means it's not seperable which means we need an integrating factor. I know in the last paragraph it said IF there is an exact solution etc... so i guess my question is, is there an exact solution? and if so can you give any hints or tricks? thanks!
I think you mean 12.2 #6. If you do mean this, then I believe the answer is that it is separable. It can be rewritten as dx/dt=-x-x^3 then dx/(-x-x^3)=dt.

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 5:52 am
by goodwine
astewar9 wrote:
astumpf wrote:Prof., for 12.6 #6, can you give us a hint on how to solve this equation. It's not exact which technically means it's not seperable which means we need an integrating factor. I know in the last paragraph it said IF there is an exact solution etc... so i guess my question is, is there an exact solution? and if so can you give any hints or tricks? thanks!
I think you mean 12.2 #6. If you do mean this, then I believe the answer is that it is separable. It can be rewritten as dx/dt=-x-x^3 then dx/(-x-x^3)=dt.
No, it's second order, so you can't solve it by hand.

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 5:52 am
by goodwine
espinell wrote:Professor,

Could you post the Fortran work you did in class today? As well as the work you did in class on Friday?
I did so today right after class.

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 5:54 am
by goodwine
Jessie wrote:For 12.7 part 2, should each of the graphs have the 4 different methods at one time step, or 1 method at the different time steps?
The only way for there to be four plots with four curves is to plot the exact answer and three different methods for a given time step size on the same plot. Thus one plot should be one time step soze, the next plot another size, &c.

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 3:23 pm
by mlamb
Professor, for problem 12.2 #6, is the differential equation supposed to be second order? That is, should the equation be x’’ + x’ + x^3=0 instead of x’ + x + x^3=0?

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 3:26 pm
by jfisher7
Is the first term in 12.2 #6 supposed to be x double dot rather than xdot?

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 5:25 pm
by goodwine
jfisher7 wrote:Is the first term in 12.2 #6 supposed to be x double dot rather than xdot?
Oops! I totally messed up above. It is only xdot. (That equation with a double-dot is a famous one, which is why I missed it before).

Re: Homework 8, due November 3, 2011.

Posted: Tue Nov 01, 2011 5:26 pm
by goodwine
goodwine wrote:
astewar9 wrote:
astumpf wrote:Prof., for 12.6 #6, can you give us a hint on how to solve this equation. It's not exact which technically means it's not seperable which means we need an integrating factor. I know in the last paragraph it said IF there is an exact solution etc... so i guess my question is, is there an exact solution? and if so can you give any hints or tricks? thanks!
I think you mean 12.2 #6. If you do mean this, then I believe the answer is that it is separable. It can be rewritten as dx/dt=-x-x^3 then dx/(-x-x^3)=dt.
No, it's second order, so you can't solve it by hand.
I totally messed this up. You were right before.

Re: Homework 8, due November 3, 2011.

Posted: Wed Nov 02, 2011 7:13 pm
by jmccormi
Do we need to turn in our pages and pages of Fotran/MATLAB code or can we just give the plots?

Re: Homework 8, due November 3, 2011.

Posted: Wed Nov 02, 2011 7:23 pm
by goodwine
jmccormi wrote:Do we need to turn in our pages and pages of Fotran/MATLAB code or can we just give the plots?
If you want credit, submit printouts of all of your programs.