tailieunhanh - A Guide to MATLAB for Beginners and Experienced Users phần 7

Đầu ra đại diện cho lợi nhuận ròng (hoặc mất mát, nếu tiêu cực) đối với các casino sau 100 trận. Trung bình, cứ 100 trò chơi casino nên giành chiến thắng 51 lần và máy nghe nhạc (s) nên giành chiến thắng 49 lần, do đó, các casino sẽ tạo ra lợi nhuận của 2 đơn vị (trung bình). Chúng ta hãy xem những gì sẽ xảy ra trong một vài chạy thử nghiệm. | Numerical Solution of the Heat Equation 177 let un u a j At nAt . After rewriting the partial differential equation in terms of finite-difference approximations to the derivatives we get u 1 u _ kun i 2un u -i At k Ax2 These are the simplest approximations we can use for the derivatives and this method can be refined by using more accurate approximations especially for the t derivative. Thus if for a particular n we know the values of un for all j we can solve the equation above to find for each j n 1 _ n b n _ 2 n n n n 1 2. n Mj uj A 2 uj 1 2uj Itj 1 S uj 1 llj 1 1 2S uj where s kAt Ax 2. In other words this equation tells us how to find the temperature distribution at time step n 1 given the temperature distribution at time step n. At the endpoints j 0 and j J this equation refers to temperatures outside the prescribed range for x but at these points we will ignore the equation above and apply the boundary conditions instead. We can interpret this equation as saying that the temperature at a given location at the next time step is a weighted average of its temperature and the temperatures of its neighbors at the current time step. In other words in time At a given section of the wire of length Ax transfers to each of its neighbors a portion s of its heat energy and keeps the remaining portion 1 2s. Thus our numerical implementation of the heat equation is a discretized version of the microscopic description of diffusion we gave initially that heat energy spreads due to random interactions between nearby particles. The following M-file which we have named iterates the procedure described above. type heat function u heat k t x init bdry Solve the 1D heat equation on the rectangle described by vectors x and t with initial condition u t 1 x init and Dirichlet boundary conditions u t x 1 bdry 1 u t x end bdry 2 . J length x N length t dx mean diff x dt mean diff t s k dt dx 2 u zeros N J 178 Chapter 10. Applications u 1 init for n 1 N-1 u n 1 2 J-1 s u n 3 J u

TỪ KHÓA LIÊN QUAN