-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
57 lines (46 loc) · 1.31 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
import numpy as np
from dotenv import load_dotenv, find_dotenv
import quack2tex
load_dotenv(find_dotenv())
@quack2tex.latify(model="models/gemini-1.5-flash-latest")
def sqrt(x: float):
"""
Compute the square root of a number.
:param x: The number.
:return: The square root of the number.
"""
x = x ** 0.5
return x
@quack2tex.latify(model="models/gemini-1.5-flash-latest")
def riemman_sum(f, a, b, n):
"""
Compute the Riemman sum of a function.
:param f: The function.
:param a: The lower bound.
:param b: The upper bound.
:param n: The number of subintervals.
:return: The Riemman sum.
"""
dx = (b - a) / n
return sum(f(a + i * dx) * dx for i in range(n))
@quack2tex.latify(model="models/gemini-1.5-flash-latest")
def gaussian_function(x):
"""
Compute the integral of a function.
:param x: The number.
:return: The integral of the number.
"""
return np.exp(-x**2)
@quack2tex.latify(model="models/gemini-1.5-flash-latest")
def standard_deviation(data):
"""
Compute the integral of a function.
:param f: The function.
:param a: The lower bound.
:param b: The upper bound.
:param n: The number of subintervals.
:return: The integral.
"""
return np.std(data)
if __name__ == "__main__":
quack2tex.run_app()