## 18.085 Fall 2012

### M W F 11-12 in 2-190

### Professor Gilbert Strang

**Office:**2-240

**e-mail:**gs@math.mit.edu

QUIZ 3 AVERAGE 88 STANDARD DEVIATION 10

I HOPE YOU HAVE A SUPER HOLIDAY

Quotes collected by my 18.085 class

Solutions: SolutionsQuiz3Fall12.pdf

Exam 3 will start at 7:40 on Thursday evening in ROOM 54-100 !!!

EARTH SCIENCES building and NOT WALKER

Question topics:

1. Fourier series / decay rate / energy / rules for df/dx etc

2. Discrete transform / FFT idea / Fourier matrix / link to K1D

3. Convolution / Toeplitz matrices / applications

4. Fourier integral / Green's function / equations on whole line

CORRECTION TO PROBLEM 4.4.9

The convolution should be (1, 2, 4) * (4, 2, 1)

Homework 1

PLEASE PRINT YOUR NAME CLEARLY

We will use this homework to make the class list

Homework 1 is due Wednesday September 12 in class

Can you write neatly and staple pages ? THANK YOU

Problems from the CSE textbook

1.1 1, 5, 12, 21, 27

1.2 1, 7, 9, 16, 19

1.3 8, 11

Here is Problem Set 1.1, Question 27 (please use this version of the question): q27.pdf

NOTE FROM CLASS Solution to Ku=F is u = K\F backslash in Matlab, K first !

NOTE 2 To explain my crazy equation delta(2x) = 1/2 delta(x) show that

integral -1 to 1 of delta(2x) dx = 1/2 (not 1 !!!)

integral of delta(2x) g(x) dx = 1/2 g(0) (not g(0) !!!)

Join Piazza for this course: https://piazza.com/mit/fall2012/18085/home

Homework 2 Due in class WED SEPT 19

PLEASE COPY THE NUMBER ON YOUR HWK 1 AT THE TOP OF ALL YOUR NEXT HWKS This is your class number -- much easier to read numbers than names

Again these come from the textbook / including a little MATLAB

1.3 13

1.4 2, 7, 11

1.5 2, 4, 9, 12, 16

1.6 6, 8, 14, 17, 20

Homework 3 for Wednesday Sept 26

2.1 3, 6, 7, 8

2.3 1, 7, 8, 9, 18

MATLAB problem to be posted soon (the answer will be printouts of graphs)

First MATLAB Homework in 18.085

Find the displacements x(1),...,x(100) of 100 masses connected by springs all with c = 1. You may take each force f(i) = .01 and consider two boundary conditions at the bottom:

(a) Spring 101 connects the last mass to a support as in Figure 2.1 in the section on masses and springs

(b) Mass 100 hangs free at the end of the line of springs.

Submit GRAPHS of the displacements in these two cases.

Here are a few MATLAB hints, mostly correct: d = ones(100,1) is a column vector of 100 ones and diag(d) is a diagonal matrix (in fact I) with d on the diagonal. diag(d,1) puts d on an off-diagonal, maybe this matrix has order 101. After computing the vector x try

plot(x,'+')

xlabel('mass number')

ylabel('displacement')

Homework 4 for WED October 3. This is the last homework before Exam 1 on WED Oct 10. (Top floor of Walker at 11:00. Open book and notes, stopping at Section 2.4 and not 1.7, 1.8, 2.2)

Section 2.4 1, 3, 7, 8, 11, 17 plus 18 and 21 (MATLAB)

Homework 5 for WED October 17

2.7 1, 2, 5, 7, 9, 10

Friday and Monday will cover the most lively example of A'CA : Structures.

Homework 6 for Wednesday OCT 24

3.1 5, 11, 14, 17, 18

3.2 1, 7, 17 (MATLAB) 18

Homework 7 for WED October 31

3.3 2, 7, 8

3.4 2, 4, 5, 18

MATLAB Problem 1 : polynomial interpolation.

Here is the MATLAB code to use for this question: polyinterp.m

This code plots a function 1/(1+25x^2) in solid blue line. It samples the function at N EQUALLY SPACED points, and plots those sample values in green circles.

It then forms the polynomial with N coefficients that passes EXACTLY through the given N points. It is plotted in dashed black line. The Vandermonde matrix (vander in MATLAB) is used to find the polynomial interpolant.

We wonder if the polynomial interpolant is a good approximation. But you will see that polynomial interpolation at equally spaced points is usually NOT a good idea. And you will see an example of the Runge phenomena. The oscillations near the boundary as N becomes large are worth seeing. See section 5.4 of the Computational Science and Engineering textbook for explanation.

a. Print and hand in one plot with N=11.

b. In this plot, we are interested in the behaviour of the polynomial interpolant near the boundary. What is the value of the target function (solid blue) at approximately x=0.95? What is the value of the interpolant (dashed black) at x=0.95?

c. Now increase the number of sampled points to N=21. Print and hand in a plot with N=21. Now what is the value of the interpolant (dashed black) at x=0.95?

d. The error is the difference between the interpolant and the target function. Comparing N=11 points, with N=21 points, is the error at x=0.95 bigger, smaller or the same?

e. The maximum error is the maximum difference between target function and interpolant on the whole interval x=[-1,1]. Answer yes or no: As you increase N, does the maximum error converge to zero?

MATLAB 2 on finite elements:

This MATLAB homework solves Laplace's equation in the unit circle with the Finite Element method. The equation inside the unit circle is

u_xx + u_yy = 0

and this comes with a boundary condition u(theta) that we choose on the unit circle. The exact analytic solution is given in the Computational Science and Engineering textbook by a Fourier analysis. See sections 3.4 and 3.6 of the CSE textbook for more explanation. For this homework, you need the following three codes from the website in the same folder:

LaplaceCircleFEM.m

huniform.m

distmesh2d.m

You only need to look at and run one of the codes: LaplaceCircleFEM. Hand in your answers to questions a., b. and c. below.

a. Run the MATLAB code LaplaceCircleFEM.m provided. It plots a finite element approximation to Laplace's equation with boundary condition u=+1 on the top of the unit circle, and u=-1 on the bottom of the unit circle. This matches the boundary condition in Section 3.4 of the the CSE textbook. Print and hand in your plot of the finite element approximation with this boundary condition.

b. Now change boundary conditions. Set the boundary condition on the unit circle to be u(theta) = sin(5*theta). This can be done by commenting out one line (for you to find and change) of the provided MATLAB code. Print and hand in your plot of the Finite Element approximation to Laplace's equation with this sine wave boundary condition.

c. Return to the original boundary condition: u=+1 on the top of the unit circle, and u=-1 on the bottom of the unit circle. Suppose now that there is a radially symmetric material constant c(r) = exp(a*r), for some real constant a. This c(r) enters the integrals that give the entries of K -- integrals of c times grad phi_i grad phi_j as in 1D. A sample output of the solution with a material constant is provided here on the website: sampleoutput.pdf. FEM.pdf

For this sample solution, of the following three options, which is the best estimate of the value of a in the material constant?

a= +3, a=0, a=-3

In order to answer this question, you may like to compute the FEM approximation with various values of the constant a, and this can be done easily by changing one line in the code. Print and hand in a plot of your finite element approximation with the value of a that you think is the best fit. On your plot, clearly write what value of a = ... that you have chosen.

NOT REQUIRED: The following is for you to think about, but NOT to hand in. You might like to compare the accuracy of the Finite Element approximation with the exact analytic formula in the book. For example, the code outputs the numerical value u(x,y) of the FEM approximation at the point (x,y) = (0.5,0.5). You would need to convert this to polar coordinates in order to compare with the formula given in the textbook. You could then see how the accuracy changes as you make the mesh finer (does it get more accurate as you make the mesh finer?). You can make the mesh finer by reducing the value of h in the MATLAB code. So that is one way to assess the accuracy of the VALUES of u(x,y) from the finite element approximation. You might also like to think about how the SLOPE of the finite element approximation compares to the slope of the exact solution.

*End of Homework*

Short homework 8 for WED November 14

3.5 1, 3

3.6 7, 9, 16 (in 7, why is U continuous between the two triangles ?)

Solutions to Quiz 2: Quiz2SolutionsFall2012.pdf

Homework 9 for WED November 21

4.1 3, 7, 9, 10, 13

4.2 1, 3

4.3 2, 8, 10, 15, 17

18.085 Homework 10 due MON DEC 3 (for return before quiz)

4.4 2, 3, 7, 8, 9

4.5 1, 2, 7, 10, 11, 14, 22

4.6 1, 2

**TAs**

*MOHAMMAD BAVARIAN*

e-mail: bavarian@mit.edu

Office hour: Fridays 4 to 5 in 2-349 applied math common room.*NETANEL BLAIER*

email: netanel@math.mit.edu

12:00 - 13:00, Tuesday, room 2-087. No office hour this week

Change of office hour this week to 27/11/2012 to 1:30-2:30 Tuesday.*Amelia Servi*

email: aservi@mit.edu

Office hour: Tuesdays 5-6pm in room 2-143.*shev macnamara*

e-mail: smacnamara@math.mit.edu

*Help sessions: Monday afternoons in same room as lecture 5.15pm*

James Noraky
**Graders**

### Course Topics

- Applied Linear Algebra
- Applied Differential Equations
- Fourier Methods
- Algorithms
- Course outline 2008

### Additional Information

- EXAMS: Oct 10 and Nov 5 at 11 in Walker. Also 54-100 Thursday evening Dec 6.
- Goals for the Course: See applications of calculus, ODE, linear algebra, and discrete methods without going into too much proof.
- Textbook:
*Computational Science and Engineering*(Wellesley-Cambridge, 2007). - Grades: Homework 25%, 3 quizzes 75%, no final exam. Please email Prof. Strang about conflicts with quiz dates.
- Homework: Due Wednesdays. Please write neatly, staple, and include your class number (to be assigned after Homework 1).
- Use of MATLAB for tedious calculations is encouraged, however you need to know
how to do the basic algorithms taught in the course
*by hand*(at least for small matrices) for the quizzes.

### Class Resources

**Movie of elimination** moe.m (also
need realmmd.m
)

**Code to create
K,T,B,C as sparse matrices**

**MATLAB's backslash command to solve Ax = b** (ps, pdf)

**Getting started with Matlab:** http://ocw.mit.edu/OcwWeb/Mathematics/18-06Spring-2005/RelatedResources/