﻿ 17074208 作业九 - 计算数学达人 - 专，学者，数值代数，微分方程数值解

### 17074208 作业九

Exercises

(P252)2.题目：Use the three-point centered-difference formula to approximate f’(0),where f(x)=e^x,for (a)h=0.1 (b)h=0.01 (c)h=0.001

(b) f’(0)=(f(h)-f(-h))/2h=1.0000166667

(c) f’(0)=(f(h)-f(-h))/2h=1.0000001667

(P263)1.题目：Apply the composite Trapezoid Rule with m=1,2 and 4 panels to approximate the integrals. Compute the error by comparing with the exact value from calculus.(b)ʃ(cosx,0,pi/2)

The error is at most (((pi/2)*(pi/2)^2)/12)*|f’’(c)|<(pi^3)/96=0.032724

When m=2,h=pi/4, ʃ(cosx,0,pi/2)=(h/2)*(y0+2*y1+y2)=(pi/8)*(1+sqrt(2))=0.948059

The error is at most (((pi/2)*(pi/4)^2)/12)*|f’’(c)|< (pi^3)/384=0.080746

Whenm=4,h=pi/8,ʃ(cosx,0,pi/2)=(h/2)*(y0+2*y2+2*y3+2*y4+y5)=(pi/16)*(1+sqrt(2)/3cos(pi/8)+cos(3pi/8))=0.848276

The error is at most (((pi/2)*(pi/16)^2)/12)*|f’’(c)|< (pi^3)/6144=0.005047

ʃ(cosx,0,pi/2)=1

1-(pi/16)*(1+sqrt(2)/2+2*cos(pi/8)+2*cos(3pi/8))=0.151782

2.题目：Apply the Composite Midpoint Rule with m =1,2 and 4 panels to approximate the integrals in Exercise 1, and report the errors.

The error is at most 0.032724.

When m=2,h=pi/4, ʃ(cosx,0,pi/2)=pi/4(f(w1)+f(w2))+pi^3/768f’’(c)=1.002280

The error is at most 0.003321.

When m=4,h=pi/8, ʃ(cosx,0,pi/2)=pi/8(f(w1)+f(w2)+f(w3)+f(w4))+pi^3/4032f’’(c)=1.000134

The error is at most 0.000208.

3.题目：Apply the composite Simpson’s Rule with m =1,2 and 4 panels to the integrals in Exercise 1, and report the errors.

The error is at most (((pi/2)*(pi/2)^2)/12)*|f’’(c)|<(pi^3)/96=0.032724

When m=2,h=pi/4, ʃ(cosx,0,pi/2)=(h/3)*( y0+4*y1+y2)= (pi/12)*(1+2*sqrt(2))=1.002280

The error is at most (((pi/2)*(pi/4)^4)/180)*|f’’(c)|< (pi^5)/92160=0.003321

Whenm=4,h=pi/8,ʃ(cosx,0,pi/2)=(h/3)*(y0+y4+2*y2+4*(y1+y3))=(pi/24)*(1+sqrt(2)+4*(cos(pi/8)+cos(3*pi/8)))=1.000134

The error is at most (((pi/2)*(pi/8)^4)/180)*|f’’(c)|< (pi^5)/1474560=0.000208

4.题目：Apply the composite Simpson’s Rule with m =1,2 and 4 panels to the integrals , and report the errors.(b) ʃ(dx/(1+x^2),0,1)

When m=2,h=1/2, ʃ(dx/(1+x^2),0,1)=0.864372.The error is at most 0.005631.

When m=4,h=1/4, ʃ(dx/(1+x^2),0,1)=0.975844.The error is at most 0.000312.

(P268)1.题目：Apply Romberg Integration to find R33 for the integrals.(c) ʃ(exp(x),0,1)

(P291)3.题目：3.Use separation of variables to find solutions of the IVP given by y(0) = 1 and the following differential equations:

(a)y'=t;    (b)y’=t^2*y;     (c)y’=2(t+1)y;     (d)y'=5*t^4*y    (e)y’=1/y^2;     (f)y’=t^3/y^2.

(b)y=e^(t^3/3).

(c)y=e^(t^2+2t).

(d)|y|=e^(t^5) or y=0.

(e)y=(3t+1)^(1/3).

(f)y=(3t^4/4+1)^(1/3).

5.题目：Apply Euler’s Method with step size h=1/4 to the IVPs in Exercise 3 on the interval [0,1].List the wi,i=0,…,4,and find the error at t=1 by comparing with the correct solution.

(b)w=[1.0000,1.0000,1.0156,1.0791,1.2309],误差=0.1648.

(c)w=[1.0000,1.5000,2.4375,4.2656,7.9980],误差=12.0875.

(d)w=[1.0000,1.0000,1.0049,1.0834,1.5119],误差=1.2064.

(e)w=[1.0000,1.2500,1.4100,1.5357,1.6417],误差=0.0543.

(f)w=[1.0000,1.0000,1.0039,1.0349,1.1334],误差=0.0717.

(P301)1.题目：Using initial condition y(0)=1 and step size h=1/4,calculate the Trapezoid Method approximation w0,…,w4,on the interval [0,1].Find the error at t=1 by comparing with the correct solution found in Exercise 6.1.3.

(b)w=[1.0000,1.0078,1.0477,1.1587,1.4054],误差=0.0097.

(c)w=[1.0000,1.7188,3.3032,7.0710,16.7935],误差=3.2920.

(d)w=[1.0000,1.0024,1.0442,1.3077,2.7068],误差=0.0115.

(e)w=[1.0000,1.2050,1.3570,1.4810,1.5871],误差=0.0003.

(f)w=[1.0000,1.0020,1.0193,1.0823,1.2182],误差=0.0132.

Computer Problems

(P254)1.题目：Make a table of the error of the three-point centered-difference formula for f’(0),where f(x)=sinx-cosx, with h=10^(-1),….,10^(-12),as in the table in Section 5.1.2.Draw a plot of the results.Dose the minimum error correspond to the theoretical expectation?

b=[];

for i=1:12

y=@(x)sin(x)-cos(x);

x=10^(-i)

y1=(y(x)-y(-x))/(2*x)

a(i)=x;

b(i)=y1;

end

(P264)1.题目：Use the composite Trapezoid Rule with m=16 and 32 panels to approximate the definite integral. Compare with the correct integral and report the two errors. (d)ʃ((x^2)*lnx,1,3)

(h)ʃ(x/sqrt((x^4)+1))

h = (b - a) / n;

x = linspace(a,b,n+1);

y1 = h * feval(f,x);

y1(1) = y1(1) / 2;

y1(n+1) = y1(n+1) / 2;

y = sum(y1);

>> traint(1,3,16,f)

ans =

7.009809235924680

>> traint(1,3,32,f)

ans =

7.001418506166504

>> syms x;

>> int(x^2*log(x),1,3)

ans =

9*log(3) - 26/9=6.99862

>> traint(1,3,16,f)

ans =

1.005896390281055

>> f=inline('x./sqrt((x.*x.*x.*x)+1)');

>> traint(0,1,32,f)

ans =

0.440605407679783

>> syms x

>> int(x/sqrt((x^4)+1),0,1)

ans =

log(2^(1/2) + 1)/2=0.440687

2.题目：Apply the composite Simpson’s Rule to the integrals in Computer Problem 1.Use m=16 and 32,and report errors.

3.题目：Use the composite Trapezoid Rule with m=16 and 32 panels to approximate the definite integral. (a)ʃ(exp(x^2),0,1)  (f)ʃ(cos(exp(x)),0,pi)

h = (b - a) / n;

x = linspace(a,b,n+1);

y1 = h * feval(f,x);

y1(1) = y1(1) / 2;

y1(n+1) = y1(n+1) / 2;

y = sum(y1);

>> traint(0,1,16,f)

ans =

1.464420310149482

>> traint(0,1,32,f)

ans =

1.463094102606428

(f)>> f=inline('cos(exp(x.*x))');

>> traint(0,pi,16,f)

ans =

-0.109110932137825

>> traint(0,pi,32,f)

ans =

-0.130624277032587

4.题目：Apply the composite Simpson’s Rule to the integrals of Computer Problem 3,using m=16 and 32. 