function snr_db = bqpsk_approx(r)
last_err = 1;
for db = -2:0.01:10
    snr = db2pow(db);
    p= 0.5*erfc(sqrt(snr*r));
    right = 1+p*log2(p)+(1-p)*log2(1-p);
    error = abs(right-r);
    if (error<last_err)
        snr_db=db;
        last_err = error; 
    else
        break;
    end
end
