Download pdf - KTH - Examples Total

Transcript
  • Refresher Material

    Numerical Analysis and Programming

    Edited by Michael Hanke, [email protected]

    version of April 28, 2010

  • Contents1 Introduction (Bengt Lindberg) 5

    2 Matlab exercises (Lennart Edsberg) 62.1 What is Matlab? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 Vectors and matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.3 Linear algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.4 Graphics and plotting of curves . . . . . . . . . . . . . . . . . . . . . . . . 92.5 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    3 Programming (Bjrn Sjgren) 103.1 Simple problems to get started . . . . . . . . . . . . . . . . . . . . . . . . 103.2 Numerical problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.3 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    4 Linear algebra (Bengt Lindberg) 134.1 General concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2 Systems of linear equations, formulations . . . . . . . . . . . . . . . . . . . 154.3 Systems of linear equations, accuracy . . . . . . . . . . . . . . . . . . . . . 164.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    5 Least squares problems (Lennart Edsberg) 195.1 General concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.2 Formulation and solution in Matlab . . . . . . . . . . . . . . . . . . . . . 205.3 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    6 Non-linear equations (Bengt Lindberg) 226.1 General concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226.2 Non-linear equations, formulations . . . . . . . . . . . . . . . . . . . . . . . 226.3 Non-linear equations, numerical methods . . . . . . . . . . . . . . . . . . . 226.4 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    7 Finite dierences and such (Jesper Oppelstrup) 247.1 Dierence operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247.2 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247.3 Quadrature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257.4 Extrapolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267.5 Band-matrix method for boundary value problems . . . . . . . . . . . . . 277.6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    3

  • 8 Ordinary dierential equations (Bengt Lindberg) 288.1 General concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288.2 Linear dierential and dierence equations and systems . . . . . . . . . . . 308.3 Numerical methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    9 Mathematical Modeling (Jesper Oppelstrup) 339.1 Applied problems: Particle Dynamics . . . . . . . . . . . . . . . . . . . . 339.2 Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349.3 Vector analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359.4 Law of Mass Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369.5 Hydrodynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369.6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    10 Partial Dierential Equations (Gunilla Kreiss) 3810.1 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    4

  • 1 Introduction (Bengt Lindberg)This collection of problems is organized into sections dealing with dierent aspects ofnumerical mathematics and programming.

    The idea behind the collection is to gather central prerequisites for starting your studyat KTH Royal Institute of Technology, Stockholm, Sweden, in Computational Science andEngineering on the Masters level. So you can see what we expect you to know in thedierent areas. If you are lacking some of this knowledge, you may need to read from thereferences to be able to solve the problems. You will have a minimum common platformto work from when you have solved this collection of problems. For us, the teachers of theMasters Programmes, it is of great value to know what the common platform is and whatwe can build upon.

    Many of the problems could be solved without a computer in a few minutes, whileothers may need a computer, reference material and more time.

    Some of the problems are intended to also give you an introduction to the computingenvironment at the School of Computer Science ans Communication (CSC) of KTH. Moredetails of the computing environment are described elsewhere.

    After having solved part of or all the problems from a section you may contact a teacheror tutor for discussions, hints and advice on possible further reading. You should solve theproblems individually, but discussions with classmates are encouraged.

    List of references are included for some of the sections but the lists are incomplete, soyou also need to use your own text-books for the refresher.

    5

  • 2 Matlab exercises (Lennart Edsberg)

    2.1 What is Matlab?

    Matlab1 is a programming environment for scientic and technical computations. It con-sists of a high-level programming language, a corresponding interpretation/compilation/runtimesystem, and an integrated development environment. Additionally, Matlab can be extendedby many toolboxes. On of the most important properties is the support of high-level nu-merical methods and easy-to-use graphical tools which makes it an excellent and versatiletool for fast prototyping both in education, academia, and industry. At KTH, many coursesmake extensive use of Matlab.It is therefore essential that you are comfortable with thebasic concepts of Matlab. The number of engineering textbooks introducing Matlab isunlimited. If you do not already have done so, learn Matlab immediately. It is worth theeort.

    Unfortunately, Matlab is a commercial product. There are some free open-source im-plementations of the Matlab programming language available. If you do not have accessto Matlab, we recommend to use GNU Octave2. Prebuild binaries for many systems areavailable, some with restricted capabilities. Try to nd one with sparse matrix capabilitiesincluded. Of course, it is not hard (but, maybe, time-consuming) to build GNU Octavefrom source. Even IDEs are available, one example is qtoctave3.

    2.2 Vectors and matrices

    1. Write a Matlab statement that generates the following row vector

    x = [0, 2, 4, . . . 322, 324, 1, 3, 17]

    2. Generate the 7 5 matrix A with the elements

    A =

    1 1 1 1 41 2 4 1/2 71 3 9 1/3 11 4 16 1/4 51 5 25 1/5 21 6 36 1/6 01 7 49 1/7 1

    3. Given the x-vector x = [0.1, 0.2, . . . , 2.0]. Generate a table [x y z] where

    y = sin(x2)/x + 1 and z = xex + 2x/(1 + x).

    1Matlab is a registrered trademark of The MathWorks, Inc., Natick, Massachusetts.2GNU Octave is Copyright John W. Eaton. It is provided under GPL.3http://qtoctave.wordpress.com/

    6

  • 4. Given the vector x = [0.98, 0.72, 0.75, 0.65, 0.07, 0.63]. Use the Matlab dot operators(+,, ., ., ./) to generate the following quantities: the mean value, the median, thestandard deviation and the harmonic mean H from the formula

    1

    H=

    1

    n

    ni=1

    1

    xi

    Check your results with the results obtained from the Matlab functions mean, median,std.

    5. Given the column vector y with the components y1, y2, . . . , y10, e.g. the digits of yoursocial security number, your bank account number, an ISBN or something similar.Generate a new vector dy containing the elements yj+1yj . Generate (without usinga for-loop) a vector with the nine components (yj + yj+1)/2. Finally, generate avector b with the following ten components: b1 = dy1, bj = dyj1+dyj, j = 2, 3, . . . , 9and b10 = dy9.

    7

  • 6. Generate the following 10 10 matrices in Matlaba. A = diag(2, 2, 2, . . . , 2)

    b. A tridiagonal matrix with 2 in the diagonal and 1 in the sub- and super diago-nals.

    c. A being a triangular matrix with the element 1 on and below the diagonal.

    7. Given the matrix A being the tridiagonal matrix in 6 b. Generate an augmentedmatrix B having the structure

    B =(A aT

    a

    )

    where a = [1, 1, . . . , 1] and = 1/2.

    2.3 Linear algebra

    8. Given the following two matrices A and B and the vector x

    A =(

    2 14 5

    ), B =

    (1 12 3

    ), x =

    (79

    )

    Generate these variables in Matlab and then generate C = AB, z = Ax, p = zT z,E = ATA, q = xTAx. Write out the results

    9. Use Matlab to solve the linear system of equations

    1 1 1 12 4 8 163 9 27 814 16 64 256

    x1x2x3x4

    =

    42214

    Write out x together with the residual r = b Ax.10. Use Matlab to solve the following over determined linear system of equations Ax b

    in the least squares sense

    1 32 43 54 65 7

    (x1x2

    )

    810121520

    Write out the least squares solution x and the residual r = b Ax. The residualshould be orthogonal to the columns of A. Check that with a Matlab command.

    8

  • 2.4 Graphics and plotting of curves

    11. The corners of a triangle have the x-coordinates 0, 4, 6.5 and the y-coordinates

    1.42, 6.18, 4.75. Mark the corners with an and draw the sides of the triangle.Compute the lengths of the sides, the circumference and the area.

    12. A circle is given by the parameter form x = xc +Rcos(), y = yc +Rsin(), where varies between 0 and 2. Plot a circle with radius 3 and with the center in (0, 1.42).Use the step 2/60. Mark the midpoint. Use axis equal after the plot statement!

    13. Plot a graph of the function y = x3/202x3ex on the interval [0, 5]. Try dierentsteps h and choose the step so that the curve looks smooth. Put the text x on thex-axis, y on the y-axis and a title with the text Graph of y = x3/20 2 x3 ex

    14. Determine the polynomial of degree three that passes through the points (1, 4),(1, 2),(2,2) and (4, 14). Mark in the same graph the four points with circles and plot asmooth curve representing the polynomial.

    15. Plot a sequence of intensity curves for the function w(, T ), which depends on wave-length and temperature T

    w(, T ) =

    5(e/(T ) 1)where = 3.7415 1016 and = 0.01438. We want curves for T = 3000, 4000, 5000and 6000 in the wavelength interval [0, 250 108]. Add a legend to the plot

    16. Let the triangle in problem 11 above be the basis (in the plane z = 0) of a pyramidhaving the top in the point xtop = 3.5, ytop = 3, ztop = 8. Plot a 3D-picture of thepyramid using mesh and surf.

    2.5 Reference

    1. Prt-Enander et. al., The Matlab Handbook, Addison Wesley Longman 1996.

    9

  • 3 Programming (Bjrn Sjgren)Write programs in Fortran or C to solve the problems below. This section requires thatyou have access to a C- or Fortran-compiler. Besides many commercial compilers, theGPLed gcc compiler suite is a well established tool. It is immediately available for manyUnix-avours4. In Microsoft Windows5, we recommend to use Cygwin6.

    3.1 Simple problems to get started

    These programs can be solved with a few lines of code. They help you to get started withthe programming environment, make you nd out how to run the compiler, and will giveyou a rst introduction to the new language.

    1. Write a program which reads a number, n, and then n numbers of type double, i.e.,input data are

    n x1 x2 x3 . . . xn

    The program should write out the average of the positive x-values. If the number ofpositive values is less than 1, the text too few numbers should be written.

    2. Write a program which reads 10 numbers, and computes the harmonic average,

    1

    H=

    1

    10

    10i=1

    1

    ai,

    for these numbers.

    3. Write a function which converts an uppercase letter AZ to the correspondinglowercase letter. If the parameter is not a letter it must be returned unchanged.Write a main program which calls the function.

    4. Write a function which computes the binomial coecient(nk

    )=

    n!

    (n k)!k! .

    Write a main program which calls the function. Try to make the function work foras big n as possible.

    5. Write a function which prints a positive integer in binary representation. Do not usearrays. Write a main program which calls the function.

    4UNIX (all capitals) is a registered trademark of The Open Group.5Microsoft Windows is a registered trademark of Microsoft Corp.6http://www.cygwin.com. Copyright RedHat, Inc.

    10

  • 3.2 Numerical problems

    The problems are here a little bit more complex than in the previous section, but should bepossible to solve in fairly short time, with not so complicated programs. Try to think aboutwhich quantities the user should input, and what the program can compute automatically.Do not forget to verify that your program computes a correct result.

    6. When solving a linear system of equations by LU -factorization, a sub step is to solvea lower triangular system Ly = d. Example:

    1.0 0 00.5 1.0 02.0 1.5 1.0

    y1y2y3

    =

    11.5

    2.5

    Write a function which given a n n-matrix L and a n-vector d, computes thesolution y of the lower triangular system Ly = d. Write a main program which callsthe function.

    7. Use the following algorithm to enclose the root of the algebraic equation f(x) = 0 inan short interval [a, b].

    (a) Choose initial guess [a, b].(b) Let m be the midpoint of the interval [a, b].(c) if f(m)f(a) < 0 then b := m else a := m.(d) goto b).

    The program should have the following features: Possibility to specify error tolerance,handling of the case where no root is found (initial guess does not satisfy f(a)f(b) 0using the initial value y(0) = 1, and the numerical method

    yn+1 = yn tynyn+1

    Solve the problem to t = 2. Choose t = 0.01.(b) The program computes y(t) in a number of points, t0, t1, . . . , tN = 2. Use matlab

    to plot the function y(t). You do this by letting your program write the data(ti, yi), i = 0, . . . , N to a le which you can read into matlab, and plot there.You can write the data either as an ascii le ( read by the matlab commandload), or as a raw binary data le ( read by the matlab function fread ). Tryboth types of les.

    11

  • 9. A computational grid in two space dimensions is described by two matrices x[i][j]and y[i][j] (or X(I, J) and Y (I, J) in Fortran). Given an arbitrary point (x0, y0), wewant to nd its location in the grid. Write a function which determines indices (i0, j0)such that the point (x0, y0) is inside the quadrilateral with corner points (xi0,j0, yi0,j0),(xi0+1,j0, yi0+1,j0), (xi0,j0+1, yi0,j0+1), and (xi0+1,j0+1, yi0+1,j0+1). Think about ways toimprove the eciency of the function.

    10. (Continuation of 9.). Once (i0, j0) is found, we want to have a more precise infor-mation about the location of (x0, y0) inside the cell. We therefore use a bilinearinterpolation to dene the coordinate mapping on the entire cell. We then have tosolve the problem

    x0 = (1 r)(1 s)xi0,j0 + (1 r)sxi0,j0+1 + r(1 s)xi0+1,j0 + rsxi0+1,j0+1y0 = (1 r)(1 s)yi0,j0 + (1 r)syi0,j0+1 + r(1 s)yi0+1,j0 + rsyi0+1,j0+1

    for the unknown (r, s) in the interval [0, 1]2. The equation above is a 2 2 system ofnonlinear equations. Newtons method for solving the system F (r, s) = 0 is given by

    J(rk, sk)((rk+1

    sk+1

    )(rk

    sk

    )) = F (rk, sk)

    where J(r, s) is the Jacobian matrix, obtained by dierentiating F with respect to(r, s). Use Newtons method to solve the system above. A linear 2 2 system hasto be solved in each iteration. To think about: Stopping criteria. Error tolerance.Initial guess.

    For 9 and 10, try the program on the matrix given by

    xi,j = (i1m1 + 1) cos 2

    j1n1

    yi,j = (i1m1 + 1) sin 2

    j1n1

    The matrix size mn can be approximately 3050. Make the choice (x0, y0) = (0.7, 1.2).

    3.3 References

    1. M. Metcalf and J. Reid, Fortran 90 explained. Oxford University Press, Oxford 1990.

    2. S. L. Edgar, FORTRAN for the 90:s, Problem Solving for Scientists and Engineers.Computer Science Press, New York 1992.

    3. B. W. Kerningham and D. M. Ritchie, The C Programming Language. Prentice-Hall,Englewood Clis, New Jersey. 1978. Second edition 1988.

    4. B. Stroustrup, The C++ Programming Language. Addison-Wesley. 1991.

    12

  • 4 Linear algebra (Bengt Lindberg)

    4.1 General concepts

    1. Which of the following matrices are non-singular and which are singular?(

    4 00 2

    ),(

    1 20 1

    ),(

    0 10 0

    ),(

    1 12 2

    )

    Determine the inverse of the matrices that posses an inverse. Determine the rank ofthe matrices.

    2. Find the solutions of the following three systems of linear equations

    x1 + 2x2 = 1 x1 + 2x2 = 3 x1 + 2x2 = 1x1 + 2x2 = 0 x1 + 4x2 = 5 2x1 + 4x2 = 2

    Generalize the three solution types to the general system Ax = b of n linear equationsfor n unknowns. Formulate conditions on A and b for each of the situations thatoccur.

    3. Find the solution of

    1 0 0 11 1 0 00 1 1 00 0 1 1

    x1x2x3x4

    =

    600500700800

    You may do the calculations by hand or by Matlab. In Matlab use the commandrref.

    4. Dene

    a. diagonal matrix

    b. tridiagonal matrix

    c. triangular matrix

    Give examples of 5 5-matrices of the three kinds.5. What is a symmetric matrix? What is an orthogonal matrix?

    6. Dene what is meant by linearly dependent and linearly independent vectors. Forthe matrices in example 1-3,12-13 of this chapter, which have linearly independentcolumns?

    7. How many linearly dependent columns can there at most be in a 3 5 matrix?

    13

  • 8. Dene a scalar product (inner product) for a vector space. What is the scalar productfor RN . Dene RN , the N-dimensional Euclidean vector space. Dene what is meantby orthogonal vectors. The following vectors in R3 are given,

    b =

    11

    1

    c =

    011

    nd a vector orthogonal to both b and c.

    9. For RN formulate the triangle inequality, the Cauchy-Schwarz inequality and thePythagorean theorem.

    10. Dene what is meant by a basis for RN , the N-dimensional Euclidean vector space.Give examples of two dierent orthogonal bases for R3.

    11. Dene what is meant by a subspace of a vector space. Give example of a subspaceof dimension 2 to R3.

    12. Determine the eigenvalues and eigenvectors of

    A =(

    4 22 1

    )

    13. Determine eigenvalues of

    A =

    5 2 10 1 0

    0 0 2

    14. Given a symmetric nn-matrix A. How many eigenvalues does the matrix A possess?What properties, if any, do the eigenvalues have? What properties, if any, do theeigenvectors have?

    15. Given a nn-matrix A. Formulate the characteristic equation P () = 0 the roots ofwhich are the eigenvalues of A. Start from the eigen relation Ax = x and use thetheorem on solvability of systems of linear equations to formulate the characteristicequation.

    16. Dene the maximum-norm of a vector and of a matrix. Compute the maximum-normof

    1 1 11 2 31 2 0

    14

  • 17. Given a vector c0 = [2, 0]T and a matrix B,

    B =1

    4

    (1 11 2

    ).

    Compute c1 = Bc0 (0, 1)T. Compute the maximum-norm and the Euclidean normof c1 c0 and of B.

    18. The solution of 2 1 01 3 1

    0 2 1

    x =

    15

    4

    is x =

    01

    2

    What is the solution of 2 1 01 3 1

    0 2 1

    y =

    1050

    40

    Almost no calculations are needed to give the answer.

    19. Perform by hand Gaussian elimination without pivoting on the system

    3x1 + 6x2 + 3x3 = 12

    6x1 + 3x2 + 3x3 = 3

    12x1 + 3x2 + 9x3 = 3

    Record all intermediate results and the nal solution of this system of linear equa-tions.

    20. How many multiplications are needed to solve a system of linear equations with nunknowns?

    4.2 Systems of linear equations, formulations

    21. The table below gives the steam pressure p at three dierent temperatures T :

    T 40 50 60p 55.3 92.5 149.4

    Formulate the system of linear equations that denes the coecients of the polyno-mial

    Q(T ) = c1 + c2T + c3T2

    that passes though the three points of the table. Use Matlab to solve the system andcompute the pressure at T = 45 and at T = 57.

    15

  • 22. Determine the temperature inside a metal bar with cross section according to thegure. The temperature on the surface is 200 or 0 according to the gure. Thetemperature values in the interior is determined according to the following rule: Thetemperature ui in a crosspoint in the grid is equal to the mean value of the thetemperature at the four nearest neighbours. Formulate and solve a system of linearequations for u1, u2, u3, u4. Use Matlab. Are there any symmetries that can be usedto check the solution or reduce the number of unknowns?

    u1 u2

    u3 u4

    0

    0

    00 0

    0

    0

    200 200

    200

    200

    23. A circle in the xy-plane is given by

    (x xc)2 + (y yc)2 = R2

    You shall formulate an algorithm to determine the center of the circle (xc, yc) andthe radius R for the circle that passes through the points (3, 15), (8, 10) and (10, 20).First formulate a system of linear equations Ac = b from the solution c of which(xc, yc) and R can be computed. Give expressions for c1, c2 and c3 using xc, yc andR.

    4.3 Systems of linear equations, accuracy

    24. Dene the condition number of a matrix. Use the condition number of A to estimatehow errors b in the right hand side b of the system of linear equations Ax = bmight aect the accuracy of the solution.

    25. During a physics lab a student had to solve the following system of linear equationsAx = c where

    A =

    0.400 1.000 0.200 0.200

    0.486 1.286 0.114 0.0290.143 0.143 0.143 0.286

    0.514 0.714 0.114 0.029

    c =

    0.000

    0.1430.572

    0.857

    His solution wasx = ( 3.000 1.000 0.000 1.000 )T

    16

  • The matrix of coecients and the right-hand side our student had determined byhand-calculations before he typed them to the computer.

    When our student had almost nished his report on the lab he realized that he duringthe hand calculations had rounded the elements of the matrix and right-hand side tothree decimals before he gave them to the computer. Help him to judge the accuracyof the solution, due to these rounding errors in the data. The maximum norm of theinverse of the matrix of coecients is 202. Do the calculations by hand or calculator.

    26. A car runs at constant acceleration a m/s2 along a straight highway. Introduce thefollowing notation

    The distance from the car to a reference point 0 at time t = 0 : s0 m,The distance from the car to a reference point 0 at time t : s m,The velocity of the car at time t = 0 : v0 m/s

    With this notation we haves = s0 + v0t +

    at2

    2

    a. Use Matlab to determine the unknown parameters from the following measure-ments

    t 2 5 9s 8.7 40.9 125.7

    b. Estimate the uncertainty of the parameters if the tabular values have errors ofmeasurements according to: Errors in s-values at most 0.05, errors in t-valuesat most 0.001. Estimate the uncertainty by experimental perturbation cal-culations, perturbing one data value a time and adding the contributions fromeach source of error. What errors are most important. Compare the estimatedinuence of errors in the s-values to an estimate obtained with the conditionnumber for the matrix of coecients. Use Matlab for the calculations.The following model of thought might be useful.

    Ax =b Ax = bx=

    s0v0a

    t1 t 2 t 3

    s1 s2 s3

    A

    b

    Data in: Formulatesystem Solve

    Data out:

    17

  • 27. Consider the following tableT oC p mm Hg40 55.345 71.950 92.555 118.060 149.4

    Use Matlab to determine the coecients of the polynomial

    p = c1 + c2T + c3T2 + c4T

    3 + c5T4

    passing through the tabulated points.

    The T -values are assumed to be exact, while the p-values are assumed to have errorsat most 0.05. Can we trust the coecients calculated in this way? Use estimatesbased on both the condition number for the matrix of coecients and experimentalperturbation calculations. If we calculate p(58) from this polynomial, how large isthe inuence of the errors in the original p-values?

    4.4 References

    1. Strang, G., Introduction to linear algebra, Wellesley-Cambridge Press, 1993

    2. Rde L., Westergren B., BETA Mathematics Handbook for Science and Engineering,Studentlitteratur, 3rd ed, 1995.

    3. Prt-Enander et. al., The Matlab Handbook, Addison Wesley Longman 1996.

    18

  • 5 Least squares problems (Lennart Edsberg)

    5.1 General concepts

    1. Given the following over-determined linear system of equations Ax b:x1 + 2x2 6x1 + x2 0

    2x1 + x2 5Compute with paper and pencil the least squares solution, the residual vector and itsEuclidean norm. Present the normal equations. Verify also that the residual vectoris orthogonal to the columns of A.

    2. Which of the following Euclidean norms is minimized when the over-determinedsystem of linear equations Ax b is solved in the least squares sense:

    I. x2 II. Ax b2 III. x b23. In the normal equations ATAx = AT b the system matrix ATA is symmetric and

    (assume) positive denite.What is meant by the matrix being symmetric?What is meant by the matrix being positive denite?Is the system matrix always positive denite?

    4. If A is an m n matrix with m > n, how many multiplications are needed tocompute the quantities B = ATA and c = AT b in the normal equations? How manymultiplications are needed to compute the solution of the normal equations?

    5. Assume that c1, c2, c3 are parameters in the following mathematical models. In whichof the models do the parameters enter linearly?

    a. y = c1 + c2ec3x

    b. y = c1 + c2sin(x) + c3cos(x)

    c. y = c1 + c2/(1 + c3x)

    d. y = c1 + c2sin(x + c3)

    6. When the parameters enter nonlinearly in a model, i.e.

    y = f(x, c1, c2, . . . , cn)

    Gauss-Newtons method can be used to t c1, c2, . . . , cn to data (xi, yi), i = 1, 2, . . . , m.

    Describe the Gauss-Newton method. Be specic what you mean by starting value,iteration and stopping criterion.

    19

  • 5.2 Formulation and solution in Matlab

    7. Compute the straight line that in the least squares sense best approximates thefollowing measured data

    x y0 1.21 1.92 2.83 4.14 5.0

    Use Matlab to

    compute the parameters of the straight line, write out a table of the measured data, the straight line values in the x-points

    and the residual,

    plot two graphs, one with the data and the tted straight line, the other withthe residuals

    8. Use the least squares method to t the parameters Tm, aT and in the periodicfunction

    T (t) = Tm + aT sin(2t

    12+ ) ()

    to the following measured data of the mean value temperature in Stockholm during12 months:

    month t 1 2 3 4 5 6 7 8 9 10 11 12temp T -2.5 -3 -0.5 4 10 15 18 17 13 7.5 3 0.5

    In the given model () the parameter enters nonlinearly. Therefore, rst rewritethe model on linear form, t the parameters in this linear model and nally transformback to the original parameters.

    Use Matlab to compute the three parameters and plot a graph of the data and thetted function over a whole year.

    9. The development of the population on earth can be modeled with a dierential equa-tion. The following three dierential equations are proposed as candidates:

    a)dx

    dt= kax

    b)dx

    dt= kbx

    2

    c)dx

    dt= kcx(1 x

    Kc)

    20

  • year t 1650 1700 1750 1800 1850 1900 1920 1940 1960pop 545 623 728 906 1171 1608 1834 2295 3003

    The data are given from the following table where the population pop is given inmillions:

    Fit the parameters ka, kb, kc and Kc in the three models above. Extrapolate the ttedthree models to, say, 1997s population. The second model will break down in nitetime. In which year will the population tend to innity for that model? The thirdmodel will stabilize to a certain value as t. What value?

    Hint: Solve the dierential equations and t the solution to the data.

    5.3 Reference

    1. Borse, G.J., Numerical Methods with Matlab, PWS Publ Company, 1997

    21

  • 6 Non-linear equations (Bengt Lindberg)

    6.1 General concepts

    1. Formulate the mean-value theorem for a function of one variable.

    2. Expand a function f(x) of one variable in Taylor series about x = a. Write down therst three terms of the Taylor expansion of f(x) = 1/x about x = 1.

    3. Discuss the concept local linearization for a function of one variable. Relate toTaylor expansion. Use Matlab to illustrate graphically by zooming in on the functionf(x) = x 4 sin 2x 3 around x = 1.75. Draw the function successively on theintervals (4, 10), (1, 3) ,(1.5, 2) and (1.7, 1.8) in dierent windows. The Matlabcommands fplot and subplot can be very useful here.

    4. Expand a function f(x) of n variables in Taylor series about x = c. Write down therst two terms of the Taylor series expansion of

    f(x) =

    2x1x3 3x

    21x

    42

    (x2 x3)2 + x31x21 + x

    22 + x

    23 6

    about x =

    11

    0

    5. For a vector valued function G of three variables we know:

    For c =

    121

    we have G =

    10.10.2

    4.8

    and

    (G

    y

    )=

    4 1 01 5 2

    0 1 2

    Compute an approximation to G(w) for w = (1.01, 1.99,1.01)T. Formulate alinear approximation to G(y) valid for all y in the neighborhood of y = c.

    6.2 Non-linear equations, formulations

    6. At a distance one meter from a tall wall there is a low wall. A ve meter long ladderleans over the low wall against the tall wall so the ladder touches the low wall. Atwhat height H does the ladder touch the tall wall? Draw a sketch by hand and derivean equation for H . Rewrite the equation as a polynomial equation and compute allthe roots, using e.g. Matlab roots. Which solutions are reasonable?

    6.3 Non-linear equations, numerical methods

    7. Estimate by hand a coarse approximation to some root of

    x6 + 2x4 2x2 = 1, 000, 000

    22

  • 8. Describe the Newton-Raphson method for solution of

    x3 + ex3 = 100 lnx

    No arithmetical calculations are needed.

    9. Find at least one solution of the equation

    60x (x2 + x + 0.1)6

    (x + 1)6 10xex = 0, x > 0

    Are there any more positive solutions? Plot and analyze what happens when xand when x 0.

    10. The equation x = ex has one root in the interval [0.5, 0.6]. The following threeiteration formulas are intended to be used to accurately determine the root.

    xn+1 = exn , xn+1 = 2(exn + 0.5xn)/3, xn+1 = ln xn

    Do the iterations converge? Discuss the convergence, without actually performingthe iterations.

    11. In the equationeax

    2

    / ln(x + b) = 1

    the parameters a and b are given according to a = 2.533103, b = 0.5432103.Determine the solution of the equation with an accuracy that is reasonable withrespect to the inaccuracies of a and b. Make numerical experiments to choose areasonable number of signicant digits in the answer.

    12. First estimate by hand a coarse approximation to a solution of

    10x + x3 y + 0.1xy = 1x + 10y + y3 = 0.5

    Then nd a solution with error less than 0.5 1010. Error estimate is required.

    6.4 Reference

    1. Borse, G.J., Numerical Methods with Matlab, PWS Publ Company, 1997

    23

  • 7 Finite dierences and such (Jesper Oppelstrup)Concepts: Dierence approximations, Order of approximation, Quadrature, Extrapola-tion, Interpolation.Denition of the O and o symbolsf(x) = O(g(x)) as x a if, for|x a| suciently small, |f(x)/g(x)| < Kf(x) = o(g(x)) as x a if limxa f(x)/g(x) = 0

    7.1 Dierence operators

    1. Dene the dierence operators

    D+f(x) = (f(x + h) f(x))/h, Df(x) = (f(x) f(x h))/hShow that if f is many times dierentiable, then

    a. D+f(x) = f (x) + h/2f (x) + O(h2)

    b. 1/2(D+ + D)f(x) = (f(x + h) f(x h))/(2h) = f (x) + O(h2)This operator is usually called the central dierence operator D0.

    c. D+(Df(x)) = D(D+f(x)) = f (x) + O(h2)This operator is related to 2, the central second dierence operator, byD+D = 2/h2.

    2. Dene the shift operator E by Ef(x) = f(x+h) and the forward dierence operator by = E 1. Powers of an operator Q are dened recursively by Qpf(x) =Q(Q(Q(...Qf(x)...))) (p applications of the operator Q). Show ( e.g. by induction )that

    kf(x) = (E 1)kf(x) =k

    j=0

    (kj

    )(1)kjf(x + jh)

    7.2 Polynomials

    3. Choose the coecients a, b, and c, such that

    (af(x h) + bf(x) + cf(x + h)) = hf (x)

    when f(x) is a polynomial of degree 0, 1, 2, ..., as high as possible. What is the orderof accuracy of this dierence operator?

    4. Same question for the single-sided dierence operator,

    (af(x 2h) + bf(x h) + cf(x))/h

    24

  • 5. Write the polynomial P (x) of minimal degree q which satises

    P (x) = f0, P (x + h) = f1, P (x + 2h) = f2

    What is q? Dierentiate P to obtain a formula for P (x) and compare with the resultof question 4.

    6. Compute f(3) by i) linear ii) quadratic iii) cubic polynomial interpolation in thetable

    x: 0 2 4 6f(x): 0 2 16 30

    7. Write a function (Matlab, Fortran, Pascal, or C) which, when given two arraysx(1:n), y(1:n) computes the coecients c(1:n) in the interpolation polynomialin Newtons form,

    P (x) = c1 + c2(x x1) + c3(x x1)(x x2) + ... + cn(x x1)...(x xn1)

    What is the degree of the polynomial? If you use C, you may want to change theindices appropriately. i.e., 0:n, etc.Matlab: function c = coeval(x,y);Fortran: SUBROUTINE COEVAL(X,Y,C,N). Note that Fortran functions cannot returnarrays. Also the lengths of arrays must be explicitly specied.Pascal: function coeval(x,y: vector): vector. Lengths of arrays must bexed since they are specied in the type vector which you may assume has beendeclared.C: double* coeval(double* x, double* y, int n);

    8. Write a function (Matlab, Fortran, Pascal, or C) which, when given two arrays x(1:n)and c(1:n) where c is the coecient array of the Newton polynomial (see 7) com-putes the coecients a(1:n) of the representation P (x) =

    nk=1 akx

    k1. How manyops are required?

    7.3 Quadrature

    9. Approximately how small steps are required for the trapezoidal formula to give arelative error smaller than, say, 50 percent when applied to

    21

    e(x0.50.01

    )2

    1 + x2dx

    Make a rough graph of the integrand!

    25

  • 10. Recall that the error in the trapezoidal rule satises

    | baf(x) dx T (h)| h

    2

    12(b a) max

    axb|f (x)|

    How small must the step-size h be in the trapezoidal rule to compute 10

    11+x3

    dx withan error less than 0.001?

    11. It is required to compute

    I = 0

    arctan x

    (1 + x)2dx =

    A0

    arctan x

    (1 + x)2dx +

    A

    arctanx

    (1 + x)2dx

    with an error less than 106. How large must A be taken to make the last integral 0.5 106?

    7.4 Extrapolation

    12. The central dierence approximation D+D is used to compute values of f (1)when f(x) = cosx with step-sizes h = 2k, k = 6, 7, ... The answer is cos(1) =0.5403023059 correctly rounded. The results of a Matlab run are

    k D+D error6 0.5402913135 1.0992e 057 0.5402995578 2.7481e 068 0.5403016188 6.8703e 079 0.5403021341 1.7178e 07

    10 0.5403022630 4.2877e 0811 0.5403022952 1.0630e 0812 0.5403023027 3.1798e 0913 0.5403022990 6.9051e 0914 0.5403022766 2.9257e 0815 0.5403022766 2.9257e 0816 0.5403022766 2.9257e 0817 0.5403022766 2.9257e 0818 0.5402984619 3.8440e 0619 0.5402832031 1.9103e 0520 0.5402832031 1.9103e 05

    Are these results consistent with the claim that the arithmetic precision is around 17decimal digits? Explain the sources of error and use extrapolation - even repeated -to produce a more accurate answer.

    13. The perimeter of a regular n-sided polygon inscribed in a unit circle is Pn = 2n sin(/n).Show that as n, Pn 2 = c2n2 + c4n4 + ... + c2kn2k + ...

    26

  • Let sin(2/n) = un. Prove the recursion formula u2n = 12

    1

    1 u2n and show

    that it is equivalent to u2n = un2

    1+

    1u2n

    Use it to compute P3, P6, and P12 exactly and apply Richardson extrapolation toobtain an improved value for 2. How large does n have to be in order for Pn tohave the same error? Why is the latter form of the recursion preferable for numericalwork? Think of rounding errors.

    7.5 Band-matrix method for boundary value problems

    14. Consider the two-point boundary value problem for the single dierential equation

    u = f(x), u(0) = a, u(L) = bDiscretize by a uniform grid

    xj = jx, x0 = 0, xN = L,x = L/N, uj u(xj)by writing one dierence equation using the central dierence operator 2 (see above)for each inner grid-point j = 1, ..., N 1. The unknowns are uj, j = 1, ..., N 1since u0 and uN are known. The result is a system of linear equations Au = f ,u =(u1, u2, ..., uN1)T . Write the matrix A and the column vector f.

    15. Consider the boundary value problem for the single dierential equation

    u = 1 + x + u, u(0) + 2u(4) = 7

    Discretize by a uniform grid xj = jx, x0 = 0, xN = 4, uj u(xj) by writing adierence equation using the forward dierence operator D+ (see above) for all grid-points possible. This is the Euler method for the dierential equation. Formulatea system of linear equations Au=f. Dont forget the extra condition. Write downthe elements of the matrix A and the column vectors u and f. Verify by numericalexperiment that the approximation has error O(x).

    16. Consider the previous problem once again. Approximate the dierential equation bythe implicit midpoint rule (also called the box scheme), i.e.

    (un+1 un)/x = f(xn+1/2, (un+1 + un)/2) for u = f(x, u)Formulate a system of linear equations Au = f . Write down the elements of thematrix A and the column vectors u and f. Verify, by Taylor expansions aroundx = xn+1/2 that the approximation has error O(x2).

    7.6 References

    1. Dahlquist, G., Bjrck, ., Numerical Methods, Prentice Hall, 1974

    27

  • 8 Ordinary dierential equations (Bengt Lindberg)

    8.1 General concepts

    1. The dierential equationdy

    dt= 0.1y

    has the general solutiony(t) = Ce0.1t

    Sketch in a t, y-coordinate system the solution curve passing through the point (0, 20),and compute y(10) for that solution curve.

    Sketch a solution curve passing through the point (2, 18) and compute y(10) for thatsolution curve.

    2. Sketch the slope eld (in the positive quadrant) for the dierential equation

    dy

    dt= 0.1y

    Sketch some solution curves.

    3. The dierential equation

    dy

    dt= 1 + t y, y(0) = 2

    is given. Calculate a coarse approximation to y(0.2). Use the slope eld.

    4. Sketch the graph of the solution to

    y = 2y +x, y(0) = 1

    for 0 x 0.15. The equations describing radioactive decay of A to B to C

    A

    k1 B

    k2 C

    are given by

    dx1/dt = k1x1dx2/dt = k1x1 k2x2dx3/dt = k2x2

    28

  • where x1 denotes the amount of A, x2 the amount of B and x3 the amount of C.k1 and k2 are time-constants for the decay. To start with there is 100 kg of A andnothing of B and C. Write the system of equations in the form

    dx

    dt= Hx, x(0) = c

    Write down x, H and c.

    6. Given the dierential equation

    md2y

    dt2+ c

    dy

    dt+ ky = 0, y(0) = y0, y

    (0) = 0

    Here m, c, k and y0 are given parameters.Write the problem on the following standard form for systems of ordinary dierentialequations

    y = f(t,y), y(0) = c

    Give expressions for y, c and f(t,y).As the problem is linear the right-hand side can be written

    f(t,y) = Ay

    where A is a matrix. Give expressions for the elements of A.

    7. The following equations describe a baseball ying in the air

    md2x

    dt2= C dx

    dt

    (dx

    dt)2 + (

    dy

    dt)2

    md2y

    dt2= mg Cdy

    dt

    (dx

    dt)2 + (

    dy

    dt)2

    m, C and g are given constants. The ball is thrown with velocity v from the positionx = 0, y = 2. The direction of the ball at the initial moment is 30 upwards.Write the system in standard form for initial value problems for ODEs

    y = f(t,y), y(0) = c

    Give expressions for y, c and f(t,y).

    29

  • 8.2 Linear dierential and dierence equations and systems

    8. Solve the dierential equation ( q is a given complex constant)

    dy

    dt qy = 0, y(0) = 1

    9. Write down the general solution of the dierential equation

    d2y

    dt2+

    dy

    dt 2y = 0

    Find the solution corresponding to the initial condition y(0) = 1, y(0) = 0.

    10. Solve the dierential equation

    d2y

    dt2+ 2

    dy

    dt+ 2y = 0, y(0) = 0, y(0) = 1

    11. Write down the general solution of the dierence equation

    yn+2 + yn+1 2yn = 0,Find the solution corresponding to the initial condition y0 = 1, y1 = 1.

    12. Solve the dierence equation

    yn+2 + 2yn+1 + 5yn = 0, y0 = 0, y1 = 1

    13. Solve the system of linear dierential equations

    y =(

    4 22 1

    )y, y(0) =

    (01

    )

    14. Given the systemy = Ay, y(0) = y0

    with y(t) a column vector with n components, and A a n n matrix with lin-early independent eigenvectors. Formulate the solution using the eigenvalues and theeigenvectors of A.

    15. Given the system

    y =

    4 1 1 01 4 1 11 1 4 10 1 1 4

    y, y(0) =

    2010

    Use Matlab to nd eigenvalues and eigenvectors, and use them to express the generalsolution of the dierential equation. Find the specic solution corresponding to theinitial value vector.

    16. Among the problems 2-7, 21 and 23 which are linear and which are non-linear?

    30

  • 8.3 Numerical methods

    17. Use Matlab to compute a numerical approximation to the solution of problem 3. inGeneral concepts for 0 t 5. The problem was

    dy

    dt= 1 + t y, y(0) = 2

    18. Use Matlab to compute a numerical approximation to the solution of problem 5. inGeneral concepts for 0 t 2. Use k1 = 10, k2 = 1.

    19. Use Matlab to compute a numerical approximation to the solution of problem 7. inGeneral concepts for 0 t 3. Use C = 0.05, m = 1, g = 9.81.

    20. Describe the Euler method for numerical solution of initial value problems

    y = f(t,y), y(0) = c

    21. Use a calculator and the Euler method with step-length 0.25 to compute u(0.5). Allintermediate results should be recorded. Here u(t) is the solution of

    du

    dt= 1 + t 3u

    1 + u2, u(0) = 2

    Write a program that computes, tabulates and plots an approximate solution for0 t 5 using the Euler method. Use step-sizes 0.1 and 0.01 and plot the twoapproximate solutions in the same graph. Estimate the error in the solution computedwith step-size 0.1.

    22. Use the Runge-Kutta method of order 4

    yn+1 = yn + (k1 + 2k2 + 2k3 + k4)/6 tn+1 = tn + h y0 = c

    k1 = hf(tn,yn)k2 = hf(tn + h/2,yn + k1/2)k3 = hf(tn + h/2,yn + k2/2)k4 = hf(tn + h,yn + k3)

    to compute a numerical approximation to the solution of problem 7. in Generalconcepts for 0 t 3. Use C = 0.05, m = 1, g = 9.81. Use constant step-size,choose the step-size so the error at t = 3 is less than 104. Experiment with thestep-size, to nd a step-size that gives sucient accuracy.

    23. Given the equation

    y + 2xy + y = 0, y(0) = 0.1, y(0) = A

    31

  • a. Determine by calculator a coarse approximation to y(0.4) when A = 0.2. Youmay use any method you like, but you have to nd an approximate solution andan estimate of the error in your solution.

    b. Use Matlab to calculate y(10) when A = 0.2. Your program also should estimatethe accuracy of the solution.

    c. The quantity A is a measured quantity. We want the error of measurement,eA,to inuence the solution value at x = 10 at most by 0.005. Modify yourprogram in b. and determine how large |eA| can be allowed to be.

    8.4 References

    The material of this test is partly covered in many text-books on elementary dieren-tial equations and elementary numerical methods. The following are one set of possiblereferences to some texts available in our library.

    Short surveys of techniques for linear dierential equations and linear dierence equa-tions are given in ref 1. section 9.3 and 9.5 respectively.For Matlab solutions of systems of ODEs see ref 2, sec. 11.2 and for Matlab calculationsof eigenvalues and eigenvectors see ref. 2, sec. 8.1.Elementary numerical methods for initial value problems are described in sec 2.2 of ref.3. The discussion in section 2.1 of ref. 3 contains general ideas on numerical solution ofODEs.

    1. Rde L., Westergren B., BETA Mathematics Handbook for Science and Engineering,Studentlitteratur, 3rd ed, 1995.

    2. Prt-Enander et. al., The Matlab Handbook, Addison Wesley Longman 1996.

    3. Golub, G.H., Ortega, J.M. Scientic Computing and Dierential Equations, An In-troduction to Numerical Methods, Academic Press, Inc, 1992

    32

  • 9 Mathematical Modeling (Jesper Oppelstrup)

    9.1 Applied problems: Particle Dynamics

    Concepts:Denition of velocity, acceleration, force, torque. Springs and dampers. New-tons law. Eigenfrequencies and eigenmodes.

    1. The material point P moves along the curve x = 2 cos(t), y = sin(t) where t is time.Determine its velocity vector and acceleration vector. Where is the accelerationlargest?

    2. A body accelerates along a straight line according to

    a(t) =

    {9 + 2t, when 0 t 112 t, when t 1

    If it starts from rest, at what time does it turn, and where?

    3. Springs and balls.A linear spring is one whose force F is proportional to its extension/compressionfrom its natural length l, F = Kx, where K is called the spring "constant". Writedown the forces in the springs, the forces acting on the balls, and the equations ofmotion for the balls.

    m

    2m

    K, l

    K, l

    g

    x

    x2

    x1

    Write the equations in the vector form

    d2u

    dt2+Au = f ,u =

    (x1x2

    )

    and write out the matrix A and the vector f . Determine the equilibrium positions,and eigen-frequencies and -modes for oscillations around the equilibrium.

    4. A spring-mass-dash-pot system oscillates according tod2u

    dt2+ 0.01

    du

    dt+ 2u = sint

    At what driving frequency does resonance occur? What is the amplitude of theforced oscillation?

    33

  • 9.2 Geometry

    Concepts: Arclength, tangent, normal, curvature, surface, volume, ..., etc.

    5. The material point P moves along the trajectory y = sin(x) with constant veloc-ity

    x2 + y2 = v, x 0 Write a dierential equation from which Ps coordinates

    x(t), y(t) can be determined.

    6. The sub-tangent s(x) of a curve y = f(x) is the distance between the abscissa xand the point of intersection between the x-axis and the tangent at x. The followingproblem was solved by both Newton and Leibniz: What is f(x) if, for all x, s(x) = 5?

    7. A supersonic aircraft in level ight follows a trajectory such that the distance to theorigin decreases every hour by c km where c is the speed of sound. If it travels at Mach2 (i.e., its velocity is = 2c), how will the trajectory look? Hint: Use polar coordinates(r, ). Obviously dr

    dt= c. The arc element along the curve is (ds)2 = (rd)2+(dr)2.

    From this you can obtain dierential equations for both r(t) and (t) which are easilysolvable. The trajectory focuses sound waves to produce a pronounced sonic boomat the origin. (A trick question: If the plane is 400 km from the origin at time 0,and c = 1200 km/hrs, when is the bang, and how long is the distance traveled?

    8. A hot air balloon has a horizontal cross-section which is a regular n-sided polygon.It is inscribed in a circle of radius r = r(z), h z H, r(H) = 0 (z is the verticalcoordinate). Develop formulae for its volume and surface area.

    9. (From a textbook by Sanchez, Allen and Kyner) A spherical moth-ball loses mass byevaporation from the surface. Assuming that the mass loss rate is proportional tothe surface area, if half the ball is gone after a fortnight, how long does it last all inall?

    10. A toroidal winding has a circular cross-section of radius r and inner radius R.

    R

    r

    Assuming that the wire is of diameter d r, and that it has been wound to max-imal density, i.e., the wire cross-sections form a densely packed hexagonal patternapproximately how long is the wire? Can you develop a more accurate formula?

    11. Four-link mechanism.

    34

  • v u

    d

    ac

    bP1

    P2

    Develop formulas to compute the angle u, and coordinates in a suitably chosen systemfor the joints P1 and P2. The answer is not " simple".

    9.3 Vector analysis

    12. It is rainy and windy. The rain intensity and direction of fall can be described by thevector q = (1, 2,3) (mm/s)- this is quite a torrent - when the x-axis points north,and the y-axis points west. How much water passes in an hour through a footballgoal of area 13 m2 facing southwest?

    13. In two space dimensions we may dene the divergence of a vector eld

    f(x, y) =(u(x, y)v(x, y)

    )according to div f = lim

    A0

    Cf nds

    or as div f =u

    x+

    v

    y

    n

    (x,y)

    n

    A

    C

    Show the equivalence of the two formulas for the case that:

    A is a circular area of radius r with center at the origin (0, 0), u(x, y) = 2x + yx, v(x, y) = y2 x2.

    35

  • Compute the line integral by the parameterization x = r cos, y = r sin and let rtend to zero.

    9.4 Law of Mass Action

    14. A chemical reaction A + 2B AB2 proceeds according to the law of mass action,i.e., if the concentrations of A, B and AB2 are called a(t), b(t), and c(t) where t istime, then

    da/dt = k1ab2 + k2cdb/dt = 2k1ab2 + 2k2cdc/dt = k1ab

    2 k2cwith initial values a(0) = a0, b(0) = b0, c(0) = c0.k1 and k2 are called reaction rate"constants".

    a. Show that the solution of the system of dierential equations satises{

    a(t) + c(t) = a0 + b0b(t) + 2c(t) = b0 + 2c0

    What is the interpretation of these two equations in terms of conservation ofatoms? Deduce from this a single dierential equation for c(t);

    b. At equilibrium ab2/c = k2/k1 = equilibrium constant, called C. Deduce fromthis and the linear invariants above a polynomial equation for the equilibriumconcentration c().

    9.5 Hydrodynamics

    15. Neglecting frictional eects, the velocity of the jet of liquid issuing from a small holeH below the free surface in the container is v =

    2gH when the gravity is g m/s2.

    Assuming the area of the hole is A, write a dierential equation for the height H(t)of the free surface in an oil barrel lying on its side, radius R, with a hole very nearthe ground. Initially the barrel is full and there is a hole at the top so the pressureequals the ambient pressure.

    36

  • gH(t)

    0v

    The equation becomes simpler if expressed not in H but in the angle v. Formulateand solve the equation also for the case when the barrel stands on its end, otherwisesimilar. Does the ow stop at a particular time or does the trickling go on forever?

    9.6 References

    1. Strang G., Introduction to applied mathematics, Wellesley-Cambridge press, 1986

    2. Logan J.D., Applied Mathematics, a contemporary approach,J. Wiley and Sons, 1987

    3. Essen, H, Basic Mechanics, the science and its applications, THS, Stockholm, 1993

    37

  • 10 Partial Dierential Equations (Gunilla Kreiss)1. Classify the following equations with respect to linearity (linear or nonlinear), order

    (rst, second ...), type (elliptic, parabolic, hyperbolic), homogeneity (homogeneousor non-homogeneous), number of dependent and independent variables.

    (a) ut = uxx + 2ux + u

    (b) utt = uxx + et

    (c) uxx + 3uxy + uyy = sin(x)

    (d) ut = (1 + u2)uxx

    2. If u1 and u2 both satisfy equation (a), is it true that the sum also satises it? If yes,prove it. Answer the same questions for equation (d).

    3. Solveut = uxx, 0 x 1, t 0

    u(0, t) = u(1, t) = 0

    with the following two sets of initial conditions. Plot the solution as a surface andas a function of x at t = 0, t = 1, t = 2, t = 10.

    (a) u(x, 0) = sin(x)

    (b) u(x, 0) = sin(2x) + 2 sin(4x) + 10 sin(6x)

    4. Verify that the DAlembert solution

    u(x, t) = (x + ct) + (x ct)

    satises the equationutt = c

    2uxx, < x

  • 6. Find the solution to the vibrating string problem

    utt = 2uxx, 0 < x < L, t > 0,

    u(0, t) = u(L, t) = 0, t u,u(x, 0) = sin(x/L) + 2 sin(3x/L), ut(x, 0) = 0, 0 < x < L.

    Plot the solution as in problem 3 in the case when = 1, L = 1. What dierencesand similarities to the solution of problem 3 do you see?

    7. Solveut + ux = 0, < x 0,

    u(x, 0) = ex2

    .

    Plot the solution at some later times.

    8. Show that any function of the form f(x, y) = ax+ by + cxy satises Laplace equation.

    9. Solveuxx + uyy = 0, 0 < x < a, 0 < y < b,

    in the following cases

    (a)u(0, y) = u(a, y) = 0, 0 < y < b,

    u(x, 0) = 0, u(x, b) = sin(nx/a) 0 < x < a.

    Here n is a positive integer.

    (b)u(0, y) = 0, u(a, y) = sin(y/b), 0 < y < b,

    u(x, 0) = u(x, b) = 0 0 < x < a.

    (c)u(0, y) = 0, u(a, y) = sin(y/b), 0 < y < b,

    u(x, 0) = 0, u(x, b) = sin(3x/a) 0 < x < a.

    Plot the solution in the last case.

    10. Construct a parabolic problem (and equation together with suitable initial and bound-ary conditions) with solution

    u(x, t) = sin(t)x(1 x).

    39

  • 10.1 Reference

    1. Farlow, Partial Dierential Equations for Scientists and Engineers, Wiley, 1982.Study chapters 1-5,16-20,27,31-33

    40