summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-fct/doc/latex/TKZdoc-fct-interpolation.tex
blob: e00ec4fa3e1ffed13ed0c291c13fe96a7878052f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
\subsection{Interpolation} 

Il s'agit ici de trouver un polynôme d'interpolation sur l'intervalle $[-1~;~1]$ de la fonction $f$ définie par :
\[
  f(x)=\frac{1}{1+8x^2}
\]
 
Le polynôme d'interpolation est celui obtenu par la méthode de \tkzimp{Lagrange} :
\begin{equation*}
\begin{split}
 P(x) = &1.000000000-0.0000000072x-7.991424876x^2+0.000001079x^3+62.60245358x^4\\
 & -0.00004253x^5-444.2347594x^6+0.0007118x^7+ 2516.046396x^8 -0.005795x^9\\ &-10240.01777x^{10} +0.025404x^{11}+28118.29594x^{12} -0.05934x^{13} -49850.83249x^{14} \\
& +0.08097x^{15}+54061.87086x^{16} -0.055620x^{17} -32356.67279x^{18} +0.015440x^{19}\\
&+8140.046421x^{20}\\
\end{split}
\end{equation*}

Ayant utilisé vingt et un points, le polynôme est de degré $20$. Celui-ci est écrit en utilisant la méthode de \tkzimp{Horner}. Dans un premier temps, on demande à gnuplot de tracer la courbe de f en rouge,  enfin on trace le polynôme d'interpolation en bleu. Les points utilisés sont en jaune. 

\subsubsection{Le code}
\begin{tkzexample}[code only]
\begin{tikzpicture}
\tkzInit[xmin=-1,xmax=1,ymin=-1.8,ymax=1.2,xstep=0.1,ystep=0.2]
\tkzGrid    
\tkzAxeXY 
\tkzFct[samples = 400, line width=4pt, color = red,opacity=.5](-1---1){1/(1+8*\x*\x)}
 \tkzFct[smooth,samples = 400, line width=1pt, color = blue,domain =-1:1]% 
{1.0+((((((((((((((((((((
                          8140.04642)*\x
                            +0.01544)*\x
                        -32356.67279)*\x
                            -0.05562)*\x
                        +54061.87086)*\x
                            +0.08097)*\x
                        -49850.83249)*\x
                            -0.05934)*\x
                        +28118.29594)*\x
                            +0.02540)*\x
                        -10240.01777)*\x
                            -0.00580)*\x
                         +2516.04640)*\x
                            +0.00071)*\x
                          -444.23476)*\x
                            -0.00004)*\x
                           +62.60245)*\x
                            +0.00000)*\x
                            -7.99142)*\x
                            -0.00000)*\x}
 \tkzSetUpPoint[size=16,color=black,fill=yellow]   
 \foreach \v in {-1,-0.8,---.,1}{\tkzDefPointByFct[draw](\v)}
\end{tikzpicture}
\end{tkzexample}

Le résultat est sur la page suivante où on peut constater le phénomène de \tkzimp{Runge}.
\subsubsection{la figure}  

\begin{sidewaysfigure}[htbp]
\centering 
\begin{tikzpicture}[scale=.75]
\tkzInit[xmin=-1,xmax=1,ymin=-1.8,ymax=1.2,xstep=0.1,ystep=0.2]
\tkzGrid
\tkzAxeXY 
\tkzFct[samples = 400, line width=4pt, color = red,opacity=.5,domain =-1:1]%
{1/(1+8*\x*\x)}
 \tkzFct[samples = 400, line width=1pt, color = blue,domain =-1:1]% 
{1.0+
((((((((((((((((((((
           8140.04642)*\x
             +0.01544)*\x
         -32356.67279)*\x
             -0.05562)*\x
         +54061.87086)*\x
             +0.08097)*\x
         -49850.83249)*\x
             -0.05934)*\x
         +28118.29594)*\x
             +0.02540)*\x
         -10240.01777)*\x
             -0.00580)*\x
          +2516.04640)*\x
             +0.00071)*\x
           -444.23476)*\x
             -0.00004)*\x
            +62.60245)*\x
             +0.00000)*\x
             -7.99142)*\x
             -0.00000)*\x}
 \tkzSetUpPoint[size=8,color=black,fill=yellow]   
 \foreach \v in {-1,-0.8,---.,1}%
 {\tkzDefPointByFct[draw](\v)}           
\end{tikzpicture}
\caption{Interpolation : $\dfrac{1}{1+8x^2}$}
\end{sidewaysfigure}

\endinput