Write script using Matlab (Mathworks)
Lessan Problem 22 Natwral Log The Taylor Series for the In(s) for any x in the range o 52 isiven by (-1)2*1 Obviously, we can't add an infinite number of terms together, but we wil use a terms to get an estimate for ln( number of terms together, but we will use a finite number of 1. In order to see how this algorithm works, il in Table below forx 1.25 Iterative Algorithm for In) 45 Initial Estimate 0 k1 Estimate Estimate+ (x-1/1 k 2 Estimate Estimate-(-1F/2 k 3 Estimate Estimate * (x-13" / 3 . k 4 Estimate Estimate W4 ILaJ Note: In(1.25)-0.2231. The algorit hm provides a pretty accurate estimate after only four terations for this particular number, x 125 write a script fle to estimate the natural log of a number which is greater than O and does . Your program should first prompt the user for the numberx, and for the number of 2. not exceed 2 using a finite number of terms from the Taylor Series desired terms, N Your program should check and see if x is an invalid number, that is, x is less than or equal to 0 or greater than 2. Use a while loop for this! if the number is invalid, prompt the user to enter a new valid value for the number. The while loop is nice because it will continue to prompt the user until the user finally enters an acceptable value of x * Your program should then use a for loop (for k 1N) to calculate the estimate of the natural log using N terms Remember: in MATLAB, natural log is log Hint: Look at Table above. Each iteration, Estimate Estimate New Term. The equation for the New Term changes every iteration. It obviously depends on see if you can figure out how to relate the equation to k (the index variable for your loop) also. . After the for loop, add an fprinet statement to display the estimate of the Inj) with places behind the decimal point 3. Test your program to make sure it doesn't accept invalid values for x Try negative values zero, and values above 2. 14PaR Test your program using the values you computed by hand in Table 4, 1.25 and try 1, 2, 3, and 4 terms 4. That is, choose xs S. Now use your program to complete Table below Test in Program Output x Number of Terms Actual Value for ln) Estimate for lInbo) 1.5 1.5 15 1.5 1.5 1.5 0.40546511 0.40546511 0.40546511 0.40546511 0.40546511 0.40546511 10 20