Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help create MATLAB function file. Create a function that allows you to ap

ID: 3007456 • Letter: P

Question

Please help create MATLAB function file.

Create a function that allows you to approximate 1/e using the formula:

Your function is to take an input D that represents the number of digits your approximation must match the true value of 1/3. You are to use a while loop to find the approximation for 1/e correct to D decimal places.

NOTE: you are NOT calculating a sum or series.

Your function should return two things: the approximation value, and the size of n that was needed to get the approximation close to the desired number of decimal places.

Explanation / Answer

function [e,n] = approx(D)
      
e = 0;
n = 0;
while abs(e-exp(-1))>10^(-D-1)
    n = n + 1;
    e = (1-1/n)^n;
end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote