|
6 | 6 |
|
7 | 7 | from sympy import Integral, Symbol, SympifyError, sympify |
8 | 8 |
|
9 | | -def find_area(f1x, f2x, var, a, b): |
10 | | - a = Integral(f1x-f2x, (var, a, b)).doit() |
| 9 | +def find_area(f, g, var, a, b): |
| 10 | + a = Integral(f-g, (var, a, b)).doit() |
11 | 11 | return a |
12 | 12 |
|
13 | 13 | if __name__ == '__main__': |
14 | | - f1x = input('Enter the upper function in one variable: ') |
15 | | - f2x = input('Enter the lower upper function in one variable: ') |
| 14 | + f = input('Enter the upper function in one variable: ') |
| 15 | + g = input('Enter the lower upper function in one variable: ') |
16 | 16 | var = input('Enter the variable: ') |
17 | 17 | l = float(input('Enter the lower bound of the enclosed region: ')) |
18 | 18 | u = float(input('Enter the upper bound of the enclosed region: ')) |
19 | 19 |
|
20 | 20 | try: |
21 | | - f1x = sympify(f1x) |
22 | | - f2x = sympify(f2x) |
| 21 | + f = sympify(f) |
| 22 | + g = sympify(g) |
23 | 23 | except SympifyError: |
24 | 24 | print('One of the functions entered is invalid') |
25 | 25 | else: |
26 | 26 | var = Symbol(var) |
27 | | - print('Area enclosed by {0} and {1} is: {2} '.format(f1x, f2x, find_area(f1x, f2x, var, l, u))) |
| 27 | + print('Area enclosed by {0} and {1} is: {2} '.format(f, g, find_area(f, g, var, l, u))) |
0 commit comments