ECM6PracticeFinalExam_07

ECM6PracticeFinalExam_07 - UNIVERSITY OF CALIFORNIA...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
UNIVERSITY OF CALIFORNIA Department of Chemical Engineering and Materials Science ECM6 Computational Methods Practice Final (Closed book and notes; no questions asked or answered) No cell phones or iPod/MP3 players allowed in the Classroom. Non- programmable calculators allowed. Prof. Higgins Spring 2007 Problem 1 (10 points) Each sub problem is worth 1 point. Be sure to give your explanation and the correct code written with clarity so that there is no ambiguity in your answer. The subproblems must be labeled and done in order. Note there may be more than one error in the code snippets. (i) Define a function to numerically integrate the function f[z] between specified limits f @ z D : = Sin @ z_ D myPlot @ f, xmin_, xmax_ D = Nintegrate @ f @ x D , 8 x, xmin, xmax <D (ii) The following For loop is used to print out a list of integers from 0 to 10 For @ i = 0; i < 10, i ++ ; Print @ i DD (iii) The following rule is required to replace the value of a followed by a 3 with a 2 alist2 = 88 1, 2, 3, a < , 8 3., 4 < , 8 2, a, 3, c, d, e < , 8 3, a, 5., f << ; alist2 ê . 8 x_, 3, a, y_ < Ø 8 x, a 2 , 3, y < (iv) The following code is required to add a column b to the matrix A A = 88 1, 2, 3 < , 8 4, 5, 6 << êê MatrixForm b = 8 8, 9 < ; Transpose @ Prepend @ A, 8 b <DD êê MatrixForm (v) The following module is required to calculate the function f[z] at the values {1+x, 2+x, 3+x,4+x} myfunc @ x_ D : = Module A8 f < , f @ z_ D : = Log @ z D ÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅÅ ÅÅÅÅÅÅÅÅÅ 2 + Sin @ z D Map @ N @ f @ # + x_ D D , 8 1, 2, 3, 4 <DE
Background image of page 1

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

View Full DocumentRight Arrow Icon
(vi) The following code is required to compare the following data on the same plot, and not have plt1 and plt2 be displayed. Block @8 $DisplayFunction Ø Identity < , data1 = Table @ Cos @ x D + 0.1 Random @D , 8 i, 1, 10 <D ; plt1 = ListPlot @ data1 D ; plt2 = Plot @ Cos @ x D , 8 x, 0, 1 <DD Show @ plt1, plt2 D (vii) The following code is used to combine two plots
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

ECM6PracticeFinalExam_07 - UNIVERSITY OF CALIFORNIA...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online