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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Maxima Manual: Функции и переменные пакета interpol</title>
<meta name="description" content="Maxima Manual: Функции и переменные пакета interpol">
<meta name="keywords" content="Maxima Manual: Функции и переменные пакета interpol">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="maxima_toc.html#Top" rel="start" title="Top">
<link href="maxima_264.html#g_t_0423_043a_0430_0437_0430_0442_0435_043b_044c-_0444_0443_043d_043a_0446_0438_0439-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0445" rel="index" title="Указатель функций и переменных">
<link href="maxima_toc.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="maxima_198.html#g_t_041f_0430_043a_0435_0442-interpol" rel="up" title="Пакет interpol">
<link href="maxima_201.html#lapack_002dpkg" rel="next" title="lapack-pkg">
<link href="maxima_199.html#g_t_0412_0432_0435_0434_0435_043d_0438_0435-_0432-_043f_0430_043a_0435_0442-interpol" rel="previous" title="Введение в пакет interpol">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {color: black; background: white; margin-left: 8%; margin-right: 13%;
font-family: "FreeSans", sans-serif}
h1 {font-size: 150%; font-family: "FreeSans", sans-serif}
h2 {font-size: 125%; font-family: "FreeSans", sans-serif}
h3 {font-size: 100%; font-family: "FreeSans", sans-serif}
a[href] {color: rgb(0,0,255); text-decoration: none;}
a[href]:hover {background: rgb(220,220,220);}
div.textbox {border: solid; border-width: thin; padding-top: 1em;
padding-bottom: 1em; padding-left: 2em; padding-right: 2em}
div.titlebox {border: none; padding-top: 1em; padding-bottom: 1em;
padding-left: 2em; padding-right: 2em; background: rgb(200,255,255);
font-family: sans-serif}
div.synopsisbox {
border: none; padding-top: 1em; padding-bottom: 1em; padding-left: 2em;
padding-right: 2em; background: rgb(255,220,255);}
pre.example {border: 1px solid rgb(180,180,180); padding-top: 1em;
padding-bottom: 1em; padding-left: 1em; padding-right: 1em;
background-color: rgb(238,238,255)}
div.spacerbox {border: none; padding-top: 2em; padding-bottom: 2em}
div.image {margin: 0; padding: 1em; text-align: center}
div.categorybox {border: 1px solid gray; padding-top: 1em; padding-bottom: 1em;
padding-left: 1em; padding-right: 1em; background: rgb(247,242,220)}
img {max-width:80%; max-height: 80%; display: block; margin-left: auto; margin-right: auto}
-->
</style>
<link rel="icon" href="figures/favicon.ico">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6>"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body lang="ru" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="g_t_0424_0443_043d_043a_0446_0438_0438-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0435-_043f_0430_043a_0435_0442_0430-interpol"></a>
<div class="header">
<p>
Previous: <a href="maxima_199.html#g_t_0412_0432_0435_0434_0435_043d_0438_0435-_0432-_043f_0430_043a_0435_0442-interpol" accesskey="p" rel="previous">Введение в пакет interpol</a>, Up: <a href="maxima_198.html#g_t_041f_0430_043a_0435_0442-interpol" accesskey="u" rel="up">Пакет interpol</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_264.html#g_t_0423_043a_0430_0437_0430_0442_0435_043b_044c-_0444_0443_043d_043a_0446_0438_0439-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0445" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Funkcii-i-peremennye-paketa-interpol"></a>
<h3 class="section">54.2 Функции и переменные пакета interpol</h3>
<a name="Item_003a-interpol_002fdeffn_002flagrange"></a><dl>
<dt><a name="index-lagrange"></a>Функция: <strong>lagrange</strong> <em>(<var>points</var>)</em></dt>
<dt><a name="index-lagrange-1"></a>Функция: <strong>lagrange</strong> <em>(<var>points</var>, <var>option</var>)</em></dt>
<dd><p>Вычисляет полиномиальную интерполяцию методом Лагранжа. Аргумент <var>points</var> должен быть либо:
</p>
<ul>
<li> матрицей из двух колонок, <code>p:matrix([2,4],[5,6],[9,3])</code>,
</li><li> списком пар, <code>p: [[2,4],[5,6],[9,3]]</code>,
</li><li> списком чисел <code>p: [4,6,3]</code>, в этом случае абсцисса будет назначена автоматически равной 1, 2, 3 и т.д.
</li></ul>
<p>В первых двух случаях, перед проведением вычислений, пары упорядочиваются в соответствии
со значением первой координаты.
</p>
<p>Аргумент <var>option</var> позволяет выбрать имя независимой переменной, по умолчанию равной <code>'x</code>.
Чтобы задать другую переменную напишите <code>varname='z</code>.
</p>
<p>Отметим, что при работе с многочленами высокого порядка, вычисления с плавающей точкой
нестабильны.
</p>
<p>Примеры:
</p>
<div class="example">
<pre class="example">(%i1) load("interpol")$
(%i2) p:[[7,2],[8,2],[1,5],[3,2],[6,7]]$
(%i3) lagrange(p);
4 3 2
73 x 701 x 8957 x 5288 x 186
(%o3) ----- - ------ + ------- - ------ + ---
420 210 420 105 5
(%i4) f(x):=''%;
4 3 2
73 x 701 x 8957 x 5288 x 186
(%o4) f(x) := ----- - ------ + ------- - ------ + ---
420 210 420 105 5
(%i5) /* Evaluate the polynomial at some points */
map(f,[2.3,5/7,%pi]);
919062
(%o5) [- 1.567534999999992, ------,
84035
4 3 2
73 %pi 701 %pi 8957 %pi 5288 %pi 186
------- - -------- + --------- - -------- + ---]
420 210 420 105 5
(%i6) %,numer;
(%o6) [- 1.567534999999992, 10.9366573451538, 2.89319655125692]
(%i7) load("draw")$ /* load draw package */
(%i8) /* Plot the polynomial together with points */
draw2d(
color = red,
key = "Lagrange polynomial",
explicit(f(x),x,0,10),
point_size = 3,
color = blue,
key = "Sample points",
points(p))$
(%i9) /* Change variable name */
lagrange(p, varname=w);
4 3 2
73 w 701 w 8957 w 5288 w 186
(%o9) ----- - ------ + ------- - ------ + ---
420 210 420 105 5
</pre></div>
</dd></dl>
<a name="Item_003a-interpol_002fdeffn_002fcharfun2"></a><dl>
<dt><a name="index-charfun2"></a>Функция: <strong>charfun2</strong> <em>(<var>x</var>, <var>a</var>, <var>b</var>)</em></dt>
<dd><p>Возвращает <code>true</code> если число <var>x</var> принадлежит интервалу <em>[a, b)</em>, и <code>false</code> в противном случае.
</p>
</dd></dl>
<a name="Item_003a-interpol_002fdeffn_002flinearinterpol"></a><dl>
<dt><a name="index-linearinterpol"></a>Функция: <strong>linearinterpol</strong> <em>(<var>points</var>)</em></dt>
<dt><a name="index-linearinterpol-1"></a>Функция: <strong>linearinterpol</strong> <em>(<var>points</var>, <var>option</var>)</em></dt>
<dd><p>Вычисляет полиномиальную интерполяцию линейным методом. Аргумент <var>points</var> должен быть либо:
</p>
<ul>
<li> матрицей из двух колонок, <code>p:matrix([2,4],[5,6],[9,3])</code>,
</li><li> списком пар, <code>p: [[2,4],[5,6],[9,3]]</code>,
</li><li> списком чисел <code>p: [4,6,3]</code>, в этом случае абсцисса будет назначена автоматически равной 1, 2, 3 и т.д.
</li></ul>
<p>В первых двух случаях, перед проведением вычислений, пары упорядочиваются в соответствии
со значением первой координаты.
</p>
<p>Аргумент <var>option</var> позволяет выбрать имя независимой переменной, по умолчанию равной <code>'x</code>.
Чтобы задать другую переменную напишите <code>varname='z</code>.
</p>
<p>Примеры:
</p><div class="example">
<pre class="example">(%i1) load("interpol")$
(%i2) p: matrix([7,2],[8,3],[1,5],[3,2],[6,7])$
(%i3) linearinterpol(p);
13 3 x
(%o3) (-- - ---) charfun2(x, minf, 3)
2 2
+ (x - 5) charfun2(x, 7, inf) + (37 - 5 x) charfun2(x, 6, 7)
5 x
+ (--- - 3) charfun2(x, 3, 6)
3
(%i4) f(x):=''%;
13 3 x
(%o4) f(x) := (-- - ---) charfun2(x, minf, 3)
2 2
+ (x - 5) charfun2(x, 7, inf) + (37 - 5 x) charfun2(x, 6, 7)
5 x
+ (--- - 3) charfun2(x, 3, 6)
3
(%i5) /* Evaluate the polynomial at some points */
map(f,[7.3,25/7,%pi]);
62 5 %pi
(%o5) [2.3, --, ----- - 3]
21 3
(%i6) %,numer;
(%o6) [2.3, 2.952380952380953, 2.235987755982989]
(%i7) load("draw")$ /* load draw package */
(%i8) /* Plot the polynomial together with points */
draw2d(
color = red,
key = "Linear interpolator",
explicit(f(x),x,-5,20),
point_size = 3,
color = blue,
key = "Sample points",
points(args(p)))$
(%i9) /* Change variable name */
linearinterpol(p, varname='s);
13 3 s
(%o9) (-- - ---) charfun2(s, minf, 3)
2 2
+ (s - 5) charfun2(s, 7, inf) + (37 - 5 s) charfun2(s, 6, 7)
5 s
+ (--- - 3) charfun2(s, 3, 6)
3
</pre></div>
</dd></dl>
<a name="Item_003a-interpol_002fdeffn_002fcspline"></a><dl>
<dt><a name="index-cspline"></a>Функция: <strong>cspline</strong> <em>(<var>points</var>)</em></dt>
<dt><a name="index-cspline-1"></a>Функция: <strong>cspline</strong> <em>(<var>points</var>, <var>option1</var>, <var>option2</var>, ...)</em></dt>
<dd><p>Вычисляет полиномиальную интерполяцию методом кубических сплайнов. Аргумент <var>points</var> должен быть либо:
</p>
<ul>
<li> матрицей из двух колонок, <code>p:matrix([2,4],[5,6],[9,3])</code>,
</li><li> списком пар, <code>p: [[2,4],[5,6],[9,3]]</code>,
</li><li> списком чисел <code>p: [4,6,3]</code>, в этом случае абсцисса будет назначена автоматически равной 1, 2, 3 и т.д.
</li></ul>
<p>В первых двух случаях, перед проведением вычислений, пары упорядочиваются в соответствии
со значением первой координаты.
</p>
<p>Существует три специальные опции:
</p><ul>
<li> <code>'d1</code>, по умолчанию <code>'unknown</code>, – первая производная в точке <em>x_1</em>. Если <code>'unknown</code>,
то вторая производная в точке <em>x_1</em> предполагается равной 0 (натуральный кубический сплайн).
Если задана, то вторая производная вычисляется исходя из этого числа.
</li><li> <code>'dn</code>, по умолчанию <code>'unknown</code>, – первая производная в точке <em>x_n</em>. Если <code>'unknown</code>,
то вторая производная в точке <em>x_n</em> предполагается равной 0 (натуральный кубический сплайн).
Если задана, то вторая производная вычисляется исходя из этого числа.
</li><li> <code>'varname</code>, по умолчанию <code>'x</code>, – имя независимой переменной.
</li></ul>
<p>Примеры:
</p><div class="example">
<pre class="example">(%i1) load("interpol")$
(%i2) p:[[7,2],[8,2],[1,5],[3,2],[6,7]]$
(%i3) /* Unknown first derivatives at the extremes
is equivalent to natural cubic splines */
cspline(p);
3 2
1159 x 1159 x 6091 x 8283
(%o3) (------- - ------- - ------ + ----) charfun2(x, minf, 3)
3288 1096 3288 1096
3 2
2587 x 5174 x 494117 x 108928
+ (- ------- + ------- - -------- + ------) charfun2(x, 7, inf)
1644 137 1644 137
3 2
4715 x 15209 x 579277 x 199575
+ (------- - -------- + -------- - ------) charfun2(x, 6, 7)
1644 274 1644 274
3 2
3287 x 2223 x 48275 x 9609
+ (- ------- + ------- - ------- + ----) charfun2(x, 3, 6)
4932 274 1644 274
(%i4) f(x):=''%$
(%i5) /* Some evaluations */
map(f,[2.3,5/7,%pi]), numer;
(%o5) [1.991460766423356, 5.823200187269903, 2.227405312429507]
(%i6) load("draw")$ /* load draw package */
(%i7) /* Plotting interpolating function */
draw2d(
color = red,
key = "Cubic splines",
explicit(f(x),x,0,10),
point_size = 3,
color = blue,
key = "Sample points",
points(p))$
(%i8) /* New call, but giving values at the derivatives */
cspline(p,d1=0,dn=0);
3 2
1949 x 11437 x 17027 x 1247
(%o8) (------- - -------- + ------- + ----) charfun2(x, minf, 3)
2256 2256 2256 752
3 2
1547 x 35581 x 68068 x 173546
+ (- ------- + -------- - ------- + ------) charfun2(x, 7, inf)
564 564 141 141
3 2
607 x 35147 x 55706 x 38420
+ (------ - -------- + ------- - -----) charfun2(x, 6, 7)
188 564 141 47
3 2
3895 x 1807 x 5146 x 2148
+ (- ------- + ------- - ------ + ----) charfun2(x, 3, 6)
5076 188 141 47
(%i8) /* Defining new interpolating function */
g(x):=''%$
(%i9) /* Plotting both functions together */
draw2d(
color = black,
key = "Cubic splines (default)",
explicit(f(x),x,0,10),
color = red,
key = "Cubic splines (d1=0,dn=0)",
explicit(g(x),x,0,10),
point_size = 3,
color = blue,
key = "Sample points",
points(p))$
</pre></div>
</dd></dl>
<hr>
<div class="header">
<p>
Previous: <a href="maxima_199.html#g_t_0412_0432_0435_0434_0435_043d_0438_0435-_0432-_043f_0430_043a_0435_0442-interpol" accesskey="p" rel="previous">Введение в пакет interpol</a>, Up: <a href="maxima_198.html#g_t_041f_0430_043a_0435_0442-interpol" accesskey="u" rel="up">Пакет interpol</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_264.html#g_t_0423_043a_0430_0437_0430_0442_0435_043b_044c-_0444_0443_043d_043a_0446_0438_0439-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0445" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|