I own a very old fashion scientific calculator and it can’t solve any simultaneous equations like those new calculators (not even 2×2!). The situation goes worst when I try to do my Circuit Theory tutorial, in which I need to solve many simultaneous equations. Can’t I just concentrate on forming the equations and let someone to solve them for me?
Well! Let the Python do it!
All you have to do is forming the proper equations. Then, fire up the following script. Key in the proper coefficients of each equation when Python asks.
Please feel free to copy and use it anywhere you like.
import numpy as np
print 'How many variables ?'
print '>> ',
total_variable = int(raw_input())
# User key in all the variable numbers
equation_list = 
for i in range(total_variable):
print 'Please enter the coefficients of the #%d equation.' % (i+1)
print 'For example: (1)*x0 + (2)*x1 = (3) ---> "1 2 3"'
print '>> ',
user_input = raw_input()
user_token_str = user_input.split()
assert (len(user_token_str)== (total_variable +1))
user_token = [float(u) for u in user_token_str]
equation_arr = np.array(equation_list)
# A * X = Y
# Given A and Y, we need to find X.
Y_arr = equation_arr[:, -1:]
A_arr = equation_arr[:, :-1]
print 'Y_arr:' , Y_arr
print 'A_arr:' , A_arr
X_arr = np.linalg.solve(A_arr, Y_arr)
for i, x in enumerate (X_arr):
print 'x%d value: %f' % (i, x)
“Solve for the currents in the circult of Figure 2, if E(t)=5H(t-2) and the initial currents are zero. [Hint : Use Lapalce transform to solve this problem.]”
So, to solve it, form mesh analysis of two loops. Then, convert them from time domain to complex domain with Laplace transform. Next, solve I1 and I2 with normal algebra. Then only inverse I1 and I2 back to time domain.
Of cause, if you familiar with Sage, you can solve it within 30min (or lesser?).
I happened to be the last batch of speakers in SAINT2012 conference. Next year it will be merged with COMPSAC as “New COMPSAC”, which will be held in Kyoto in 2013. The name of “SAINT” will not be used anymore.
Happened to know that I have to teeeaaaach in the coming short-semester. It seems like I am getting far far away from my PhD completion. I blame noone but myself. When will I have the gut to tender resignation letter? When will I have the time to do nothing but my own research?
Visit some old cities of Turkey during the SAINT2012 conference. Tortured by the sunshine, and was amazed at the legacy of Ephesus.