log for forward and backward algorithm