Question: Write MATLAB Live Script code ( . mlx file ) to estimate l n ( x ) for a user inputted value of x using
Write MATLAB Live Script code mlx file to estimate for a user inputted value of using the series expansion:
dots valid for
Note: the natural function in MATLAB is log
Use a for loop to calculate the series. The maximum value of in the equation above should be a user inputted value of in other words, instead of calculating the infinite series, the user can specify the number of terms so that goes from to
The user should be prompted to enter the value of If the value entered is not within the valid range the user should be prompted again for a new value of
The user should be prompted to enter the value of
Your code should output the estimated value of from the series calculation and the difference between it and the value MATLAB calculates as Be sure to label what each of the two values are in your output.
Use fprintf statements to have each value display using fixedpoint notation with a field width of and digits after the decimal place. Use and to run your code.
Write a new MATLAB Live Script code mIx file to perform the same calculation but this time use a while loop to calculate for as many terms as it takes to have the difference between the series estimate and the actual value of to be less than or equal to Also output the number of iterations it took to meet this tolerance. Test your code for Note: you can copy the code from Part into a new file and edit your code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
