这个作业是用Python完成微积分方程、矩阵等数学题

Final Project – Math 104B, Spring 20201
1.(30分)考虑平方上u的以下偏微分方程
D = [0,1] 2:
u = f(x,y),0x,y1,
在@D上u = 0。 (1)
在(1)中,
u = @ 2u
@ x2 +
@ 2u
@ y2(2)
@D是D的边界:
@D = {0,1}⇥[0,1] [[0,1]⇥{0,1}。 (3)
我们构建一个二维网格:令h = 1 / n,并设置
xi = ih,i = 0,1,。。 。 。 ,n,
yj = jh,j = 0,1,。 。 。 ,n。 (4)
我们以类似于在讲座中所做的方式离散方程式:
@ 2u
@ x2(xi,yj)= u(xi + h,yj)2u(xi,yj)+ u(xi h,yj)
h2 + O(h2),(5)

@ 2u
@ y2(xi,yj)= u(xi,yj + h)2u(xi,yj)+ u(xi,yj h)
h2 + O(h2)。 (6)
1所有课程资料(课堂讲课和讨论,讲义,作业,考试,网络
资料等)和课程本身的知识内容受美国联邦版权保护
法律和加利福尼亚民法典。 UC政策102.23明确禁止学生(和所有其他人员)
从录制演讲或讨论,以及分发或出售演讲笔记以及所有其他课程
未经教师事先书面许可的材料。
1个
2
因此我们建立了系统
ui + 1,j 2ui,j + ui1,j
h2 ui,j + 1 2ui,j + ui,j1
h2 = fi,j,i,j = 1,2,。 。 。 ,n。
(7)
(一个)。 (5分)构造函数f(x,y)使得u(x,y)= sin(16⇡x(1
x)y(1 y))求解方程(见图1)。
图1:方程(1)的解。
(b)。 (25分)使用共轭梯度法求解系统(7)。设置
公差为108,并使用n = 10、20、40、80、160、320。
迭代次数,并根据n确定每个缩放比例。校验
在数值上近似值是二阶精度的。
实施技巧:
(一个)。对于简单的实现,您可以定义解决方案u(以及
共轭梯度法)作为二维数组,就像定义的一样
在(7)中。
3
(xi,yj)
(xi,yj + 1)
(xi,yj1)
(xi1,yj)(xi + 1,yj)
图2:二维网格中节点的索引。
(b)。不要构造与系统(7)相关的完整矩阵。相反,有
您可以做的其他事情,例如您可以使用稀疏定义矩阵
线性代数,或简单地定义一个函数以求矩阵/矢量积
直:
(Ap)ij = pi + 1,j 2pi,j + pi1,j
h2 pi,j + 1 2pi,j + pi,j1
h2。 (8)
2.(30分)已知物理量P取决于温度T。
文件包含实验结果。您可以使用读取数据
(一个)。 (20分)使用最小二乘法和Householder QR拟合
形式为多项式模型的数据
P(T)= c0 + c1T + c2T2 + … + ckTk
,(9)

4
for k = 1, 2, 3, 4, 5. Compute the modeling error in each case. Plot the values
(Ti, Pi) and the results from each model for comparison.
(b). (10 points) Do a log-log plot of the same values. Explain why the log-log plot
indicates that P(T) = aTb for some a and b. Use the Least Squares method
and solve the Normal Equations to estimate the values of a and b, and do a
regular plot and a log-log plot with the values (Ti, Pi) and the values (Ti, aTb
i )
to show how good your approximation is. Compute the modeling error as well.
Extra Credit – Math 104B, Spring 20201
Due on Friday, June 12th, 2020
Instructor: Carlos J. García Cervera
1. (40 points) When discretizing the dierential equation
u
00(x) = f(x), x 2 [0, 1]
u(0) = u(1) = 0, (1)
using second order centered dierences, we obtained the tridiagonal matrix
A = 1
h2
0
BBBBBBBBBBBBB@
2 1 0 0 … 0 0
1 2 1 0 … 0 0
0 1 2 1 … 0 0
.
.
. .
.
. … … … .
.
. .
.
.
000 1 2 1 0
0000 1 2 1
00000 1 2
1
CCCCCCCCCCCCCA
. (2)
In components, remember that this means
ui+1 2ui + ui1
h2 = f(xi) i = 1, 2, . . . , n, (3)
where h = 1/(n + 1).
(a). (10 points) For each k = 1, 2,…,n, show that the vector u(k) given by
u(k)
i = sin ✓ ⇡ki
n + 1◆
, i = 1, 2,…,n (4)
1All course materials (class lectures and discussions, handouts, homework assignments, examinations, web
materials, etc) and the intellectual content of the course itself are protected by United States Federal Copyright
Law, and the California Civil Code. The UC Policy 102.23 expressly prohibits students (and all other persons)
from recording lectures or discussions and from distributing or selling lecture notes and all other course
materials without the prior written permission of the instructor.
1
2
is an eigenvector of the matrix A, and determine the corresponding eigenvalue
k.
(b). (5 points) The Jacobi iteration matrix is defined as
TJ = D1(L + U), (5)
where A = L + D + U. Show that the vectors (12) are also eigenvectors of
TJ and find its eigenvalues. Hint: Prove that since D = dI (constant multiple
of the identity),
TJx = µx () Ax = d(µ + 1)x. (6)
(c). (5 points) Determine the spectral radius of TJ,
⇢(TJ) = max k=1,…,n
|µk|. (7)
.
(d). (5 points) The Jacobi iteration can be written as
x(k+1) = TJx(k) + c. (8)
From the previous steps, we know that TJ is symmetric and diagonalizable.
Use this fact to show that if x⇤ is the (unique) fixed point of (8), then
kx(k) x⇤k2  ⇢(TJ)
kkx(0) x⇤k2 (9)
(e). (5 points) Use formula (9) and the spectral radius obtained earlier to show that
the method converges, and to estimate the number of iterations necessary for
the error to be less than a given ✏ as a function of the number of grid points
used, n. You should end up with a formula of the form Iter(n) = O(n↵) for
some ↵. Hint: At the end you might need to use Taylor to estimate ↵.
(f). (5 points) To verify the value of ↵ numerically, fix ✏ = 106. Consider an
initial random vector x(0), and solve the system of equations
Ax = 0 (10)
3
using Jacobi’s method. Use the values n = 10, 20, 40, 80, 160, 320. Do a
log-log plot of the number of Jacobi iterations necessary for the error to satisfy
kx(k)
k2  ✏kx(0)k2. (11)
How does the computed number of iterations compare with the theoretical one
obtained earlier?
(g). (5 points) Repeat the previous part with Gauss-Seidel’s method. How much
faster is it?
2. (20 points) In this problem, we analyze the Gauss-Seidel method in the same way
we studied Jacobi’s method above:
(a). (10 points) For each k = 1, 2,…,n, show that the vector u(k) given by
u(k)
i =

cos ✓ k⇡
n + 1◆◆i
sin ✓ ⇡ki
n + 1◆
, i = 1, 2,…,n (12)
is an eigenvector of the corresponding Gauss-Seidel iteration matrix, and determine the corresponding eigenvalue k. Hint: Verify directly that(L+D)u(k) =
kUu(k) for some k.
(b). (5 points) Use the previous part to show that ⇢(TGS) = ⇢(TJ )2, where TGS
and TJ are the iteration matrices for the Gauss-Seidel and the Jacobi methods,
respectively.
(c). (5 points) Explain why if one uses the Gauss-Seidel method for this equation,
one only needs half the number of iterations of the Jacobi method to reach a
tolerance ✏.


EasyDue™ 支持PayPal, AliPay, WechatPay, Taobao等各种付款方式!

E-mail: easydue@outlook.com  微信:easydue


EasyDue™是一个服务全球中国留学生的专业代写公司
专注提供稳定可靠的北美、澳洲、英国代写服务
专注提供CS、统计、金融、经济、数据科学专业的作业代写服务