Homework 8, due Monday, November 3.

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

Homework 8, due Monday, November 3.

Post by goodwine »

  1. Write a program in FORTRAN, C, C++ or Java to determine an approximate numerical solution to
    • Image
    The program should use the 4th order Runge-Kutta method and have all the variables and functions declared as double precision.
    • Use the term 1.0/6.0 in your code (multiplying the sum of the 4 "k" and "l" terms) and time steps of 0.01 and 0.005. Does the error chance as expected?
    • Use the term 1.0D0/6.0D0 in your code for the same time steps. Does the error change as expected? Explain any difference from what you saw with 1.0/6.0.
  2. Write a computer program in FORTRAN, C, C++ or Java to determine an approximate numerical solution to
    • Image
    Also assume the initial condition for the second derivative is zero.
    The program should use the 4th order Runge-Kutta method.
Bill Goodwine, 376 Fitzpatrick
mzenz

Re: Homework 8, due Monday, November 3.

Post by mzenz »

I am coding in C++, so I was wondering if I still needed to do the 1.0d0/6.0d0 because I am not sure how real and integer precision works in C++. And if I do need to do this is the code the same?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 8, due Monday, November 3.

Post by goodwine »

mzenz wrote:I am coding in C++, so I was wondering if I still needed to do the 1.0d0/6.0d0 because I am not sure how real and integer precision works in C++. And if I do need to do this is the code the same?
Well, you can't do the "D" part, but do it with and without double precision. If you are not sure how it works in C++, that's something you need to figure out.
Bill Goodwine, 376 Fitzpatrick
pburns3

Re: Homework 8, due Monday, November 3.

Post by pburns3 »

You do not give an intial condition for d2x/dt2 in problem two. Are we supposed to find this somehow or is it missing from the problem statement?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 8, due Monday, November 3.

Post by goodwine »

pburns3 wrote:You do not give an intial condition for d2x/dt2 in problem two. Are we supposed to find this somehow or is it missing from the problem statement?
Sorry, it's missing. You may assume it is zero.
Bill Goodwine, 376 Fitzpatrick
amrugala

Re: Homework 8, due Monday, November 3.

Post by amrugala »

I don't think the pgf77 compiler likes some of the code for the R-K problems... I compiled my code with it and got a straight line at x(t) = 1, whereas with f77 I actually got a graph. Could there be a problem with my code or is it just the compiler?
xdong

Re: Homework 8, due Monday, November 3.

Post by xdong »

I am having the exact same problem
jnelso10

Re: Homework 8, due Monday, November 3.

Post by jnelso10 »

I see no difference when I include or don't include the D0 with either time step. What is D0 generally supposed to do when you add it?
jnelso10

Re: Homework 8, due Monday, November 3.

Post by jnelso10 »

I figured out what the D notation means. When D0 is not included, should x(1) and x(2) only be single precision?

Mt solutions are still the same with and without D0.
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 8, due Monday, November 3.

Post by goodwine »

amrugala wrote:I don't think the pgf77 compiler likes some of the code for the R-K problems... I compiled my code with it and got a straight line at x(t) = 1, whereas with f77 I actually got a graph. Could there be a problem with my code or is it just the compiler?
There may be differences in the compilers and it may be the case that pgf77 is smart enough to consider constants that multiply something as the correct precision. I don't know for sure and won't be able to check it before tomorrow, so if there isn't any difference for you, then I would probably just leave it at that.

I can't see how it would give a constant solution, though. I suspect that is a problem with your code.
Bill Goodwine, 376 Fitzpatrick
gtorrisi

Re: Homework 8, due Monday, November 3.

Post by gtorrisi »

for the 2nd part of the homework, do we need to turn in a graph of the solution and show what the actual solution is, or just write the computer program and submit the code?
goodwine
Site Admin
Posts: 1596
Joined: Tue Aug 24, 2004 4:54 pm
Location: 376 Fitzpatrick
Contact:

Re: Homework 8, due Monday, November 3.

Post by goodwine »

gtorrisi wrote:for the 2nd part of the homework, do we need to turn in a graph of the solution and show what the actual solution is, or just write the computer program and submit the code?
Unless a problem says otherwise, you should always submit a plot of the solution too.
Bill Goodwine, 376 Fitzpatrick
Post Reply

Return to “AME 30314, Homework 8”