I bet £20 at odds of 3.0. I have the chance to hedge this bet by laying an amount £$L$ at odds of 3.2, but will have to pay 5% commission on the winnings. How should I choose $L$ to maximise my minimum payoff?
Original post below:
Could someone please help me out with the equations behind this calulator? I need to work out the equation for the lay stake which gives an answer of £19.05 in the example. I hope this question makes it a bit clearer. Any help is greatly appreciated. Here is an example

You can have a look at Wikipedia article about betting exchanges for more details on what backing and laying actually means. Notice that to make profit, laying odds have to be lower than backing odds. (Laying odds say how much you have to pay out.) So in the situation described in your post you would be losing money.
In everything I write below I will use decimal odds.
Laying as usual betting. Laying means that you behave like a bookmaker. I.e., you accept bet from another user of the betting exchange. Other than that, it is basically betting on the opposite outcome but with different odds. Namely if the odds are $o$ and if the amount is $b$, laying means that you accepted somebody's bet with odds $o$ and they wagered amount $b$.
So if you prefer to think about laying this way, it is the same as the usual betting, but you have to modify the odds to $$O=\frac{o-c}{1-c}.$$ You can find information how to calculate profit for complementary events here: How is potential profit from an arbitrage bet (a.k.a. surebet) calculated? (sports.SE).
This calculator. Let us check what you actually calculate in the linked calculator.
With one bookmaker, you have wagered $b'$ for odds $o'$, so there you stand to win $o'b'$ or lose $b'$. The situation with the betting exchange is analysed above.
You want to maximize your profit, which means that possible win (including wagered amount) is in both cases the same. That means \begin{gather*} W=b(o-c)=o'b' \end{gather*} From this you get $$b=\frac{o'}{o-c}\cdot b'.$$ This means you are wagering (risking) $B=b'+b(o-1)$.
The total profit will be $W-B$.
In your case $b'=20$, $o'=3.2$, $o=3.2$, so you get $$b=\frac{3}{3.2-0.05}\cdot20 \doteq 19.05.$$ Google calculator
In the case of either outcome, total winnings are $o'b'=60$. But after subtracting $B=b'+b(o-1)=20+19.048\cdot2.2 \doteq 61.91$ you see that you are actually Google calculator loosing around $1.91$.
To summarize once again in numbers what was described in symbols above:
In fact, the amount you are losing (or winning) should be the same in both cases, the difference above is due to rounding errors.