Group Abstract Group Abstract

Message Boards Message Boards

Solve an ODE using Runge-Kutta methods?

Hello All:

Hope everyone is doing well. I am attempting to create functions that use Runge-Kutta to solve an ODE. At the moment results are very close to exact solutions in a small example.

My question is in regards to the need of using "Evaluate Notebook" twice for getting good results after opening the notebook. Why is this happening(?)

Any advise is welcome!!! I highly appreciate your feedback letting me know my failures.

The attached file contains my attempts.

Attachments:
POSTED BY: Marcolino R-M
5 Replies
POSTED BY: Murray Eisenberg
Attachments:
POSTED BY: Marcolino R-M
POSTED BY: Murray Eisenberg

Professor Eisenberg:

Thanks a lot for taking the time to scrutinize the code and relay in writing your observations. I really appreciate your effort and feel thankful for it. Per your notes, I proceeded as follows:

[01] Clearly understood your point on evaluating cells one-by-one instead the entire notebook.

[02] I was not aware of the precedence's need during function declaration. This area is clear now.

[03] Currently I am investigating how to avoid using a "For" loop with other constructs (i.e. Table).

[04] Per your note, RK4 and f have been changed to return a result.

[05] Variable i removed from f since it was not being used.

[06] With your observations regarding precedence of functions and their return of values now can state code as: k1 = h f[x, yn], etc...

[07] Not using symbol, *, for multiplication helps in de-cluttering the code.

[08] In RK4 the inputs (x, y, m, h) are declared globally to accommodate variants of initial value problems.

[09] Coefficients declaration (i.e. k1,...) changed and this makes their intent more clear.

[10] With all your observations, the code have been changed and the need for TWICE evaluation is abolished!!!

Currently I will use your observations on a package to solve BVP. Please be sure that as I found setbacks, I will seek the advise of experts like you on this forum.

Thanks!!!

Attachments:
POSTED BY: Marcolino R-M
POSTED BY: Murray Eisenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard