-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
47 lines (41 loc) · 989 Bytes
/
functions.py
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
42
43
44
45
46
47
import math
from graph import Graph
class Functions:
"""
Class for functions
"""
def linear(self, m, b):
"""
Linear function
"""
x = range(-8, 8)
y = [m * i + b for i in x]
return Graph(x, y)
def quadratic(self, a, b, c):
"""
Quadratic function
"""
x = range(-8, 8)
y = [a * i ** 2 + b * i + c for i in x]
return Graph(x, y)
def cubic(self, a, b, c, d):
"""
Cubic function
"""
x = range(-8, 8)
y = [a * i ** 3 + b * i ** 2 + c * i + d for i in x]
return Graph(x, y)
def exponential(self, a, b):
"""
Exponential function
"""
x = range(-4, 8)
y = [a * b ** i for i in x]
return Graph(x, y)
def logarithmic(self, b):
"""
Logarithmic function
"""
x = range(1, 15)
y = [math.log(i, b) for i in x]
return Graph(x, y)