I want to find the representation of vector (-9, 1, -9/2)
in basis B =
{v1, v2} = {(10, 4, 5), (2, 1, 1)}
using python. I know that the answer is
(-11/2, 23)
, this question is on how to find that result using python. I'm
not interested in writing the algorithm from scratch, but instead am
wondering what methods from numpy / similar libraries I should use.
Given the following matrix:
A = np.array([ [10,2,-9], [4, 1, 1], [5, 1, -9/2]])
array([[10. , 2. , -9. ],
[ 4. , 1. , 1. ],
[ 5. , 1. , -4.5]])
The result should be
array([[ 1 , , -11/2 ],
[ , 1 , 23 ],
[ , , 0]])
Note - I've typed the result out there, I'm not necessarily expecting results represented as fractions using sympy or such.
If this were to be computed by hand, the steps might be as follows:
Step 1
10 2 -9
4 1 1
5 1 -9/2
Step 2
1 1/5 -9/10
4 1 1
5 1 -9/2
Step 3
1 1/5 -9/10
0 1/5 4.6
0 0 0
Step 4
1 0 -5.5
0 1 23
0 0 0
Edit
The following may be used:
In [2]: A = np.array([ [10,2,-9], [4, 1, 1], [5, 1, -9/2]])
In [5]: sympy.Matrix( A ).rref()
Out[5]:
(Matrix([
[1, 0, -5.5],
[0, 1, 23.0],
[0, 0, 0]]),
(0, 1))
Somewhat surprised there's no solution using NumPy.