You just need to plug those expressions inside the formula: it doesn't matter if they're expressions involving a variable instead of plain numbers: the formula becomes

If you want, you can simplify it by expanding the square and then multiply the two parenthesis:
