Exam #1

Methods of Engineering Analysis ENCH620

Fall 2002

Instruction

You may use one 8.5''x11'' sheet of notes. No electronic devices of any kind (calculator, palm PC, radio, watches /w build-in calculator, etc.) Any act of academic dishonesty will not be tolerated. Show your work when appropriate. However, since time is limited, keep your answer succinct.
  1. (5 pts.) Honor Codes. Indicate whether the following statements are true or false for this class.

    1. You may discuss with your friends to figure out the answers to a homework problem together. |T|F|

      Solution:

      True. (Because I said so.)

    2. You can copy the homework solution from your friends, change the student name to yours, move a few items around, then turn in for credit. |T|F|

      Solution:

      False. (If you do, you face the Student Honor Council.)

    3. You see that the source codes posted on the class' web page can solve a homework assignment. You may copy and paste part of it into your work, provided that you give proper credit to the source. |T|F|

      Solution:

      True. (I post stuff on the class web to help you. Everyone has access to the same material; thus, there is no question of fairness.

    4. If convicted of cheating, you will get a grade of "F" for the course. |T|F|

      Solution:

      False. (You get a grade of "XF" meaning failure due to academic dishonesty.)

  2. (20 pts.) In a previous homework assignment, we practiced fitting exp(-x2) in x=[-5, 5] with an n-th degree polynomial.
      p(x) = a0 + a1*x + a2*x2 + ... + an*xn
    
    1. Provide the actual numerical value for the coefficients a0 when we have 11 equally spaced interpolation points. Find a0 for 21 equally spaced interpolation points.

      Solution: The many parts of this problem enforce the concept that at interpolation points, the interpolating polynomial passes through the given points exactly. In other words, there is no error.

        p(0) = exp(-02) = 1
        p(0) = a0
      
      Thus, a0 = 1

    2. Provide the numerical value for the coefficients a0 when we have 11 Chebyshev points. Find a0 for 21 Chebyshev points.

      Solution:

      Same as in Part a). a0 = 1

    3. Find the coefficients a1, a3, and a5.

      Solution:

      The given function exp(-x2) is symmetrical with respect to x=0 (i.e., in math jargon, it is an even function), and it does not contain any odd power terms, such as x, x3, and x5. Thus, a1=a3=a5=0

    4. Give the numerical value(s) as predicted by our interpolating polynomial(s) at x=-5, i.e., p(-5).

      Solution:

      Same idea as in Part a), namely, at interpolation points (which include the two end points), the interpolating polynomial passes through the given points exactly.

        p(-5) = exp(-52)
      

    5. Give the numerical values as predicted by our cubic spline at x=-5.

      Solution:

        p(-5) = exp(-52)
      

    6. If we need to predict at x=-6, which one of the following polynomial(s) should we choose?
      1. Taylor's series expansion
      2. Interpolating polynomial with 11 equally spaced interpolating points.
      3. Interpolating polynomial with 21 equally spaced interpolating points.
      4. Interpolating polynomial with 11 Chebyshev points.
      5. Interpolating polynomial with 21 Chebyshev points.
      6. Cubic spline
      7. None of the above

      Solution:

      Answer is "vii) None of the above". Never extrapolate.

    7. In general, how many roots (real and complex combined) exist in the above nth degree polynomial, i.e., p(x)=0?

      Solution:

      For an n-th degree polynomial, there are n roots in general (although some of the roots may be repeated).

    8. Since exp(-x2) is never zero within x=[-5, 5]. Can we expect to find roots to p(x)=0 in the interval x=[-5, 5]?

      Solution:

      Yes. The interpolating polynomial can oscillate up and down and crosses the x-axis.

    9. In general (for an arbitrary continuous function f(x)), can we expect the largest error to be less if we employed more equally spaced interpolating points?

      Solution: No, more points do not necessarily yield closer estimates.

    10. If we have an interpolating polynomial in x=[-5, 5] that gives good prediction at x=5, can we trust the result at x=4? If we have a Taylor's series expansion around x=0 that gives good prediction at x=5, can we trust the result at x=4?

      Solution:

      Yes, interpolating polynomial will work at x=4, but the validity of the Taylor's series expansion may not reach as far as x=4.

  3. (10 pts.) Find the inverse of the following matrix via Gaussian elimination. Work systematically, and show your work for elimination of the first column only (because of limited time). Describe how you will work through the rest of the problem.
          | 0   2   3  |
      A = | 1   2   2  |
          | 1   2   1  |
    

    Solution:

    In finding inverse, we look for a solution to the following: A*x=I

          | 0   2   3  |           | 1 0 0 |
      A = | 1   2   2  |       I = | 0 1 0 |
          | 1   2   1  |           | 0 0 1 |
    
    Combine A and I (just to save space).
      Original matrix: | A | I |
        | 0   2   3  |  1 0 0 |   (1.1)
        | 1   2   2  |  0 1 0 |   (1.2)
        | 1   2   1  |  0 0 1 |   (1.3)
    
    Pivoting: swap rows 1 and 2 to bring the row with the largest element (in the absolute value sense) in column 1 to the top row.
        | 1   2   2  |  0 1 0 |   (1.2)
        | 0   2   3  |  1 0 0 |   (1.1)
        | 1   2   1  |  0 0 1 |   (1.3)
    
    Multiply (1.2) by 0/1 and subtract it from (1.1) --> (2.2)
    Multiply (1.2) by 1/1 and subtract it from (1.3) --> (2.3)
        | 1   2   2  |  0  1 0 |   (2.1)
        | 0   2   3  |  1  0 0 |   (2.2)
        | 0   0  -1  |  0 -1 1 |   (2.3)
    
    You are asked to perform Gaussian Elimination up to this point... (The rest of the steps comprise of eliminating the second column, then work backwards to eliminate the third column, followed by the second column. The matrix A now should be diagonal. Finally, we divide each row by the diagonal element...)

    Pivoting: A22 already has the largest magnitude; there is not need to swap rows.

    Multiply (2.2) by 0/2 and subtract it from (2.3) --> (3.3)
        | 1   2   2  |  0  1 0 |   (3.1)
        | 0   2   3  |  1  0 0 |   (3.2)
        | 0   0  -1  |  0 -1 1 |   (3.3)
    
    Now, perform the elimination process in reverse direction.
    Multiply (3.3) by 3/(-1) and subtract it from (3.2) --> (4.2)
    Multiply (3.1) by 2/(-1) and subtract it from (3.1) --> (4.1)
        | 1   2   0  |  0 -1  2 |   (4.1)
        | 0   2   0  |  1 -3  3 |   (4.2)
        | 0   0  -1  |  0 -1  1 |   (4.3)
    Multiply (4.2) by 2/2 and subtract it from (4.1) --> (5.1)
        | 1   0   0  | -1  2 -1 |   (5.1)
        | 0   2   0  |  1 -3  3 |   (5.2)
        | 0   0  -1  |  0 -1  1 |   (5.3)
    Divide each row by the corresponding diagonal element.
        | 1   0   0  | -1    2  -1  |   (6.1)
        | 0   1   0  | 1/2 -3/2 3/2 |   (6.2)
        | 0   0   1  |  0    1  -1  |   (6.3)
    
    Thus, the second part gives the answer to the linear equation A*x=I
                 | -1    2  -1  |
      x= inv(A)= | 1/2 -3/2 3/2 |
                 |  0    1  -1  |
    

  4. (20 pts.) Certain chemical species (e.g., phosphoric acid, pH indicators, amino acids, etc) can double dissociate and possess two dissociation constants: K1 and K2, which are defined as:
       AH2 --> AH- + H+      K1=10-pK1=[AH-]*[H+]/[AH2]    (1)
       AH- --> A= + H+       K2=10-pK2=[A=]*[H+]/[AH-]     (2)
    
    In addition, conservation of mass means that all three possible fractions (concentrations) must add up to unity (total concentration):
       [AH2]+[AH-]+[A=]=Atotal        (3a)
       [AH2]+[AH-]+[A=]=1            (3b)
    
    1. Are equations (1)-(3) linear with respect to the mole fractions (concentrations)? If so, express them in the standard "Ax=b" format and identify the matrix A and the vector b. If not, express them in the standard "f(x)=0" format. (Do not reduce the number of simultaneous equations, as we are practicing handling multiple algebraic equations, not our skill at manually reducing the number of equations.)

      Solution:

      The three equations are rearranged as:
          K1*AH2 - H*AH-        = 0    (1)
                  K2*AH- - H*A=  = 0    (2)
             AH2   + AH-   + A=  = 1    (3)
      
      The equations are linear with respect to the three fractions of A.
      In the standard Ax=b format, the matrix A is:
         x = [  AH2    AH-    A=  ]T  ... three fractions
      
             [  K1     -H     0   ]  ... (1)
         A = [   0     K2    -H   ]  ... (2)
             [   1      1     1   ]  ... (3)
      
      In the standard Ax=b format, the column vector b is:
             [ 0 ]
         b = [ 0 ]
             [ 1 ]
      

    2. We measure the concentration of three species at different pH values. Set up the equation(s) to find the dissociation constants from these measurements.
        pH  ----Concentration (M)--
       value   AH2     AH-      A=
       ----------------------------
        1.5   3.999   0.001   0.000
        2.3   1.980   0.001   0.002
        2.3   2.180   0.003   0.001 (repeated reading)
        2.6   2.38    0.004   0.005
         :     :       :       :
         :     :       :       :
      

      Solution:

      This is a regression problem. Since the equations that relates the different variables are already given, the most prudent is to use them. There are several ways of doing regression, depending on how we regard each variable (or combinations thereof) as dependent or independent. If we simply place the independent variables on the LHS and dependent variables on the RHS, we have directly from Eqns (1) and (2),

        [AH-]*[H+]/[AH2] = K1*1   (1)
        [A=]*[H+]/[AH-]  = K2*1   (2)
      
      Thus, perhaps the simplest is to regress the quantity [AH-]*[H+]/[AH2] versus a basis function of 1, and the coefficient resulting from this regression will be the best estimate of K1. In other words, based on the defining equations (1) and (2), form the "measured" values of K1 and K2. Take the average (which is another way of saying regress the "measured" values of K1 and K2 against a basis variable of 1).
        K1 = a0*1
      
        pH  ----Concentration (M)--
       value   AH2     AH-      A=     K1       K2
       --------------------------------------------
        1.5   3.999   0.001   0.000    :       :
        2.3   1.980   0.001   0.002    :       :
        2.3   2.180   0.003   0.001    :       :
        2.6   2.38    0.004   0.005    :       :
         :     :       :       :       :       :
         :     :       :       :       :       :
       ----------------------------------------------
                                   Average1  Average2
      
      Here is another scheme where we regress [AH-] against [AH2]/[H+].
        [AH-] = K1*[AH2]/[H+]
      
      The coefficient resulting from this regression will also yield an estimate of K1...

    3. We wish to utilize measurements of all three concentrations. Do you expect problems with this approach? If so, give reason and provide methods to avoid your stated problems.

      Solution:

      There is no problem in taking averages. However, we would face singularity problems, had we not given the defining equation for K1 and regressed against each of the three fractions, like the following.

        y = a0 + a1*AH2 + a2*AH- + a3*A= +...
        (What is the dependent variable y in this equation anyway?)
      
      The problem comes from the linearly dependent columns of the supposedly independent matrix (i.e., the set of independent variables). The three variables [AH2], [AH-], and [A=] are linearly correlated, as described by Eqn (3).

    4. Are there potential problems with taking measurements several times at the same pH value (e.g., pH=2.3 in the above table)? If so, give reason and provide approach to avoid your stated problems.

      Solution:

      There is no problem in having additional data points measured at identical pH values. The problem (which does not apply to this question) comes from linearly correlated independent variables, not more data points. (Remember the homework problem on regressing viscosity versus wt%, where an identical wt% value appeared in many data points.) In fact, the whole idea of regression is built on having lots of data points.

  5. (20 pts.) Consider the following set of reversible gas phase reactions that are dominant in forming hydrogen from natural gas.
                                k1
      Reaction #1:   CH4 + H2O <---> CO  + 3 H2    K1 = equilibrium constant
                                k2
    
                                k3
      Reaction #2:   CO  + H2O <---> CO2 + H2      K2 = equilibrium constant
                                k4
    
    Initially, 10 moles of gas containing 20% CH4 and 80% H2O is present at 1 atmospheric pressure. Let e1 and e2 be the extent of reaction for the 1st and 2nd reaction, respectively. The mass fractions of the various component present in the system are:
      YCO  = (e1-e2)/ntotal
      YH2  = (3e1+e2)/ntotal
      YH2O = (8-e1-e2)/ntotal
      YCO2 = e2/ntotal
      YCH4 = (2-e1)/ntotal
    where
      Total number of moles: ntotal = 10 + 2e1
    
    Therefore, the equilibrium constant expressions are:
            (e1-e2)(3e1+e2)3
    K1 = ------------------------ P2       (1)
         (2-e1)(8-e1-e2)(10+2e1)2
    
            e2(3e1+e2)
    K2 = ---------------                   (2)
         (e1-e2)(8-e1-e2)
    
    1. Are the above two equations (1)-(2) linear with respect to the extents of reactions? If so, express the equations in the standard "Ax=b" format. And give the equation that solves for the extents of reaction, given the equilibrium constants. If the equations are nonlinear, write them in the standard "f(x)=0" format, and show one iteration in the solution of these equations (say, with Newton's method).

      Solution:

      Nonlinear. Simply shift the K1 and K2 terms from the LHS to the RHS of the equations.

                         (e1-e2)(3e1+e2)3
      f1(e1,e2) = K1 - ------------------------ P2 = 0      (1)
                      (2-e1)(8-e1-e2)(10+2e1)2
      
                         e2(3e1+e2)
      f2(e1,e2) = K2 - --------------- = 0                  (2)
                      (e1-e2)(8-e1-e2)
      
      Solution of the f(e)=0: start with an initial guess of, say, e<0>=[1,1]T, then iterate with Newton's method.
        e<j+1> = e<j> - fe-1(e<j>)*f(e<j>)
      
      where fe(e<j>) is a 2x2 matrix of derivatives of the two algebraic equations f1 and f2 wrt the two unknown variables e1 and e2 evaluated at the jth iteration of e, e<j>.

    2. Initially, 10 moles of gas containing 20% CH4 and 80% H2O is present at 1 atmospheric pressure at T=2000°K. We measure the various concentrations at constant temperature and pressure and generate a measurement table like the following.
         t    -------Concentration (atm)---------
       (nsec)  YCO     YH2     YH2O     YCO2     YCH4
        -----------------------------------------
         10   0.000   0.000   0.800   0.000   0.200
         20   0.001   0.001   0.794   0.000   0.198
         :     :       :       :       :       :
         :     :       :       :       :       :
      
      From these measurements, find the reaction rate constants k=[k1, k2, k3, k4]T

      Solution:

      This is a linear regression problem of the form y=X*k where y is a 5nx1 vector of the difference of concentrations, e.g., YCO(t)-YCO(0); X is a 5nx4 matrix of the various integrated concentrations, e.g., integral from 0 to t of YCH4*YH2O(t)*dx; and k is a 4x1 vector defined in the problem statement. Normal equation gives the solution.

        k=(XT*X)-1*XT*y
      

    3. We conduct similar experiments at a series of temperatures and generate the following table showing the dependence of reaction rate constants on temperature.
        T       k1    k2    k3    k4
       -------------------------------
       1000     :     :     :     :
       1200     :     :     :     :
        :       :     :     :     :
        :       :     :     :     :
      
      Find activation energy for the first reaction Ea1. Activation energy for a reaction is defined as:
        k(T)=k0*exp(-Ea/RT)
      

      Solution:

      Form the quantity to be minimized (sse), which is a function of two parameters: k0 and Ea

         sse(k01,Ea1) = Si [ k1i - k01*exp(-Ea1/RTi) ]2
      
      We find minimum where the derivatives wrt to the parameters to be minimized are 0.
         0 = d(sse)/dk01
         0 = d(sse)/dEa1
      
      Finally we find the solution to the above two nonlinear algebraic equations.

      Although less desirable, alternatively, we can find Ea1 from linear regression of ln(k1) against 1/T.

        ln(k1) = ln(k10) - Ea/R*(1/T)
      

    4. When there are many reactions (which is actually the case in generating hydrogen from natural gas), we may wish to employ a compact vector/matrix notation to describe how the composition depends on the extent of reaction.
        n=n0 + s*e
      
      where n and n0 are vectors of number of moles of the various species present at time t and that at t=0, respectively; e=[e1 e2]T is a vector of extents of reaction. What is s? Provide s (in vector/matrix notation) for the above system of two coupled reactions.

      Solution:

      The matrix s contains the stoichiometric coefficients of the reactions, with the convention of negative signs for reactants and positive signs for products.

        n = [nCH4  nH2O  nCO  nH2  nCO2]T
      
        s = [ -1   -1    1    3    0 ]T     ... Reaction #1
            [  0   -1   -1    1    1 ]      ... Reaction #2
      

  6. (10 pts.) Linear independence.

    1. Are the following two functions linearly independent: f1=sin(x), f2=cos(x)? Briefly, why?

      Solution:

      Yes, they are linearly independent. Reason: two vectors sin(x) and cos(x) are linearly independent if

        a1*sin(x) + a2*cos(x) = 0
      
      means a1=a2=0. In other words we cannot express sin(x) as a linear combination of cos(x). Do not confuse linear independence with the fact that we can express one function in terms of another, e.g., sin(x+p/2)=cos(x) or sin2(x)=1-cos2(x)

    2. Are the following three functions linearly independent: f1=sin(x), f2=cos(x), f3=sin(2x)? Briefly, why? (Hint: Trig Identity: sin(2x)=2sin(x)cos(x))

      Solution:

      Yes, they are linearly independent. Again, the trig identity does not make them linearly dependent.

    3. Are the following three vectors linearly independent: x1=(1,0,0), x2=(0,1,0), x3=(1,1,1)?

      Solution:

      Yes, they are linearly independent.

  7. (15 pts.) Consider the following Bessel's differential equation for a coupled system of diffusion (LHS) and reaction (RHS)
      x2y" + x*y' + x2*y = y    for x=[0,1]   B.C.: y'(0)=0   y(1)=1
    

    1. Set up the equation(s) to find a solution via the finite difference method, where the first derivative dy/dx and the second derivative d2y/dx2 are approximated as:
        dy/dx  ==> 0.5(yi+1-yi-1)/Dx
      
        d2y/dx2 ==> (yi+1-2yi+yi-1)/(Dx)2
      
      where Dx=1/n is the step size and n is the number of divisions.

      Solution:

      Substituting the finite difference approximation into the given ODE yields,

        0 = (xi2-Dx/2*xi)*yi-1
            + (Dx2*xi2-2*xi2-a*Dx2)*yi
            + (xi2+Dx/2*xi)*yi+1    ... for all the internal points i=1,2,...,n-1
        Boundary conditions:
          y0-y1=0
          yn=1
      
      We can express these equations in the compact linear form A*y=b, where the matrix A's elements are:
        For all the internal points i=1,2,...,n-1
          Ai,i-1 = xi2-Dx/2*xi
          Ai,i  = Dx2*xi2-2*xi2-a*Dx2
          Ai,i+1 = xi2+Dx/2*xi
        For two end points,
          A0,0=1    A0,1=-1
          An,n=1    bn=1
      
      Finally, we take the inverse of A to obtain a solution.
        y=A-1*b
      

    2. How do we know if we have chosen an appropriate value for n?

      Solution:

      Change n and see if the solution remains unchanged. For example, double the number of divisions. If the solutions remain unchanged (within some acceptable tolerance level), we have converged to a solution.

    3. Is it possible to obtain multiple solutions for this boundary value problem?

      Solution:

      We have a linear algebraic equation of the form A*y=b; thus, the solution is unique.


Return to Prof. Nam Sun Wang's Home Page
Return to Methods of Engineering Analysis (ENCH620)

Methods of Engineering Analysis -- Exam #1
Forward comments to:
Nam Sun Wang
Department of Chemical Engineering
University of Maryland
College Park, MD 20742-2111
301-405-1910 (voice)
301-314-9126 (FAX)
e-mail: nsw@eng.umd.edu ©2002 by Nam Sun Wang
UMCP logo