If you are not sure from where these equations come, then watch this video for the explanation. Link: https://youtu.be/wHdamYfPYM4