Question: 3. The following Matlab function function y = mytanh (x) y = (exp(x)-exp(-x) ) / (exp(x) +exp(-x) ) for computing tanh(x) = (er-e-x)/( large values

3. The following Matlab function function y = mytanh (x) y = (exp(x)-exp(-x) ) / (exp(x) +exp(-x) ) for computing tanh(x) = (er-e-x)/( large values of] (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%, k2.-1, 0, 1, 2, 3. Submit your code and your test results. You can compare with the built-in function tanh. e +e*) was found to return NaN for
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
