I don’t see ‘P’ anywhere, so I’ll wait for clarification on it.
The rest is relatively straightforward:
First, consider the triangle on the right —
For the area, since it’s a right triangle, D = base = height and the area of it is —
The area of the rectangle bounded by L and W is obvious.
So the area of the entire figure is —
I’ll leave you to simplify this expression and do all the coding. (It’s all just secondary-school geometry and algebra.)