Question: 1. The following Matlab function function y- mytanh (x) y (exp (x)-exp (-z) ) / (exp (x)-exp (-x)) for computing tanh(x) (ex-e-x)/(ex + e-x) was

 1. The following Matlab function function y- mytanh (x) y (exp

1. The following Matlab function function y- mytanh (x) y (exp (x)-exp (-z) ) / (exp (x)-exp (-x)) for computing tanh(x) (ex-e-x)/(ex + e-x) was found to return NaN for (a) Rewrite the code so that it computes accurate values for both large and (b) Test your code for the values: x 10%, k--2,-1, 0, , 2, 3 . Recre- large values of |x| (say x 1000) small values of x whether x is positive or negative. Submit your code ate the table below and fill it in with the values from your function rmytanh xtnh Cx) +10 +10 rmytanh(x)tanh(x) 10 10 +10 +10+ +10+ 10 10+ -10+ You can compare with the built-in function tanh. 2. The variance s2 of a set of values xi,x2, ...,Xn is given by 12 (xi-x)2, where 12 A commonly used alternative formula is Get the set of values from hw2q4datafile.mat, and compute the variance by the two formulas above. You can load the data into Matlab using

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!