CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: test
Views: 91872
1
# -*- coding: utf-8 -*-
2
"""
3
Created on Tue Apr 21 18:40:47 2015
4
5
@author: Roger
6
"""
7
8
9
10
11
def dx(t, y):
12
return y
13
14
15
def euler(t0, tmax, y0, dx, step=1.):
16
t = t0
17
y = y0
18
while t < tmax:
19
f = dx(t,y)
20
y = y + step*dx(t, y)
21
t +=step
22
23
return y
24
25
26
print(euler(0, 4, 1, dx, step=0.25))
27