What Are We Going To Use?For building our integral calculator, you need to have 3 things:-
- Python 3 Installed On your computer.
- Basic Knowledge Of maths (If I Say Basic, I mean very less 😛 )
- A maths library called Sympy (Will tell you how to install that further in the article )
1- Making Indefinite Integral Calculator On PythonSo here is the code of python script to make Indefinite Integral calculator. Just copy and make a new .py file and save it.
from sympy import Symbol, integrate equation = input("Enter Equation : ") x = Symbol('x') result = integrate(equation, x) print(result)Now after saving your python file. Run it. Now it asks you to enter your integral equation. Just enter Your equation. Note:- While writing your equation, be sure that for multiplication you have to use “*” symbol. And for raising exponential power, you have to use “**“. For example
x+(4*x) – 36
(4*x) + 23 + (x**3)If you have any doubt in entering equations, you can comment down. I will help you with that. Now lets head over to another part, that is calculating definite integral on python.
2- Making Definite Numerical Integration On PythonNow let me tell you how you can also calculate definite Numerical integration on python. Like the previous one, again copy and paste the below script in a new.py file.
from sympy import Symbol, integrate equation = input("Enter Equation : ") lowerlimit = str(input("Enter Lower Limit: ")) upperlimit = str(input("Enter Upper Limit : ")) x = Symbol('x') result = integrate(equation, (x, lowerlimit, upperlimit)) print(result)After saving the file. Just run it, and it will ask you to enter the equation. As mentioned previously you have to enter the equation in the same manner. After Entering the equation, it will ask you to enter the lower limit and the upper limit of your equation. Then, after entering all the 3 things. It will calculate the answer and then it will show to you.