function [Ptotal] = PtotalForFixedR1(R1)

global Rdesired;
global R;

R2 = 1/(1/Rdesired-1/R1);


if log10pe > -200
    
    pe = 10^(log10pe);

    Ptstart1 = 2^(2*R1*(1-hb(pe)))  - 1;
    Ptstart2 = 2^(2*R2*(1-hb(pe)))  - 1;
    
    
else 
    
    Ptstart1 = 2^(2*R1)-1;
    Ptstart2 = 2^(2*R2)-1;
    
end

Ptend = 100;

%for R = 0.1:0.1:2

%    R

R = R1;

[Ptopt1, Ptotalmin1] = fminbnd(@findtotalpower,Ptstart,Ptend,optimset('TolX',1e-12));


R = R2;

[Ptopt1, Ptotalmin1] = fminbnd(@findtotalpower,Ptstart,Ptend,optimset('TolX',1e-12));


if Ptopt1>9
    disp('Perror:: Ptopt1>99');
end


if Ptopt2>99
    disp('Perror:: Ptopt2>99');
end


Ptotal = ((1/R1)*Ptotalmin1 + (1/R2)*Ptotalmin2)   /  ( 2/Rdesired );