Added derivation of algorighm to latex notes