Your function is complex-valued when g<0, as you can see from
Reduce[FunctionDomain[TP[x, g], {x, g}],
 {x, g}, Reals]
From a plot
Plot3D[TP[x, g], {x, 0, 1}, {g, 0, 10},
 PlotRange -> {-300, 0}]
I am tempted to guess that your function has no optimal point for x,g>0, or that the optimum is at x=Infinity, g=0. My suggestion is to give sensible constraints to x and g.