Definite Integration using Python

Python Coding
Aug 10, 2024

--

import sympy as sp

x = sp.Symbol('x')
f = input("Enter the function(in terms of x):")

F_indefinite = sp.integrate(f, x)
print("Indefinite integral ∫f(x) dx =", F_indefinite)

a = float(input("Enter the lower limit of integration: "))
b = float(input("Enter the upper limit of integration: "))

F_definite = sp.integrate(f, (x, a, b))
print(f"Definite integral ∫f(x) dx from {a} to {b} =", F_definite)

#clcoding.com
Indefinite integral ∫f(x) dx = x**3/3 + 3*x
Definite integral ∫f(x) dx from 9.0 to 27.0 = 6372.00000000000

--

--

Python Coding
Python Coding

Written by Python Coding

Learn python tips and tricks with code I Share your knowledge with us to help society. Python Quiz: https://www.clcoding.com/p/quiz-questions.html

No responses yet