Homework Help

can you please explain step by step the math how did we get the last version of this equation. I didn't know what to do after the second step.