This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import time | |
import matplotlib.pyplot as plt | |
#function | |
def f(x): | |
y = x**2 - 4*x*np.sin(x) + (2*np.sin(x))**2 | |
return y | |
#routine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## a second order differential equation | |
## D2 y + 2 r w D y + w^2 y = 0 | |
# D is the differential operator | |
# r is the damping ratio (r = c/(2mw)) | |
# w is the undamped frequency | |
# c is the viscous damping coefficent | |
# m is the mass | |
#//////////////////////////////////////////////////////////////////////////////// | |
#// // | |
#// Description: // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vanilla RK4 written in R (07Dec2011) | |
# evaluates a 2nd order ODE by splitting into 2- 1st order ODE | |
# and solved by Runge-Kutta Method | |
# Concepts and algorithm from: | |
# http://en.wikipedia.org/wiki/Runge-Kutta_methods | |
# http://www.cms.livjm.ac.uk/etchells/notes/ma200/2ndodes.pdf | |
# | |
# f1(t,y) : substituted function from dz(y')/dt = F(z,y,t), z = y' | |
# | |
# rk4(f, h, tinit, yinit, limit): main RK4 routine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vanilla RK4 written in R (09Dec2011) v1.1 | |
# evaluates a 2nd order ODE by splitting into 2- 1st order ODE | |
# and solved by Runge-Kutta Method | |
# Concepts and algorithm from: | |
# http://en.wikipedia.org/wiki/Runge-Kutta_methods | |
# http://www.cms.livjm.ac.uk/etchells/notes/ma200/2ndodes.pdf | |
# | |
# f1(t,y) : substituted function from dz(y')/dt = F(z,y,t), z = y' | |
# | |
# rk4(f, h, tinit, yinit, limit): main RK4 routine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cat_n_times(s, n): | |
print n*str(s) | |
def is_divisible_by_3(n): | |
if n%3 == 0: print "This number is divisible by 3." | |
else: print "This number is not divisible by 3." | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.misc import * | |
import time | |
def func(x): | |
return x*x - 4*x*np.sin(x) +(2*np.sin(x))**2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = "Chester Balingit" | |
import numpy as np | |
from scipy import optimize | |
import matplotlib.pyplot as plt | |
## Part 1 - Find all the zeros of the function: | |
## f(x) = cos(x) - xsin(x) using the optimize.brentq | |
## function of the scipy library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.optimize as optimize | |
import numpy as np | |
import collections | |
import matplotlib.pyplot as plt | |
from numpy import random | |
def sampler(points,mu,sigma): | |
return np.linspace(0, 2*np.pi, points), \ | |
np.sin(np.linspace(0, 2*np.pi, points)) \ | |
+ random.normal(mu,sigma,size=(points)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
func = lambda x: np.sin(x) | |
d1func = lambda x: np.cos(x) | |
d3func = lambda x: -1*np.cos(x) | |
def trapezoidal(func, n, dfunc='null',dddfunc='null', x0=0, xn=np.pi): | |
x = np.linspace(x0, xn, n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import networkx as nx | |
from plots import * | |
import pickle | |
#bump | |
def coord_solver(trigs, rad): | |
""" |
OlderNewer