% % two simple plots % % bessel coefficients dt = 0.05; t = dt:6*dt:1-dt; nmax=50; save = []; clf; subplot(2,1,1); hold on for ns = 1:nmax coeff = 2*(-1)^(ns-1)*besselj(ns,ns*t)./(ns*t); plot(log(ns), log(abs(coeff(end))),'rx') save = [save ; coeff]; end axis([0 4 -7 0]) title('\bf bessel coefficients at t=0.95') xlabel('\bf log(n)-axis') ylabel('\bf log|a_n(0.95)|-axis') text(0.2,-6,'(how close to the asymptotic slope does this give?)') % nonlinear wave solution dx=pi/50; x = -2*pi:dx:2*pi; subplot(2,1,2); hold on for j=1:size(t,2) sol = 0; for ns =1:nmax sol = sol + save(ns,j)*sin(ns*x); end plot(x,sol,'b') axis([-2*pi 2*pi -1.3 1.1]) end title(['\bf nonlinear wave: u(x,t), ' num2str(nmax) '-term series)']) xlabel('\bf x-axis') ylabel('\bf u-axis') text(-3,0.5,'t = 0.05, 0.35, 0.65, 0.95') text(0,-1.15,'(notice the weak resolution errors at t =0.95)')