0% found this document useful (0 votes)
28 views

Numerical Analysis Assignment Help

This document contains problems related to partial differential equations and their solutions. Problem 1 involves finding the Green's function and maximum eigenvalue for an operator. Problem 2 involves numerically solving the Laplacian eigenproblem in a cylinder and comparing to analytical solutions. Problem 3 involves finding steady-state and Green's function solutions to the wave equation with an oscillating force density.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Numerical Analysis Assignment Help

This document contains problems related to partial differential equations and their solutions. Problem 1 involves finding the Green's function and maximum eigenvalue for an operator. Problem 2 involves numerically solving the Laplacian eigenproblem in a cylinder and comparing to analytical solutions. Problem 3 involves finding steady-state and Green's function solutions to the wave equation with an oscillating force density.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

For any help related queries, call us at: – 

+1 678 648 4277


You can mail us at:- [email protected] or
reach us at:- https://www.mathhomeworksolver.com/
Problem

Consider the operator Aˆ= −c(x)Y2 in some 2d region Ω ⊆ R2 with


Dirichle tboundaries (u|∂Ω =0), where c(x) > 0. Suppose the eigen
functions of Aˆ are un(x) with eigen values λn [that is, =Aun λnun]
for n =1, 2,..., numbered in order λ1 <λ2 <λ3 < ···. Let G(x, x ') be the
Green’s function of Aˆ.

(a) If f (x) = n αnun(x) for some coefficients αn = (expression in


terms of f and un), the G(x, x')f (x')d2x' = (in
terms of αn and un).

(b) The maximum possible value of


for any possible u(x), is _____________________ (in terms of
quantities mentioned above). [Hint: min–max. Use the fact, from
the handout, that if Aˆis self-adjoint then Aˆ−1 is also self-adjoint.]

Problem 2:

In this problem, we will solve the Laplacian eigen problem −Y2u =


λu in a 2d radius-1 cylinder r ≤ 1 with Dirichlet boundary
conditions u|r=1Ω =0 by “brute force” in Julia with a 2d finite-
difference discretization, and compare to the analytical Bessel
solutions.
You will find the IJulia notebooks posted on the 18.303 website for
Lecture 9 and Lecture 11 extremely useful! (Note: when you open
the notebook, you can choose “Run All” from the Cell menu to load
all the commands in it.)

(a) Using the notebook for a 100 × 100 grid, compute the 6 smallest-
magnitude eigen values and eigen functions of A with λi,
Ui=eigs(Ai,nev=6,which=”SM”). The eigen values are given by λi. The
notebook also shows how to compute the exact eigen value from
the square of the root of the Bessel function. Compared with the
high-accuracy λ1 value, compute the error Δλ1 in the corresponding
finite-difference eigen value from the previous part. Also compute
Δλ1 for Nx = Ny = 200 and 400. How fast is the convergence rate
with Δx? Can you explain your results, in light of the fact that the
center-difference approximation we are using has an error that is
supposed to be ∼ Δx2? (Hint: think about how accurately the
boundary condition on ∂Ω is described in this finite-difference
approximation.)

(b) Modify the above code to instead discretize Y·cY, by writing A 0 as


−G CgG for some G matrix that implements Y and for some C g matrix
T

that multiplies the gradient by c(r)= r +1. Draw a sketch of the grid
2

points at which the components of Y are discretized—these will not


be the same as the (nx,ny) where u is discretized, because of the
centered differences. Be careful that you need to evaluate c at the Y
grid points now! Hint: you can make the matrix (M1/M2) in Julia by
the syntax [M1;M2].
Hint: Notice in the IJulia notebook from Lecture 11 how a matrix r is
created from a column-vector of x values and a row-vector of y
values. You will need to modify these x and/or y values to evaluate r
on a new grid(s). Given the r matrix rc on this new grid, you can
evaluate c(r) on the grid by c = rc.^2+1, and then make a diagonal
sparse matrix of these values by spdiagm(reshape(c, prod(size(c)))).

(c) Using this A ≈ Y· cY, compute the smallest-|λ| eigensolution and


plot it. Given the eigenfunction converted to a 2d Nx × Ny array u,
as in the Lecture 11 notebook, plot u(r) as a function of r, along with
a plot of the exact Bessel eigenfunction J0(k0r) from the c =1 case
for comparison.
plot(r[Nx/2:end,Ny/2], u[Nx/2:end,Ny/2]) k0 = so.newton(x ->
besselj(0,x), 2.0) plot(0:0.01:1, besselj(0, k0 * (0:0.01:1))/50)
Here, I scaled J0(k0r) by 1/50, but you should change this scale
factor as needed to make the plots of comparable magnitudes. Note
also that the r array here is the radius evaluated on the original u
grid, as in the Lecture 11 notebook.

Can you qualitatively explain the differences?

Problem 3:

Recall that the displacement u(x, t) of a stretched string [with fixed


ends: u(0,t)= u(L, t)=0]
satisfies the wave equation where f(x, t) is an
external force density (pressure) on the string.

(a) Suppose that f(x, t)= �[g(x)e−iωt], an oscillating force with a


frequency ω. Show that, instead of solving the wave equation
with this f(x, t), we can instead use a complex force f˜(x, t)=
g(x)e−iωt, solve for a complex u˜(x, t), and then take u = �u˜to
obtain the solution for the original f(x, t).

(b) Suppose that f(x, t)= g(x)e−iωt, and we want to find a steady-
state solution u(x, t)=
−iωt
v(x)ethat is oscillating everywhere at the same frequency as the
input force. (This will be the solution after a long time if there is
any dissipation in the system to allow the initial transients to die
away.) Write an equation ˆ= A self-adjoint? Av g that v solves. Is
ˆ
Positive/negative definite/semidefinite?

(c) Solve for the Green’s function G(x, x') of this ˆ A, assuming that
ω= nπ/L for any integer n (i.e. assume ω is not an eigenfrequency
[why?]). [Write down the continuity conditions that G must satisfy
at x = x', solve for x= x', and then use the continuity conditions to
eliminate unknowns.]
(d) Form a finite-difference approximation A of your Aˆ. Compute
an approximate G(x, x ) in Matlab by A\ dk, where dk is the unit
'

vector of all 0’s except for one 1/Δx at index k = x /Δx, and compare
'

(by plotting both) to your analytical solution from the previous part
for a couple values of x and a couple of different frequencies ω
(one < π/L and one > π/L) with L =1.

(e) Show the limit ω → 0 of your G relates in some expected way


to the Green’s function of –d2/dx2 from class.
Solutions
Problem 1:

(a) is self-ad joint under the inner product from


class (and the 1d version in homework), and hence the eigen
functions are orthogonal for distinct eigen values (but not
necessarily normalized to IunI =1), hence The
expression u(x)= is just the solution to i.e. it is u =
A−1f =

(b) This is just (u, Aˆ−1u)/(u, u), which is a Rayleigh quotient for
the self-adjoint operator Aˆ−1, and hence (thanks to the min–max
theorem) it is bounded above by the largest eigen value of Aˆ−1,
which is 1/λ1 (the inverse of the smallest eigen value of Aˆ).
(Note that by positive- definiteness 0 < λ1 < λ2 < · · · .)

Problem 2:

In this problem, we will solve the Laplacian eigen problem


in a 2d radius-1 cylinder r <= 1 with Dirichlet boundary conditions
by “brute force” in Julia with a 2d finite- difference
discretization, and compare to the analytical Bessel solutions. You
will find the IJulia notebooks posted on the 18.303 website for
Lecture 9 and Lecture 11 extremely useful! (Note: when you open
the notebook, you can choose “Run All” from the Cell menu to
load all the commands in it.)
(a) Using the notebook for a 100 X 100 grid, compute the 6
smallest-magnitude eigen values and eigen functions of A with
λi, Ui= eigs(Ai, nev=6,which=”SM”). The eigen values are given
by λi. The notebook also shows how to compute the exact eigen
value from the square of the root of the Bessel function.
Compared with the high-accuracy λ1 value, compute the error
Δλ1 in the corresponding finite-difference eigen value from the
previous part. Also compute Δλ1 for Nx = Ny = 200 and 400. How
fast is the convergence rate with Δx? Can you explain your
results, in light of the fact that the center-difference
approximation we are using has an error that is supposed to be
Δx2? (Hint: think about how accurately the boundary condition
on ∂Ω is described in this finite-difference approximation.)
(b) Modify the above code to instead discretize by writing A0
as −GT CgG for some G matrix that implements and for some
Cg matrix that multiplies the gradient by c(r)= r2 +1. Draw a
sketch of the grid points at which the components of are
discretized—these will not be the same as the (nx,ny) where u is
discretized, because of the centered differences. Be careful that
you need to evaluate c at the grid points now! Hint: you can
make the matrix (M1 M2 ) in Julia by the syntax [M1;M2].
Hint: how a matrix r is created from a column-vector of x values and
a row-vector of y values. You will need to modify these x and/or y
values to evaluate r on a new grid(s). Given the r matrix rc on this
new grid, you can evaluate c(r) on the grid by c = rc.^2+1, and then
make a diagonal sparse matrix of these values by
spdiagm(reshape(c, prod(size(c)))).
Using this A ≈' · c', compute the smallest-|λ| eigensolution and plot
it. Given the eigenfunction converted to a 2d Nx × Ny array u, as in
the Lecture 11 notebook, plot u(r) as a function of r, along with a
plot of the exact Bessel eigenfunction J0(k0r) from the c =1 case for
comparison.

plot(r[Nx/2:end,Ny/2], u[Nx/2:end,Ny/2]) k0 = so.newton(x ->


besselj(0,x), 2.0) plot(0:0.01:1, besselj(0, k0 * (0:0.01:1))/50)
1 Here, I scaled J0(k0r) by 1/50, but you should change this scale
factor as needed to make the plots of comparable magnitudes.
Note also that the r array here is the radius evaluated on the
original u grid, as in the Lecture 11 notebook.

Can you qualitatively explain the differences?

Problem 3:

Recall that the displacement u(x, t) of a stretched string [with fixed


ends: u(0,t)= u(L, t)=0]
uu
satisfies the wave equation ∂2 +f(x, t)= ∂2 , where f(x, t) is an external
force density (pressure)
∂x2 ∂t2
on the string.
∂2
u˜u˜
(a) Suppose that u˜solves ∂2 + f˜(x, t)= and satisfies u˜(0,t)= u˜(L,
t)=0. Now, consider
∂x2 ∂t2
u˜+u˜¯
u = �u˜= . Clearly, u(0,t)= u(L, t)=0, so u satisfies the same
boundary conditions. It
2

also satisfies the PDE:

since f = ˜˜¯= �f˜. The key factors that allowed us to do this are (i)
linearity, and (ii) the 2 real-ness of the PDE (the PDE itself contains
no i factors or other complex coefficients).

(b) Plugging u(x, t)= v(x)e−iωt and f(x, t)= g(x)e−iωt into the PDE, we
obtain

and The boundary conditions are v(0) = v(L)=0, from the


boundary conditions on u
Since ω2 is real, this is in the general Sturm-Liouville form that we
showed in class is selfadjoint.
Subtracting a constant from an operator just shifts all of the
eigenvalues by that constant, keeping the eigenfunctions the
same. Thus Aˆis still positive-definite if ω2 is < the smallest
eigenvalue of −∂2/∂x2, and positive semidefinite if ω2 = the
smallest eigenvalue. In this case, we know analytically that the
eigenvalues of −∂2/∂x2 with these boundary conditions are (nπ/L)2
for n =1, 2,.... So Aˆis positive-definite if ω2 < (π/L)2, it is positive-
semidefinite if ω2 =(π/L)2, and it is indefinite otherwise.

(c) We know that ˆ')=0 for x x'. Also, just as in class and as in the
notes, the fact AG(x, x = that ˆ')= ') meas that G must be
continuous (otherwise there would be a δ'

AG(x,x δ(x − x factor) and ∂G/∂x must have a jump discontinuity:

for −∂2G/∂x2 to give δ(x − x'). We could also show this more
explicitly by integrating:

which gives the same result.


Now, similar to class, we will solve it separately for x<x and for
x>x', and then impose the continuity requirements at x = x to find
the unknown coefficients.
For x<x , AG =0 means that ∂2 = −ω2G, hence G(x, x') is some sine
or cosine of ωx. But since G(0,x')=0, we must therefore have G(x,
x')= α sin(ωx) for some coefficient α.

Similarly, for x > x', we also have a sine or cosine of ωx. To get G(L,
x') = 0, the simplest way to do this is to use a sine with a phase
shift: G(x, x') = β sin(ω[L x]) for some coefficient β.  
Continuity now gives two equations in the two unknowns α and
β:

which has the solution

This simplifies a bit from the identity sinAcosB + cosB sinA = sin(A
+ B), and hence

which obviously obeys reciprocity.


Note that if ω is an eigen frequency, i.e. ω = nπ/L for some n, then
this G blows up.
The reason is that A in that case is singular (the nth eigen value
was shifted to zero), and defining A -1 ˆis more problematical.
(Physically, this corresponds to driving the oscillating string at a
resonance frequency, which generally leads to a diverging solution
unless there is dissipation in the system.)

(d) It is critical to get the signs right. Recall that we approximated


d/dx2 by −DTD for a 1st derivative matrix D. Therefore, you want to
make a matrix A = DTD − ω2I. In Matlab, A = D’*D -omega^2 *
eye(N) where N is the size of the matrix D = diff1(N) / dx with dx =
1/(N+1). We make dk by dk = zeros(N,1); dk(k) = 1/dx. I used N =
100.

The resulting plots are shown in figure 1, for ω =0.4π/L (left) and ω
=5.4π/L (right)
and x’ =0.5 and 0.75. As expected, for ω < π/L where it is positive-
definite, the Green’s function is positive and qualitatively similar to
that for ω =0, except that it is slightly curved. For larger ω, though,
it becomes oscillatory and much more interesting in shape. The
exact G and the finite-difference G match very well, as they should,
although the match becomes worse at higher frequencies—the
difference approximations become less and less accurate as the
function becomes more and more oscillatory relative to the grid
Δx, just as was the case
for the eigenfunctions as discussed in class.

[If you try to plug in an eigenfrequency (e.g. 4π/L) for ω, you may
notice that the exact G blows up but the finite-difference G is
finite. The reason for this is simple: the eigenvalues of the finite-
difference matrix DTD are not exactly (nπ/L)2, so the matrix is not
exactly singular, nor is it realistically possible to make it exactly
singular thanks to rounding errors. If you plug in something very
close to an eigenfrequency, then G becomes very close to an
eigenfunction multipled by a large amplitude. It is easy to see why
this is if you look at the expansion of the solution in terms of the
eigenfunctions.]
(e) For small ω, sin(ωy) ≈ ωy for any y, and hence

which matches the Green’s function of –d2/dx2 from class.


(Equivalently, you get 0/0 as ω → 0 and hence must use
L’Hôpital’s rule or similar to take the limit.)

You might also like