function P = optpower(epsil, n, R);
% compute the smallest required power to communicate at rate R with p.e. epsil and blocklength n
K = @(A) A./sqrt(2) .* sqrt(A.^2 + 2)./(A.^2 + 1) *log2(exp(1)) * norminv(epsil, 0, 1);

normapx = @(A) 1/2 * log2(1 + A.^2) + K(A)/sqrt(n) + 1/2 *log2(n)/n;
A0 = sqrt(2^(2*R) - 1);
A1 = fzero(@(A) normapx(A) - R, A0);
P = A1^2;

yp-mit
github-repos/MATLAB/yp-mit-spectre/spectre-57af76799e4eb43aa707cc13c4c5220d281e0b78/awgn/optpower.m
spectre
github-repos/MATLAB/yp-mit-spectre
57af76799e4eb43aa707cc13c4c5220d281e0b78