##Transient analysis
##pg no - 8.17
##example no - 8.13
import math
import numpy
a=((10.*30.)/(10.+30.));
d=5./a;
b=0.;
c=5.*(20./30.);
print"%s %.2f %s"%("iL(0-) = ",d," A");
print"%s %.2f %s"%("\nvb(0-) = ", b,"");
print"%s %.2f %s"%("\nva(0-) = ",c," V");
print("Applying Kcl equations at t=0+");
print("((va(0+)-5)/10)+(va(0+)/10)+(va(0+)-vb(0+))/20 = 0"); ##equation 1
print("((vb(0+)-va(0+))/20)+((vb(0+)-5)/10)+(2/3) = 0"); ##equation 2
##solving 1 and 2
M=numpy.matrix([[0.25, -0.05],[-0.05, 0.15]]);
N=numpy.matrix([[0.5], [-0.167]]);
X=numpy.dot(numpy.linalg.inv(M),N);
print[X]
print("va(0+)= 1.9 A");
print("vb(0+)= -0.477 A");
##Transient analysis
##pg no - 8.17
##example no - 8.13
print("va(0+) = 5V");
print("vb(0+) = 5V");
print("vb(0+) = 5V");
print("Writing KCL Equation at t=0+");
print("0.25*va(0+) = 0.75");
x=(0.75)/(0.25);
print"%s %.2f %s"%("va(0+) = ",x," V");