def energy_corrections(perturbation, n, a=10, mass=0.5):
 (x, _a) = var('x _a')
 Vnm = (lambda n, m, a: Integral(((X_n(n, a, x) * X_n(m, a, x)) * perturbation.subs({_a: a})), (x, 0, a)).n())
 return (E_n(n, a, mass).evalf(), Vnm(n, n, a).evalf(), (((Vnm(n, (n - 1), a) ** 2) / (E_n(n, a, mass) - E_n((n - 1), a, mass))) + ((Vnm(n, (n + 1), a) ** 2) / (E_n(n, a, mass) - E_n((n + 1), a, mass)))).evalf())

def energy_corrections ( perturbation , n , a = 10 , mass = 0.5 ) : ( x , _a ) = var ( 'x _a' ) Vnm = ( lambda n , m , a : Integral ( ( ( X_n ( n , a , x ) * X_n ( m , a , x ) ) * perturbation . subs ( { _a : a } ) ) , ( x , 0 , a ) ) . n ( ) ) return ( E_n ( n , a , mass ) . evalf ( ) , Vnm ( n , n , a ) . evalf ( ) , ( ( ( Vnm ( n , ( n - 1 ) , a ) ** 2 ) / ( E_n ( n , a , mass ) - E_n ( ( n - 1 ) , a , mass ) ) ) + ( ( Vnm ( n , ( n + 1 ) , a ) ** 2 ) / ( E_n ( n , a , mass ) - E_n ( ( n + 1 ) , a , mass ) ) ) ) . evalf ( ) )
calculating first two order corrections due to perturbation theory and returns tuple where zero element is unperturbated energy .