Question: 3. The following Matlab function function y mytanh (x) y (exp(x)-exp(-x))/(exp(x)+exp(-x)) for computing tanh(x) = (e* -e*)/(e*+e) was found to return NaN for large

3. The following Matlab function function y mytanh (x) y (exp(x)-exp(-x))/(exp(x)+exp(-x)) for computing tanh(x) = (e* -e*)/(e*+e) was found to return NaN for large values of |x| (say x = 1000). Rewrite the code so that it computes accurate values for both large and small values of x whether x is positive or negative. Test your code for the values: x = 10%, k = -2, -1, 0, 1, 2, 3. Submit your code and your test results. You can compare with the built-in function tanh.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
