Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Code cleanup example

Original code, based on code from the free E-book Computational Physics: Problem Solving with Python, 3rd edition, by Landau, Páez, and Bordeianu. Modified primarily to use matplotlib instead of VPython.

<Figure size 500x500 with 1 Axes>

Try to clean it up. Two possible solutions: one closer to the original (but fixing some bugs, like the plot title color being wrong!):

Notebook Cell
<Figure size 500x500 with 1 Axes>

And one going a bit further and vectorizing the function properly, and fixing the color display:

Notebook Cell
<Figure size 500x500 with 1 Axes>