% calculating inverse of the entropy function in steps determined by the number itself! 

function [entinv] = hbinv(x)

z = 0; % Initial value

imax = 2.*log2(1./x)+70;

for i = 1:imax % for 200, 10^-53, for 100, 10^-30
    
    y = (2.*z + 2^(-i))/2; % the mid point of the current interval.
    
    if hb(y) < x
        
        z = z + 2^(-(i+1));
        
    end
    
end

entinv = z;
