Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bonus notebook #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

rockets818
Copy link

No description provided.

@rockets818
Copy link
Author

Here is my bonus notebook.
While I was struggling with controlling Github app, I submitted my notebook via e-mail.
As I solved the problem controlling Github, I just committed my notebook and pull a request.

Happy New Year.

Sungrae Kim

@labarba
Copy link
Member

labarba commented Jan 9, 2015

I don't know if you realized it, but Heun's method is just a variant of modified Euler's method or of 2n-order Runge-Kutta, which we covered in lesson 4 of Module 1:
http://nbviewer.ipython.org/github/numerical-mooc/numerical-mooc/blob/master/lessons/01_phugoid/01_04_Second_Order_Methods.ipynb

The version we showed in the course lesson uses the slope evaluated at the starting point to step forward by a half-time-step, then obtains the slope at that mid-point using the original ODE to advance the full time step from the starting point with a "better" slope. The version you show takes the full time step from the starting point with the average of the slope on the left side of the interval and the right side of the interval. This is still an explicit midpoint method!

I'm not suer why you have defined two functions called euler() that do exactly the same and I'm a little uneasy that you might have a fundamental misconception about the naming of input variables, which is immaterial. You also have the function heun() defined twice ...

The notebook, as you submitted it, does not fully run. We get a first error: NameError: name 'mpl' is not defined when executing:
mpl.rcParams['legend.fontsize'] = 10
(I'm guessing you copied this line from another code). I fixed it by executing instead:

from matplotlib import rcParams
rcParams['legend.fontsize'] = 10

You also forgot to load:

%matplotlib inline

and thus your plot pops up as a new window.

There's a new error further below, in the cell that calls your heun() function for the first time, where we get:
TypeError: 'numpy.ndarray' object is not callable

You submitted broken code!

Overall, a passable but scanty effort at a course project.

*other typos/mistakes
breifly—>briefly (again below)
we need to suppose—>we need to assume

"When we reduce the timestep..."—>When we reduce the timestep by one half...
"...Heun's method may yield the result 4 times(=2^2) accurable"—>a result 4 times ... more accurate

@rockets818 rockets818 changed the title Sungrae's bonus notebook Bonus notebook Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants