Making matrix solver/ solver for X

steffie.booij at gmail.com steffie.booij at gmail.com
Thu Apr 12 18:53:10 EDT 2018


Hee guys,

I'm learning Python partly for school and wanted to see if I could figure some things out myself.

I wanted to make like a value finder, sort of like numpy.solve (sounds more ambitious than it is) but I'm sort of stuck, since I'm a beginner.

Let's say I want to find the values of matrix X with X1, X2, X3 and X4. And that X is multiplied with matrix Q and then X substracted from it.

I thought about:

X = np.array(['X1', 'X2', 'X3', 'X4'])

Q = np.array(['Q1', 'Q2', 'Q3', 'Q4'])

P = (X*Q)-X

I chose array's since all the X and Q values can be different.

How would I be able to find the values of X if the Q-array would be given and it would have to be solved under the condition that out of 4 P values, at least 2 would be more or equal to sum of X.

So solve condition:
P[0]+P[1] ,P[0]+P[2] ,P[0]+P[3] ,P[1]+P[2] ,P[1]+P[3] ,P[2]+P[3] >= np.sum(X)

So summary:
If Q is given here, and only X is unknown, and P has only one unknown (X-array), how can I calculate the X-matrix with the solve condition?

Can you guys help me? I feel like it's an easy set of lines of code, but like I said I'm still trying to learn. And improvise to see if I understand it.


More information about the Python-list mailing list