function u = economics_pde_burgers(y,t,nu_0) % copy of Amit's burgersa.f code to numerically evaluate the Burgers % equation for the dimension-reduced variable. % Initialise parameters and number of points to integrate over numerically T = 10; L = 1000; dt = 0.01; dx = 1.0; dy = 1.0; u = exp(-(1:L));%rand(1,10000); Lx = L/dx; Ly = L/dy; nt = T/dt; % loop multiple times to improve accuracy for j = 1:nt % initialise derivatives for i = 2:Lx-1 delu(i) = (u(i+1)-u(i-1))./(2*dy); delsqu(i) = (u(i+1)+u(i-1)-2*u(i))/(dy*dy); end % initialise periodic boundary conditions delu(1) = (u(2)-u(Ly))/2*dy; delu(Lx) = (u(1)-u(Ly-1))/2*dy; delsqu(1) = (u(2)+u(Ly)-2*u(1))/(dy*dy); delsqu(Lx) = (u(1)+u(Ly-1)-2*u(Lx))/(dy*dy); % fixed end points u(1) = 0; u(Lx) = 0; % solve equation now for i = 1:Ly u(i) = u(i)+dt*(delsqu(i) - (1/sqrt(nu_0))*u(i)*delu(i)); end end end