Sie sind auf Seite 1von 2

ASE 311 Fall 2012: Homework #1

Reading: Chapters 1-4 Homework:

Due Friday September 7th

Turn all problems in IN THE ORDER THEY ARE ASSIGNED. Each problem needs to be labeled so the TA can nd your work, and each problem should be neatly presented. Include any MATLAB code used in nding your solutions. You can use the command diary or diary(hw1.txt) to record your Matlab session, but please clean-up the output to make things easier on the grader. For example, please be sure to clearly label what the problem is and the solution, and please dont include stu like: x*x+1 ??? Undefined function or variable x. Remember, all homework problems should be completed independently.

1. Problem 3.9: Code this problem as a function that accepts one input (a matrix). If you are slick, the body of the function requires only 3 lines of code. A for-loop is ne by me. Use the fprintf function for displaying outputs. You will probably need to use trial-and-error to get the spacing of the outputs right, but make the column labels n, S, B, H, and U as centered as possible on the column data. 2. Problem 3.12: Write this as an M-le. Here, you are supposed to be slick and get rid of the for-loop. Hint: x=2:4:10 is the vectorized version of the for-loop for i = 1:3 x(i) = 2+4*(i-1); end

3. Problem 3.14: In addition to the problem instructions, write an M-le script that calls the M-le function to evaluate v(t) (Hint: use if-elseif logic structure) at all the points of t. Use a step size of 0.25 for t, and label the axes in the plot. Also, use the scatter command to plot the maximum velocity on the same plot. Annotate the plot with a legend. This should all be done in the code. (See help xlabel and help ylabel, e.g., if you are not familiar with these commands) 4. Assume that your workspace has a 2-D array, A. You have no prior knowledge of the dimensions nor the values in A. Write a script that will generate a dierent 2-D array B according to the following rules (a) If ajk < 0 then bkj = sin ajk (b) If ajk = 0 then bkj = 0 (c) If ajk > 0 then bkj = eajk Test your script for 2 4 0 3 1 A = 5 3 4 0 5 1 2 Take a second and think: what should the dimensions of B be?

5. Problem 4.4 6. Problem 4.5: Be sure to investigate the challenge question. You might nd section 4.2.1 to be useful along with the help documentation related to realmin. 7. Problem 4.7 8. Problem 4.15 9. This problem involves the Taylor Series of a function f about a point x f (x + h) = f (x) + f (x)h + f (x) 2 f 3 h + h + + Rn 2! 3!

(a) Derive the Taylor Series centered at x = /4 of sin x for 1 term, 2 terms and 3 terms. In addition, indicate the order of the error for each derivation, i.e., include in the series the term Rn as O(h ), where you must properly indicate the for each order expansion. (b) Let x = /2 and vary h from 0 to 1 with an increment of 0.01. Plot the absolute value of the true error for varying h for the 1 term, 2 term and 3 term approximations on a log-log plot. You will need to use loglog() instead of plot(). Be sure to include appropriate labels and a legend for your plot. (c) Comment on the shape of your plots.