Diff equation calculation