2071 Lab 4 Summary $Id: summary.txt,v 1.10 2016/12/22 21:03:19 mike Exp $ M. M. Sussman {@(#) Sat Jan 9 15:25:10 2016 } EXERCISE 1 1. copy exer1a.m, U = [1.0 0.36362 0.12893 0.26023 0.72636 1.5]' 2. exer1b.m: (1+C*dx-C*dx/2)*U(1)-2*(1+C*dx)*U(2)+(1+C*dx+C*dx/2)*U(3)-0.4*dx^2 3. exer1c.m: U=1 is correct 4. exer1d.m: U=x is correct 5. exer1e.m: U=x^2 is correct, need variable rhog 6. plot: piecewise linear endpoints y=1,1.5 at x=0,5 EXERCISE 2 1,2 rope_bvp.m with comments. 3. check: U = [1.0 0.36362 0.12893 0.26023 0.72636 1.5]' SAME 4. copy rope_bvp with solution =1 RHOG=0; URight=1; 5. copy rope_bvp with solution =x RHOG=C; ULeft=0; URight=5; 6. copy rope_bvp with solution =x^2 RHOG=2+4*C*x(2:N+1); ULeft=0; URight=25; b=RHOG'*dx^2.*ones(N,1); 7. plot rope as curve with 4 circles: "perfect" U(50)=0.126957483290832 EXERCISE 3 1. phi.m 2. plots of phi_3 and phi_4 3. Show phi_n is cont at x_{n-2}, x_{n}, and x_{n+2} for even n, and phi_n is cont at x_{n-1}, and x_{n+1} for odd n. Also $phi_n(x_m)=\delta_{mn}$ 4. phip.m (derivative) 5. plot phi3 and phip3 together and phi4 and phip4 together 6. (phi(3,h,.41)-phi(3,h,.39))/(.02)=-3.2=phip(3,h,.4) (phi(4,h,.41)-phi(4,h,.39))/(.02)= 5.6=phip(4,h,.4) EXERCISE 4 1. A1= -21.333 10.667 0.000 0.000 0.000 0.000 0.000 10.667 -18.667 10.667 -1.333 0.000 0.000 0.000 0.000 10.667 -21.333 10.667 0.000 0.000 0.000 0.000 -1.333 10.667 -18.667 10.667 -1.333 0.000 0.000 0.000 0.000 10.667 -21.333 10.667 0.000 0.000 0.000 0.000 -1.333 10.667 -18.667 10.667 0.000 0.000 0.000 0.000 0.000 10.667 -21.333 2. norm(A1-A1','fro')=roundoff 3. plot sum of phi 4. A1*ones(N,1)= -10.67 1.33 0. 0. 0. 1.33 -10.67 5. result of given code is 0,0,0,0,0,1.33,-10.67 6. RHS1=-.33 -.167 -.33 -.167 -.33 -.167 -.33 A1*v-F1=all roundoff values EXERCISE 5 1. A3 = 0.1333 0.0167 0 0 0 0 0 0.0167 0.0667 0.0167 -0.0083 0 0 0 0 0.0167 0.1333 0.0167 0 0 0 0 -0.0083 0.0167 0.0667 0.0167 -0.0083 0 0 0 0 0.0167 0.1333 0.0167 0 0 0 0 -0.0083 0.0167 0.0667 0.0167 0 0 0 0 0 0.0167 0.1333 2. symmetric 3. note bvp has solution x*(1-x) 4. rhs5.m RHS2(x)=-2+x*(1-x), F2=integral vs. phi RHS5= -0.31562 -0.15052 -0.29479 -0.14531 -0.29479 -0.15052 -0.31562 5. Correct test solution? EXERCISE 6 1. A2= 0 0.6667 0 0 0 0 0 -0.6667 0.0000 0.6667 -0.1667 0 0 0 0 -0.6667 0 0.6667 0 0 0 0 0.1667 -0.6667 0.0000 0.6667 -0.1667 0 0 0 0 -0.6667 0 0.6667 0 0 0 0 0.1667 -0.6667 0.0000 0.6667 0 0 0 0 0 -0.6667 0 2. confirm skew-symmetric 3. note A=A1+A2+A3 4. note bvp has solution x*(1-x) 5. rhs6.m = -2+(1-x*x)+x*(1-x) RHS6= -0.19062 -0.10885 -0.25312 -0.14531 -0.33646 -0.19219 -0.44062 6. confirm correct test solution EXERCISE 7 1. exact7.m (vector notation preferred) 2. rhs7.m for rhs 3. solve7.m to do solution 4. N h error ratio 7 1.2500e-1 7.2202e-06 15.460 15 6.2500e-2 4.6703e-07 15.788 31 3.1250e-2 2.9581e-08 14.013 61 1.6129e-2 2.1110e-09 14.951 121 8.1967e-3 1.4119e-10 EXERCISE 8 1. burgers_ode.m, 2. interior F 3. interior D 4. left F,D 5. right F,D 6. UInit=(1-x).^3; 7. compare with correct values 8. download back_euler.m, newton4euler.m 9. solve: U(200,50)=0.979077601035924 10. plot(x, U(k,:) ) for k=50: front around x=.5 11. flicker picture: last one. EXTRA CREDIT (shooting) 1. rope_ode.m 2. alpha=0, u(5)-1.5=3.7970, (u(5)=U(end,1)=5.2970) 3. alpha=-1, u(5)-1.5=-0.83416-1.5=-0.66584 4. rope_shoot.m: uses ode45 to solve rope_ode, return y-1.5 at 5 5. alpha=-0.85080 6. plot not required. Does pass through (0,1) and (5,1.5). min approx .2 at x=2.1 (eyeball) 7. slope at x=0 from rope_bvp (U(2)-U(1))/(x(2)-x(1)) = -0.84160