コード例 #1
0
%matplotlib inline
from math import pi
from scipy.integrate import odeint  # integrates a system of ODEs
import numpy as np
import matplotlib.pyplot as plt
plt.install_repl_displayhook()

# change some of the defaults for plots
plt.rcParams['text.usetex'] = False
plt.rcParams['axes.grid'] = True
plt.rcParams['figure.figsize'] = [12,6]
plt.rcParams['axes.labelsize'] = 16
plt.rcParams['legend.fontsize'] = 16
plt.rcParams['xtick.labelsize'] = 14
plt.rcParams['ytick.labelsize'] = 14
from IPython.display import display, Markdown, Latex, Math, Pretty

############################ constants
m = 1                      # mass
ell = 1                    # length
g = 10                     # free-fall acceleration
Omega = np.sqrt( g / ell ) # natural frequency
N = 100                    # number of time steps per period
n = 10                     # number of periods
############################ calculated constants
T = 2*pi/Omega             # period
dT = T / N                 # time step
t = np.arange(0,n*T,dT)    # times, $t_i, i=0...nN-1$

コード例 #2
0
 def __exit__(self, exc_type, exc_value, traceback):
     if self.wasinteractive:
         interactive(True)
         install_repl_displayhook()
     del self.wasinteractive