# Assignment 07 - University of California, Berkeley Fall...

This preview shows pages 1–2. Sign up to view the full content.

University of California, Berkeley Department of Mechanical Engineering Fall Semester 2008 Instructors: M. Frenklach, R. Horowitz E7, Assignment 7 Assigned: Thursday, October 16, 2008 Due: 12:00 pm, Friday, October 24, 2008. This assignment is a continuation on using definite and conditional loops in MATLAB as well as an introduction to understanding machine precision and computer representation. As before, turn in the hard copy of your published file to the drop boxes in Etcheverry 1109 and upload the soft copies of your script and your functions (the M-files) to bspace. Do not forget to name your main M-file as lastname_firstname_SID_lab07.m NOTE: Do not forget to display the contents of your user-defined functions using the command type. Also, do not forget using CTRL+C in the command window to break the current MATLAB operation, in case you encounter an infinite loop. MATLAB commands * introduced in this assignment: factorial, sign, loglog, legend 1. Recall Problem 1, part d of Assignment 6. Write a function called exp_app2 that takes two input arguments, the exponent x and the tolerance tol , and calculates the approximation of the exponential function e x . The function should continue calculating the partial sum until the absolute value of the difference between the current sum and the previous sum is less than the tolerance and return the resulting sum. Use the MATLAB built-in function factorial to calculate the factorials inside exp_app2 . Use exp_app2 to determine the value of e 5 within a precision of 6 decimal digits (i.e. tol = 0.000001). Compare your result to the actual value returned by exp(5) . Set your format to long to see the difference. Set your format back to short after you see the difference.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## Assignment 07 - University of California, Berkeley Fall...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online