Scroll to Top

Virtual Math Learning Center

Virtual Math Learning Center Texas A&M University Virtual Math Learning Center

Definite and Indefinite Integrals in Python

Author: David Manuel

In this video, it is demonstrated how to find solve definite and indefinite integrals using Python.

Transcript 09

Problem: Suppose we have an alternating current voltage \[v(t)=V\cos(\omega t).\] Calculate the following:

  1. \( \displaystyle \int (v(t)^2\, dt\)
  2. \( \displaystyle \int_0^{2\pi/\omega} (v(t))^2\, dt\)
  3. \( \displaystyle \text{rms}=\sqrt{\dfrac{\omega}{2\pi} \int_0^{2\pi/\omega} (v(t))^2\, dt}\)

Python Code:
from sympy import *

V,omega,t=symbols('V omega t', positive=True)
v=V*cos(omega*t)
v_int=(v**2).integrate(t)
#You can also use: v_int=integrate(v**2,t)
print(v_int)

vdef=integrate(v**2,(t,0,2*pi/omega))
print('The integral from 0 to 2pi/omega is', vdef)

rms=sqrt(omega/(2*pi)*vdef)
print('The root mean square value of the voltage is', rms)

Open Python Notebook File

See more videos from this section