Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Suppose I have a recurrence:

$$ F_{i+1} = U_i F_i $$

and I expand it out:

$$ F_n = U_n U_{n-1} ... U_1 U_0 F_0 $$

I want to speed up some code by pre-computing parts of this large matrix chain. One of my $U$ terms, say $U_k$, is going to vary a lot, so I rewrite this:

$$ F_n = A U_k B F_0 $$

Where $A$ and $B$ could be the identity matrix based on the position of $U_k$ in the chain. As I understand it the multiplication is associative so it's OK that I've done this.

So the logic seems to hold up until I actually start to vary $U_k$ around. I can compute $F_n$ the long and short way all the same if I leave $U_k$ undisturbed. Once I start to vary it I can get some really wildly different answers.

A few other things to help sniff out the problem:

  • I'm actually varing 3 of my $U$ terms in the same manner shown.
  • $U_k$ is varied by two parameters unrelated to the rest of the multiplication.

Is there something mathematically wrong here or is it a coding error to blame?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.