Sunteți pe pagina 1din 5

2-6-08 FIRST IN-TERM EXAM

Name:

EGM 3344 Introduction to Numerical Methods of Engineering Analysis


In this exam you may use only one 8.5x11 formula page, and a pen or a pencil (no computers or calculators).. Please sign a pledge that you have not violated any of the university honesty provisions with regards to this exam. Also, please provide a 4 digit PIN that you will use to access your grade. If you do not provide one, the first four digits of your UF ID will be used except that leading zeros will be omitted.
(1%)_____________________ PIN __________

1. (25%) The density of freshwater can be computed as a function of temperature in centigrade, with the following equation = 106 (0.055TC3 8.5TC2 ) + 1 Write Matlab code needed to generate a vector of temperatures ranging from 0 to 30 degrees (centigrade) in increments of 2 degrees, compute a vector of densities, and plot density vs. temperature.
>> TC = 0:2:30; >> rho = 1e-6*(0.055*TC.^3-8. *TC.^2)+ +1; >> plot(TC,rho)

Name: 2. ((25%) Write an M-file function to determine the elapsed days from the beginning of the year to a given date. For simplicity assume that it is NOT a leap year. Use a combination of the for and switch structures. The first line of the function should be function nd=days(mo,da), and the last statement should be end. You need about 10 additional lines in between.
function nd = days(mo, da) nd = da; for m=1:mo-1 switch m case {1, 3, 5, 7, 8, 10, 12} nd=nd + 31; case {4, 6, 9, 11} nd = nd+30; case 2 nday = nd+ 28; end end

Name: 3. (25%) Consider the function f(x)=x2 at x=2. a. Compare the forward and centered difference approximations to derivative of the function with a step size h=1 with the exact derivative. Forward: 32-22=5 Central: (32-12)/2=4 Exact: 2x=4.

b. Write the Taylor series of the function at x=2, and check whether the error in the forward differences result agrees with the remainder term.

Taylor series about x=1 f ( x) = f (2) + f '(2)( x 2) + 0.5 f "(2)( x 2) 2


= 4 + 4( x 2) + ( x 2) 2 Forward differences leaves out the last term, so its error is (x-2)2/h=(3-1)2/1=1.

Name: 4. (6%) Use the linspace function to create a vector identical to the vector created by t=5:6:33 The sequence generated by the column format will be [5 11 17 23 29], so to generate the same sequence with linspace, we need linspace(5,29,5).

5. (6%) Write a single Matlab statement that will take a vector x of numbers and set all the negative components to zero, leaving the positive ones unchanged.

xpositive=0.5*(sign(x)+1).*x

6. (6%) Write the output of the Matlab statement bin2dec(1010). Show your computation. The decimal number 1010=1*103+1*101 With base 2 we change 10 to 2 to get 1*23+1*21=10

Problem 7 - Instructor Feedback (6 points for simply answering all of the following questions):

a) In your opinion, what is the best thing about this course so far?

b) In your opinion, what is the worst thing about this course so far?

c) Do you have any constructive criticisms about the book?

d) Do you have any constructive criticisms about the lectures?

e) Do you have any constructive criticisms about the course in general?

f) If you could change on thing about the course to make it better for the remainder of the semester, what would you change and why?

S-ar putea să vă placă și