Docsity

Sample Midterm Exam Questions - Computational Methods/Engineer | MAE 107, Exams of Mechanical Engineering

Toggle sidebar
bg1
MAE 107 – Computational Methods
Summer Session II 2009
Midterm sample
Guidelines: This is a closed bo ok and closed notes exam. No calculator or computer allowed.
Clearly explain your answers to each of the question and write your solution neatly. Detail all necessary
intermediate steps and clearly identify your final answers (e.g. box them in). Do not forget to put your
name and student ID on your test and staple/attach all the pages together.
Problem 1
Write a short Matlab function that takes only one argument nand returns the factorial of nfor n≥0
(remember the convention 0! = 1).
Problem 2
Consider the matrix A=
2−1 3
−2−2−2
2−7 4
.
1. Obtain the LU decomposition of Ausing Gauss elimination without partial pivoting.
2. Using this decomposition, compute the determinant of A.
3. Using the LU decomposition, compute the matrix Y=A−1.
4. Check your result using the direct formula for the inverse of a square matrix.
Problem 3
The function
f(x) = x3+ 2x−3
has a root at x= 1. Construct a fixed-point iteration scheme of the form
x(n+1) =g(x(n))
that will converge to this root with a quadratic rate of convergence, given an initial guess sufficiently close
to the root.
Problem 4
1. Show that the Taylor Series of f(x) = 1
1+xin x= 0 up to O(x4) is
f(x)=1−x+x2−x3+O(x4).
1
pf3

Partial preview of the text

Download Sample Midterm Exam Questions - Computational Methods/Engineer | MAE 107 and more Exams Mechanical Engineering in PDF only on Docsity!

MAE 107 – Computational Methods

Summer Session II 2009

Midterm sample

Guidelines: This is a closed book and closed notes exam. No calculator or computer allowed. Clearly explain your answers to each of the question and write your solution neatly. Detail all necessary intermediate steps and clearly identify your final answers (e.g. box them in). Do not forget to put your name and student ID on your test and staple/attach all the pages together.

Problem 1

Write a short Matlab function that takes only one argument n and returns the factorial of n for n ≥ 0 (remember the convention 0! = 1).

Problem 2

Consider the matrix A =

  1. Obtain the LU decomposition of A using Gauss elimination without partial pivoting.
  2. Using this decomposition, compute the determinant of A.
  3. Using the LU decomposition, compute the matrix Y = A−^1.
  4. Check your result using the direct formula for the inverse of a square matrix.

Problem 3

The function f (x) = x^3 + 2x − 3

has a root at x = 1. Construct a fixed-point iteration scheme of the form

x(n+1)^ = g(x(n))

that will converge to this root with a quadratic rate of convergence, given an initial guess sufficiently close to the root.

Problem 4

  1. Show that the Taylor Series of f (x) = (^) 1+^1 x in x = 0 up to O(x^4 ) is

f (x) = 1 − x + x^2 − x^3 + O(x^4 ).

  1. Use this result to obtain the Taylor Series expansion of g(x) = (^1) 1+−xx near x = 0 up to O(x^4 ).
  2. Show that the Taylor Series expansion of h(y) =

1 + y in y = 0 up to O(y^4 ) is:

h(y) = 1 + y 2

y^2 8

y^3 16

  • O(y^4 ).
  1. Use the results of the previous questions to obtain the Taylor Series expansion of p(x) =

1 −x 1+x in x = 0 up to O(x^4 ).

Problem 5

Consider the following matlab function Thomas.m that solves a tridiagonal system Ax = b.

function x=Thomas(a,b,c,r)

% Solve for x in A.x=b for A tridiagonal using Thomas algorithm % Inputs: a: subdiagonal of A % b: main diagonal of A % c: super diagonal of A % r: right hand side of the equation % outputs: x: solution

% Forward elimination n=length(b); for j=2:n, factor=a(j)/b(j-1); b(j)=b(j)-factorc(j-1); r(j)=r(j)-factorr(j-1); end

% Backward substitution

x=zeros(n,1); x(n)=r(n)/b(n); for j=n-1:-1:1, x(j)=(r(j)-c(j)*x(j+1))/b(j); end

  1. This function only takes the three non-zero diagonal of A as input. Give the expression of the matrix A for n = 5.
  2. Are all the coefficients in a, b and c useful? If not, which are the unused coefficients for a general value n of the matrix size?