<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE MAN SYSTEM "../../manrev.dtd">
<MAN>
  <LANGUAGE>eng</LANGUAGE>
  <TITLE>diff</TITLE>
  <TYPE>Scilab Function</TYPE>
  <DATE>April 1993</DATE>
  <SHORT_DESCRIPTION name="diff"> Difference and discrete derivative</SHORT_DESCRIPTION>
  <CALLING_SEQUENCE>
    <CALLING_SEQUENCE_ITEM>y=diff(x)  </CALLING_SEQUENCE_ITEM>
    <CALLING_SEQUENCE_ITEM>y=diff(x [,n [,dim]])  </CALLING_SEQUENCE_ITEM>
  </CALLING_SEQUENCE>
  <PARAM>
    <PARAM_INDENT>
      <PARAM_ITEM>
        <PARAM_NAME>x</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: vector or matrix (real, complex, sparse or polynomial)</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>n</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: integer the order of differentiation</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>dim</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: integer or character string with values &quot;r&quot;,&quot;c&quot; and &quot;*&quot;</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
      <PARAM_ITEM>
        <PARAM_NAME>y</PARAM_NAME>
        <PARAM_DESCRIPTION>
          <SP>: scalar or vector</SP>
        </PARAM_DESCRIPTION>
      </PARAM_ITEM>
    </PARAM_INDENT>
  </PARAM>
  <DESCRIPTION>
    <P><VERB>y=diff(x)</VERB>  compute the difference function y=x(2:$)-x(1:$-1)</P>
    <P><VERB>diff(x,n,dim)</VERB> is the <VERB>n</VERB> th difference function along
    dimension <VERB>dim</VERB>.</P>
    <P><VERB>diff(x,n,&quot;*&quot;)</VERB> is equivalent to diff(x(:),n).</P>
    <P>
    Default value for <VERB>n</VERB> is 1.  Default value for
    <VERB>dim</VERB> is <VERB>&quot;*&quot;</VERB>.</P>
    <P><VERB>dim='r'</VERB> is equivalent to <VERB>dim=1</VERB> and <VERB>dim='c'</VERB> is
    equivalent to <VERB>dim=2</VERB>.</P>
  </DESCRIPTION>
  <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)

//approximate differentiation
step=0.001
t=0:step:10;
y=sin(t);
dy=diff(sin(t))/step; //approximate differentiation of sine function
norm(dy-cos(t(1:$-1)),%inf)
 ]]>
  </EXAMPLE>
</MAN>
