def (ut) len( zeros(( + , + ) [ , for in range( ) [ , - beta/dx** [ , - *beta/dx** [ , + beta/dx** [ , - (beta/dx** )* [ , (beta/dx** )*(- return import odespy solver odespy backwardeuler(rhsf_is_linear=truejac=ksolver odespy thetarule(rhsf_is_linear=truejac=ktheta= solver set_initial_condition(u_ * * n_t int(round( /float(dt))time_points linspace( tn_t+ ut solver solve(time_pointsthe file rod_be py has all the details and shows movie of the solution we can run it with any we wantits size just impacts the accuracy of the first steps odespy solvers apply dense matriceslooking at the entries of the matrixwe realize that there are at maximum three entries different from zero in each row thereforemost of the entries are zeroes the odespy solvers expect dense square matrices as inputhere with elements when solving the linear systemsa lot of storage and work are spent on the zero entries in the matrix it would be much more efficient to store the matrix as tridiagonal matrix and apply specialized gaussian elimination solver for tridiagonal systems actuallythis reduces the work from the order to the order in one-dimensional diffusion problemsthe savings of using tridiagonal matrix are modest in practicesince the matrices are very small anyway in twoand three-dimensional pde problemshoweverone cannot afford dense square matrices ratherone must resort to more efficient storage formats and algorithms tailored to such formatsbut this is beyond the scope of the present text exercises exercise simulate diffusion equation by hand consider the problem given by ( )( and ( set and compute and by hand for use these values to construct test function for checking that the implementation is correct copy useful functions from test_diffusion_pde_exact_linear py and make new test function test_diffusion_hand_calculation filenametest_rod_hand_calculations py