python - np.linalg.solve is not giving correct result -


i tried parameterize arbitrary t vector given bases ss function linalg.solve:

t = np.array([0.4, 0., 0., 0., 0., 0., 0., 0.3, 0., 0., 0., 0., 0.2, 0., 0., 0.1]) ss = np.array([[1.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  1.],            [0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.],            [0.,  0., -1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0., -1.,  0.],            [1.,  0.,  0.,  0.,  0.,  0.,  0., -1.,  0.,  0., -0.,  0.,  1.,  0.,  0., -1.],            [0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.],            [0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],            [0.,  0.,  0.,  0.,  0.,  0., -1.,  0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.],            [0.,  0.,  0.,  1.,  0.,  0.,  0., -0.,  0.,  0., -1.,  0.,  0.,  0.,  0., -0.],            [0.,  0.,  0.,  0., -1.,  0.,  0.,  0.,  0.,  0.,  0., -1.,  0.,  0.,  0.,  0.],            [0.,  0.,  0.,  0.,  0.,  0., -1.,  0.,  0., -1.,  0.,  0.,  0.,  0.,  0.,  0.],            [0.,  0.,  0.,  0.,  0., -1., -0.,  0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],            [0.,  0.,  0.,  0., -1.,  0.,  0., -0.,  0.,  0.,  0.,  1.,  0.,  0.,  0., -0.],            [1.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  0., -1., -0.,  0., -1.],            [0.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0., -0., -1.,  0., -0.],            [0.,  0., -1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0., -0.,  0.,  1., -0.],            [1.,  0.,  0.,  0.,  0.,  0.,  0., -1.,  0.,  0., -0.,  0., -1., -0.,  0.,  1.]]) 

then do:

para = sp.linalg.solve(ss, t)  print para  print np.dot(ss, para) == t 

i got:

[ 0.175 0. -0. 0.15 -0. 0. -0. 0.125 0. -0. -0.15 0. 0.025 -0. 0. 0.075]

[ true true true true true true true true true true true true true true true false]

clearly not right... why false happens?

looks it's rounding/numerical-approximation error:

t[-1] out[493]: 0.10000000000000001  np.dot(ss,para)[-1] out[495]: 0.099999999999999964 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -