Code_ninja
Code_ninja

Reputation: 117

Solve linear recursive matrix

I have the equation:

S= C.(BSQ)+(1-C)I where S,B,Q are square matrices of nXn dim,C is a constant and I is identity matrix.S is initialised to identity matrix I want to solve the equation to find S.Can I do this without taking any inverse on both sides and then simplifying and so on?(I am working with large datasets taking inverse might be very slow)By just using the above equation I got some results but I am not sure if its correct as you cant do three matrix multiplications simultaneously.What can I do to solve for S?

the answer I am getting after plugging in all the matrices with values

Upvotes: 1

Views: 302

Answers (2)

ubuntu_noob
ubuntu_noob

Reputation: 2365

for t in range(100):

        s=c*(sc.dot(sc.dot(Qin.T,s),Qin))+ (1-c)*I

This solves the equation recursively 100 times.You can do a convergence test that is Si-Si-1=some small value to check for convergence too.

Upvotes: 0

Nico Schertler
Nico Schertler

Reputation: 32627

Depending on your matrices, you might be able to just iterate that formula and hope that it converges. I.e. start with S=I, and re-calculate S until it does not change anymore. Of course, this is not guaranteed to converge, but you might want to try.

If you want to solve that directly, you can derive a linear system. Just factor the RHS out (such that you get an expression for every entry in the resulting matrix) and set up equations for every entry. E.g. for the first entry, this would look like this:

s11 = 1 - c + c * (q11 * (b11 * s11 + b12 * s21 + b13 * s31 + ...) + 
                   q21 * (b11 * s12 + b12 * s22 + b13 * s32 + ...) + 
                   q31 * (b11 * s13 + b12 * s23 + b13 * s33 + ...) + 
                   ...)

Solve for the s.. and you're done. If the system admits a solution, of course. Otherwise, you might want to solve for a least-squares solution.

Upvotes: 0

Related Questions