Artificial intelligent assistant

overflow, round-off error a) If the following function is written in a program, in what range of x would overflow or zero divide originated from round-off error occur? > $f(x) = \frac{1}{1-tanh(x)}$ Assume that the smallest positive number is 3 x 10 ^ 39 and machine epsilon is $1.2 x {10^-}^1$ b) rewrite the equation so that no subtraction is necessary.

Express $\tanh x$ with the exponential function: $$\tanh x = \frac{\sinh x}{\cosh x}=\frac{e^{x}-e^{-x}}{e^{x}+e^{-x}}=\frac{e^{2x}-1}{e^{2x}+1}$$ and get $$f(x)=\frac{1}{1-\tanh x}=\frac{1}{1 - \frac{e^{2x}-1}{e^{2x}+1}}= \frac{e^{2x}+1}{e^{2x}+1-(e^{2x}-1)}=\frac{e^{2x}+1}{2}=\frac{1}{2}+\frac{e^{2x}}{2}$$ Obviously overflow cannot be avoided for large x because the function goes to $\infty$, but my expression does not suffer from cancellation error for large $x$ where $\tanh x \approx 1.$

And since you do not have corrected your machine/arithmetic constants, your range questions have no definit answers (e.g. division by zero would occur if $\tanh x -1=0$ in your arithmetic, for IEEE single this would be for $x > 9.1$)

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 51be06c297f3186caf6097662a7b3273