Ortogonaalsed polünoomid

Legendre polünoom

\(L[n_, x_] := 
      ExpandNumerator[
        Simplify[∂\_{x, n}\((x\^2 - 1)\)\^n\/\(2\^n\ \(n!\)\)]]\)

Lpoly1 = L[1, x]

Lpoly2 = L[2, x]

Joonestame Legendre polünoomide graafikud.

Plot[{Lpoly1, Lpoly2}, {x, -1.5, 1.5}, 
      AspectRatio -> Automatic, PlotRange -> {-1.5, 1.5}, 
      GridLines -> Automatic];

Tshebõshevi polünoomid

T[0, x_] := 1; 
T[1, x_] := x; 
T[n_, x_] := Expand[2 x T[n - 1, x] - T[n - 2, x]]

Tpoly2 = T[2, x]

Tpoly3 = T[3, x]

Joonestame Tshebõshevi polünoomide graafikud.

Plot[{T[1, x], Tpoly2, Tpoly3}, {x, -1.5, 1.5}, 
      AspectRatio -> Automatic, PlotRange -> {-1.5, 1.5}, 
      GridLines -> Automatic];

Numbriline diferentseerimine

LagrangePoly[xx_List, ff_List, x_Symbol] := 
      Module[{n = Length[xx]}, 
        Expand[(∑_(i = 1)^n)((∏_(k = 1)^(n - 1))((x - Drop[xx, {i}][[k]])/(xx[[i]] - Drop[xx, {i}][[k]]))) ff[[
                i]]]]

sõlmed = {{1, 2}, {1.5, 3.8}, {2, 4.2}, {2.8, 3.1}}; 
xx = sõlmed /. {x_, y_} -> x; 
yy = 
      sõlmed /. {x_, y_} -> y;

Lpoly = LagrangePoly[xx, yy, x]

dL = (∂_x) Lpoly

x0 = 1.7; 
k = (∂_x) Lpoly /. x -> x0

Graafiline interpretatsioon.

y0 = Lpoly /. x -> x0; 
puutuja = (x - x0) k + y0

Plot[{Lpoly, puutuja}, {x, 0, 3}, 
      Epilog -> {PointSize[0.03], Point /@ sõlmed, Hue[0], 
          Point[{x0, y0}]}];

Väliskaubandusbilansi näide

solmex  = {{1993,  10635.5}, {1994,  16927.3}, {1995, 
            21071.6}, {1996, 25036.6}, 
{1997, 
            40785.4}, {1998, 45575.2}, {1999, 43164}, {2000, 65189.3}, {2001, 
            70112.9}, 
{2002, 70843.5}, {2003, 
            77573.4}, {2004, 78923.4}};

solmimp  = {{1993,  11829.6}, {1994,  21484.0}, {1995, 
            29119.5}, {1996, 38885.1}, 
{1997, 
            61661.1}, {1998, 67377.9}, {1999, 60475.2}, {2000, 
            86117.1}, {2001, 91351.4}, 
{2002, 
            95261.5}, {2003, 109905.0}, {2004, 
            111530.5}};

pex = Fit[solmex, {1, x, x^2, x^3, x^4, x^5}, x]

pimp = Fit[solmimp, {1, x, x^2, x^3, x^4, x^5}, x]

Plot[pex, {x, 1992, 2004}, 
      Epilog -> {PointSize[0.02], 
          Point /@ solmex}, 
PlotStyle -> 
        RGBColor[0, 0, 1]]

Plot[{pimp, pex}, {x, 1992, 2004}, 
      Epilog -> {{PointSize[0.02],  Hue[0.01], 
            Point /@ solmimp}, {PointSize[0.02],  Hue[0.6], 
            Point /@ solmex}}, 
PlotStyle -> {RGBColor[
            1, 0, 0], RGBColor[0, 0, 1]}]

NSolve[pimp == pex, x]