2
2
from sympy import lambdify , symbols , sympify
3
3
4
4
5
- def get_inputs ():
5
+ def get_inputs () -> tuple :
6
6
"""
7
7
Get user input for the function, lower limit, and upper limit.
8
8
@@ -23,7 +23,7 @@ def get_inputs():
23
23
return func , a , b
24
24
25
25
26
- def safe_function_eval (func_str ):
26
+ def safe_function_eval (func_str ) -> float :
27
27
"""
28
28
Safely evaluates the function by substituting x value using sympy.
29
29
@@ -41,7 +41,7 @@ def safe_function_eval(func_str):
41
41
return lambda_func
42
42
43
43
44
- def compute_table (func , a , b , acc ):
44
+ def compute_table (func , a , b , acc ) -> tuple :
45
45
"""
46
46
Compute the table of function values based on the limits and accuracy.
47
47
@@ -71,7 +71,7 @@ def compute_table(func, a, b, acc):
71
71
return table , h
72
72
73
73
74
- def apply_weights (table ):
74
+ def apply_weights (table ) -> list :
75
75
"""
76
76
Apply Simpson's rule weights to the values in the table.
77
77
@@ -98,7 +98,7 @@ def apply_weights(table):
98
98
return add
99
99
100
100
101
- def compute_solution (add , table , h ):
101
+ def compute_solution (add , table , h ) -> float :
102
102
"""
103
103
Compute the final solution using the weighted values and table.
104
104
@@ -122,15 +122,15 @@ def compute_solution(add, table, h):
122
122
from doctest import testmod
123
123
124
124
testmod ()
125
-
126
- func , a , b = get_inputs ()
127
- acc = 1
128
- solution = None
129
-
130
- while acc <= 100_000 :
131
- table , h = compute_table (func , a , b , acc )
132
- add = apply_weights (table )
133
- solution = compute_solution (add , table , h )
134
- acc *= 10
135
-
136
- print (f" Solution: { solution } " )
125
+
126
+ # func, a, b = get_inputs()
127
+ # acc = 1
128
+ # solution = None
129
+
130
+ # while acc <= 100_000:
131
+ # table, h = compute_table(func, a, b, acc)
132
+ # add = apply_weights(table)
133
+ # solution = compute_solution(add, table, h)
134
+ # acc *= 10
135
+
136
+ # print(f' Solution: {solution}' )
0 commit comments