<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<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="diff" xml:lang="pt">
    <refnamediv>
        <refname>diff</refname>
        <refpurpose>diferença e derivada discreta</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Seqüência de Chamamento</title>
        <synopsis>
            y = diff(x)
            y = diff(x, n)
            y = diff(x, n, dim)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Parâmetros</title>
        <variablelist>
            <varlistentry>
                <term>x</term>
                <listitem>
                    <para>vetor ou matriz (de reais, complexos, esparso(a) ou de
                        polinômios)
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>n</term>
                <listitem>
                    <para>inteiro, ordem da diferenciação</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>dim</term>
                <listitem>
                    <para>inteiro ou cadeia de caracteres com valores "r","c" e "*"
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>y</term>
                <listitem>
                    <para>escalar ou vetor </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Descrição</title>
        <para>
            <literal>y=diff(x)</literal> computa a função de diferença
            y=x(2:$)-x(1:$-1)
        </para>
        <para>
            <literal>diff(x,n,dim)</literal> é a n-ésima função de diferença ao
            longo da dimensão <literal>dim</literal>.
        </para>
        <para>
            <literal>diff(x,n,"*")</literal> é equivalente a
            diff(x(:),n).
        </para>
        <para>
            O valor padrão para <literal>n</literal> é 1. O valor padrão para
            <literal>dim</literal> é <literal>"*"</literal>.
        </para>
        <para>
            <literal>dim='r'</literal> é equivalente a <literal>dim=1</literal>
            e <literal>dim='c'</literal> é equivalente a
            <literal>dim=2</literal>.
        </para>
    </refsection>
    <refsection>
        <title>Exemplos</title>
        <programlisting role="example"><![CDATA[
v = (1:8)^3;
diff(v)
diff(v,3)

A=[(1:8)^2
   (1:8)^3
   (1:8)^4];

diff(A,3,2)

//diferenciação aproximada
step = 0.001
t = 0:step:10;
y = sin(t);
dy = diff(sin(t)) / step; //diferenciação aproximada da função seno
norm(dy-cos(t(1:$-1)), %inf)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>Ver Também</title>
        <simplelist type="inline">
            <member>
                <link linkend="numderivative">numderivative</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
