Created
May 25, 2016 02:42
-
-
Save ariesobj/01e83589479e0d27a6c7fe357a97fb46 to your computer and use it in GitHub Desktop.
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 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