Homework 2, due September 10, 2008.

Due Wednesday, September 10, 2008.
Post Reply
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Homework 2, due September 10, 2008.

Post by goodwine »

Reading: read Chapter 2 from the course text.

Exercises: unless otherwise indicated, all problems are from the course text.
  1. 1.2
  2. 1.3
  3. 1.4
  4. 2.5
  5. 2.6
  6. 2.11
  7. 2.12
Bill Goodwine, 376 Fitzpatrick
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 2, due September 10, 2008.

Post 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 ^).
Bill Goodwine, 376 Fitzpatrick
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 2, due September 10, 2008.

Post 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.
Bill Goodwine, 376 Fitzpatrick
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 2, due September 10, 2008.

Post 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?
Bill Goodwine, 376 Fitzpatrick
am2011

Re: Homework 2, due September 10, 2008.

Post by am2011 »

Attached are the fortran codes for problems 1.2, 1.3, 1.4
You do not have the required permissions to view the files attached to this post.
kdacey

Re: Homework 2, due September 10, 2008.

Post by kdacey »

My homework 2 programs
however, it would not allow me to attach the figures of my plots
kevin dacey
You do not have the required permissions to view the files attached to this post.
dlundber

Re: Homework 2, due September 10, 2008.

Post by dlundber »

Attached are the C codes for hw problems 1.2, 1.3, and 1.4
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “AME 30314, Homework 2”