Representing non-linear reaction term in matrix form (homework 5)