In [53]:
import numpy

matrix_A = numpy.matrix('1,-1,-1,0,0,0;0,1,0,-1,-1,0;0,0,1,1,0,-1;0,6,0,0,4,0;0,0,12,0,0,8;0,0,0,0,4,-8')
matrix_B = numpy.matrix('0;0;0;20;20;0')

print("Matrix A:")
print(str(matrix_A))
print("Matrix B:")
print(matrix_B)

matrix_A_inverse = numpy.linalg.inv(matrix_A)

dot_product = numpy.dot(matrix_A_inverse,matrix_B)
#print(type(dot_product))

print('')
for i in range (0, len(dot_product)):
    current_string = "current " + str(i) + ": " + str(dot_product.item(i)) + " amps"
    print(current_string)


Matrix A:
[[ 1 -1 -1  0  0  0]
 [ 0  1  0 -1 -1  0]
 [ 0  0  1  1  0 -1]
 [ 0  6  0  0  4  0]
 [ 0  0 12  0  0  8]
 [ 0  0  0  0  4 -8]]
Matrix B:
[[ 0]
 [ 0]
 [ 0]
 [20]
 [20]
 [ 0]]

current 0: 3.0 amps
current 1: 2.0 amps
current 2: 1.0 amps
current 3: 0.0 amps
current 4: 2.0 amps
current 5: 1.0 amps

In [86]:
sigma_1 = (1 + numpy.sqrt(5)) / 2
sigma_2 = (1 - numpy.sqrt(5)) / 2 

print(sigma_1)
print

coefficient_string = '%4.5f,%4.5f;%4.5f,%4.5f' % ( sigma_1, sigma_2, sigma_1**2, sigma_2**2 )
coefficient_matrix = numpy.matrix(coefficient_string)
matrix_right = numpy.matrix('1;2')

matrix_left_inverse = numpy.linalg.inv(matrix_left)
solutions = numpy.dot(matrix_left_inverse,matrix_right)
print(solutions)

print(sigma_1/numpy.sqrt(5))
print(-sigma_2/numpy.sqrt(5))


1.61803398875

[[ 0.7236076]
 [ 0.2763924]]
0.72360679775
0.27639320225

In [21]:
x2 = numpy.arange(3.0)
x1 = numpy.arange(9.0).reshape((3,3))

numpy.multiply(x1,x2)


Out[21]:
array([[  0.,   1.,   4.],
       [  0.,   4.,  10.],
       [  0.,   7.,  16.]])

In [98]:
if type(x1) != type(sigma_1):
    print(type(sigma_1))
    
float_test = 1 + 5**0.5
try:
    print(type(len(float_test)))
except:
    print('hi')


<type 'numpy.float64'>
hi