You are on page 1of 2

Computational Mechanics

Dr. Prapanch Nair

APL300 - Assignment 1
Due Date: 11.00 PM, Friday, 11 February 2022.
For the descriptive problems, you may provide a hand written and scanned answer. For the coding parts,
create one or more IPython notebooks with your name/entry number and assignment number in the file
name ( amaxxxxx_a1_0.ipynb). You could also export the python notebook as a pdf and submit it along with
the hand written part. Please use moodle for uploading the answers. Alternatively you can share over email
to pnair@am.iitd.ac.in.
1. Derive the one sided approximation to u0 ( x̄ ) based on u( x̄ ), u( x̄ − h) and u( x̄ − 2h) . Note that this was
used in setting Neumann boundary conditions. Also derive the this approximation by approximating
the function u( x ) as a polynomial p( x ) and then use p0 ( x̄ as an approximation to u0 ( x̄ ). Show that the
approximation is the same with the polynomial approach as with the previous approach that you use.
Write down the first term in the trunction error for this approximation.
2. a. For the stencil x̄ − 2h, x̄ − h, x̄, x̄ + h , use the general approach to derive the finite difference coefficient
for u0 ( x ) at x̄. Write down the Vandermonde matrix whose form is:

1 1 if l = k,
l! j∑
l
c (
j jx − x̄ ) =
=1
0 otherwise.

and write down the difference approximation.


b. For the same stencil write down the Vandermonde matrix and the difference approximation for

u00 ( x )

.
3. Write a python code to do the follwing:
a) Solve u00 ( x ) = e x with boundary conditions u0 (0) = σ and u(1) = β . Take σ = β = 0 . Use 20 grid points.
Use the first order one sided derivative for Neumann BC, namely :

U1 − U0

h
.

1
b) Solve the above problem with second order approximations for the Neumann BC (second approach and
third approach as discussed in the lectures).
c) Plot the solutions obtained for all the three Neumann BC approaches for the resolution of 20 grid points.
d) Plot the error ( analytical solution of the given ODE is trivial because f ( x ) is an exponential function ) for
each of the three approaches against different h values ( say 20, 15, 10 grid points ). Plot these on a log log
plot to demonstrate which Neumann BC approach gives us better order of accuracy by computing the
slopes of these lines.

You might also like