You are on page 1of 37

4.

3
4.3


4.3


m
y ( x ) = a m x m + a m 1 x m 1 + a m 2 x m 2 + " + a 0
f (x)
m = 0
m = 1
m = 2
1 m 2m

n
1 n G = a f ( x)dx Ak f ( x k )
b

k =0

m = 2n 1
2. n
x k Ak
m = 2n 1

x0 , x1 , ", x n

a b
(a) (b)


m

f ( x ) = 1, x , x 2 , " , x m

bab
13: a f ( x)dx [ f (a ) + f (b)]
2

f ( x ) = 1, x
b ba ba
a 1dx = b a =
2
[1 + 1] =
2
[ f (a ) + f (b)]
b 1 2 ba ba
a xdx = 2 (b a ) = 2 [a + b] = 2 [ f (a) +
2
f (b)]

f ( x) = x 2
b b 3
a 3
ba 2 ba

a
x 2 dx =
3

2
[a + b 2 ] =
2
[ f (a) + f (b)]

c0 + c1 x
f ( x ) = 1, x

3

[-11]
n

f ( x)dx Ak f ( xk )
1

1
k =0

x0 , x1 , ", xn n + 1
( x) = ( x x0 )( x x1 )( x x2 )" ( x xn )
(x) n q(x)
1 ( x)q( x)dx = 0
1

2n + 1
( x) x k
Ak = 1
1
dx
( x xk ) ( xk )
xk Ak
Legendre
1 dn
p n ( x) = n n [( x 2 1) n ]
2 n! dx
[-11]
1 pn ( x) pn+1 ( x)dx = 0
1

[2(n + 1)]!
p n+1 ( x ) n+1
2 [(n + 1)!]2
2 n +1[(n + 1)!]2 (n + 1)! d n +1
( x) = pn +1 ( x) = n +1 [( x 2 1) n +1 ]
[2(n + 1)]! [2(n + 1)]! dx
n

p n+1 ( x) n + 1 : 1 f ( x)dx Ak f ( xk )
1

k =0
x0 , x1 , ", xn
xk Ak

( x)
Ak = 1
1
dx
( x xk ) ( xk )

2
Ak =
(1 xk2 )[ pn+1 ( xk )]2

2 2 n +3 [(n + 1)!]4 ( 2 n + 2 )
R( f ) = f ( ), [-1,1]
2n + 3 [(2n + 2)!] 3

1 dn
p n ( x) = n n [( x 2 1) n ]
(1) n = 0 (1 2 n! dx
1 d 2
p1 ( x) = ( x 1) = x, Ak =
2
2 dx (1 xk2 )[ pn+1 ( xk )]2
p1 ( x) = 1

x0 = 0 A0 = 2
n

1 f ( x)dx
1

k =0
Ak f ( xk )
1
f ( x ) dx 2 f (0)
1
R( f ) = f ( )
3
1 dn
p n ( x) = n n [( x 2 1) n ]
2 n! dx
2
2n = 1 (2 Ak =
(1 xk2 )[ pn+1 ( xk )]2
1 d2 2 1
p2 ( x ) = 2
( x 1) 2
= (3 x 2
1) p2 ( x ) = 3 x
8 dx 2
1 1
x0 = , x1 = A0 = A1 = 1
3 3
1
1 1
1 f ( x)dx Ak f ( xk ) =
1
2 f ( )+ f ( )
k =0 3 3
1 ( 4)
R( f ) = f ( )
135
3 (n = 2)
1 5 15 8 5 15

1
f ( x ) dx
9
f (
5
) + f ( 0) + f (
9 9 5
)

1

1
f ( x)dx A0 f ( x0 ) + A1 f ( x1 )

A0 , A1 , x0 , x13
f ( x) = 1, x, x , x
2 3

A0 + A1 = 2
A x + A x = 0
0 0 1 1

A x
0 0
2
+ A1 1 = 2/3
x 2

A x3 + A x3 = 0
0 0 1 1

1 1
x0 = , x1 = , A0 = A1 = 1
3 3
n 2
[-1,1]

[a, b] ,
1 1
x = (b + a) + (b a)t
2 2
[a, b] [-1,1]
ba 1
(t )dt
b

a
f ( x)dx = 1
2
a+b ba
(t ) = f ( + t)
2 2
1 1
x = (b + a) + (b a)t
2 2
14

I = 0 1 + x 2 dx
1

1 1 1+ t
a = 0 b = 1 x = + t =
2 2 2
1 1 1 1

1
I = 1 + x dx = 1 + (1 + t ) 2 dt
2
1
f ( x)dx A0 f ( x0 ) + A1 f ( x1 )
0 2 1 4

1 1 1 2 1 1 2
[ 1 + (1 ) + 1 + (1 + ) ]
2 4 3 4 3
= 1.147833092

: a=0, b=1, N=1000, I=1.147793
(n=2)
subroutine Gauss(a,b,G)
dimension t(3),w(3)
data t/0.,0.774597,-0.774597/
data w/0.888889,0.555556,0.555556/
G=0.0 1 1
do 10 i=1,3 x = (b + a) + (b a)t
2 2
x=0.5*[(b+a)+(b-a)*t(i)]
10 G=G+w(i)*f(x) n

f ( x)dx Ak f ( xk )
1

1
G=0.5*(b-a)*G k =0

return ba
(t )dt
b 1
f ( x ) dx =
end a
2 1
I = 0 1 + x 2 dx
1

14
external f
real*8 a,b,G
a=0.
b=1.
call gauss(a,b,G,f)
write(*,*) G
end

subroutine Gauss(a,b,G,f)
real*8 t(3),W(3),a,b,G,x
data t/0.,0.774597,-0.774597/
data W/0.888889,0.555556,0.555556/
G=0.0
do 10 i=1,3
x=0.5*((b+a)+(b-a)*t(i))
10 G=G+w(i)*f(x)
G=0.5*(b-a)*G
return : N=1000, I=1.147793
end

function f(x)
real*8 f,x
f=sqrt(1.+x**2) I = 1.147801134
end

15
2.0 ( b2 ) 1.5 ( b1 )
I=
1.4 ( a 2 ) 1.0 ( a1 )
ln( x + 2 y )dxdy

: R = {( x, y) | 1.4 x 2.0, 1.0 y 1.5}

R = {(u, v) | 1 u 1, 1 v 1}
1 1
x = 2 (b2 + a2 ) + 2 (b2 a2 )u

y = 1 (b + a ) + 1 (b a )v
2
1 1
2
1 1
2.0 1.5
I = ln( x + 2 y )dxdy
1.4 1.0
1 1
= 0.075 ln(0.3u + 0.5v + 4.2)dudv
1 1

n = 2
u0 = v0 = 0.774 5967 u1 = v1 = 0 u2 = v2 = 0.774 5967
A0 = A2 = 0.555 5556 A1 = 0.888 8889
:
2 .0 ( b 2 ) 1 . 5 ( b1 )
I =
1 .4
( a 2 ) 1 . 0 ( a1 )
ln( x + 2 y ) dxdy

2 2
= 0.075 A A ln(0.3u
i =0 j =0
i j i + 0.5v j + 4.2)

= 0.429 5545

3 1
EX3-935 1 dx
x

EX3-104
2 .0 1 .5
I =
1 .4 1 .0
ln( x + 2 y ) dxdy

EX3-11 n = 2, 4
/2 dx
G= =
0 cos 2 x + 4 sin 2 x 4
EX3-10(3)
external f
real*8 a1,b1,a2,b2,G
a1=1.
b1=1.5
a2=1.4
b2=2.0
call gauss(a1,b1,a2,b2,G,f)
write(*,*) G
end
subroutine Gauss(a1,b1,a2,b2,G,f)
real*8 t(3),W(3),a1,b1,a2,b2,G,x,y
data t/0.,0.774597,-0.774597/
data W/0.888889,0.555556,0.555556/
G=0.0
do i=1,3
x=0.5*((b2+a2)+(b2-a2)*t(i)) 1 1
x = (b2 + a2
) + (b2 a2 )u
2 2
do j=1,3
y=0.5*((b1+a1)+(b1-a1)*t(j))
G=G+w(i)*w(j)*f(x,y) y = 1 (b + a ) + 1 (b a )v
enddo 2
1 1
2
1 1

enddo
G=0.25*(b2-a2)*(b1-a1)*G
return
end
function f(x,y)
real*8 f,x,y
f=dlog(x+2.*y)
end

()







123

4.3
b n
f ( x)dx f ( x
a k =1
k )

w(x)

b n

w( x) f ( x)dx A
a k =1
k f ( xk )

xk,Akxk,Ak

4.3

1. Gauss - Legendre
n
f ( x )dx Ak f ( xk )
1
1
k =0

Legendre
2
Ak =
(1 xk 2 )Pn '( xk )2

Guassxk, GuassAk

4.3
4.3
n

f ( x )dx Ak f ( x k )
1

1
k =0


1
n = 0, f ( x )dx 2 f (0)
1

n=1
1
1
f ( x )dx f ( 0.5773502692) + f (0.5773502692)

n=2
1
1
f ( x )dx 0.555555556 f ( 0.7745966692)
+0.888888889 f (0) + 0.555555556 f (0.7745966692)
4.3
: -

1
x + 1.5dx
1
:-


1
x + 1.5dx
1

0.555556( 0.725403 + 2.274596) + 0.888889 1.5


= 2.399709

1
1 x + 1.5dx 3 ( 0.5 + 4 1.5 + 2.5) = 2.395742
1


1
x + 1.5dx = 2.399529
1
4.3

Gauss - Legendre
[a,b]
ba a+b
x= t+
2 2
[a,b][-1,1],
ba 1 ba a+b

b
f ( x )dx = f( t+ )dt
a 2 1 2 2
Gauss - Legendre
.
4.3
f ( x )dx
1
n = 1Gauss Legendre
0

Gaussx0 , x1A0 , A1


1
f ( x )dx A0 f ( x0 ) + A1 f ( x1 )
0

Gauss

1 1 1 1
x = (a + b ) + (b a )t = (1 + t ), dx = dt
2 2 2 2

1 1 1 1 1 1
f ( x )dx = f ( (1 + t ))dt = F ( t )dt
0 2 1 2 2 1

Gauss Legendre F (t )dt F (0.577) + F (0.577)


1

1 1 1 1 1 1 1 1
0 f ( x)dx = 2 1 f ( 2 (1 + t ))dt = 2 f ( 2 (1 0.577)) + 2 f ( 2 (1 + 0.577))
4.3
1
f ( x )dx
n = 3Gauss Legendre
0
Gaussx0 , x1 , x2 , x3
A0 , A1 , A2 , A3
1
0
f ( x )dx A0 f ( x0 ) + A1 f ( x1 ) + A2 f ( x2 ) + A3 f ( x3 )
Gauss

1 1 1 1
x = (a + b ) + (b a )t = (1 + t ), dx = dt
2 2 2 2
1 1 1 1 1
f ( x )dx = f ( (1 + t ))dt = F ( t )dt
1

0 2 1 2 2 1
F ( t )dt Gauss Legendre
1


1
F ( t )dt A0 F ( t 0 ) + A1 F ( t1 ) + A2 F ( t 2 ) + A3 F ( t 3 )
1
4.3

t i Ai ,( i = 0,1, 2, 3)

1 1
0 f ( x )dx = 2 1 F (t )dt
1

1
( A0 F ( t0 ) + A1 F ( t1 ) + A2 F ( t 2 ) + A3 F ( t 3 ))
2
1 1 1 1
= ( A0 f ( (1 + t0 )) + A1 f ( (1 + t1 )) + A2 f ( (1 + t 2 ))
2 2 2 2
1
+ A3 f ( (1 + t 3 )))
2
1 1
xi = (1 + t i ) Ai = Ai i = 0,1, 2, 3
2 2
4.3
1 1
xi = (1 + t i ) Ai = Ai i = 0,1, 2, 3
2 2

i=0 1 2 3
t i = 0.861136 0.339981 0.339981 0.861136
Ai = 0.347855 0.652145 0.652145 0.347855
xi = 0.069432 0.330009 0.669991 0.930568
Ai = 0.173927 0.326073 0.326073 0.173927
f ( x )dx 0.173927 f (0.069432)
1

+ 0.326073 f (0.330009)
+ 0.326073 f (0.669991)
+ 0.173927 f (0.930518)
4.3
1 dx
0 1+ x
: x=1/2 (1+t),
1 dx 1 dt
I= =
0 1+ x 1 3 + t

-Legendren=4
I 0.69314719"

I=ln2=0.69314718
.
4.3

:,
1 sin x
I= dx
0 x

1Newton-Cotes
n=1I0.9270354
n=2, Simpson,
I 0.9461359

I=0.9460831
4.3
5Gauss
sin( t + 1) / 2
1
I = dt
x=(t+1)/2, 1 t +1 I=0.9460831
12Gauss
1 1
sin ( 0 . 5773503 + 1 ) sin ( 0 . 5773503 + 1 )
I 2 + 2 = 0 .9460411
0 .5773503 + 1 0 .5773503 + 1

23Gauss
1 1
sin (0.7745907 + 1) s in
I 0.5555556 2 2
+ 0 .8 8 8 8 8 8 9
0.7745907 + 1 0+1
1
sin (0.7745907 + 1)
+ 0.5555556 2 = 0.9460831
0.7745907 + 1
4.3

Gauss
Gauss
[a , b] n
Gauss,
Gauss

Gauss-LegenderGauss
.
[a , b] n
ba
h= , x k = a + kh, k = 0,1, ..., n
n
4.3
n 1

f ( x )dx =
b x k +1
f ( x )dx
a xk
k =0

xk +1 xk xk + xk +1
x = t+
2 2
[ x k , x k + 1 ][ 1,1].
xk + xk +1 1
xk +1 xk = h, = a + (k + )h
2 2
1
x = a + (k + (1 + t ))h
2
h n1 1 1
f ( x)dx = f (a + (k + (1 + t ))h)dt
b

a 2 k=0 1 2
4.3

Gauss-Legender
Gauss.
,2Gauss-Legender,
9-4,n=1,Aj =1,xj=0.5773502692
,2Gauss-Legender

b
f ( x)dx
a
h n1
( f (a + (k + 0.211325h) + f (a + (k + 0.788675h))
2 k =0