% Avoiding overflows 

x=input('Input x to evaluate e^x/(e^x+1):  ');
format long e
e=exp(x);
y=e/(e+1);
fprintf('\n  exp(x) \t\t= \t%1.16e\n  (e+1)/e \t= \t%1.16e\n\n',e,y);

e=exp(-x);
y=1/(e+1);
fprintf('\n  exp(-x) \t\t= \t%1.16e\n  1/(1+e) \t= \t%1.16e\n\n',e,y);

