-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.py
More file actions
41 lines (33 loc) · 673 Bytes
/
functions.py
File metadata and controls
41 lines (33 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import math
import numpy as np
class Functions:
"""
x(0) = 1
0 <= t <= 1
"""
@staticmethod
def f1(t, x):
return -2 * x + math.exp(t)
@staticmethod
def f1_solution(t):
return (1 / 3) * np.exp(-2 * t) * (np.exp(3 * t) + 2)
"""
x(1) = 0
1 <= t <= 2
"""
@staticmethod
def f2(t, x):
return -(x/t) + 1 + 1/t
@staticmethod
def f2_solution(t):
return (t - 3/t + 2)/2
"""
x(1) = -1
1 <= t <= 2
"""
@staticmethod
def f3(t, x):
return (x*x + t*t) / (t*x)
@staticmethod
def f3_solution(t):
return -t * math.sqrt(2 * math.log(t) + 1)