linear algebra and its Applications 4E: Exercise 1.33 1.34

最近在看线性代数和它的应用的这本书, 看的是英文版,也有中文版对着看。看到了一道应用线性代数解决实际问题的一道题,说实在话这才是第一次应用线性代数啊!过程是对这个计算写出线性方程组(system of linear equations), 把线性方程组用增广矩阵(augmented matrix)表示出来,然后解出来。这时想起了numpy, 查了一下果然有方便的方法(numpy.linalg.solve(a, b))用计算机算出结果来。

下面的题目:

An important concern in the study of heat transfer is to determine the steady-state temperature distribution of a thin plate when the temperature around the boundary is know. Assume the plate shown in the figure represents a cross section of a metal beam, with negligible heat flow in the direction perpendicular to the plate. Let T1 , …, T4 denote the temperatures at the four interior nodes of the mesh in the figure. The temperature at a node is approximately equal to the average of the four nearest nodes — to the left, above, to the right, and below. For instance,

33. Write a system of four equations whose solution gives estimates for the temperatures T1, …, T4.

34. Solve the system of equations from Exercise 33.  [Hint: To speed up the calculations, interchange rows 1 and 4 before starting “replace” operations.]

下面是我做的答案:

  1. 按照真实业务情况需求,先是得到这个方程组:

 

做一下处理:

再做一下处理, 缺少的变量用0乘变量表示出来:

2. 由方程组的系数和常量可得到增广矩阵,大小为4X5, 增广矩阵由线性方程组的各系数和常量组成:

然后用2个矩阵a,b分别表示系数,常量:

3. 接下来python程序上场了,用a,b两矩阵输入np.linalg.slove(a,b),返回值就是一个由各变量值组成的矩阵。这个矩阵就是我需要的方程组的解。

python程序如下:

运行程序得到的结果如下:

这个结果的意思就是(x1, x2, x3, x4)为(20, 27.5, 30, 22.5)就是上面方程组的解,也就是我要求的4个点的温度。

打赏