summaryrefslogtreecommitdiff
path: root/modules/interpolation/help/pt_BR/interp.xml
blob: e2caba8d644563fc4c5cb048915c2089b61a87a6 (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
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
<?xml version="1.0" encoding="ISO-8859-1"?>
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="interp" xml:lang="en">
    <refnamediv>
        <refname>interp</refname>
        <refpurpose>função de avaliação de spline cúbico</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Seqüência de Chamamento</title>
        <synopsis>[yp [,yp1 [,yp2 [,yp3]]]]=interp(xp, x, y, d [, out_mode])</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Parâmetros</title>
        <variablelist>
            <varlistentry>
                <term>xp</term>
                <listitem>
                    <para>vetor ou matriz de reais</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>x,y,d</term>
                <listitem>
                    <para>vetores de reais de mesmo tamanho definindo uma função de
                        spline cúbico ou sub-spline (chamado <literal>s</literal> a partir
                        daqui) 
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>out_mode</term>
                <listitem>
                    <para>
                        (opcional) string definido a avaliação de <literal>s</literal>
                        fora do intervalo [x1,xn]
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>yp</term>
                <listitem>
                    <para>
                        vetor ou matriz de mesmo tamanho que <literal>xp</literal>,
                        avaliação elemento a elemento de <literal>s</literal> em
                        <literal>xp</literal> (yp(i)=s(xp(i) ou yp(i,j)=s(xp(i,j))
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>yp1, yp2, yp3</term>
                <listitem>
                    <para>vetores (ou matrizes) de mesmo tamanho que
                        <literal>xp</literal>, avaliação elemento a elemento das derivadas
                        sucessivas de <literal>s</literal> em <literal>xp</literal>
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Descrição</title>
        <para>
            Dados três vetores <literal>(x,y,d)</literal> ddefinindo uma função
            de spline cúbico ou sup-spline (ver <link linkend="splin">splin</link>)
            com <literal>yi=s(xi), di = s'(xi)</literal> esta função avalia
            <literal>s</literal> (e <literal>s', s'', s'''</literal> se necessário) em
            <literal>xp(i)</literal> :
        </para>
        <programlisting role=""><![CDATA[ 
yp(i) = s(xp(i))    ou  yp(i,j) = s(xp(i,j))
yp1(i) = s'(xp(i))   ou  yp1(i,j) = s'(xp(i,j))
yp2(i) = s''(xp(i))   ou  yp2(i,j) = s''(xp(i,j))
yp3(i) = s'''(xp(i))   ou  yp3(i,j) = s'''(xp(i,j))
 ]]></programlisting>
        <para>
            O parâmetro <literal>out_mode</literal> ajusta a regra de avaliação
            para extrapolação, i.e., para <literal>xp(i)</literal> fora de [x1,xn] :
        </para>
        <variablelist>
            <varlistentry>
                <term>"by_zero"</term>
                <listitem>
                    <para>uma extrapolação por zero é feita </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"by_nan"</term>
                <listitem>
                    <para>extrapolação por NaN </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"C0"</term>
                <listitem>
                    <para>a extrapolação é definida como segue :</para>
                    <programlisting role=""><![CDATA[ 
s(x) = y1  para  x < x1
s(x) = yn  para  x > xn
 ]]></programlisting>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"natural"</term>
                <listitem>
                    <para>a extrapolação é definida como segue (p_i sendo o polinômio
                        que define <literal>s</literal> em [x_i,x_{i+1}]) :
                    </para>
                    <programlisting role=""><![CDATA[ 
s(x) = p_1(x)      para  x < x1
s(x) = p_{n-1}(x)  para  x > xn
 ]]></programlisting>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"linear"</term>
                <listitem>
                    <para>a extrapolação é definida como segue :</para>
                    <programlisting role=""><![CDATA[ 
s(x) = y1 + s'(x1)(x-x1)  para  x < x1
s(x) = yn + s'(xn)(x-xn)  para  x > xn
 ]]></programlisting>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"periodic"</term>
                <listitem>
                    <para>
                        <literal>s</literal> é estendido por periodicidade. 
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Exemplos </title>
        <programlisting role="example"><![CDATA[ 
// veja os exemplos de splin e lsq_splin

// um exemplo exibindo as continuidades C2 e C1 de um spline e um sub-spline
a = -8; b = 8;
x = linspace(a,b,20)';
y = sinc(x);
dk = splin(x,y);  // not_a_knot
df = splin(x,y, "fast");
xx = linspace(a,b,800)';
[yyk, yy1k, yy2k] = interp(xx, x, y, dk); 
[yyf, yy1f, yy2f] = interp(xx, x, y, df); 
clf()
subplot(3,1,1)
plot2d(xx, [yyk yyf])
plot2d(x, y, style=-9)
legends(["spline não é um nó","sub-spline rápido","pontos de interpolação"],...
        [1 2 -9], "ur",%f)
xtitle("interpolação por spline")
subplot(3,1,2)
plot2d(xx, [yy1k yy1f])
legends(["spline não é um nó","sub-spline rápido"], [1 2], "ur",%f)
xtitle("interpolação por spline (derivadas)")
subplot(3,1,3)
plot2d(xx, [yy2k yy2f])
legends(["spline não é um nó","sub-spline rápido"], [1 2], "lr",%f)
xtitle("interpolação por splines (segundas derivadas)")

// aqui está um exemplo mostrando as diferentes possibilidades de extrapolação
x = linspace(0,1,11)';
y = cosh(x-0.5);
d = splin(x,y);
xx = linspace(-0.5,1.5,401)';
yy0 = interp(xx,x,y,d,"C0");
yy1 = interp(xx,x,y,d,"linear");
yy2 = interp(xx,x,y,d,"natural");
yy3 = interp(xx,x,y,d,"periodic");  
clf()
plot2d(xx,[yy0 yy1 yy2 yy3],style=2:5,frameflag=2,leg="C0@linear@natural@periodic")
xtitle(" Modos diferentes de avaliar um spline fora de seu domínio")
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>Ver Também</title>
        <simplelist type="inline">
            <member>
                <link linkend="splin">splin</link>
            </member>
            <member>
                <link linkend="lsq_splin">lsq_splin</link>
            </member>
        </simplelist>
    </refsection>
</refentry>