- Write a program in FORTRAN, C, C++ or Java to determine an approximate numerical solution to
- 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.
- Write a computer program in FORTRAN, C, C++ or Java to determine an approximate numerical solution to
The program should use the 4th order Runge-Kutta method.
Homework 8, due Monday, November 3.
-
- Site Admin
- Posts: 1596
- Joined: Tue Aug 24, 2004 4:54 pm
- Location: 376 Fitzpatrick
- Contact:
Homework 8, due Monday, November 3.
Bill Goodwine, 376 Fitzpatrick
Re: Homework 8, due Monday, November 3.
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?
-
- Site Admin
- Posts: 1596
- Joined: Tue Aug 24, 2004 4:54 pm
- Location: 376 Fitzpatrick
- Contact:
Re: Homework 8, due Monday, November 3.
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.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?
Bill Goodwine, 376 Fitzpatrick
Re: Homework 8, due Monday, November 3.
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?
-
- Site Admin
- Posts: 1596
- Joined: Tue Aug 24, 2004 4:54 pm
- Location: 376 Fitzpatrick
- Contact:
Re: Homework 8, due Monday, November 3.
Sorry, it's missing. You may assume it is zero.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?
Bill Goodwine, 376 Fitzpatrick
Re: Homework 8, due Monday, November 3.
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?
Re: Homework 8, due Monday, November 3.
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?
Re: Homework 8, due Monday, November 3.
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.
Mt solutions are still the same with and without D0.
-
- Site Admin
- Posts: 1596
- Joined: Tue Aug 24, 2004 4:54 pm
- Location: 376 Fitzpatrick
- Contact:
Re: Homework 8, due Monday, November 3.
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.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?
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
Re: Homework 8, due Monday, November 3.
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?
-
- Site Admin
- Posts: 1596
- Joined: Tue Aug 24, 2004 4:54 pm
- Location: 376 Fitzpatrick
- Contact:
Re: Homework 8, due Monday, November 3.
Unless a problem says otherwise, you should always submit a plot of the solution too.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?
Bill Goodwine, 376 Fitzpatrick