function [Ptotal] = findtotalpower(Pt2)
% I know Pt, gamma, pe, and I find power required.

global  gamma;
global Pt;
global maxdeg;

Pt = Pt2;

[gopt,nmax] = maxnforpt();

%Pt
%nmax

Ptotal = Pt + gamma*log2( ((maxdeg-2)/maxdeg)*nmax  + 2/maxdeg )  /  log2(maxdeg-1);



