We can approach this problem in the following way:
1) We construct a variation equation for each variation
2) We combine these two
First variation equation would be:

This is a direct variation equation.
Second variation equation is:

This is a inverse variation equation.
We combine these two by multiplying them. This will give us our final function.
Let us call it f(x,z).

Since

and

are only constants we can just combine them and call their product k.
Our final function would be:
