home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / doc / octave.i07 (.txt) < prev    next >
GNU Info File  |  2000-01-15  |  51KB  |  1,115 lines

  1. This is Info file octave, produced by Makeinfo-1.64 from the input file
  2. octave.tex.
  3. START-INFO-DIR-ENTRY
  4. * Octave: (octave).    Interactive language for numerical computations.
  5. END-INFO-DIR-ENTRY
  6.    Copyright (C) 1996, 1997 John W. Eaton.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions.
  17. File: octave,  Node: Rearranging Matrices,  Next: Special Utility Matrices,  Prev: Finding Elements and Checking Conditions,  Up: Matrix Manipulation
  18. Rearranging Matrices
  19. ====================
  20.  - Function File:  fliplr (X)
  21.      Return a copy of X with the order of the columns reversed.  For
  22.      example,
  23.            fliplr ([1, 2; 3, 4])
  24.           =>  2  1
  25.                     4  3
  26.  - Function File:  flipud (X)
  27.      Return a copy of X with the order of the rows reversed.  For
  28.      example,
  29.            flipud ([1, 2; 3, 4])
  30.           =>  3  4
  31.                     1  2
  32.  - Function File:  rot90 (X, N)
  33.      Return a copy of X with the elements rotated counterclockwise in
  34.      90-degree increments.  The second argument is optional, and
  35.      specifies  how many 90-degree rotations are to be applied (the
  36.      default value is 1).   Negative values of N rotate the matrix in a
  37.      clockwise direction.   For example,
  38.            rot90 ([1, 2; 3, 4], -1)
  39.           =>  3  1
  40.                     4  2
  41.      rotates the given matrix clockwise by 90 degrees.  The following
  42.      are all  equivalent statements:
  43.            rot90 ([1, 2; 3, 4], -1)
  44.           ==
  45.            rot90 ([1, 2; 3, 4], 3)
  46.           ==
  47.            rot90 ([1, 2; 3, 4], 7)
  48.  - Function File:  reshape (A, M, N)
  49.      Return a matrix with M rows and N columns whose elements are
  50.      taken from the matrix A.  To decide how to order the elements,
  51.      Octave pretends that the elements of a matrix are stored in
  52.      column-major  order (like Fortran arrays are stored).
  53.      For example,
  54.            reshape ([1, 2, 3, 4], 2, 2)
  55.           =>  1  3
  56.                     2  4
  57.      If the variable `do_fortran_indexing' is nonzero, the `reshape'
  58.      function is equivalent to
  59.            retval = zeros (m, n);
  60.            retval (:) = a;
  61.      but it is somewhat less cryptic to use `reshape' instead of the
  62.      colon operator.  Note that the total number of elements in the
  63.      original  matrix must match the total number of elements in the
  64.      new matrix.
  65.  - Function File:  shift (X, B)
  66.      If X is a vector, perform a circular shift of length B of  the
  67.      elements of X.
  68.      If X is a matrix, do the same for each column of X.
  69.  - Loadable Function: [S, I] = sort (X)
  70.      Return a copy of X with the elements elements arranged in
  71.      increasing order.  For matrices, `sort' orders the elements in each
  72.      column.
  73.      For example,
  74.           sort ([1, 2; 2, 3; 3, 1])
  75.                =>  1  1
  76.                    2  2
  77.                    3  3
  78.      The `sort' function may also be used to produce a matrix
  79.      containing the original row indices of the elements in the sorted
  80.      matrix.  For example,
  81.           [s, i] = sort ([1, 2; 2, 3; 3, 1])
  82.                => s = 1  1
  83.                       2  2
  84.                       3  3
  85.                => i = 1  3
  86.                       2  1
  87.                       3  2
  88.    Since the `sort' function does not allow sort keys to be specified,
  89. it can't be used to order the rows of a matrix according to the values
  90. of the elements in various columns(1) in a single call.  Using the
  91. second output, however, it is possible to sort all rows based on the
  92. values in a given column.  Here's an example that sorts the rows of a
  93. matrix based on the values in the second column.
  94.      a = [1, 2; 2, 3; 3, 1];
  95.      [s, i] = sort (a (:, 2));
  96.      a (i, :)
  97.           =>  3  1
  98.               1  2
  99.               2  3
  100.  - Function File:  tril (A, K)
  101.  - Function File:  triu (A, K)
  102.      Return a new matrix formed by extracting extract the lower (`tril')
  103.      or upper (`triu') triangular part of the matrix A, and  setting
  104.      all other elements to zero.  The second argument is optional,  and
  105.      specifies how many diagonals above or below the main diagonal
  106.      should  also be set to zero.
  107.      The default value of K is zero, so that `triu' and `tril' normally
  108.      include the main diagonal as part of the result  matrix.
  109.      If the value of K is negative, additional elements above (for
  110.      `tril') or below (for `triu') the main diagonal are also  selected.
  111.      The absolute value of K must not be greater than the number of
  112.      sub- or super-diagonals.
  113.      For example,
  114.            tril (ones (3), -1)
  115.           =>  0  0  0
  116.                     1  0  0
  117.                     1  1  0
  118.      and
  119.            tril (ones (3), 1)
  120.           =>  1  1  0
  121.                     1  1  1
  122.                     1  1  1
  123.  - Function File:  vec (X)
  124.      Return the vector obtained by stacking the columns of the matrix X
  125.      one above the other.
  126.  - Function File:  vech (X)
  127.      Return the vector obtained by eliminating all supradiagonal
  128.      elements of  the square matrix X and stacking the result one
  129.      column above the  other.
  130.    ---------- Footnotes ----------
  131.    (1)  For example, to first sort based on the values in column 1, and
  132. then, for any values that are repeated in column 1, sort based on the
  133. values found in column 2, etc.
  134. File: octave,  Node: Special Utility Matrices,  Next: Famous Matrices,  Prev: Rearranging Matrices,  Up: Matrix Manipulation
  135. Special Utility Matrices
  136. ========================
  137.  - Built-in Function:  eye (X)
  138.  - Built-in Function:  eye (N, M)
  139.      Return an identity matrix.  If invoked with a single scalar
  140.      argument, `eye' returns a square matrix with the dimension
  141.      specified.  If you supply two scalar arguments, `eye' takes them
  142.      to be the number of rows and columns.  If given a vector with two
  143.      elements, `eye' uses the values of the elements as the number of
  144.      rows and columns, respectively.  For example,
  145.           eye (3)
  146.                =>  1  0  0
  147.                    0  1  0
  148.                    0  0  1
  149.      The following expressions all produce the same result:
  150.           eye (2)
  151.           ==
  152.           eye (2, 2)
  153.           ==
  154.           eye (size ([1, 2; 3, 4])
  155.      For compatibility with MATLAB, calling `eye' with no arguments is
  156.      equivalent to calling it with an argument of 1.
  157.  - Built-in Function:  ones (X)
  158.  - Built-in Function:  ones (N, M)
  159.      Return a matrix whose elements are all 1.  The arguments are
  160.      handled the same as the arguments for `eye'.
  161.      If you need to create a matrix whose values are all the same, you
  162.      should use an expression like
  163.           val_matrix = val * ones (n, m)
  164.  - Built-in Function:  zeros (X)
  165.  - Built-in Function:  zeros (N, M)
  166.      Return a matrix whose elements are all 0.  The arguments are
  167.      handled the same as the arguments for `eye'.
  168.  - Loadable Function:  rand (X)
  169.  - Loadable Function:  rand (N, M)
  170.  - Loadable Function:  rand (`"seed"', X)
  171.      Return a matrix with random elements uniformly distributed on the
  172.      interval (0, 1).  The arguments are handled the same as the
  173.      arguments for `eye'.  In addition, you can set the seed for the
  174.      random number generator using the form
  175.           rand ("seed", X)
  176.      where X is a scalar value.  If called as
  177.           rand ("seed")
  178.      `rand' returns the current value of the seed.
  179.  - Loadable Function:  randn (X)
  180.  - Loadable Function:  randn (N, M)
  181.  - Loadable Function:  randn (`"seed"', X)
  182.      Return a matrix with normally distributed random elements.  The
  183.      arguments are handled the same as the arguments for `eye'.  In
  184.      addition, you can set the seed for the random number generator
  185.      using the form
  186.           randn ("seed", X)
  187.      where X is a scalar value.  If called as
  188.           randn ("seed")
  189.      `randn' returns the current value of the seed.
  190.    The `rand' and `randn' functions use separate generators.  This
  191. ensures that
  192.      rand ("seed", 13);
  193.      randn ("seed", 13);
  194.      u = rand (100, 1);
  195.      n = randn (100, 1);
  196.      rand ("seed", 13);
  197.      randn ("seed", 13);
  198.      u = zeros (100, 1);
  199.      n = zeros (100, 1);
  200.      for i = 1:100
  201.        u(i) = rand ();
  202.        n(i) = randn ();
  203.      end
  204. produce equivalent results.
  205.    Normally, `rand' and `randn' obtain their initial seeds from the
  206. system clock, so that the sequence of random numbers is not the same
  207. each time you run Octave.  If you really do need for to reproduce a
  208. sequence of numbers exactly, you can set the seed to a specific value.
  209.    If it is invoked without arguments, `rand' and `randn' return a
  210. single element of a random sequence.
  211.    The `rand' and `randn' functions use Fortran code from RANLIB, a
  212. library of fortran routines for random number generation, compiled by
  213. Barry W. Brown and James Lovato of the Department of Biomathematics at
  214. The University of Texas, M.D. Anderson Cancer Center, Houston, TX 77030.
  215.  - Built-in Function:  diag (V, K)
  216.      Return a diagonal matrix with vector V on diagonal K.  The second
  217.      argument is optional.  If it is positive, the vector is placed on
  218.      the K-th super-diagonal.  If it is negative, it is placed on the
  219.      -K-th sub-diagonal.  The default value of K is 0, and the vector
  220.      is placed on the main diagonal.  For example,
  221.           diag ([1, 2, 3], 1)
  222.                =>  0  1  0  0
  223.                    0  0  2  0
  224.                    0  0  0  3
  225.                    0  0  0  0
  226.    The functions `linspace' and `logspace' make it very easy to create
  227. vectors with evenly or logarithmically spaced elements.  *Note Ranges::.
  228.  - Built-in Function:  linspace (BASE, LIMIT, N)
  229.      Return a row vector with N linearly spaced elements between BASE
  230.      and LIMIT.  The number of elements, N, must be greater than 1.
  231.      The BASE and LIMIT are always included in the range.  If BASE is
  232.      greater than LIMIT, the elements are stored in decreasing order.
  233.      If the number of points is not specified, a value of 100 is used.
  234.      The `linspace' function always returns a row vector, regardless of
  235.      the value of `prefer_column_vectors'.
  236.  - Function File:  logspace (BASE, LIMIT, N)
  237.      Similar to `linspace' except that the values are logarithmically
  238.      spaced from  10^base to 10^limit.
  239.      If LIMIT is equal to  pi,  the points are between  10^base and pi,
  240.      *not*  10^base and 10^pi,  in order to  be compatible with the
  241.      corresponding MATLAB function.
  242.  - Built-in Variable: treat_neg_dim_as_zero
  243.      If the value of `treat_neg_dim_as_zero' is nonzero, expressions
  244.      like
  245.           eye (-1)
  246.      produce an empty matrix (i.e., row and column dimensions are zero).
  247.      Otherwise, an error message is printed and control is returned to
  248.      the top level.  The default value is 0.
  249. File: octave,  Node: Famous Matrices,  Prev: Special Utility Matrices,  Up: Matrix Manipulation
  250. Famous Matrices
  251. ===============
  252.    The following functions return famous matrix forms.
  253.  - Function File:  hankel (C, R)
  254.      Return the Hankel matrix constructed given the first column C, and
  255.      (optionally) the last row R.  If the last element of C is  not
  256.      the same as the first element of R, the last element of C is used.
  257.      If the second argument is omitted, the last row is  taken to be
  258.      the same as the first column.
  259.      A Hankel matrix formed from an m-vector C, and an n-vector R, has
  260.      the elements
  261.            H (i, j) = c (i+j-1),  i+j-1 <= m;
  262.            H (i, j) = r (i+j-m),  otherwise
  263.  - Function File:  hilb (N)
  264.      Return the Hilbert matrix of order N.  The  i, j  element of a
  265.      Hilbert matrix is defined as
  266.            H (i, j) = 1 / (i + j - 1)
  267.  - Function File:  invhilb (N)
  268.      Return the inverse of a Hilbert matrix of order N.  This is exact.
  269.      Compare with the numerical calculation of `inverse (hilb (n))',
  270.      which suffers from the ill-conditioning of the Hilbert matrix, and
  271.      the  finite precision of your computer's floating point arithmetic.
  272.  - Function File:  sylvester_matrix (K)
  273.      Return the Sylvester matrix of order  n = 2^k.
  274.  - Function File:  toeplitz (C, R)
  275.      Return the Toeplitz matrix constructed given the first column C,
  276.      and (optionally) the first row R.  If the first element of C  is
  277.      not the same as the first element of R, the first element of C is
  278.      used.  If the second argument is omitted, the first row is  taken
  279.      to be the same as the first column.
  280.      A square Toeplitz matrix has the form
  281.            c(0)  r(1)   r(2)  ...  r(n)
  282.            c(1)  c(0)   r(1)      r(n-1)
  283.            c(2)  c(1)   c(0)      r(n-2)
  284.             .                       .
  285.             .                       .
  286.             .                       .
  287.           
  288.            c(n) c(n-1) c(n-2) ...  c(0)
  289.  - Function File:  vander (C)
  290.      Return the Vandermonde matrix whose next to last column is C.
  291.      A Vandermonde matrix has the form
  292.            c(0)^n ... c(0)^2  c(0)  1
  293.            c(1)^n ... c(1)^2  c(1)  1
  294.             .           .      .    .
  295.             .           .      .    .
  296.             .           .      .    .
  297.           
  298.            c(n)^n ... c(n)^2  c(n)  1
  299.    % DO NOT EDIT!  Generated automatically by munge-texi.
  300. File: octave,  Node: Arithmetic,  Next: Linear Algebra,  Prev: Matrix Manipulation,  Up: Top
  301. Arithmetic
  302. **********
  303.    Unless otherwise noted, all of the functions described in this
  304. chapter will work for real and complex scalar or matrix arguments.
  305. * Menu:
  306. * Utility Functions::
  307. * Complex Arithmetic::
  308. * Trigonometry::
  309. * Sums and Products::
  310. * Special Functions::
  311. * Mathematical Constants::
  312. File: octave,  Node: Utility Functions,  Next: Complex Arithmetic,  Prev: Arithmetic,  Up: Arithmetic
  313. Utility Functions
  314. =================
  315.    The following functions are available for working with complex
  316. numbers.  Each expects a single argument.  They are called "mapping
  317. functions" because when given a matrix argument, they apply the given
  318. function to each element of the matrix.
  319.  - Mapping Function:  ceil (X)
  320.      Return the smallest integer not less than X.  If X is complex,
  321.      return `ceil (real (X)) + ceil (imag (X)) * I'.
  322.  - Mapping Function:  exp (X)
  323.      Compute the exponential of X.  To compute the matrix exponential,
  324.      see *Note Linear Algebra::.
  325.  - Mapping Function:  fix (X)
  326.      Truncate X toward zero.  If X is complex, return `fix (real (X)) +
  327.      fix (imag (X)) * I'.
  328.  - Mapping Function:  floor (X)
  329.      Return the largest integer not greater than X.  If X is complex,
  330.      return `floor (real (X)) + floor (imag (X)) * I'.
  331.  - Mapping Function:  gcd (X, `...')
  332.      Compute the greatest common divisor of the elements of X, or the
  333.      list of all the arguments.  For example,
  334.            gcd (a1, ..., ak)
  335.      is the same as
  336.            gcd ([a1, ..., ak])
  337.      An optional second return value, V  contains an integer vector
  338.      such that
  339.            g = v(1) * a(k) + ... + v(k) * a(k)
  340.  - Mapping Function:  lcm (X, `...')
  341.      Compute the least common multiple of the elements elements of X, or
  342.      the list of all the arguments.  For example,
  343.            lcm (a1, ..., ak)
  344.      is the same as
  345.            lcm ([a1, ..., ak]).
  346.  - Mapping Function:  log (X)
  347.      Compute the natural logarithm for each element of X.  To compute
  348.      the matrix logarithm, see *Note Linear Algebra::.
  349.    See also: log2, log10, logspace, exp
  350.  - Mapping Function:  log10 (X)
  351.      Compute the base-10 logarithm for each element of X.
  352.    See also: log, log2, logspace, exp
  353.  - Mapping Function: Y = log2 (X)
  354.  - Mapping Function: [F, E] log2 (X)
  355.      Compute the base-2 logarithm of X.  With two outputs, returns F
  356.      and E such that   1/2 <= abs(f) < 1 and x = f * 2^e.
  357.    max (X): maximum value(s) of a vector (matrix)
  358.    min (X): minimum value(s) of a vector (matrix)
  359.  - Function File:  nextpow2 (X)
  360.      If X is a scalar, returns the first integer N such that   2^n >=
  361.      abs (x).
  362.      If X is a vector, return `nextpow2 (length (X))'.
  363.  - Mapping Function:  pow2 (X)
  364.  - Mapping Function:  pow2 (F, E)
  365.      With one argument, computes   2 .^ x  for each element of X.  With
  366.      two arguments, returns   f .* (2 .^ e).
  367.  - Mapping Function:  rem (X, Y)
  368.      Return the remainder of `X / Y', computed using the  expression
  369.            x - y .* fix (x ./ y)
  370.      An error message is printed if the dimensions of the arguments do
  371.      not  agree, or if either of the arguments is complex.
  372.  - Mapping Function:  round (X)
  373.      Return the integer nearest to X.  If X is complex, return `round
  374.      (real (X)) + round (imag (X)) * I'.
  375.    See also: rem
  376.  - Mapping Function:  sign (X)
  377.      Compute the "signum" function, which is defined as
  378.                      -1, x < 0;
  379.           sign (x) =  0, x = 0;
  380.                       1, x > 0.
  381.      For complex arguments, `sign' returns `x ./ abs (X)'.
  382.  - Mapping Function:  sqrt (X)
  383.      Compute the square root of X.  If X is negative, a complex result
  384.      is returned.  To compute the matrix square root, see *Note Linear
  385.      Algebra::.
  386. File: octave,  Node: Complex Arithmetic,  Next: Trigonometry,  Prev: Utility Functions,  Up: Arithmetic
  387. Complex Arithmetic
  388. ==================
  389.    The following functions are available for working with complex
  390. numbers.  Each expects a single argument.  Given a matrix they work on
  391. an element by element basis.  In the descriptions of the following
  392. functions, Z is the complex number X + IY, where I is defined as `sqrt
  393. (-1)'.
  394.  - Mapping Function:  abs (Z)
  395.      Compute the magnitude of Z, defined as |Z| = `sqrt (x^2 + y^2)'.
  396.      For example,
  397.           abs (3 + 4i)
  398.                => 5
  399.  - Mapping Function:  angle (Z)
  400.      Compute the argument of Z, defined as THETA = `atan (Y/X)'.
  401.      in radians.
  402.      For example,
  403.           arg (3 + 4i)
  404.                => 0.92730
  405.  - Mapping Function:  conj (Z)
  406.      Return the complex conjugate of Z, defined as `conj (Z)' = X - IY.
  407.    See also: real, imag
  408.  - Mapping Function:  imag (Z)
  409.      Return the imaginary part of Z as a real number.
  410.    See also: real, conj
  411.  - Mapping Function:  real (Z)
  412.      Return the real part of Z.
  413.    See also: imag, conj
  414. File: octave,  Node: Trigonometry,  Next: Sums and Products,  Prev: Complex Arithmetic,  Up: Arithmetic
  415. Trigonometry
  416. ============
  417.    Octave provides the following trigonometric functions.  Angles are
  418. specified in radians.  To convert from degrees to radians multipy by
  419. `pi/180'  (e.g. `sin (30 * pi/180)' returns the sine of 30 degrees).
  420.  - Mapping Function:  sin (X)
  421.      sin (X): compute the sin of X for each element of X
  422.  - Mapping Function:  cos (X)
  423.      cos (X): compute the cosine of X for each element of X
  424.  - Mapping Function:  tan (Z)
  425.      tan (X): compute tanget of X for each element of X
  426.  - Mapping Function:  sec (X)
  427.      sec (X): compute the secant of X for each element of X
  428.  - Mapping Function:  csc (X)
  429.      csc (X): compute the cosecant of X for each element of X
  430.  - Mapping Function:  cot (X)
  431.      cot (X): compute the cotangent of X for each element of X
  432.  - Mapping Function:  asin (X)
  433.      asin (X): compute inverse sin (X) for each element of X
  434.  - Mapping Function:  acos (X)
  435.      acos (X): compute the inverse cosine of X for each element of X
  436.  - Mapping Function:  atan (X)
  437.      atan (X): compute the inverse tangent of (X) for each element of X
  438.  - Mapping Function:  asec (X)
  439.      asec (X): compute the inverse secant of X for each element of X
  440.  - Mapping Function:  acsc (X)
  441.      acsc (X): compute the inverse cosecant of X for each element of X
  442.  - Mapping Function:  acot (X)
  443.      acot (X): compute the inverse cotangent of X for each element of X
  444.  - Mapping Function:  sinh (X)
  445.      sinh (X): compute the inverse hyperbolic sin of X for each element
  446.      of X
  447.  - Mapping Function:  acosh (X)
  448.      acosh (X): compute the inverse hyperbolic cosine of X for each
  449.      element of X
  450.  - Mapping Function:  tanh (X)
  451.      tanh (X): compute hyperbolic tangent of X for each element of X
  452.  - Mapping Function:  sech (X)
  453.      sech (X): compute the hyperbolic secant of X for each element of X
  454.  - Mapping Function:  coth (X)
  455.      coth (X): compute the hyperbolic cotangent of X for each element
  456.      of X
  457.  - Mapping Function:  asinh (X)
  458.      asinh (X): compute the inverse hyperbolic sin (X) for each element
  459.      of X
  460.  - Mapping Function:  acosh (X)
  461.      acosh (X): compute the inverse hyperbolic cosine of X for each
  462.      element of X.
  463.  - Mapping Function:  atanh (X)
  464.      atanh (X): compute the inverse hyperbolic tanget of X for each
  465.      element of X
  466.  - Mapping Function:  asech (X)
  467.      asech (X): compute the inverse hyperbolic secant of X for each
  468.      element of X
  469.  - Mapping Function:  acsch (X)
  470.      acsch (X): compute the inverse hyperbolic for each element of X
  471.    acoth (z):  compute the inverse hyperbolic cotangent for each
  472. element of z.
  473.    Each of these functions expect a single argument.  For matrix
  474. arguments, they work on an element by element basis.  For example,
  475.      sin ([1, 2; 3, 4])
  476.           =>  0.84147   0.90930
  477.               0.14112  -0.75680
  478.    atan2 (Y, X): atan (Y / X) in range -pi to pi
  479. File: octave,  Node: Sums and Products,  Next: Special Functions,  Prev: Trigonometry,  Up: Arithmetic
  480. Sums and Products
  481. =================
  482.    sum (X): sum of elements
  483.    prod (X): products
  484.    cumsum (X): cumulative sums
  485.    cumprod (X): cumulative products
  486.    sumsq (X): sum of squares of elements.
  487.    This function is equivalent to computing
  488.    sum (X .* conj (X))
  489.    but it uses less memory and avoids calling conj if X is real.
  490. File: octave,  Node: Special Functions,  Next: Mathematical Constants,  Prev: Sums and Products,  Up: Arithmetic
  491. Special Functions
  492. =================
  493.  - Mapping Function:  besseli (ALPHA, X)
  494.  - Mapping Function:  besselj (ALPHA, X)
  495.  - Mapping Function:  besselk (ALPHA, X)
  496.  - Mapping Function:  bessely (ALPHA, X)
  497.      Compute Bessel functions of the following types:
  498.     `besselj'
  499.           Bessel functions of the first kind.
  500.     `bessely'
  501.           Bessel functions of the second kind.
  502.     `besseli'
  503.           Modified Bessel functions of the first kind.
  504.     `besselk'
  505.           Modified Bessel functions of the second kind.
  506.      The second argument, X, must be a real matrix, vector, or scalar.
  507.      The first argument, ALPHA, must be greater than or equal to zero.
  508.      If ALPHA is a range, it must have an increment equal to one.
  509.      If ALPHA is a scalar, the result is the same size as X.
  510.      If ALPHA is a range, X must be a vector or scalar, and the  result
  511.      is a matrix with `length(X)' rows and `length(ALPHA)' columns.
  512.  - Mapping Function:  beta (A, B)
  513.      Return the Beta function,
  514.            beta (a, b) = gamma (a) * gamma (b) / gamma (a + b).
  515.  - Mapping Function:  betai (A, B, X)
  516.      Return the incomplete Beta function,
  517.                                                x
  518.                                               /
  519.            betai (a, b, x) = beta (a, b)^(-1) | t^(a-1) (1-t)^(b-1) dt.
  520.                                               /
  521.                                            t=0
  522.      If x has more than one component, both A and B must be  scalars.
  523.      If X is a scalar, A and B must be of  compatible dimensions.
  524.  - Mapping Function:  bincoeff (N, K)
  525.      Return the binomial coefficient of N and K, defined as
  526.             /   \
  527.             | n |    n (n-1) (n-2) ... (n-k+1)
  528.             |   |  = -------------------------
  529.             | k |               k!
  530.             \   /
  531.      For example,
  532.            bincoeff (5, 2)
  533.           => 10
  534.  - Mapping Function:  erf (Z)
  535.      Computes the error function,
  536.                                    z
  537.                                   /
  538.           erf (z) = (2/sqrt (pi)) | e^(-t^2) dt
  539.                                   /
  540.                                t=0
  541.    See also: erfc, erfinv
  542.  - Mapping Function:  erfc (Z)
  543.      Computes the complementary error function, `1 - erf (Z)'.
  544.    See also: erf, erfinv
  545.  - Mapping Function:  erfinv (Z)
  546.      Computes the inverse of the error function,
  547.  - Mapping Function:  gamma (Z)
  548.      Computes the Gamma function,
  549.                       infinity
  550.                       /
  551.           gamma (z) = | t^(z-1) exp (-t) dt.
  552.                       /
  553.                    t=0
  554.    See also: gammai, lgamma
  555.  - Mapping Function:  gammai (A, X)
  556.      Computes the incomplete gamma function,
  557.                                          x
  558.                                1        /
  559.            gammai (a, x) = ---------    | exp (-t) t^(a-1) dt
  560.                            gamma (a)    /
  561.                                      t=0
  562.      If A is scalar, then `gammai (A, X)' is returned  for each element
  563.      of X and vice versa.
  564.      If neither A nor X is scalar, the sizes of A and X must agree, and
  565.      GAMMAI is applied element-by-element.
  566.  - Mapping Function:  lgamma (A, X)
  567.  - Mapping Function:  gammaln (A, X)
  568.      Return the natural logarithm of the gamma function.
  569.    See also: gamma, gammai
  570.  - Function File:  cross (X, Y)
  571.      Computes the vector cross product of the two 3-dimensional vectors
  572.      X and Y.  For example,
  573.            cross ([1,1,0], [0,1,1])
  574.           => [ 1; -1; 1 ]
  575.  - Function File:  commutation_matrix (M, N)
  576.      Return the commutation matrix   K(m,n)   which is the unique M*N
  577.      by M*N   matrix such that K(M,N) * vec (A) = vec (A')   for all M
  578.      by N   matrices A.
  579.      If only one argument M is given,   K(m,m)   is returned.
  580.      See Magnus and Neudecker (1988), Matrix differential calculus with
  581.      applications in statistics and econometrics.
  582.  - Function File:  duplication_matrix (N)
  583.      Return the duplication matrix D_N   which is the unique N^2 by
  584.      N*(N+1)/2   matrix such that D_N \cdot vech (A) = vec (A)   for
  585.      all symmetric N by N   matrices A.
  586.      See Magnus and Neudecker (1988), Matrix differential calculus with
  587.      applications in statistics and econometrics.
  588. File: octave,  Node: Mathematical Constants,  Prev: Special Functions,  Up: Arithmetic
  589. Mathematical Constants
  590. ======================
  591.  - Built-in Variable: I
  592.  - Built-in Variable: J
  593.  - Built-in Variable: i
  594.  - Built-in Variable: j
  595.      A pure imaginary number, defined as   `sqrt (-1)'.  The `I' and
  596.      `J' forms are true constants, and cannot be modified.  The `i' and
  597.      `j' forms are like ordinary variables, and may be used for other
  598.      purposes.  However, unlike other variables, they once again assume
  599.      their special predefined values if they are cleared *Note Status
  600.      of Variables::.
  601.  - Built-in Variable: Inf
  602.  - Built-in Variable: inf
  603.      Infinity.  This is the result of an operation like 1/0, or an
  604.      operation that results in a floating point overflow.
  605.  - Built-in Variable: NaN
  606.  - Built-in Variable: nan
  607.      Not a number.  This is the result of an operation like 0/0, or
  608.      `Inf - Inf', or any operation with a NaN.
  609.      Note that NaN always compares not equal to NaN.  This behavior is
  610.      specified by the IEEE standard for floating point arithmetic.  To
  611.      find NaN values, you must use the `isnan' function.
  612.  - Built-in Variable: pi
  613.      The ratio of the circumference of a circle to its diameter.
  614.      Internally, `pi' is computed as `4.0 * atan (1.0)'.
  615.  - Built-in Variable: e
  616.      The base of natural logarithms.  The constant  E  satisfies the
  617.      equation  `log' (E) = 1.
  618.  - Built-in Variable: eps
  619.      The machine precision.  More precisely, `eps' is the largest
  620.      relative spacing between any two adjacent numbers in the machine's
  621.      floating point system.  This number is obviously system-dependent.
  622.      On machines that support 64 bit IEEE floating point arithmetic,
  623.      `eps' is approximately  2.2204e-16.
  624.  - Built-in Variable: realmax
  625.      The largest floating point number that is representable.  The
  626.      actual value is system-dependent.  On machines that support 64 bit
  627.      IEEE floating point arithmetic, `realmax' is approximately
  628.      1.7977e+308
  629.  - Built-in Variable: realmin
  630.      The smallest floating point number that is representable.  The
  631.      actual value is system-dependent.  On machines that support 64 bit
  632.      IEEE floating point arithmetic, `realmin' is approximately
  633.      2.2251e-308
  634.    % DO NOT EDIT!  Generated automatically by munge-texi.
  635. File: octave,  Node: Linear Algebra,  Next: Nonlinear Equations,  Prev: Arithmetic,  Up: Top
  636. Linear Algebra
  637. **************
  638.    This chapter documents the linear algebra functions of Octave.
  639. Reference material for many of these functions may be found in Golub
  640. and Van Loan, `Matrix Computations, 2nd Ed.', Johns Hopkins, 1989, and
  641. in `LAPACK Users' Guide', SIAM, 1992.
  642. * Menu:
  643. * Basic Matrix Functions::
  644. * Matrix Factorizations::
  645. * Functions of a Matrix::
  646. File: octave,  Node: Basic Matrix Functions,  Next: Matrix Factorizations,  Prev: Linear Algebra,  Up: Linear Algebra
  647. Basic Matrix Functions
  648. ======================
  649.  - Loadable Function: AA = balance (A, OPT)
  650.  - Loadable Function: [DD, AA] = balance (A, OPT)
  651.  - Loadable Function: [CC, DD, AA, BB] = balance (A, B, OPT)
  652.      `[dd, aa] = balance (a)' returns `aa = dd \ a * dd'.  `aa' is a
  653.      matrix whose row and column norms are roughly equal in magnitude,
  654.      and `dd' = `p * d', where `p' is a permutation matrix and `d' is a
  655.      diagonal matrix of powers of two.  This allows the equilibration
  656.      to be computed without roundoff.  Results of eigenvalue
  657.      calculation are typically improved by balancing first.
  658.      `[cc, dd, aa, bb] = balance (a, b)' returns `aa = cc*a*dd' and `bb
  659.      = cc*b*dd)', where `aa' and `bb' have non-zero elements of
  660.      approximately the same magnitude and `cc' and `dd' are permuted
  661.      diagonal matrices as in `dd' for the algebraic eigenvalue problem.
  662.      The eigenvalue balancing option `opt' is selected as follows:
  663.     `"N"', `"n"'
  664.           No balancing; arguments copied, transformation(s) set to
  665.           identity.
  666.     `"P"', `"p"'
  667.           Permute argument(s) to isolate eigenvalues where possible.
  668.     `"S"', `"s"'
  669.           Scale to improve accuracy of computed eigenvalues.
  670.     `"B"', `"b"'
  671.           Permute and scale, in that order. Rows/columns of a (and b)
  672.           that are isolated by permutation are not scaled.  This is the
  673.           default behavior.
  674.      Algebraic eigenvalue balancing uses standard LAPACK routines.
  675.      Generalized eigenvalue problem balancing uses Ward's algorithm
  676.      (SIAM Journal on Scientific and Statistical Computing, 1981).
  677.  - Function File:  cond (A)
  678.      Compute the (two-norm) condition number of a matrix. `cond (a)' is
  679.      defined as `norm (a) * norm (inv (a))', and is computed via a
  680.      singular value decomposition.
  681.  - Loadable Function:  det (A)
  682.      Compute the determinant of A using LINPACK.
  683.  - Loadable Function: LAMBDA = eig (A)
  684.  - Loadable Function: [V, LAMBDA] = eig (A)
  685.      The eigenvalues (and eigenvectors) of a matrix are computed in a
  686.      several step process which begins with a Hessenberg decomposition,
  687.      followed by a Schur decomposition, from which the eigenvalues are
  688.      apparent.  The eigenvectors, when desired, are computed by further
  689.      manipulations of the Schur decomposition.
  690.  - Loadable Function: G = givens (X, Y)
  691.  - Loadable Function: [C, S] = givens (X, Y)
  692.      Return a 2 by 2 orthogonal matrix `G = [C S; -S' C]' such that `G
  693.      [X; Y] = [*; 0]' with X and Y scalars.
  694.      For example,
  695.           givens (1, 1)
  696.                =>   0.70711   0.70711
  697.                    -0.70711   0.70711
  698.  - Loadable Function:  inv (A)
  699.  - Loadable Function:  inverse (A)
  700.      Compute the inverse of the square matrix A.
  701.  - Function File:  norm (A, P)
  702.      Compute the p-norm of the matrix A.  If the second argument is
  703.      missing, `p = 2' is assumed.
  704.      If A is a matrix:
  705.     P = `1'
  706.           1-norm, the largest column sum of A.
  707.     P = `2'
  708.           Largest singular value of A.
  709.     P = `Inf'
  710.           Infinity norm, the largest row sum of A.
  711.     P = `"fro"'
  712.           Frobenius norm of A, `sqrt (sum (diag (A' * A)))'.
  713.      If A is a vector or a scalar:
  714.     P = `Inf'
  715.           `max (abs (A))'.
  716.     P = `-Inf'
  717.           `min (abs (A))'.
  718.     other
  719.           p-norm of A, `(sum (abs (A) .^ P)) ^ (1/P)'.
  720.  - Function File:  null (A, TOL)
  721.      Return an orthonormal basis of the null space of A.
  722.      The dimension of the null space is taken as the number of singular
  723.      values of A not greater than TOL.  If the argument TOL  is
  724.      missing, it is computed as
  725.            max (size (A)) * max (svd (A)) * eps
  726.  - Function File:  orth (A, TOL)
  727.      Return an orthonormal basis of the range space of A.
  728.      The dimension of the range space is taken as the number of singular
  729.      values of A greater than TOL.  If the argument TOL is  missing,
  730.      it is computed as
  731.            max (size (A)) * max (svd (A)) * eps
  732.  - Loadable Function:  pinv (X, TOL)
  733.      Return the pseudoinverse of X.  Singular values less than TOL are
  734.      ignored.
  735.      If the second argument is omitted, it is assumed that
  736.           tol = max (size (X)) * sigma_max (X) * eps,
  737.      where `sigma_max (X)' is the maximal singular value of X.
  738.  - Function File:  rank (A, TOL)
  739.      Compute the rank of A, using the singular value decomposition.
  740.      The rank is taken to be the number  of singular values of A that
  741.      are greater than the specified tolerance TOL.  If the second
  742.      argument is omitted, it is taken to be
  743.            tol = max (size (A)) * sigma (1) * eps;
  744.      where `eps' is machine precision and `sigma' is the largest
  745.      singular value of A.
  746.  - Function File:  trace (A)
  747.      Compute the trace of A, `sum (diag (A))'.
  748. File: octave,  Node: Matrix Factorizations,  Next: Functions of a Matrix,  Prev: Basic Matrix Functions,  Up: Linear Algebra
  749. Matrix Factorizations
  750. =====================
  751.  - Loadable Function:  chol (A)
  752.      Compute the Cholesky factor, R, of the symmetric positive definite
  753.      matrix A, where
  754.           r' * r = a.
  755.  - Loadable Function: H = hess (A)
  756.  - Loadable Function: [P, H] = hess (A)
  757.      Compute the Hessenberg decomposition of the matrix A.
  758.      The Hessenberg decomposition is usually used as the first step in
  759.      an eigenvalue computation, but has other applications as well (see
  760.      Golub, Nash, and Van Loan, IEEE Transactions on Automatic Control,
  761.      1979.  The Hessenberg decomposition is `p * h * p' = a' where `p'
  762.      is a square unitary matrix (`p' * p = I', using complex-conjugate
  763.      transposition) and `h' is upper Hessenberg (`i >= j+1 => h (i, j)
  764.      = 0').
  765.  - Loadable Function: [L, U, P] = lu (A)
  766.      Compute the LU decomposition of A, using subroutines from LAPACK.
  767.      The result is returned in a permuted form, according to the
  768.      optional return value P.  For example, given the matrix `a = [1,
  769.      2; 3, 4]',
  770.           [l, u, p] = lu (a)
  771.      returns
  772.           l =
  773.           
  774.             1.00000  0.00000
  775.             0.33333  1.00000
  776.           
  777.           u =
  778.           
  779.             3.00000  4.00000
  780.             0.00000  0.66667
  781.           
  782.           p =
  783.           
  784.             0  1
  785.             1  0
  786.  - Loadable Function: [Q, R, P] = qr (A)
  787.      Compute the QR factorization of A, using standard LAPACK
  788.      subroutines.  For example, given the matrix `a = [1, 2; 3, 4]',
  789.           [q, r] = qr (a)
  790.      returns
  791.           q =
  792.           
  793.             -0.31623  -0.94868
  794.             -0.94868   0.31623
  795.           
  796.           r =
  797.           
  798.             -3.16228  -4.42719
  799.              0.00000  -0.63246
  800.      The `qr' factorization has applications in the solution of least
  801.      squares problems
  802.           `min norm(A x - b)'
  803.      for overdetermined systems of equations (i.e., `a'  is a tall,
  804.      thin matrix).  The QR factorization is `q * r = a' where `q' is an
  805.      orthogonal matrix and `r' is upper triangular.
  806.      The permuted QR factorization `[Q, R, P] = qr (A)' forms the QR
  807.      factorization such that the diagonal entries of `r' are decreasing
  808.      in magnitude order.  For example, given the matrix `a = [1, 2; 3,
  809.      4]',
  810.           [q, r, pi] = qr(a)
  811.      returns
  812.           q =
  813.           
  814.             -0.44721  -0.89443
  815.             -0.89443   0.44721
  816.           
  817.           r =
  818.           
  819.             -4.47214  -3.13050
  820.              0.00000   0.44721
  821.           
  822.           p =
  823.           
  824.              0  1
  825.              1  0
  826.      The permuted `qr' factorization `[q, r, p] = qr (a)' factorization
  827.      allows the construction of an orthogonal basis of `span (a)'.
  828.  - Loadable Function: LAMBDA = qz (A, B)
  829.      Generalized eigenvalue problem A x = s B x, QZ decomposition.
  830.      Three ways to call:
  831.        1. `lambda = qz(A,B)'
  832.           Computes the generalized eigenvalues LAMBDA of (A - sB).
  833.        2. `[AA, BB, Q, Z {, V, W, lambda}] = qz (A, B)'
  834.           Computes qz decomposition, generalized eigenvectors, and
  835.             generalized eigenvalues of (A - sB)
  836.                        A V = B V diag(lambda)
  837.                        W' A = diag(lambda) W' B
  838.                        AA = Q'*A*Z, BB = Q'*B*Z  with Q, Z orthogonal (unitary)= I
  839.        3. `[AA,BB,Z{,lambda}] = qz(A,B,opt)'
  840.           As in form [2], but allows ordering of generalized eigenpairs
  841.                  for (e.g.) solution of discrete time algebraic
  842.           Riccati equations.          Form 3 is not available for
  843.           complex matrices and does not compute         the generalized
  844.           eigenvectors V, W, nor the orthogonal matrix Q.
  845.          OPT
  846.                for ordering eigenvalues of the GEP pencil.  The leading
  847.                block              of the revised pencil contains all
  848.                eigenvalues that satisfy:
  849.               `"N"'
  850.                     = unordered (default)
  851.               `"S"'
  852.                     = small: leading block has all |lambda| <=1
  853.               `"B"'
  854.                     = big: leading block has all |lambda >= 1
  855.               `"-"'
  856.                     = negative real part: leading  block has all
  857.                     eigenvalues                   in the open left
  858.                     half-plant
  859.               `"+"'
  860.                     = nonnegative real part:  leading block has all
  861.                     eigenvalues                   in the closed right
  862.                     half-plane
  863.      Note: qz performs permutation balancing, but not scaling (see
  864.      balance).        Order of output arguments was selected for
  865.      compatibility with MATLAB
  866.      See also: balance, dare, eig, schur
  867.  - Function File: [AA, BB, Q, Z] = qzhess (A, B)
  868.      Compute the Hessenberg-triangular decomposition of the matrix
  869.      pencil `(A, B)', returning `AA = Q * A * Z', `BB = Q * B * Z',
  870.      with Q and Z  orthogonal.  For example,
  871.            [aa, bb, q, z] = qzhess ([1, 2; 3, 4], [5, 6; 7, 8])
  872.           => aa = [ -3.02244, -4.41741;  0.92998,  0.69749 ]
  873.           => bb = [ -8.60233, -9.99730;  0.00000, -0.23250 ]
  874.           =>  q = [ -0.58124, -0.81373; -0.81373,  0.58124 ]
  875.           =>  z = [ 1, 0; 0, 1 ]
  876.      The Hessenberg-triangular decomposition is the first step in
  877.      Moler and Stewart's QZ decomposition algorithm.
  878.      Algorithm taken from Golub and Van Loan, `Matrix Computations, 2nd
  879.      edition'.
  880.  - Loadable Function: S = schur (A)
  881.  - Loadable Function: [U, S] = schur (A, OPT)
  882.      The Schur decomposition is used to compute eigenvalues of a square
  883.      matrix, and has applications in the solution of algebraic Riccati
  884.      equations in control (see `are' and `dare').  `schur' always
  885.      returns `s = u' * a * u' where `u'  is a unitary matrix (`u'* u'
  886.      is identity) and `s' is upper triangular.  The eigenvalues of `a'
  887.      (and `s') are the diagonal elements of `s' If the matrix `a' is
  888.      real, then the real Schur decomposition is computed, in which the
  889.      matrix `u' is orthogonal and `s' is block upper triangular with
  890.      blocks of size at most `2 x 2' blocks along the diagonal.  The
  891.      diagonal elements of `s' (or the eigenvalues of the `2 x 2'
  892.      blocks, when appropriate) are the eigenvalues of `a' and `s'.
  893.      The eigenvalues are optionally ordered along the diagonal
  894.      according to the value of `opt'.  `opt = "a"' indicates that all
  895.      eigenvalues with negative real parts should be moved to the leading
  896.      block of `s' (used in `are'), `opt = "d"' indicates that all
  897.      eigenvalues with magnitude less than one should be moved to the
  898.      leading block of `s' (used in `dare'), and `opt = "u"', the
  899.      default, indicates that no ordering of eigenvalues should occur.
  900.      The leading `k' columns of `u' always span the `a'-invariant
  901.      subspace corresponding to the `k' leading eigenvalues of `s'.
  902.  - Loadable Function: S = svd (A)
  903.  - Loadable Function: [U, S, V] = svd (A)
  904.      Compute the singular value decomposition of A
  905.           a = u * sigma * v'
  906.      The function `svd' normally returns the vector of singular values.
  907.      If asked for three return values, it computes U, S, and V.  For
  908.      example,
  909.           svd (hilb (3))
  910.      returns
  911.           ans =
  912.           
  913.             1.4083189
  914.             0.1223271
  915.             0.0026873
  916.      and
  917.           [u, s, v] = svd (hilb (3))
  918.      returns
  919.           u =
  920.           
  921.             -0.82704   0.54745   0.12766
  922.             -0.45986  -0.52829  -0.71375
  923.             -0.32330  -0.64901   0.68867
  924.           
  925.           s =
  926.           
  927.             1.40832  0.00000  0.00000
  928.             0.00000  0.12233  0.00000
  929.             0.00000  0.00000  0.00269
  930.           
  931.           v =
  932.           
  933.             -0.82704   0.54745   0.12766
  934.             -0.45986  -0.52829  -0.71375
  935.             -0.32330  -0.64901   0.68867
  936.      If given a second argument, `svd' returns an economy-sized
  937.      decomposition, eliminating the unnecessary rows or columns of U or
  938.      V.
  939. File: octave,  Node: Functions of a Matrix,  Prev: Matrix Factorizations,  Up: Linear Algebra
  940. Functions of a Matrix
  941. =====================
  942.  - Loadable Function:  expm (A)
  943.      Return the exponential of a matrix, defined as the infinite Taylor
  944.      series
  945.           expm(a) = I + a + a^2/2! + a^3/3! + ...
  946.      The Taylor series is *not* the way to compute the matrix
  947.      exponential; see Moler and Van Loan, `Nineteen Dubious Ways to
  948.      Compute the Exponential of a Matrix', SIAM Review, 1978.  This
  949.      routine uses Ward's diagonal Pade' approximation method with three
  950.      step preconditioning (SIAM Journal on Numerical Analysis, 1977).
  951.      Diagonal Pade'  approximations are rational polynomials of matrices
  952.                -1
  953.           D (a)   N (a)
  954.      whose Taylor series matches the first `2q+1' terms of the Taylor
  955.      series above; direct evaluation of the Taylor series (with the
  956.      same preconditioning steps) may be desirable in lieu of the Pade'
  957.      approximation when `Dq(a)' is ill-conditioned.
  958.  - Loadable Function:  logm (A)
  959.      Compute the matrix logarithm of the square matrix A.  Note that
  960.      this is currently implemented in terms of an eigenvalue expansion
  961.      and needs to be improved to be more robust.
  962.  - Loadable Function:  sqrtm (A)
  963.      Compute the matrix square root of the square matrix A.  Note that
  964.      this is currently implemented in terms of an eigenvalue expansion
  965.      and needs to be improved to be more robust.
  966.  - Function File:  kron (A, B)
  967.      Form the kronecker product of two matrices, defined block by block
  968.      as
  969.            x = [a(i, j) b]
  970.      For example,
  971.            kron (1:4, ones (3, 1))
  972.           =>  1  2  3  4
  973.                     1  2  3  4
  974.                     1  2  3  4
  975.  - Loadable Function: X = syl (A, B, C)
  976.      Solve the Sylvester equation
  977.           A X + X B + C = 0
  978.      using standard LAPACK subroutines.  For example,
  979.           syl ([1, 2; 3, 4], [5, 6; 7, 8], [9, 10; 11, 12])
  980.                => [ -0.50000, -0.66667; -0.66667, -0.50000 ]
  981.    % DO NOT EDIT!  Generated automatically by munge-texi.
  982. File: octave,  Node: Nonlinear Equations,  Next: Quadrature,  Prev: Linear Algebra,  Up: Top
  983. Nonlinear Equations
  984. *******************
  985.    Octave can solve sets of nonlinear equations of the form
  986.      F (x) = 0
  987. using the function `fsolve', which is based on the MINPACK subroutine
  988. `hybrd'.
  989.  - Loadable Function: [X, INFO] = fsolve (FCN, X0)
  990.      Given FCN, the name of a function of the form `f (X)' and an
  991.      initial starting point X0, `fsolve' solves the set of equations
  992.      such that `f(X) == 0'.
  993.  - Loadable Function:  fsolve_options (OPT, VAL)
  994.      When called with two arguments, this function allows you set
  995.      options parameters for the function `fsolve'.  Given one argument,
  996.      `fsolve_options' returns the value of the corresponding option.  If
  997.      no arguments are supplied, the names of all the available options
  998.      and their current values are displayed.
  999.    Here is a complete example.  To solve the set of equations
  1000.      -2x^2 + 3xy   + 4 sin(y) = 6
  1001.       3x^2 - 2xy^2 + 3 cos(x) = -4
  1002. you first need to write a function to compute the value of the given
  1003. function.  For example:
  1004.      function y = f (x)
  1005.        y(1) = -2*x(1)^2 + 3*x(1)*x(2)   + 4*sin(x(2)) - 6;
  1006.        y(2) =  3*x(1)^2 - 2*x(1)*x(2)^2 + 3*cos(x(1)) + 4;
  1007.      endfunction
  1008.    Then, call `fsolve' with a specified initial condition to find the
  1009. roots of the system of equations.  For example, given the function `f'
  1010. defined above,
  1011.      [x, info] = fsolve ("f", [1; 2])
  1012. results in the solution
  1013.      x =
  1014.      
  1015.        0.57983
  1016.        2.54621
  1017.      
  1018.      info = 1
  1019.    A value of `info = 1' indicates that the solution has converged.
  1020.    The function `perror' may be used to print English messages
  1021. corresponding to the numeric error codes.  For example,
  1022.      perror ("fsolve", 1)
  1023.           -| solution converged to requested tolerance
  1024.    % DO NOT EDIT!  Generated automatically by munge-texi.
  1025. File: octave,  Node: Quadrature,  Next: Differential Equations,  Prev: Nonlinear Equations,  Up: Top
  1026. Quadrature
  1027. **********
  1028. * Menu:
  1029. * Functions of One Variable::
  1030. * Orthogonal Collocation::
  1031. File: octave,  Node: Functions of One Variable,  Next: Orthogonal Collocation,  Prev: Quadrature,  Up: Quadrature
  1032. Functions of One Variable
  1033. =========================
  1034.  - Loadable Function: [V, IER, NFUN, ERR] = quad (F, A, B, TOL, SING)
  1035.      Integrate a nonlinear function of one variable using Quadpack.
  1036.      The first argument is the name of the  function to call to compute
  1037.      the value of the integrand.  It must have the form
  1038.           y = f (x)
  1039.      where Y and X are scalars.
  1040.      The second and third arguments are limits of integration.  Either
  1041.      or both may be infinite.
  1042.      The optional argument TOL is a vector that specifies the desired
  1043.      accuracy of the result.  The first element of the vector is the
  1044.      desired absolute tolerance, and the second element is the desired
  1045.      relative tolerance.  To choose a relative test only, set the
  1046.      absolute tolerance to zero.  To choose an absolute test only, set
  1047.      the relative tolerance to zero.
  1048.      The optional argument SING is a vector of values at which the
  1049.      integrand is known to be singular.
  1050.      The result of the integration is returned in V and IER contains an
  1051.      integer error code (0 indicates a successful integration).  The
  1052.      value of NFUN indicates how many function evaluations were
  1053.      required, and ERR contains an estimate of the error in the
  1054.      solution.
  1055.  - Loadable Function:  quad_options (OPT, VAL)
  1056.      When called with two arguments, this function allows you set
  1057.      options parameters for the function `quad'.  Given one argument,
  1058.      `quad_options' returns the value of the corresponding option.  If
  1059.      no arguments are supplied, the names of all the available options
  1060.      and their current values are displayed.
  1061.    Here is an example of using `quad' to integrate the function
  1062.        F(X) = X * sin (1/X) * sqrt (abs (1 - X))
  1063. from X = 0 to X = 3.
  1064.    This is a fairly difficult integration (plot the function over the
  1065. range of integration to see why).
  1066.    The first step is to define the function:
  1067.      function y = f (x)
  1068.        y = x .* sin (1 ./ x) .* sqrt (abs (1 - x));
  1069.      endfunction
  1070.    Note the use of the `dot' forms of the operators.  This is not
  1071. necessary for the call to `quad', but it makes it much easier to
  1072. generate a set of points for plotting (because it makes it possible to
  1073. call the function with a vector argument to produce a vector result).
  1074.    Then we simply call quad:
  1075.      [v, ier, nfun, err] = quad ("f", 0, 3)
  1076.           => 1.9819
  1077.           => 1
  1078.           => 5061
  1079.           => 1.1522e-07
  1080.    Although `quad' returns a nonzero value for IER, the result is
  1081. reasonably accurate (to see why, examine what happens to the result if
  1082. you move the lower bound to 0.1, then 0.01, then 0.001, etc.).
  1083. File: octave,  Node: Orthogonal Collocation,  Prev: Functions of One Variable,  Up: Quadrature
  1084. Orthogonal Collocation
  1085. ======================
  1086.  - Loadable Function: [R, A, B, Q] = colloc (N, "left", "right")
  1087.      Compute derivative and integral weight matrices for orthogonal
  1088.      collocation using the subroutines given in J. Villadsen and M. L.
  1089.      Michelsen, `Solution of Differential Equation Models by Polynomial
  1090.      Approximation'.
  1091.    Here is an example of using `colloc' to generate weight matrices for
  1092. solving the second order differential equation U' - ALPHA * U" = 0 with
  1093. the boundary conditions U(0) = 0 and U(1) = 1.
  1094.    First, we can generate the weight matrices for N points (including
  1095. the endpoints of the interval), and incorporate the boundary conditions
  1096. in the right hand side (for a specific value of ALPHA).
  1097.      n = 7;
  1098.      alpha = 0.1;
  1099.      [r, a, b] = colloc (n-2, "left", "right");
  1100.      at = a(2:n-1,2:n-1);
  1101.      bt = b(2:n-1,2:n-1);
  1102.      rhs = alpha * b(2:n-1,n) - a(2:n-1,n);
  1103.    Then the solution at the roots R is
  1104.      u = [ 0; (at - alpha * bt) \ rhs; 1]
  1105.           => [ 0.00; 0.004; 0.01 0.00; 0.12; 0.62; 1.00 ]
  1106.    % DO NOT EDIT!  Generated automatically by munge-texi.
  1107. File: octave,  Node: Differential Equations,  Next: Optimization,  Prev: Quadrature,  Up: Top
  1108. Differential Equations
  1109. **********************
  1110.    Octave has two built-in functions for solving differential equations.
  1111. Both are based on reliable ODE solvers written in Fortran.
  1112. * Menu:
  1113. * Ordinary Differential Equations::
  1114. * Differential-Algebraic Equations::
  1115.