Page 1 of 1
Homework 2, due September 10, 2008.
Posted: Fri Sep 05, 2008 10:21 am
by goodwine
Reading: read Chapter 2 from the course text.
Exercises: unless otherwise indicated, all problems are from the course text.
- 1.2
- 1.3
- 1.4
- 2.5
- 2.6
- 2.11
- 2.12
Re: Homework 2, due September 10, 2008.
Posted: Sun Sep 07, 2008 6:17 pm
by goodwine
Someone asked me:
I am working on the homework for this week, and I am having trouble with one of the graphs. On problem 1.4, I entered the following into MATLAB
dsolve('D2x + t*Dx + 2*x = 0', 'x(0)=3', 'Dx(0)=-2')
and the answer I am getting from MATLAB is this:
-2*exp(-1/2*t^2)*t+3/2*i/pi^(1/2)*2^(1/2)*(-i*pi^(1/2)*2^(1/2)+exp(-1/2*t^2)*pi*erf(1/2*i*2^(1/2)*t)*t).
I'm stuck on how to graph that. My knowledge of MATLAB is pretty basic, and I haven't been able to find anything online or in my MATLAB handbook that looks like it will help me. I've tried a few different things, but nothing is working. This equation looks pretty horrific, so I'm not even sure that it's right or that I should take the hours it would take me to put this into FORTRAN to compute so I can graph it. Am I doing something wrong? How can I graph the comparison?
Part of the reading assignment for last week covered how to numerically solve differential equations in Matlab. The method you used solves it symbolically (analytically), which usually won't work for nonlinear equations. Do it the way the book said to.
ps. Even though you shouldn't do it, plotting that equation using FORTRAN wouldn't be that hard. Just cut and past the expression into a loop and change the syntax to FORTRAN where it is different (e.g., ** instead of ^).
Re: Homework 2, due September 10, 2008.
Posted: Sun Sep 07, 2008 6:22 pm
by goodwine
Someone asked me:
I have a few questions about the homework for this week:
Once I have created the .d file using the fortran code, what was the command to plot in matlab? also, how do I use matlab to check my answer? I think you said there was some sort of built in function to use, but I'm not sure what it is.
Use "load" to load the data and then plot it using "plot"
See above for the answer to the second part of your question -- it was part of last week's reading assignment.
Re: Homework 2, due September 10, 2008.
Posted: Mon Sep 08, 2008 7:38 pm
by goodwine
I am having problems with the homework due this week. I may have finally figured out how to make problem 1.2 work in FORTRAN, but now I am completely stuck when I go to solve it in matlab to compare. I know it is in the book, but the way it is explained still doesn't quite make sense to me and everything I have tried changing to make it work just comes back with errors. I think that I am doing something wrong with the function part, but I am not very good with Matlab and I'm having trouble figuring out what to put to make it work. This is what I currently put in the .m file:
function xdot= firstorder(t,x)
xdot = exp((3*t))-x;
and then this was in the command line:
[T,Y] = ODE45(@firstorder,[0 30],[0 1])
but it just comes up with errors.
What are do the [0 30] and the [0 1] represent?
Re: Homework 2, due September 10, 2008.
Posted: Wed Sep 10, 2008 2:29 am
by am2011
Attached are the fortran codes for problems 1.2, 1.3, 1.4
Re: Homework 2, due September 10, 2008.
Posted: Wed Sep 10, 2008 11:23 am
by kdacey
My homework 2 programs
however, it would not allow me to attach the figures of my plots
kevin dacey
Re: Homework 2, due September 10, 2008.
Posted: Fri Sep 12, 2008 4:17 am
by dlundber
Attached are the C codes for hw problems 1.2, 1.3, and 1.4