CS计算机代考程序代写 scheme matlab algorithm 10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 1/28

5/25 Questions Answered
Saved on Oct 22 at 10:09 PM

Assignment 3

Q1 Boundary Value Problem
3 Points

You are required to find the numerical solution to the following ordinary differential equation

in the domain . You are required to solve this equation using numerical methods

with the boundary conditions and .

Q1.1
1 Point

As shown in lectures, the derivative of a function can be calculated using the second

order central, and first order forward and backward difference schemes


dx2
d y2


dx

dy
2y = 10 cos(10x)

0 ≤ x ≤ 1
y(0) = 1 y(1) = 0

y(x)

(x ) ≈
dx

dy
i (y −i+1 y )/(2Δ)i−1

x(x ) ≈
dx

dy
0 (y −1 y )/Δ0

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 2/28

The double derivative can be approximated as

Show that if you discretize equation shown in Q1 using the differentiation schemes above and

implementing the boundary conditions, you will get a set of equations that can be expressed as

where

(x ) ≈
dx

dy
N−1 (y −N−1 y )/Δ.N−2

(x ) ≈
dx2
d y2

i (y −i−1 2y +i y )/Δi+1
2

(x ) ≈
dx2
d y2

0 (y −0 2y +1 y )/Δ2 2

(x ) ≈
dx2
d y2

N−1 (y −N −1x 2y +N−2 y )/Δ .N−3
2

=

⎣⎢
⎢⎢⎢
⎢⎢⎢
⎢⎢⎢
⎢⎢⎡

1
α 1
0
0


0
0
0

0
β 1
α 2
0


0
0
0

0
γ 1
β 2
α 3


0
0
0

0
0
γ2
β 3




0

0
0
0
γ 3


α N−3

0

0
0
0
0


β N−3
α N−2

0





γ N−3
β N−2

0

0
0
0
0


0

γ N−2
1 ⎦

⎥⎥⎥
⎥⎥⎥
⎥⎥⎥
⎥⎥⎥

⎩⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎨
⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎧ y 0

y 1
y 2
y 3


y N−3
y N−2
y N−1

⎭⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎬
⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎫

⎩⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎨
⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎧ a

Q 1
Q 2
Q 3


Q N−3
Q N−2
b

⎭⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎬
⎪⎪⎪⎪⎪
⎪⎪⎪⎪⎪
⎪⎪⎫

α =i +Δ2
1


1

β =i − −Δ2
2

2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 3/28

where is the spacing between your equally spaced grid points. There are a

total of grid points. and . is the approximate value of .

Upload PDF file of your solution using link below

Note Oct 22, 2021.pdf  Download  Remove

Please select file(s) Select file(s)

Save Answer Last saved on Oct 22 at 8:11 PM

Q1.2
1 Point

Write a MATLAB program that uses the Thomas algorithm (from Assignment 2) to solve the

tridiagonal system found above in Q1.1. Compute your numerical solution using

and and plot vs for all values of .

Upload PDF file of your solution using link below

Untitled 2 pdf  Remove

γ =i −Δ2
1


1

Q =i 10 cos(10x )i

a = 1, b = 0

x =i+1 x +i Δ Δ
N x =0 0 x =N−1 1 y i y(x )i

CURRENTLY UPLOADED FILES

No file chosenChoose Files

Δ = 0.2, 0.1
0.01 y i x i Δ

CURRENTLY UPLOADED FILES

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226575303/Note_Oct_22__2021.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111903Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=a8318bd1b330395f0dc319350ffa3f7fe251861e4b65097eb0bc89bcacc618c7
https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226881577/Untitled_2.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111903Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=05aa015c5773c7ecc2f75d45439e75bb2b016f0e464869907fe912455cfb7283

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 4/28

Untitled 2.pdf  Download  Remove

Please select file(s) Select file(s)

Upload MATLAB code using link below

A3_Q1_2.m  Download  Remove

Please select file(s) Select file(s)

Save Answer Last saved on Oct 22 at 8:11 PM

Q1.3
0.5 Points

It is also possible to cast the problem shown in Q1 in terms of derivative matrices (using the

derivative formulae stated in Q1.1). Set up the first and second derivative matrices and use them

to construct the resulting matrix equations needed to solve the equation in Q1

and are your first and second derivative matrices respectively and is your

solution vector. This matrix should be “full” (with lots of zeros!) and you can use the

linsolve() function in MATLAB to solve the problem. Compute your numerical solution

using and and plot vs for all values of . Your answer should be

exactly the same as Q1.2. This will ensure that your derivative matrices are correct. Please

make sure you get this part right as you will be using the derivative matrices again in Q2 and

Q4 below.

No file chosenChoose Files

No file chosenChoose Files

CURRENTLY UPLOADED FILES

No file chosenChoose Files

[D2] − [D1] − 2[I] {y} =[ ] {10 cos(10x)}.

[D1] [D2] {y}

Δ = 0.2, 0.1 0.01 y i x i Δ

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226881577/Untitled_2.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111903Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=05aa015c5773c7ecc2f75d45439e75bb2b016f0e464869907fe912455cfb7283
https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226881578/A3_Q1_2.m?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111904Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=47967fd27323f1603b8ccfe4af75271b68a1b1e589459e596588ab69ff07be84

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 5/28

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q1.4
0.5 Points

Compare your approximated solutions from Q1.2 and Q1.3 to the exact solution to problem

shown in Q1

Comment on the accuracy of your numerical solutions.

Upload PDF file of your solution using link below

1.4.pdf  Download  Remove

Please select file(s) Select file(s)

Upload MATLAB code using link below

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

No file chosenChoose Files

y(x) = −0.06982599398e +2x 1.166931859e −−x cos(10x) −
2626
255

sin(10x).
2626
25

CURRENTLY UPLOADED FILES

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226881561/1.4.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111903Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=ecf81a234d826dc17131fcc6ad34661215a2ea06fb984e69f40930f3544df40d

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 6/28

A3_Q1_4.m  Download  Remove

Please select file(s) Select file(s)

Save Answer Last saved on Oct 22 at 8:11 PM

Q2
3 Points

This question is extracted from the book Numerical Analysis by Burden and Faires. The
governing equation for the deflection, , of a beam with two ends supported when

subjected to a uniform load of intensity (see figure above) is given by

where in is the length of the beam, lb/in is the modulus of elasticity,

in is the central moment of intertia, lb is the stress at the end points.

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

CURRENTLY UPLOADED FILES

No file chosenChoose Files

y(x)
q

=
dx2
d y2

y +
EI

S
x(x −

2EI
q

l)

l = 120 E = 3.0 × 107 2

I = 625 4 S = 1000

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226881563/A3_Q1_4.m?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111903Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=bed6179b17f9fe615e08da0e129043594d2740028e844fadf16b295f08c04045

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 7/28

Since the beam is supported at both ends, the boundary conditions are and

.

Q2.1
0.5 Points

Discretize the equation given in Q2 using the derivative schemes shown in Q1.1 and show that

the discretized equation can be expressed as a tridiagonal system (see Q1.1) with

Upload PDF file of your solution using link below

Note Oct 22, 2021 (2).pdf  Download  Remove

Please select file(s) Select file(s)

Save Answer Last saved on Oct 22 at 8:11 PM

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

y(0) = 0 y(l) =
0

α =i Δ2
1

β =i − −Δ2
2

EI

S

γ =i Δ2
1

Q =i x (x −2EI
q

i i l)

a = b = 0.

CURRENTLY UPLOADED FILES

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226881489/Note_Oct_22__2021__2_.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111903Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=f56a702428571b8ab953c984dab1b9f5323145cf292f24bb1835a9339701a644

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 8/28

Q2.2
1 Point

Write a computer program that uses the Thomas algorithm to solve the above set of tridiagonal

system for and lb/in. Approximate the deflection every 1.2 in, i.e. use

in. How can you be sure that your results are accurate? Do you need to use smaller

values of ? Justify your solution.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

A3_Q2_2.m  Download  Remove

Please select file(s) Select file(s)

Save Answer Last saved on Oct 22 at 10:09 PM

Q2.3
0.5 Points

If you use Thomas algorithm to solve this system of equation, you need to derive the

expressions shown in Q2.1. One of the advantages of using derivative matrices (see Q1.3) is

that you can use them to solve the equation shown in Q2, without doing any further

mathematics. Use the derivative matrices in Q1.3 to construct the resulting matrix equations

needed to solve the equation in Question 2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

q = 10, 15 25 y(x)
Δ = 1.2

Δ

No file chosenChoose Files

CURRENTLY UPLOADED FILES

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

https://production-gradescope-uploads.s3-us-west-2.amazonaws.com/uploads/text_file/file/226892987/A3_Q2_2.m?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGIENPBVZV37ZJPA%2F20211028%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20211028T111904Z&X-Amz-Expires=21600&X-Amz-SignedHeaders=host&X-Amz-Signature=23eaceb3f5d21f1e7f8ce611ae32721dd1642f5d714ab32c425992e885dcf139

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 9/28

This matrix should be “full” (again with lots of zeros!) and you can use the linsolve() function

in MATLAB to solve the problem. Use the value that gives a solution that is “sufficiently

accurate” which you have justified in Q2.2.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q2.4
1 Point

The law requires that the maximum deflection is to be less than 1/300 in. Use the necessary

numerical techniques to find the range of the values of where the maximum deflection is

within the acceptable range. For this question, you can use your code either in Q2.2 or Q2.3.

and only the value which you justified in Q2.2.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

[D2] − (S/(EI)[I] {y} =[ ] {(q/(2EI))x(x − l)}.

Δ

No file chosenChoose Files

No file chosenChoose Files

q

Δ

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 10/28

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q3 Initial Value Problem
5 Points

You are given that a very simple mathematical model of the motion of a sailboat in wavy waters

is given by the following ordinary differential equation

is the wind speed, is the angle in which the wind is blowing. is when the wind

is blowing in the positive direction (i.e. direction of travel of the sailboat) and is

when the wind is blowing directly opposite to the positive direction. is the amplitude

of the waves. Note that should be in radians when computing the term on the

right hand side of the equation given in this question above.

Q3.1
1 Point

Write a computer program to that uses the 2nd order Runge Kutta method to solve the equation

in Q3. Use this computer program to solve the equation for , and

. Assume that . Plot for . Use a small

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

100 =
dt2
d x2

40V cos(θ) +wind 5.5A sin −waves ( 10
x ) 50 .

dt

dx

V wind θ θ = 0o

x θ = 180o

x A waves
x/10 sin ( 10

x )

V =wind 12 θ = 30o

A =waves 2 dx/dt(0) = x(0) = 0 dx/dt t ∈ [0, 50]

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 11/28

value of time step size so that you are reasonably sure that your results are accurate.

Justify the value of that you use in order to get an accurate solution.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q3.2
2 Points

Compute the solution for and m. Keep , . Plot

for for and m. According to this model, what happens to the

velocity, , of the sailboat when increases? Use the value of that you have

justified in Q3.1.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

Δt
Δt

No file chosenChoose Files

No file chosenChoose Files

A =waves 0.1, 1 5 V =wind 12 θ = 30o dx/dt
0 ≤ t ≤ 50 A =waves 0.1, 1 5

dx/dt A waves Δt
No file chosenChoose Files

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 12/28

Save Answer

Q3.3
2 Points

Compute the solution for and . Keep , m.

Use a small value of so that you are reasonably sure that your results are accurate. You

should justify this value of . Plot for for all values of . According to

this model, what happens to the velocity of the sailboat when increases? Use the value of

that you have justified in Q3.1.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q4 Unsteady Convection–Diffusion
9 Points

The concentration of a contaminant as a function of location and time , , in an

environment where air is flowing at (constant) velocity and viscous diffusion can be

modelled by the following partial differential equation

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

θ = 0 , 10 , 30 , 50o o o o 90o V =wind 12 A =waves 5
h

Δt dx/dt 0 ≤ t ≤ 50 θ
θ Δt

No file chosenChoose Files

No file chosenChoose Files

x t ϕ(x, t)
U ν

2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 13/28

Here the left hand side represents the convection of by the air and the right hand side the

diffusion of throughout the fluid in the pipe. You are interested in the value of for

during .

We’ll consider the case where the convection velocity has a constant value and the

diffusivity is and impose the following boundary condition

The initial concentration of the contaminant is given by a Gaussian function

Our aim in this question is to analyse the effects of various spatial discretisation schemes in

conducting the simulations and then find the location where the concentration of the

contaminant has decreased to 50% of its initial value.

Q4.1
0.5 Points

For Q4.1-Q4.6, we will be using the discretisation schemes shown in Q1.1. Explain how you can

use derivative matrices to write the discretise form of the convection diffusion equation as the

following set of ordinary differential equations

Show that for (assuming equally spaced grid points with spacing ),

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

+
∂t
∂ϕ

U =
∂x
∂ϕ

ν .
∂x2
∂ ϕ2

ϕ

ϕ ϕ(x, t)
x ∈ [0, 20] t ∈ [0, 20]

U = 1
ν = 0.02

ϕ(x = 0, t) = 0

ϕ(x, 0) = e .−((x−2)/0.5)
2

{ϕ} =
dt

d
L {ϕ}.[ ]

N =x 6 Δ x

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 14/28

and

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Save Answer

Q4.2
0.5 Points

You are given the boundary condition is , i.e. . Explain how you

would incorporate this boundary condition into in the equation above to get

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

{ϕ} =

⎩⎪⎪⎪⎪⎪
⎪⎪⎨
⎪⎪⎪⎪⎪
⎪⎪⎧ϕ 0
ϕ 1
ϕ 2
ϕ 3
ϕ 4
ϕ 5
⎭⎪⎪⎪⎪⎪
⎪⎪⎬
⎪⎪⎪⎪⎪
⎪⎪⎫

[L] = − +
2Δ x

U

⎣⎢
⎢⎢⎢
⎢⎢⎢
⎡−2

−1
0
0
0
0

2
0

−1
0
0
0

0
1
0

−1
0
0

0
0
1
0

−1
0

0
0
0
1
0

−2

0
0
0
0
1
2⎦
⎥⎥⎥
⎥⎥⎥⎥

Δ x2
ν

⎣⎢
⎢⎢⎢
⎢⎢⎢
⎡1

1
0
0
0
0

−2
−2
1
0
0
0

1
1

−2
1
0
0

0
0
1

−2
1
1

0
0
0
1

−2
−2

0
0
0
0
1
1⎦
⎥⎥⎥
⎥⎥⎥⎥

No file chosenChoose Files

ϕ(x = 0, t) = 0 ϕ =0 0
[L]

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 15/28

Show that for ,

and

is the spacing between the (equally spaced) grid points.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

S A

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

{ϕ } =
dt

d ′ L {ϕ } +[ ′] ′ {P}.

N =x 6

{ϕ } =′

⎩⎪⎪⎪⎪⎪
⎨⎪
⎪⎪⎪⎪⎧ϕ 1ϕ 2
ϕ 3
ϕ 4
ϕ 5
⎭⎪⎪⎪⎪⎪
⎬⎪
⎪⎪⎪⎪⎫

[L ] =′ − +
2Δ x

U

⎣⎢
⎢⎢⎢⎢
⎡ 0

−1
0
0
0

1
0

−1
0
0

0
1
0

−1
0

0
0
1
0

−2

0
0
0
1
2⎦
⎥⎥⎥
⎥⎥⎤

Δ x
2

ν

⎣⎢
⎢⎢⎢⎢
⎡−2

1
0
0
0

1
−2
1
0
0

0
1

−2
1
1

0
0
1

−2
−2

0
0
0
1
1⎦
⎥⎥⎥
⎥⎥⎤

{P} = ϕ

⎩⎪⎪⎪⎪⎪
⎨⎪
⎪⎪⎪⎪⎧ + 2Δ x

U
Δ x

2
ν

0
0
0
0

⎭⎪⎪⎪⎪⎪
⎬⎪
⎪⎪⎪⎪⎫

0

Δ x

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 16/28

Save Answer

Q4.3
1 Point

Write a MATLAB program that solves the system of equation in Q4.2 above using the 2nd order

Runge–Kutta method. Carry out simulations with and .

Provide plots of the approximated solution at , , and (i.e. plot

, , , vs ). Does your solution look

reasonable for this value of ?

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q4.4
1 Point

Plot all of the eigenvalues of the operator multiplied by and the stability region of the

2nd order Runge-Kutta method (see Lecture 18). You can use the eig() function in MATLAB to

obtain your eigenvalues for the operator . Investigate the effect of varying the size of the

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

N =x 40 Δt = 0.1
t = 0 t = 5 t = 10 t = 15

ϕ(x, t = 0) ϕ(x, t = 5) ϕ(x, t = 10) ϕ(x, t = 15) x
N x

No file chosenChoose Files

No file chosenChoose Files

L′ Δt

L′

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 17/28

time steps between and . For this question, use .

Discuss the effect of varying the time step on the stability of the system of equations. Can you

get a solution with ?

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q4.5
1 Point

Using will not be able to give you a very good solution as the spatial resolution is not

sufficiently fine. Vary the number of points in your mesh using and

assume a constant time step of . Discuss the effect of varying on the stability of

the approximated solution. Can you get a solution using and ? Suggest

values of that you can use with to obtain a solution with and .

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

Δt = 0.01, 0.05, 0.1, 0.2, 0.5 1 N =x 40

Δt = 1.0

No file chosenChoose Files

No file chosenChoose Files

N =x 40
N =x 100, 200, 300, 500

Δt = 0.1 N x
N =x 500 Δt = 0.1

Δt N =x 100 N =x 500

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 18/28

Please select file(s) Select file(s)

Save Answer

Q4.6
1 Point

Provide plots of the at , , and using and the

value that you have suggested in Q4.5.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q4.7
1 Point

So far, we have obtained approximated solutions of the partial differential equation shown in Q4

by calculating and using very basic (and not very accurate) 2nd order central

difference schemes (with 1st order approximation at the end nodes). As was shown in lectures,

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

ϕ(x, t) t = 0 t = 5 t = 10 t = 15 N =x 500 Δt

No file chosenChoose Files

No file chosenChoose Files

∂ϕ/∂x ∂ ϕ/∂x2 2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 19/28

the accuracy of calculating derivatives and can be improved by using

spectral differentiation using Gauss-Lobatto points. For Q4.7-Q4.9, we will analyse the

properties of the numerical solution obtained using spectral differentiation and Gauss-Lobatto

points.

Using the lglnodes() and the DerivMatrix() MATLAB functions provided in Lecture 14,

construct derivative matrices that uses spectral Gauss-Lobatto scheme to calculate and

. Note that for this question, the derivative matrices (unlike the derivative matrices for

the 2nd order schemes) are ‘full’ matrices and do not contain any zeros.

Compute the solution using and and provide plots of the at

, , and . Compare with the solutions you obtain using finite difference

schemes in Q4.3. Which one do you think is more accurate?

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q4.8
1 Point

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

∂ϕ/∂x ∂ ϕ/∂x2 2

∂ϕ/∂x
∂ ϕ/∂x2 2

N =x 40 Δt = 0.1 ϕ(x, t) t = 0
t = 5 t = 10 t = 15

No file chosenChoose Files

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 20/28

If you want to get a more accurate solution, you can increase . Perform stability analysis for

(i.e find the eigevalues of , similar to what you did in Q4.4 and Q4.5) and

suggest a value of that can be used to get a good solution.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q4.9
1 Point

Provide plots of the at , , and using and the

value that you have suggested in Q4.8.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

S A

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

N x
N =x 100 [L ]′

Δt

No file chosenChoose Files

No file chosenChoose Files

ϕ(x, t) t = 0 t = 5 t = 10 t = 15 N =x 100 ΔtNo file chosenChoose Files

No file chosenChoose Files

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 21/28

Save Answer

Q4.10
1 Point

You are given that it safe for people to stand where the value of becomes less than 0.5.

Where would you ask these people to stand? To answer this question, you can use any of your

answer above and any other numerical method that feel is appropriate.

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q5 Two Dimensional Boundary Value Problems
5 Points

In this question, you are asked to find the solution that satisfies the partial differential

equation below using the spectral collocation method (with Gauss Lobatto and also evenly

spaced points).

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

ϕ

No file chosenChoose Files

No file chosenChoose Files

u(x, y)

2 2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 22/28

In order to do that, you will need to first find the derivative matrices and use them to construct

the system of algebraic equation that looks something like

Q5.1 – Q5.2 will go through the steps on how you can set up the matrix . The solution is

obtained in Q5.4.

To extend the one-dimensional spectral collocation method with Gauss-Lobatto points into two

dimensions, we can tile the one dimensional mesh along the second direction. Suppose that

and are arrays containing th order ( point) one-dimensional meshes, then

we generate our two-dimensional mesh by repeating at a spacing determined by the

points in . The idea is akin to how MATLAB’s meshgrid() function works.

To illustrate this consider a two-dimensional mesh generated from the third order Gauss–

Lobatto points.

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

+
∂x2
∂ u2

=
∂y2
∂ u2

f(x, y)

[A]{u} = {f}

[A] {u}

{X} {Y } N N + 1
{X}

{Y }

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 23/28

Here the nodes follow the lexicographic ordering from left to right, bottom to top.

The advantage of this type of construction is that it essentially decouples the axes, meaning

that we can take the one dimensional Lagrange basis functions and multiply them together to

produce the two-dimensional interpolants

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 24/28

Hence the second derivatives are given by

For convenience, we write the coefficients in the vector

where .

Then the second derivative matrix may be written as

where is some operation on the one-dimensional second derivative matrix and the

identity matrix that produces the correct two-dimensional derivative matrix

Q5.1
1 Point

For the moment, assume a mesh. Show that the two dimensional derivative matrices are

given by

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

u(x, y) ≈ u L (x)L (y)
i=0


N

j=0


N

j,i i j

u (x, y)xx
u (x, y)yy

≈ u L (x)L (y)∑
i=0
N ∑

j=0
N

j,i i
′′

j

≈ u L (x)L (y).∑
i=0
N ∑

j=0
N

j,i i j
′′

u j,i

{u} = (u ,u , … ,u , … ,u ) =1 2 ℓ (N+1)2
T (u ,u , … ,u , … ,u )0,0 0,1 i,j N ,N

T

ℓ = 1 + i + (N + 1)j

u (x , y ) = [I] ⊗ [D ]{u}xx i i 2

u (x , y ) = [D ] ⊗ [I]{u}yy i i 2

⊗ [D ]2

[I]

2 × 2

2 2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 25/28

The result above can be extended to an mesh. The operation on two matrices is

called the Kronecker product which is implemented in MATLAB using the kron() function. For
an matrix and a matrix is defined as

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Save Answer

Q5.2
1 Point

Use the kron()} function in MATLAB to set up a matrix operator to calculate

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

[D ] 2 x

[D ] 2 y

=

⎝⎜
⎜⎜⎛

D 11
2

D 21
2

D 12
2

D 22
2

D 11
2

D 21
2

D 12
2

D 22
2 ⎠⎟
⎟⎟⎞

=

⎝⎜
⎜⎜⎛

D 11
2

D 21
2

D 11
2

D 21
2

D 12
2

D 22
2

D 12
2

D 22
2 ⎠⎟
⎟⎟⎞

N × N ⊗

m × n [A] p × q [B]

[A] ⊗ [B] = ⎝⎜⎜
⎛a [B]11


a [B]n1


a [B]1n


a [B].nn ⎠

⎟⎟⎞

No file chosenChoose Files

2 2

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

10/29/21, 12:17 AM Submit Assignment 3 | Gradescope

https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 26/28

on a mesh of size . Test your matrix operator on the function

in the domain . You can use lglnodes() (to get the Gauss

Lobatto points) and the DerivMatrix() MATLAB functions provided in Lecture 14. To generate

the evenly spaced grid, use any inbuilt functions in MATLAB. Show that it works by using the

contour() or surf() function in MATLAB to plot the results of your matrix operation and

compare with the analytical function . You should show this for both

the evenly spaced grid and the Gauss Lobatto grid. You should get very good results, even

with relatively small values of .

Upload PDF file of your solution using link below

Please select file(s) Select file(s)

Upload MATLAB code using link below

Please select file(s) Select file(s)

Save Answer

Q5.3
1 Point

Now we will apply the Spectral collocation method, and use the matrix operator above to solve

Poisson equation

No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files

+
∂x2
∂ u2

∂y2
∂ u2

N × N u(x, y) =
sin(πx) cos(πy) −1 < x, y < 1 −2π sin(πx) cos(πy)2 N No file chosenChoose Files  No file chosenChoose Files  2 2 No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files No file chosenChoose Files 10/29/21, 12:17 AM Submit Assignment 3 | Gradescope https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 27/28 on the square with an arbitrary forcing function , which is also coupled with the dirichlet boundary condition for . Write a MATLAB function Poisson_solve(f,N,method)} that takes the inputs f , the forcing function, , the order of the mesh, and method , which is either the string GLo or Even for Gauss--Lobatto or Evenly spaced nodes respectively. Your function should output the the and coordinates as well as the solution at the start of this question in a form that can be directly inputted into the MATLAB functions contour() or surf() . Upload PDF file of your solution using link below Please select file(s) Select file(s) Upload MATLAB code using link below Please select file(s) Select file(s) Save Answer Q5.4 2 Points + ∂x2 ∂ u2 = ∂y2 ∂ u2 f(x, y) −1 < x, y < 1 f u = 0 x, y = ±1 N x y u   10/29/21, 12:17 AM Submit Assignment 3 | Gradescope https://www.gradescope.com/courses/278786/assignments/1367535/submissions/new 28/28 Using your function Poisson_solve() , plot the solution of the Poisson equation when Use both a Gauss--Lobatto and even spaced grid of order . Upload PDF file of your solution using link below Please select file(s) Select file(s) Upload MATLAB code using link below Please select file(s) Select file(s) Save Answer Save All Answers Submit & View Submission  f(x, y) = 10 sin {8x(y − 1)} 20   https://www.gradescope.com/courses/278786/assignments/1367535/submissions/95372409