Skip to content

Instantly share code, notes, and snippets.

@ariesobj
Created May 25, 2016 02:42
Show Gist options
  • Save ariesobj/01e83589479e0d27a6c7fe357a97fb46 to your computer and use it in GitHub Desktop.
Save ariesobj/01e83589479e0d27a6c7fe357a97fb46 to your computer and use it in GitHub Desktop.
import math
# One of the method for solving odes numerically
# Given a implicit function and x for initial x to marched to
def euler_method(implicit, x, y, marched, cleavage):
dx = (marched - x) / cleavage
for i in range(cleavage):
y = y + dx * implicit(x, y)
x += dx
return y
def diff_circle(x, y):
return -x/y
def antiderivative(r, x):
return math.sqrt(r*r - x*x)
def test(r, marched, cleavage):
print(euler_method(diff_circle, 0, r, marched, cleavage))
print(antiderivative(r, marched))
def
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment