You are on page 1of 12

Genie

Intégration numérique
Partie 1
2
int ,x
1 Ctan x
1 2
K ln 1 Ctan x Cln 1 Ctan x Cx (1.1)
2
2
Int ,x ;
1 Ctan x
2
dx (1.2)
1 Ctan x
value % ;
1 2
K ln 1 Ctan x Cln 1 Ctan x Cx (1.3)
2
simplify % ;
1 1 cos x Csin x
K ln 2
Cln Cx (1.4)
2 cos x cos x
simplify %, symbolic ;
ln cos x Csin x Cx (1.5)
2
dx
1 Ctan x
1 2
K ln 1 Ctan x Cln 1 Ctan x Cx (1.6)
2

Partie 2
2
f x d ;
1 Ctan x
2
x/ (2.1)
1 Ctan x
A d plot f x , x = 0 ..1, color = COLOR RGB, .75, .75, .75 , filled = true :
B d plot f x , x =K.2 ..1.5, color = red :
C d plot 1, 0 , 1, f 1 , color = black :
plots display A, B, C ;
1
1
evalf 20 dx ;
x Cexp x
0
0.51630076336901667193 (3.3)
1
1
evalf 50 dx ;
x Cexp x
0
0.51630076336901667193104134782977767559156911103485 (3.4)
1
g x d ;
x Cexp x

1
x/ (3.5)
x Cex
C1 d plot f x , x = 0 ..1, color = COLOR RGB, .75, .75, .75 , filled = true :
C2 d plot f x , x =K.2 ..1.5, color = red :
C3 d plot 0, 0 , 0, 2 , 1, f 1 , 1, 0 , 0, 0 , color = COLOR RGB, .4, 0, .9 , thickness
=3 :
C4 d plot 0, 0 , 0, 2 , 1, 2 , 1, 0 , 0, 0 , color = COLOR RGB, .4, 0, .9 , linestyle = 5 :
#C5 d plot 0, f 1 , 1, f 1 , color = COLOR RGB, 0, .9, 0 , thickness = 2 :
plots display C1, C2, C3, C4 ;
%
1
h y0 C2 y1 C2 y2 C2 y3 C2 y4 Cy5 (4.1.4)
2
5
3
2 x
value 2$x K dx ;
3
1
92
(4.1.5)
3
x3
student trapezoid 2$x2 K , x = 1 ..5, 4 ;
3
3
5C >
j=1
2 1 Cj 2 K
1
3
1 Cj 3
(4.1.6)

value %
30 (4.1.7)
3
x
value student trapezoid 2$x2 K , x = 1 ..5, 8
3
61
(4.1.8)
2
2 x3
value student trapezoid 2$x K , x = 1 ..5, 16
3
245
(4.1.9)
8
2 x3
value student trapezoid 2$x K , x = 1 ..5, 42
3
40564
(4.1.10)
1323
92 40564
evalf K
3 1323
0.006046863190 (4.1.11)
?trapezoid

B (package Student)
with Student :
x3
ApproximateInt 2$x2 K , x = 1 ..5, method = trapezoid, partition = 4
3
30 (4.2.1)
3
x
ApproximateInt 2$x2 K , x = 1 ..5, method = trapezoid, partition = 4, output = sum
3
3
1
2 >
i1 = 0
2 1 Ci1 2 K
1
3
1 Ci1 3 C2 2 Ci1 2 K
1
3
2 Ci1 3
(4.2.2)
?ApproximateInt
3
x
ApproximateInt 2$x2 K , x = 1 ..5, method = trapezoid, partition = 4, output = plot
3

10

0
1 2 3 4 5

5
Une approximation de f x dx utilisant la règle des trapèzes,
1
1 3
où f x = 2 x2 K x et la partition est uniforme. La valeur
3
approximative de l'intégrale est 30.00000000. Nombre de sous-
intervalles utilisés: 4.
2x3
ApproximateInt 2$x K , x = 1 ..5, method = trapezoid, output = animation ;
3
10

0
1 2 3 4 5

5
Une approximation animée de f x dx utilisant la règle des
1
1 3
trapèzes, où f x = 2 x2 K x et la partition est uniforme. La
3
valeur approximative de l'intégrale est 30.66656250. Nombre
de sous-intervalles utilisés: 320.

Programmation!!!
?proc
b Ka h
trapimi dproc f, a, b, n local i, h; h d evalf ; if n = 1 then evalf $ f a
n 2
h
Cf b ; else evalf f a C2$ sum f a Ci$h , i = 1 .. n K1 Cf b ; end if
2
end proc;
proc f, a, b, n (4.3.1)
local i, h;
h := evalf b K a / n ;
if n = 1 then
evalf 1 / 2 * h * f a Cf b
else
evalf 1 / 2 * h * f a C2 * sum f a Ch * i , i = 1 ..n K 1 Cf b
end if
end proc
3
x
ApproximateInt 2$x2 K , x = 1 ..5, method = trapezoid, partition = 4
3
30 (4.3.2)
3
x
ff x d 2$x2 K : RR d int ff x , x = 1 ..5 ;
3
92
(4.3.3)
3
trapimi ff, 1, 5, 4 ;
30.00000000 (4.3.4)
for i from 1 to 20 do tp d trapimi ff, 1, 5, i ; err d evalf RR Ktp; print i,
"sous intervalles KO ", tp, err ; end do:
1, "sous intervalles -O ", 20.00000000, 10.66666667
2, "sous intervalles -O ", 28.00000000, 2.66666667
3, "sous intervalles -O ", 29.48148148, 1.18518519
4, "sous intervalles -O ", 30.00000000, 0.66666667
5, "sous intervalles -O ", 30.24000000, 0.42666667
6, "sous intervalles -O ", 30.37037038, 0.29629629
7, "sous intervalles -O ", 30.44897960, 0.21768707
8, "sous intervalles -O ", 30.50000000, 0.16666667
9, "sous intervalles -O ", 30.53497942, 0.13168725
10, "sous intervalles -O ", 30.56000000, 0.10666667
11, "sous intervalles -O ", 30.57851240, 0.08815427
12, "sous intervalles -O ", 30.59259260, 0.07407407
13, "sous intervalles -O ", 30.60355030, 0.06311637
14, "sous intervalles -O ", 30.61224488, 0.05442179
15, "sous intervalles -O ", 30.61925926, 0.04740741
16, "sous intervalles -O ", 30.62500000, 0.04166667
17, "sous intervalles -O ", 30.62975778, 0.03690889
18, "sous intervalles -O ", 30.63374484, 0.03292183
19, "sous intervalles -O ", 30.63711912, 0.02954755
20, "sous intervalles -O ", 30.64000000, 0.02666667 (4.3.5)

Partie 5 (Simpson, boole composites)


f d 'f': x d 'x': a d 'a': b d 'b': n d 'n': h d 'h':
Int f x , x = a ..b = student simpson f x , x = a ..a Cn$h, n ;

1 1
n n K1
b 2 2

a
f x dx =
1
3
h f a Cf h n Ca C4 >f
j=1
a C 2 j K1 h C2 >
j= 1
f 2hj (5.1)
Ca

f x d sin x ;
x/sin x (5.2)
Pi 3$Pi
R d Int f x , x = .. ;
4 4
3
p
4
sin x dx (5.3)
1
p
4
Pi 3$Pi
a d evalf : b d evalf :
4 4
CC1 d plot f x , x = 0 ..Pi, thickness = 2 :
CC2 d plot 0, f x , x = a ..b, adaptive = false, numpoints = 20, color = COLOR RGB, .4, 0, .9 ,
thickness = 3 :
CC3 d plot f x , x = a ..b, color = COLOR RGB, .75, .75, .75 , filled = true :
CC4 d plot a, f a , a, 0 , b, 0 , b, f b , color = COLOR RGB, .4, 0, .9 , thickness = 3 :
plots display CC1, CC3, CC2, CC4 ;
1

0.8

0.6

0.4

0.2

0
5p 3p 7p p 9p 5p 11 p 3p
16 8 16 2 16 8 16 4

3
p
4
Une approximation de f x dx utilisant la règle de
1
p
4
Simpson, où f x = sin x et la partition est uniforme. La
valeur approximative de l'intégrale est 1.414213581. Nombre
de sous-intervalles utilisés: 20.
ApproximateInt R, method = boole, output = value ;
1
p 21 C7 5 C 5 C7 5 K 5 C7 2 5 C3 2 K 2 C15 2C 2 (5.7)
1800
27 29
C7 2 5 C 5 C7 5 C7 2 C64 sin
p C64 sin p
80 80
21 23 5 37
C64 sin p C64 sin p C64 sin p C64 sin p
80 80 16 80
39 31 33 7
C64 sin p C64 sin p C64 sin p C64 sin p
80 80 80 16

C6 2C 2 5 C 5 C3 2C 2 5 C6 2K 2 5C 5

C3 2K 2 5 C3 2 5K 5 2 K 2 C3 2 5K 5 2C 2

evalf %
1.414213562 (5.8)
ApproximateInt R, method = boole, output = plot, partition = 10 ;
1

0.8

0.6

0.4

0.2

0
5p 3p 7p p 9p 5p 11 p 3p
16 8 16 2 16 8 16 4

3
p
4
Une approximation de f x dx utilisant la règle de Boole,
1
p
4
où f x = sin x et la partition est uniforme. La valeur
approximative de l'intégrale est 1.414213562. Nombre de sous-
intervalles utilisés: 10.
?evalf

You might also like