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
|
<?xml version="1.0" encoding="UTF-8"?>
<refentry version="5.0-subset Scilab" xml:id="splin" xml:lang="en"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ns5="http://www.w3.org/1999/xhtml"
xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:db="http://docbook.org/ns/docbook">
<info>
<pubdate>$LastChangedDate$</pubdate>
</info>
<refnamediv>
<refname>splin</refname>
<refpurpose>cubic spline interpolation</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Calling Sequence</title>
<synopsis>d = splin(x, y [,spline_type [, der]])</synopsis>
</refsynopsisdiv>
<refsection>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>x</term>
<listitem>
<para>a strictly increasing (row or column) vector (x must have at
least 2 components)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>y</term>
<listitem>
<para>a vector of same format than <literal>x</literal></para>
</listitem>
</varlistentry>
<varlistentry>
<term>spline_type</term>
<listitem>
<para>(optional) a string selecting the kind of spline to
compute</para>
</listitem>
</varlistentry>
<varlistentry>
<term>der</term>
<listitem>
<para>(optional) a vector with 2 components, with the end points
derivatives (to provide when spline_type="clamped")</para>
</listitem>
</varlistentry>
<varlistentry>
<term>d</term>
<listitem>
<para>vector of the same format than <literal>x</literal>
(<literal>di</literal> is the derivative of the spline at
<literal>xi</literal>)</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Description</title>
<para>This function computes a cubic spline or sub-spline
<emphasis>s</emphasis> which interpolates the <emphasis>(xi,yi)</emphasis>
points, ie, we have <emphasis>s(xi)=yi</emphasis> for all
<emphasis>i=1,..,n</emphasis>. The resulting spline <emphasis>s</emphasis>
is completly defined by the triplet <literal>(x,y,d)</literal> where
<literal>d</literal> is the vector with the derivatives at the
<literal>xi</literal>: <emphasis>s'(xi)=di</emphasis> (this is called the
<emphasis>Hermite</emphasis> form). The evaluation of the spline at some
points must be done by the <link linkend="interp">interp</link> function.
Several kind of splines may be computed by selecting the appropriate
<literal>spline_type</literal> parameter:</para>
<variablelist>
<varlistentry>
<term>"not_a_knot"</term>
<listitem>
<para>this is the default case, the cubic spline is computed by
using the following conditions (considering n points
x1,...,xn):</para>
<informalequation>
<mediaobject>
<imageobject>
<imagedata align="center" fileref="../mml/splin_equation1.mml" />
</imageobject>
</mediaobject>
</informalequation>
</listitem>
</varlistentry>
<varlistentry>
<term>"clamped"</term>
<listitem>
<para>in this case the cubic spline is computed by using the end
points derivatives which must be provided as the last argument
<literal>der</literal>:</para>
<informalequation>
<mediaobject>
<imageobject>
<imagedata align="center" fileref="../mml/splin_equation2.mml" />
</imageobject>
</mediaobject>
</informalequation>
</listitem>
</varlistentry>
<varlistentry>
<term>"natural"</term>
<listitem>
<para>the cubic spline is computed by using the conditions:</para>
<informalequation>
<mediaobject>
<imageobject>
<imagedata align="center" fileref="../mml/splin_equation3.mml" />
</imageobject>
</mediaobject>
</informalequation>
</listitem>
</varlistentry>
<varlistentry>
<term>"periodic"</term>
<listitem>
<para>a periodic cubic spline is computed (<literal>y</literal> must
verify <emphasis>y1=yn</emphasis>) by using the conditions:</para>
<informalequation>
<mediaobject>
<imageobject>
<imagedata align="center" fileref="../mml/splin_equation4.mml" />
</imageobject>
</mediaobject>
</informalequation>
</listitem>
</varlistentry>
<varlistentry>
<term>"monotone"</term>
<listitem>
<para>in this case a sub-spline (<emphasis>s</emphasis> is only one
continuously differentiable) is computed by using a local scheme for
the <emphasis>di</emphasis> such that <emphasis>s</emphasis> is
monotone on each interval:</para>
<informalequation>
<mediaobject>
<imageobject>
<imagedata align="center" fileref="../mml/splin_equation5.mml" />
</imageobject>
</mediaobject>
</informalequation>
</listitem>
</varlistentry>
<varlistentry>
<term>"fast"</term>
<listitem>
<para>in this case a sub-spline is also computed by using a simple
local scheme for the <emphasis>di</emphasis> : d(i) is the
derivative at x(i) of the interpolation polynomial of
(x(i-1),y(i-1)), (x(i),y(i)),(x(i+1),y(i+1)), except for the end
points (d1 being computed from the 3 left most points and dn from
the 3 right most points).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>"fast_periodic"</term>
<listitem>
<para>same as before but use also a centered formula for
<emphasis>d1 = s'(x1) = dn = s'(xn)</emphasis> by using the
periodicity of the underlying function (<literal>y</literal> must
verify <emphasis>y1=yn</emphasis>).</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Remarks</title>
<para>From an accuracy point of view use essentially the <emphasis
role="bold">clamped</emphasis> type if you know the end point derivatives,
else use <emphasis role="bold">not_a_knot</emphasis>. But if the
underlying approximated function is periodic use the <emphasis
role="bold">periodic</emphasis> type. Under the good assumptions these
kind of splines got an <literal>O(h^4)</literal> asymptotic behavior of
the error. Don't use the <emphasis role="bold">natural</emphasis> type
unless the underlying function have zero second end points
derivatives.</para>
<para>The <emphasis role="bold">monotone</emphasis>, <emphasis
role="bold">fast</emphasis> (or <emphasis
role="bold">fast_periodic</emphasis>) type may be useful in some cases,
for instance to limit oscillations (these kind of sub-splines have an
<literal>O(h^3)</literal> asymptotic behavior of the error).</para>
<para>If <emphasis>n=2</emphasis> (and <literal>spline_type</literal> is
not <emphasis role="bold">clamped</emphasis>) linear interpolation is
used. If <emphasis>n=3</emphasis> and <literal>spline_type</literal> is
<emphasis role="bold">not_a_knot</emphasis>, then a <emphasis
role="bold">fast</emphasis> sub-spline type is in fact computed.</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
// example 1
deff("y=runge(x)","y=1 ./(1 + x.^2)")
a = -5; b = 5; n = 11; m = 400;
x = linspace(a, b, n)';
y = runge(x);
d = splin(x, y);
xx = linspace(a, b, m)';
yyi = interp(xx, x, y, d);
yye = runge(xx);
clf()
plot2d(xx, [yyi yye], style=[2 5], leg="interpolation spline@exact function")
plot2d(x, y, -9)
xtitle("interpolation of the Runge function")
// example 2 : show behavior of different splines on random datas
a = 0; b = 1; // interval of interpolation
n = 10; // nb of interpolation points
m = 800; // discretisation for evaluation
x = linspace(a,b,n)'; // abscissae of interpolation points
y = rand(x); // ordinates of interpolation points
xx = linspace(a,b,m)';
yk = interp(xx, x, y, splin(x,y,"not_a_knot"));
yf = interp(xx, x, y, splin(x,y,"fast"));
ym = interp(xx, x, y, splin(x,y,"monotone"));
clf()
plot2d(xx, [yf ym yk], style=[5 2 3], strf="121", ...
leg="fast@monotone@not a knot spline")
plot2d(x,y,-9, strf="000") // to show interpolation points
xtitle("Various spline and sub-splines on random datas")
xselect()
]]></programlisting>
</refsection>
<refsection>
<title>See Also</title>
<simplelist type="inline">
<member><link linkend="interp">interp</link></member>
<member><link linkend="lsq_splin">lsq_splin</link></member>
</simplelist>
</refsection>
<refsection>
<title>Authors</title>
<simplelist type="vert">
<member>B. Pincon</member>
<member>F. N. Fritsch (pchim.f Slatec routine is used for monotone
interpolation)</member>
</simplelist>
</refsection>
</refentry>
|