home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-bin.lha / info / octave.info-4 (.txt) < prev    next >
GNU Info File  |  1996-10-12  |  49KB  |  1,109 lines

  1. This is Info file octave.info, produced by Makeinfo-1.64 from the input
  2. file octave.texi.
  3.    Copyright (C) 1993, 1994, 1995 John W. Eaton.
  4.    Permission is granted to make and distribute verbatim copies of this
  5. manual provided the copyright notice and this permission notice are
  6. preserved on all copies.
  7.    Permission is granted to copy and distribute modified versions of
  8. this manual under the conditions for verbatim copying, provided that
  9. the entire resulting derived work is distributed under the terms of a
  10. permission notice identical to this one.
  11.    Permission is granted to copy and distribute translations of this
  12. manual into another language, under the above conditions for modified
  13. versions.
  14. File: octave.info,  Node: User Preferences,  Next: Other Built-in Variables,  Prev: Predefined Constants,  Up: Built-in Variables
  15. User Preferences
  16. ================
  17.    This section describes the variables that you can use to customize
  18. Octave's behavior.
  19.    Normally, preferences are set in the file `~/.octaverc', so that you
  20. can customize your environment in the same way each time you use Octave
  21. without having to remember and retype all the necessary commands.
  22. *Note Startup Files:: for more information.
  23. `EDITOR'
  24.      A string naming the editor to use with the `edit_history' command.
  25.      If the environment variable `EDITOR' is set when Octave starts, its
  26.      value is used as the default.  Otherwise, `EDITOR' is set to
  27.      `"vi"'.
  28. `IMAGEPATH'
  29.      A colon separated list of directories in which to search for image
  30.      files.  *Note Image Processing:: for a description of Octave's
  31.      image processing capabilities.
  32. `INFO_FILE'
  33.      A string naming the location of the Octave info file.
  34.      The default value is `"/ade/info/octave.info"'.
  35. `LOADPATH'
  36.      A colon separated list of directories in which to search for
  37.      function files.  *Note Functions and Scripts::.  The value of
  38.      `LOADPATH' overrides the environment variable `OCTAVE_PATH'.
  39.      *Note Installation::.
  40.      `LOADPATH' is now handled in the same way as TeX handles
  41.      `TEXINPUTS'.  If the path starts with `:', the standard path is
  42.      prepended to the value of `LOADPATH'.  If it ends with `:' the
  43.      standard path is appended to the value of `LOADPATH'.
  44.      In addition, if any path element ends in `//', that directory and
  45.      all subdirectories it contains are searched recursively for
  46.      function files.  This can result in a slight delay as Octave
  47.      caches the lists of files found in the `LOADPATH' the first time
  48.      Octave searches for a function.  After that, searching is usually
  49.      much faster because Octave normally only needs to search its
  50.      internal cache for files.
  51.      To improve performance of recursive directory searching, it is
  52.      best for each directory that is to be searched recursively to
  53.      contain *either* additional subdirectories *or* function files, but
  54.      not a mixture of both.
  55.      *Note Organization of Functions:: for a description of the
  56.      function file directories that are distributed with Octave.
  57. `OCTAVE_VERSION'
  58.      The version number of Octave, as a string.
  59. `PAGER'
  60.      The default value is `"less"', or, if `less' is not available on
  61.      your system, `"more"'.  *Note Installation::, and *Note Input and
  62.      Output::.
  63. `PS1'
  64.      The primary prompt string.  When executing interactively, Octave
  65.      displays the primary prompt `PS1' when it is ready to read a
  66.      command.  Octave allows the prompt to be customized by inserting a
  67.      number of backslash-escaped special characters that are decoded as
  68.      follows:
  69.     `\t'
  70.           The time.
  71.     `\d'
  72.           The date.
  73.     `\n'
  74.           Begins a new line by printing the equivalent of a carriage
  75.           return followed by a line feed.
  76.     `\s'
  77.           The name of the program (usually just `octave').
  78.     `\w'
  79.           The current working directory.
  80.     `\W'
  81.           The basename of the current working directory.
  82.     `\u'
  83.           The username of the current user.
  84.     `\h'
  85.           The hostname.
  86.     `\#'
  87.           The command number of this command, counting from when Octave
  88.           starts.
  89.     `\!'
  90.           The history number of this command.  This differs from `\#'
  91.           by the number of commands in the history list when Octave
  92.           starts.
  93.     `\$'
  94.           If the effective UID is 0, a #, otherwise a $.
  95.     `\nnn'
  96.           The character whose character code in octal is `nnn'.
  97.     `\\'
  98.           A backslash.
  99.      The default value of `PS1' is `"\s:\#> "'.  To change it, use a
  100.      command like
  101.           octave:13> PS1 = "\\u@\\h> "
  102.      which will result in the prompt `boris@kremvax> ' for the user
  103.      `boris' logged in on the host `kremvax'.  Note that two
  104.      backslashes are required to enter a backslash into a string.
  105.      *Note String Constants::.
  106. `PS2'
  107.      The secondary prompt string, which is printed when Octave is
  108.      expecting additional input to complete a command.  For example,
  109.      when defining a function over several lines, Octave will print the
  110.      value of `PS1' at the beginning of each line after the first.
  111.      Octave allows `PS2' to be customized in the same way as `PS1'.
  112.      The default value of `PS2' is `"> "'.
  113. `PS4'
  114.      If Octave is invoked with the `--echo-input' option, the value of
  115.      `PS4' is printed before each line of input that is echoed.  Octave
  116.      allows `PS4' to be customized in the same way as `PS1'.  The
  117.      default value of `PS4' is `"+ "'.  *Note Invoking Octave::, for a
  118.      description of `--echo-input'.
  119. `automatic_replot'
  120.      If this variable is `"true"', Octave will automatically send a
  121.      `replot' command to `gnuplot' each time the plot changes.  Since
  122.      this is fairly inefficient, the default value is `"false"'.
  123. `default_return_value'
  124.      The value given to otherwise unitialized return values if
  125.      `define_all_return_values' is `"true"'.  The default value is `[]'.
  126. `default_save_format'
  127.      Specify the default format used by the `save' command.  Options are
  128.      `"ascii"', `"binary"', `"mat-binary"', or `"float-binary"'.  The
  129.      default value is `ascii'.
  130. `define_all_return_values'
  131.      If the value of `define_all_return_values' is `"true"', Octave
  132.      will substitute the value specified by `default_return_value' for
  133.      any return values that remain undefined when a function returns.
  134.      The default value is `"false"'.
  135. `do_fortran_indexing'
  136.      If the value of `do_fortran_indexing' is `"true"', Octave allows
  137.      you to select elements of a two-dimensional matrix using a single
  138.      index by treating the matrix as a single vector created from the
  139.      columns of the matrix.  The default value is `"false"'.
  140. `empty_list_elements_ok'
  141.      This variable controls whether Octave ignores empty matrices in a
  142.      matrix list.
  143.      For example, if the value of `empty_list_elements_ok' is `"true"',
  144.      Octave will ignore the empty matrices in the expression
  145.           a = [1, [], 3, [], 5]
  146.      and the variable `a' will be assigned the value `[ 1 3 5 ]'.
  147.      The default value is `"warn"'.
  148. `gnuplot_binary'
  149.      The name of the program invoked by the plot command.  The default
  150.      value is `"gnuplot"'.  *Note Installation::.
  151. `ignore_function_time_stamp'
  152.      This variable variable can be used to prevent Octave from making
  153.      the system call `stat()' each time it looks up functions defined in
  154.      function files.  If `ignore_function_time_stamp' to `"system"',
  155.      Octave will not automatically recompile function files in
  156.      subdirectories of `/ade/lib/1.1.1' if they have changed since they
  157.      were last compiled, but will recompile other function files in the
  158.      `LOADPATH' if they change.  If set to `"all"', Octave will not
  159.      recompile any function files unless their definitions are removed
  160.      with `clear'.  For any other value of
  161.      `ignore_function_time_stamp', Octave will always check to see if
  162.      functions defined in function files need to recompiled.  The
  163.      default value of `ignore_function_time_stamp' is `"system"'.
  164. `implicit_str_to_num_ok'
  165.      If the value of `implicit_str_to_num_ok' is `"true"', implicit
  166.      conversions of strings to their numeric ASCII equivalents are
  167.      allowed.  Otherwise, an error message is printed and control is
  168.      returned to the top level.  The default value is `"false"'.
  169. `ok_to_lose_imaginary_part'
  170.      If the value of `ok_to_lose_imaginary_part' is `"true"', implicit
  171.      conversions of complex numbers to real numbers are allowed (for
  172.      example, by fsolve).  If the value is `"warn"', the conversion is
  173.      allowed, but a warning is printed.  Otherwise, an error message is
  174.      printed and control is returned to the top level.  The default
  175.      value is `"warn"'.
  176. `output_max_field_width'
  177.      This variable specifies the maximum width of a numeric output
  178.      field.  The default value is 10.
  179.      It is possible to achieve a wide range of output styles by using
  180.      different values of `output_precision' and
  181.      `output_max_field_width'.  Reasonable combinations can be set using
  182.      the `format' function.  *Note Basic Input and Output::.
  183. `output_precision'
  184.      This variable specifies the minimum number of significant figures
  185.      to display for numeric output.  The default value is 5.
  186.      It is possible to achieve a wide range of output styles by using
  187.      different values of `output_precision' and
  188.      `output_max_field_width'.  Reasonable combinations can be set using
  189.      the `format' function.  *Note Basic Input and Output::.
  190. `page_screen_output'
  191.      If the value of `page_screen_output' is `"true"', all output
  192.      intended for the screen that is longer than one page is sent
  193.      through a pager.  This allows you to view one screenful at a time.
  194.      Some pagers (such as `less'--see *Note Installation::) are also
  195.      capable of moving backward on the output.  The default value is
  196.      `"true"'.  *Note Input and Output::.
  197.      You can choose the program to use as the pager by setting the
  198.      variable `PAGER'.
  199. `prefer_column_vectors'
  200.      If `prefer_column_vectors' is `"true"', operations like
  201.           for i = 1:10
  202.             a (i) = i;
  203.           endfor
  204.      (for `a' previously  undefined) produce column vectors.
  205.      Otherwise, row vectors are preferred.  The default value is
  206.      `"false"'.
  207.      If a variable is already defined to be a vector (a matrix with a
  208.      single row or column), the original orientation is respected,
  209.      regardless of the value of `prefer_column_vectors'.
  210. `prefer_zero_one_indexing'
  211.      If the value of `prefer_zero_one_indexing' is `"true"', Octave
  212.      will perform zero-one style indexing when there is a conflict with
  213.      the normal indexing rules.  *Note Index Expressions::.  For
  214.      example, given a matrix
  215.           a = [1, 2, 3, 4]
  216.      with `prefer_zero_one_indexing' is set to `"true"', the expression
  217.           a ([1, 1, 1, 1])
  218.      results in the matrix `[ 1  2  3  4 ]'.  If the value of
  219.      `prefer_zero_one_indexing' set to `"false"', the result would be
  220.      the matrix `[ 1 1 1 1 ]'.
  221.      In the first case, Octave is selecting each element corresponding
  222.      to a `1' in the index vector.  In the second, Octave is selecting
  223.      the first element multiple times.
  224.      The default value for `prefer_zero_one_indexing' is `"false"'.
  225. `print_answer_id_name'
  226.      If the value of `print_answer_id_name' is `"true"', variable names
  227.      are printed along with the result.  Otherwise, only the result
  228.      values are printed.  The default value is `"true"'.
  229. `print_empty_dimensions'
  230.      If the value of `print_empty_dimensions' is `"true"', the
  231.      dimensions of empty matrices are printed along with the empty
  232.      matrix symbol, `[]'.  For example, the expression
  233.           zeros (3, 0)
  234.      will print
  235.           ans =
  236.           
  237.           [](3x0)
  238. `propagate_empty_matrices'
  239.      If the value of `propagate_empty_matrices' is `"true"', functions
  240.      like `inverse' and `svd' will return an empty matrix if they are
  241.      given one as an argument.  The default value is `"true"'.  *Note
  242.      Empty Matrices::.
  243. `resize_on_range_error'
  244.      If the value of `resize_on_range_error' is `"true"', expressions
  245.      like
  246.           for i = 1:10
  247.             a (i) = i;
  248.           endfor
  249.      (for `a' previously undefined) result in the variable `a' being
  250.      resized to be just large enough to hold the new value.  Otherwise
  251.      uninitialized elements are set to zero.  If the value of
  252.      `resize_on_range_error' is `"false"', an error message is printed
  253.      and control is returned to the top level.  The default value is
  254.      `"true"'.
  255. `return_last_computed_value'
  256.      If the value of `return_last_computed_value' is true, and a
  257.      function is defined without explicitly specifying a return value,
  258.      the function will return the value of the last expression.
  259.      Otherwise, no value will be returned.  The default value is
  260.      `"false"'.
  261.      For example, the function
  262.           function f ()
  263.             2 + 2;
  264.           endfunction
  265.      will either return nothing, if `return_last_computed_value' is
  266.      `"false"', or 4, if it is `"true"'.
  267. `save_precision'
  268.      This variable specifies the number of digits to keep when saving
  269.      data with the `save' command.  The default value is 17.
  270. `silent_functions'
  271.      If the value of `silent_functions' is `"true"', internal output
  272.      from a function is suppressed.  Otherwise, the results of
  273.      expressions within a function body that are not terminated with a
  274.      semicolon will have their values printed.  The default value is
  275.      `"false"'.
  276.      For example, if the function
  277.           function f ()
  278.             2 + 2
  279.           endfunction
  280.      is executed, Octave will either print `ans = 4' or nothing
  281.      depending on the value of `silent_functions'.
  282. `split_long_rows'
  283.      For large matrices, Octave may not be able to display all the
  284.      columns of a given row on one line of your screen.  This can
  285.      result in missing information or output that is nearly impossible
  286.      to decipher, depending on whether your terminal truncates or wraps
  287.      long lines.
  288.      If the value of `split_long_rows' is `"true"', Octave will display
  289.      the matrix in a series of smaller pieces, each of which can fit
  290.      within the limits of your terminal width.  Each set of rows is
  291.      labeled so that you can easily see which columns are currently
  292.      being displayed.  For example:
  293.           octave:13> rand (2, 9)
  294.           ans =
  295.           
  296.            Columns 1 through 7:
  297.           
  298.              0.92205  0.72628  0.99841  0.62590  0.82422  0.77486  0.30258
  299.              0.15999  0.79484  0.75443  0.86995  0.91430  0.23980  0.64591
  300.           
  301.            Columns 8 and 9:
  302.           
  303.             0.08894  0.13266
  304.             0.28008  0.65575
  305.      The default value of `split_long_rows' is `"true"'.
  306. `suppress_verbose_help_message'
  307.      If the value of `suppress_verbose_help_message' is `"true"',
  308.      Octave will not add additional help information to the end of the
  309.      output from the `help' command and usage messages for built-in
  310.      commands.
  311. `treat_neg_dim_as_zero'
  312.      If the value of `treat_neg_dim_as_zero' is `"true"', expressions
  313.      like
  314.           eye (-1)
  315.      produce an empty matrix (i.e., row and column dimensions are zero).
  316.      Otherwise, an error message is printed and control is returned to
  317.      the top level.  The default value is `"false"'.
  318. `warn_assign_as_truth_value'
  319.      If the value of `warn_assign_as_truth_value' is `"true"', a
  320.      warning is issued for statements like
  321.           if (s = t)
  322.             ...
  323.      since such statements are not common, and it is likely that the
  324.      intent was to write
  325.           if (s == t)
  326.             ...
  327.      instead.
  328.      There are times when it is useful to write code that contains
  329.      assignments within the condition of a `while' or `if' statement.
  330.      For example, statements like
  331.           while (c = getc())
  332.             ...
  333.      are common in C programming.
  334.      It is possible to avoid all warnings about such statements by
  335.      setting `warn_assign_as_truth_value' to `"false"', but that may
  336.      also let real errors like
  337.           if (x = 1)  # intended to test (x == 1)!
  338.             ...
  339.      slip by.
  340.      In such cases, it is possible suppress errors for specific
  341.      statements by writing them with an extra set of parentheses.  For
  342.      example, writing the previous example as
  343.           while ((c = getc()))
  344.             ...
  345.      will prevent the warning from being printed for this statement,
  346.      while allowing Octave to warn about other assignments used in
  347.      conditional contexts.
  348.      The default value of `warn_assign_as_truth_value' is `"true"'.
  349. `warn_comma_in_global_decl'
  350.      If the value of `warn_comma_in_global_decl' is `"true"', a warning
  351.      is issued for statements like
  352.           global a = 1, b
  353.      which makes the variables `a' and `b' global and assigns the value
  354.      1 to the variable `a', because in this context, the comma is not
  355.      interpreted as a statement separator.
  356.      The default value of `warn_comma_in_global_decl' is `"true"'.
  357. `warn_divide_by_zero'
  358.      If the value of `warn_divide_by_zero' is `"true"', a warning is
  359.      issued when Octave encounters a division by zero.  If the value is
  360.      `"false"', the warning is omitted.  The default value is `"true"'.
  361. `warn_function_name_clash'
  362.      If the value of `warn_function_name_clash' is `"true"', a warning
  363.      is issued when Octave finds that the name of a function defined in
  364.      a function file differs from the name of the file.  If the value is
  365.      `"false"', the warning is omitted.  The default value is `"true"'.
  366. `whitespace_in_literal_matrix'
  367.      This variable allows some control over how Octave decides to
  368.      convert spaces to commas and semicolons in matrix expressions like
  369.      `[m (1)]' or
  370.           [ 1, 2,
  371.             3, 4 ]
  372.      If the value of `whitespace_in_literal_matrix' is `"ignore"',
  373.      Octave will never insert a comma or a semicolon in a literal matrix
  374.      list.  For example, the expression `[1 2]' will result in an error
  375.      instead of being treated the same as `[1, 2]', and the expression
  376.           [ 1, 2,
  377.             3, 4 ]
  378.      will result in the vector [1 2 3 4] instead of a matrix.
  379.      If the value of `whitespace_in_literal_matrix' is `"traditional"',
  380.      Octave will convert spaces to a comma between identifiers and `('.
  381.      For example, given the matrix
  382.           m = [3 2]
  383.      the expression
  384.           [m (1)]
  385.      will be parsed as
  386.           [m, (1)]
  387.      and will result in
  388.           [3 2 1]
  389.      and the expression
  390.           [ 1, 2,
  391.             3, 4 ]
  392.      will result in a matrix because the newline character is converted
  393.      to a semicolon (row separator) even though there is a comma at the
  394.      end of the first line (trailing commas or semicolons are ignored).
  395.      This is apparently how MATLAB behaves.
  396.      Any other value for `whitespace_in_literal_matrix' results in
  397.      behavior that is the same as traditional, except that Octave does
  398.      not convert spaces to a comma between identifiers and `('.  For
  399.      example, the expression
  400.           [m (1)]
  401.      will produce `3'.  This is the way Octave has always behaved.
  402. File: octave.info,  Node: Other Built-in Variables,  Next: Summary of Preference Variables,  Prev: User Preferences,  Up: Built-in Variables
  403. Other Built-in Variables
  404. ========================
  405.    In addition to these variables, there are two other special built-in
  406. variables whose values are automatically updated.
  407. `ans'
  408.      This variable holds the most recently computed result that was not
  409.      explicitly assigned to a variable.  For example, after the
  410.      expression
  411.           3^2 + 4^2
  412.      is evaluated, the value of `ans' is `25'.
  413. `PWD'
  414.      The current working directory.  The value of `PWD' is updated each
  415.      time the current working directory is changed with the `cd'
  416.      command.  *Note System Utilities::.
  417. File: octave.info,  Node: Summary of Preference Variables,  Prev: Other Built-in Variables,  Up: Built-in Variables
  418. Summary of Preference Variables
  419. ===============================
  420.    Here is a summary of all of Octave's preference variables and their
  421. default values.  In the following table `OCTAVE_HOME' stands for the
  422. root directory where Octave is installed, and `VERSION' stands for the
  423. Octave version number.
  424.      EDITOR                        EDITOR environment variable, or "vi"
  425.      INFO_FILE                     "OCTAVE_HOME/info/octave.info"
  426.      LOADPATH                      OCTAVE_PATH environment variable, or
  427.                                    ".:OCTAVE_HOME/lib/VERSION"
  428.      PAGER                         "less", or "more"
  429.      PS1                           "\s:\#> "
  430.      PS2                           "> "
  431.      PS4                           "+ "
  432.      automatic_replot              "false"
  433.      default_return_value          []
  434.      do_fortran_indexing           "false"
  435.      define_all_return_values      "false"
  436.      empty_list_elements_ok        "warn"
  437.      gnuplot_binary                "gnuplot"
  438.      ignore_function_time_stamp    "system"
  439.      implicit_str_to_num_ok        "false"
  440.      ok_to_lose_imaginary_part     "warn"
  441.      output_max_field_width        10
  442.      output_precision              5
  443.      page_screen_output            "true"
  444.      prefer_column_vectors         "false"
  445.      prefer_zero_one_indexing      "false"
  446.      print_answer_id_name          "true"
  447.      print_empty_dimensions        "true"
  448.      resize_on_range_error         "true"
  449.      return_last_computed_value    "false"
  450.      save_precision                17
  451.      silent_functions              "false"
  452.      split_long_rows               "true"
  453.      suppress_verbose_help_message "true"
  454.      treat_neg_dim_as_zero         "false"
  455.      warn_assign_as_truth_value    "true"
  456.      warn_comma_in_global_decl     "true"
  457.      warn_divide_by_zero           "true"
  458.      warn_function_name_clash      "true"
  459.      whitespace_in_literal_matrix  ""
  460. File: octave.info,  Node: Arithmetic,  Next: Linear Algebra,  Prev: Built-in Variables,  Up: Top
  461. Arithmetic
  462. **********
  463.    Unless otherwise noted, all of the functions described in this
  464. chapter will work for real and complex scalar or matrix arguments.
  465. * Menu:
  466. * Utility Functions::
  467. * Complex Arithmetic::
  468. * Trigonometry::
  469. * Sums and Products::
  470. * Special Functions::
  471. File: octave.info,  Node: Utility Functions,  Next: Complex Arithmetic,  Prev: Arithmetic,  Up: Arithmetic
  472. Utility Functions
  473. =================
  474.    The following functions are available for working with complex
  475. numbers.  Each expects a single argument, and given a matrix, they work
  476. on an element by element basis.
  477. `ceil (X)'
  478.      Return the smallest integer not less than X.  If X is complex,
  479.      return `ceil (real (X)) + ceil (imag (X)) * I'.
  480. `floor (X)'
  481.      Return the largest integer not greater than X.  If X is complex,
  482.      return `floor (real (X)) + floor (imag (X)) * I'.
  483. `fix (X)'
  484.      Truncate X toward zero.  If X is complex, return `fix (real (X)) +
  485.      fix (imag (X)) * I'.
  486. `round (X)'
  487.      Return the integer nearest to X.  If X is complex, return `round
  488.      (real (X)) + round (imag (X)) * I'.
  489. `sign (X)'
  490.      Compute the "signum" function, which is defined as
  491.                      -1, x < 0;
  492.           sign (x) =  0, x = 0;
  493.                       1, x > 0.
  494.      For complex arguments, `sign' returns `x ./ abs (X)'.
  495. `exp (X)'
  496.      Compute the exponential of X.  To compute the matrix exponential,
  497.      see *Note Linear Algebra::.
  498. `gcd (X, `...')'
  499.      Compute the greatest common divisor of the elements of X, or the
  500.      list of all the arguments.  For example,
  501.           gcd (a1, ..., ak)
  502.      is the same as
  503.           gcd ([a1, ..., ak])
  504.      An optional second return value, V contains an integer vector such
  505.      that
  506.           g = v(1) * a(k) + ... + v(k) * a(k)
  507. `lcm (X, `...')'
  508.      Compute the least common multiple of the elements elements of X, or
  509.      the list of all the arguments.  For example,
  510.           lcm (a1, ..., ak)
  511.      is the same as
  512.           lcm ([a1, ..., ak]).
  513. `log (X)'
  514.      Compute the natural logarithm of X.  To compute the matrix
  515.      logarithm, see *Note Linear Algebra::.
  516. `log2 (X)'
  517.      Compute the base-2 logarithm of X.
  518. `log10 (X)'
  519.      Compute the base-10 logarithm of X.
  520. `sqrt (X)'
  521.      Compute the square root of X.  To compute the matrix square root,
  522.      see *Note Linear Algebra::.
  523. `max (X)'
  524.      For a vector argument, return the maximum value.  For a matrix
  525.      argument, return the maximum value from each column, as a row
  526.      vector.  Thus,
  527.           max (max (X))
  528.      returns the largest element of X.
  529.      For complex arguments, the magnitude of the elements are used for
  530.      comparison.
  531. `min (X)'
  532.      Like `max', but return the minimum value.
  533. `rem (X, Y)'
  534.      Return the remainder of `X / Y', computed using the expression
  535.           x - y .* fix (x ./ y)
  536.      An error message is printed if the dimensions of the arguments do
  537.      not agree, or if either of the arguments is complex.
  538. File: octave.info,  Node: Complex Arithmetic,  Next: Trigonometry,  Prev: Utility Functions,  Up: Arithmetic
  539. Complex Arithmetic
  540. ==================
  541.    The following functions are available for working with complex
  542. numbers.  Each expects a single argument.  Given a matrix they work on
  543. an element by element basis.
  544. `abs (X)'
  545.      Compute the magnitude of X.
  546. `angle (X)'
  547. `arg (X)'
  548.      Compute the argument of X.
  549. `conj (X)'
  550.      Return the complex conjugate of X.
  551. `imag (X)'
  552.      Return the imaginary part of X.
  553. `real (X)'
  554.      Return the real part of X.
  555. File: octave.info,  Node: Trigonometry,  Next: Sums and Products,  Prev: Complex Arithmetic,  Up: Arithmetic
  556. Trigonometry
  557. ============
  558.    Octave provides the following trigonometric functions:
  559.      sin    asin    sinh    asinh
  560.      cos    acos    cosh    acosh
  561.      tan    atan    tanh    atanh
  562.      
  563.      sec    asec    sech    asech
  564.      csc    acsc    csch    acsch
  565.      cot    acot    coth    acoth
  566. Each of these functions expect a single argument.  For matrix arguments,
  567. they work on an element by element basis.  For example, the expression
  568.      sin ([1, 2; 3, 4])
  569. produces
  570.      ans =
  571.      
  572.         0.84147   0.90930
  573.         0.14112  -0.75680
  574.    `atan2 (Y, X)'
  575. File: octave.info,  Node: Sums and Products,  Next: Special Functions,  Prev: Trigonometry,  Up: Arithmetic
  576. Sums and Products
  577. =================
  578. `sum (X)'
  579.      For a vector argument, return the sum of all the elements.  For a
  580.      matrix argument, return the sum of the elements in each column, as
  581.      a row vector.  The sum of an empty matrix is 0 if it has no
  582.      columns, or a vector of zeros if it has no rows (*note Empty
  583.      Matrices::.).
  584. `prod (X)'
  585.      For a vector argument, return the product of all the elements.
  586.      For a matrix argument, return the product of the elements in each
  587.      column, as a row vector.  The product of an empty matrix is 1 if
  588.      it has no columns, or a vector of ones if it has no rows (*note
  589.      Empty Matrices::.).
  590. `cumsum (X)'
  591.      Return the cumulative sum of each column of X.  For example,
  592.           cumsum ([1, 2; 3, 4])
  593.      produces
  594.           ans =
  595.           
  596.             1  2
  597.             4  6
  598. `cumprod (X)'
  599.      Return the cumulative product of each column of X.  For example,
  600.           cumprod ([1, 2; 3, 4])
  601.      produces
  602.           ans =
  603.           
  604.             1  2
  605.             3  8
  606. `sumsq (X)'
  607.      For a vector argument, return the sum of the squares of all the
  608.      elements.  For a matrix argument, return the sum of the squares of
  609.      the elements in each column, as a row vector.
  610. File: octave.info,  Node: Special Functions,  Prev: Sums and Products,  Up: Arithmetic
  611. Special Functions
  612. =================
  613. `beta'
  614.      Returns the beta function,
  615.           beta (a, b) = gamma (a) * gamma (b) / gamma (a + b).
  616. `betai (A, B, X)'
  617.      Returns the incomplete beta function,
  618.                                               x
  619.                                              /
  620.           betai (a, b, x) = beta (a, b)^(-1) | t^(a-1) (1-t)^(b-1) dt.
  621.                                              /
  622.                                           t=0
  623.      If x has more than one component, both A and B must be scalars.
  624.      If X is a scalar, A and B must be of compatible dimensions.
  625. `erf'
  626.      Computes the error function,
  627.                                    z
  628.                                   /
  629.           erf (z) = (2/sqrt (pi)) | e^(-t^2) dt
  630.                                   /
  631.                                t=0
  632. `erfc (Z)'
  633.      Computes the complementary error function, `1 - erf (Z)'.
  634. `erfinv'
  635.      Computes the inverse of the error function.
  636. `gamma (Z)'
  637.      Computes the gamma function,
  638.                       infinity
  639.                       /
  640.           gamma (z) = | t^(z-1) exp (-t) dt.
  641.                       /
  642.                    t=0
  643. `gammai (A, X)'
  644.      Computes the incomplete gamma function,
  645.                                         x
  646.                               1        /
  647.           gammai (a, x) = ---------    | exp (-t) t^(a-1) dt
  648.                           gamma (a)    /
  649.                                     t=0
  650.      If A is scalar, then `gammai (A, X)' is returned for each element
  651.      of X and vice versa.
  652.      If neither A nor X is scalar, the sizes of A and X must agree, and
  653.      GAMMAI is applied element-by-element.
  654. `lgamma'
  655.      Returns the natural logarithm of the gamma function.
  656. File: octave.info,  Node: Linear Algebra,  Next: Polynomial Manipulations,  Prev: Arithmetic,  Up: Top
  657. Linear Algebra
  658. **************
  659.    This chapter documents the linear algebra functions of Octave.
  660. Reference material for many of these options may be found in Golub and
  661. Van Loan, `Matrix Computations, 2nd Ed.', Johns Hopkins, 1989, and in
  662. `LAPACK Users' Guide', SIAM, 1992.
  663. * Menu:
  664. * Basic Matrix Functions::
  665. * Matrix Factorizations::
  666. * Functions of a Matrix::
  667. File: octave.info,  Node: Basic Matrix Functions,  Next: Matrix Factorizations,  Prev: Linear Algebra,  Up: Linear Algebra
  668. Basic Matrix Functions
  669. ======================
  670. `balance'
  671.           aa = balance (a, opt)
  672.           [dd, aa] =  balance(a, opt)
  673.           [dd, aa] = balance (a, opt)
  674.           [cc, dd, aa, bb] = balance (a, b, opt)
  675.      `[dd, aa] = balance (a)' returns `aa = dd \ a * dd'.  `aa' is a
  676.      matrix whose row/column norms are roughly equal in magnitude, and
  677.      `dd' = `p * d', where `p' is a permutation matrix and `d' is a
  678.      diagonal matrix of powers of two.  This allows the equilibration
  679.      to be computed without roundoff.  Results of eigenvalue
  680.      calculation are typically improved by balancing first.
  681.      `[cc, dd, aa, bb] = balance (a, b)'  returns `aa' (`bb') `=
  682.      cc*a*dd (cc*b*dd)'), where `aa' and `bb' have non-zero elements of
  683.      approximately the same magnitude and `cc' and `dd'  are permuted
  684.      diagonal matrices as in `dd' for the algebraic eigenvalue problem.
  685.      The eigenvalue balancing option `opt' is selected as follows:
  686.     `"N"', `"n"'
  687.           No balancing; arguments copied, transformation(s) set to
  688.           identity.
  689.     `"P"', `"p"'
  690.           Permute argument(s) to isolate eigenvalues where possible.
  691.     `"S"', `"s"'
  692.           Scale to improve accuracy of computed eigenvalues.
  693.     `"B"', `"b"'
  694.           Permute and scale, in that order. Rows/columns of a (and b)
  695.           that are isolated by permutation are not scaled.  This is the
  696.           default behavior.
  697.      Algebraic eigenvalue balancing uses standard LAPACK routines.
  698.      Generalized eigenvalue problem balancing uses Ward's algorithm
  699.      (SIAM Journal on Scientific and Statistical Computing, 1981).
  700. `cond (A)'
  701.      Compute the (two-norm) condition number of a matrix. `cond (a)' is
  702.      defined as `norm (a) * norm (inv (a))', and is computed via a
  703.      singular value decomposition.
  704. `det (A)'
  705.      Compute the determinant of A using LINPACK.
  706. `eig'
  707.                       = eig (a)
  708.           [v, lambda] = eig (a)
  709.      The eigenvalues (and eigenvectors) of a matrix are computed in a
  710.      several step process which begins with a Hessenberg decomposition
  711.      (see `hess'), followed by a Schur decomposition (see `schur'), from
  712.      which the eigenvalues are apparent.  The eigenvectors, when
  713.      desired, are computed by further manipulations of the Schur
  714.      decomposition.
  715.      See also: `hess', `schur'.
  716. `givens'
  717.           [c, s] = givens (x, y)
  718.           G = givens (x, y)
  719.      `G = givens(x, y)' returns a 2 x 2 orthogonal matrix `G = [c s;
  720.      -s' c]' such that `G [x; y] = [*; 0]'  (x, y scalars)
  721. `inv (A)'
  722. `inverse (A)'
  723.      Compute the inverse of the square matrix A.
  724. `norm (A, P)'
  725.      Compute the p-norm of the matrix A.  If the second argument is
  726.      missing, `p = 2' is assumed.
  727.      If A is a matrix:
  728.     P = `1'
  729.           1-norm, the largest column sum of A.
  730.     P = `2'
  731.           Largest singular value of A.
  732.     P = `Inf'
  733.           Infinity norm, the largest row sum of A.
  734.     P = `"fro"'
  735.           Frobenius norm of A, `sqrt (sum (diag (a' * a)))'.
  736.      If A is a vector or a scalar:
  737.     P = `Inf'
  738.           `max (abs (a))'.
  739.     P = `-Inf'
  740.           `min (abs (a))'.
  741.     other
  742.           p-norm of A, `(sum (abs (a) .^ p)) ^ (1/p)'.
  743. `null (A, TOL)'
  744.      Returns an orthonormal basis of the null space of A.
  745.      The dimension of the null space is taken as the number of singular
  746.      values of A not greater than TOL.  If the argument TOL is missing,
  747.      it is computed as
  748.           max (size (a)) * max (svd (a)) * eps
  749. `orth (A, TOL)'
  750.      Returns an orthonormal basis of the range of A.
  751.      The dimension of the range space is taken as the number of singular
  752.      values of A greater than TOL.  If the argument TOL is missing, it
  753.      is computed as
  754.           max (size (a)) * max (svd (a)) * eps
  755. `pinv (X, TOL)'
  756.      Returns the pseudoinverse of X.  Singular values less than TOL are
  757.      ignored.
  758.      If the second argument is omitted, it is assumed that
  759.           tol = max (size (X)) * sigma_max (X) * eps,
  760.      where `sigma_max (X)' is the maximal singular value of X.
  761. `rank (A, TOL)'
  762.      Compute the rank of A, using the singular value decomposition.
  763.      The rank is taken to be the number  of singular values of A that
  764.      are greater than the specified tolerance TOL.  If the second
  765.      argument is omitted, it is taken to be
  766.           tol =  max (size (a)) * sigma (1) * eps;
  767.      where `eps' is machine precision and `sigma' is the largest
  768.      singular value of `a'.
  769. `trace (A)'
  770.      Compute the trace of A, `sum (diag (a))'.
  771. File: octave.info,  Node: Matrix Factorizations,  Next: Functions of a Matrix,  Prev: Basic Matrix Functions,  Up: Linear Algebra
  772. Matrix Factorizations
  773. =====================
  774. `chol (A)'
  775.      Compute the Cholesky factor, R, of the symmetric positive definite
  776.      matrix A, where
  777.           r' * r = a.
  778. `hess (A)'
  779.      Compute the Hessenberg decomposition of the matrix A.
  780.                h = hess (a)
  781.           [p, h] = hess (a)
  782.      The Hessenberg decomposition is usually used as the first step in
  783.      an eigenvalue computation, but has other applications as well (see
  784.      Golub, Nash, and Van Loan, IEEE Transactions on Automatic Control,
  785.      1979.  The Hessenberg decomposition is `p * h * p' = a' where `p'
  786.      is a square unitary matrix (`p' * p = I', using complex-conjugate
  787.      transposition) and `h' is upper Hessenberg (`i >= j+1 => h (i, j)
  788.      = 0').
  789. `lu (A)'
  790.      Compute the LU decomposition of A, using subroutines from LAPACK.
  791.      The result is returned in a permuted form, according to the
  792.      optional return value P.  For example, given the matrix `a = [1,
  793.      2; 3, 4]',
  794.           [l, u, p] = lu (a)
  795.      returns
  796.           l =
  797.           
  798.             1.00000  0.00000
  799.             0.33333  1.00000
  800.           
  801.           u =
  802.           
  803.             3.00000  4.00000
  804.             0.00000  0.66667
  805.           
  806.           p =
  807.           
  808.             0  1
  809.             1  0
  810. `qr (A)'
  811.      Compute the QR factorization of A, using standard LAPACK
  812.      subroutines.  For example, given the matrix `a = [1, 2; 3, 4]',
  813.           [q, r] = qr (a)
  814.      returns
  815.           q =
  816.           
  817.             -0.31623  -0.94868
  818.             -0.94868   0.31623
  819.           
  820.           r =
  821.           
  822.             -3.16228  -4.42719
  823.              0.00000  -0.63246
  824.      The `qr' factorization has applications in the solution of least
  825.      squares problems
  826.           `min norm(A x - b)'
  827.      for overdetermined systems of equations (i.e., `a'  is a tall,
  828.      thin matrix).  The `qr' factorization is `q * r = a' where `q' is
  829.      an orthogonal matrix and `r' is upper triangular.
  830.      The permuted `qr' factorization `[q, r, pi] = qr (a)' forms the
  831.      `qr' factorization such that the diagonal entries of `r' are
  832.      decreasing in magnitude order.  For example, given the matrix `a =
  833.      [1, 2; 3, 4]',
  834.           [q, r, pi] = qr(a)
  835.      returns
  836.           q =
  837.           
  838.             -0.44721  -0.89443
  839.             -0.89443   0.44721
  840.           
  841.           r =
  842.           
  843.             -4.47214  -3.13050
  844.              0.00000   0.44721
  845.           
  846.           p =
  847.           
  848.              0  1
  849.              1  0
  850.      The permuted `qr' factorization `[q, r, pi] = qr (a)'
  851.      factorization allows the construction of an orthogonal basis of
  852.      `span (a)'.
  853. `schur'
  854.           [u, s] = schur (a, opt)   opt = "a", "d", or "u"
  855.                s = schur (a)
  856.      The Schur decomposition is used to compute eigenvalues of a square
  857.      matrix, and has applications in the solution of algebraic Riccati
  858.      equations in control (see `are' and `dare').  `schur' always
  859.      returns `s = u' * a * u' where `u'  is a unitary matrix (`u'* u'
  860.      is identity) and `s' is upper triangular.  The eigenvalues of `a'
  861.      (and `s') are the diagonal elements of `s' If the matrix `a' is
  862.      real, then the real Schur decomposition is computed, in which the
  863.      matrix `u' is orthogonal and `s' is block upper triangular with
  864.      blocks of size at most `2 x 2' blocks along the diagonal.  The
  865.      diagonal elements of `s' (or the eigenvalues of the `2 x 2'
  866.      blocks, when appropriate) are the eigenvalues of `a' and `s'.
  867.      The eigenvalues are optionally ordered along the diagonal
  868.      according to the value of `opt'.  `opt = "a"' indicates that all
  869.      eigenvalues with negative real parts should be moved to the leading
  870.      block of `s' (used in `are'), `opt = "d"' indicates that all
  871.      eigenvalues with magnitude less than one should be moved to the
  872.      leading block of `s' (used in `dare'), and `opt = "u"', the
  873.      default, indicates that no ordering of eigenvalues should occur.
  874.      The leading `k' columns of `u' always span the `a'-invariant
  875.      subspace corresponding to the `k' leading eigenvalues of `s'.
  876. `svd (A)'
  877.      Compute the singular value decomposition of A
  878.           a = u * sigma * v'
  879.      The function `svd' normally returns the vector of singular values.
  880.      If asked for three return values, it computes U, S, and V.  For
  881.      example,
  882.           svd (hilb (3))
  883.      returns
  884.           ans =
  885.           
  886.             1.4083189
  887.             0.1223271
  888.             0.0026873
  889.      and
  890.           [u, s, v] = svd (hilb (3))
  891.      returns
  892.           u =
  893.           
  894.             -0.82704   0.54745   0.12766
  895.             -0.45986  -0.52829  -0.71375
  896.             -0.32330  -0.64901   0.68867
  897.           
  898.           s =
  899.           
  900.             1.40832  0.00000  0.00000
  901.             0.00000  0.12233  0.00000
  902.             0.00000  0.00000  0.00269
  903.           
  904.           v =
  905.           
  906.             -0.82704   0.54745   0.12766
  907.             -0.45986  -0.52829  -0.71375
  908.             -0.32330  -0.64901   0.68867
  909.      If given a second argument, `svd' returns an economy-sized
  910.      decomposition, eliminating the unnecessary rows or columns of U or
  911.      V.
  912. File: octave.info,  Node: Functions of a Matrix,  Prev: Matrix Factorizations,  Up: Linear Algebra
  913. Functions of a Matrix
  914. =====================
  915. `expm'
  916.           expm (a)
  917.      Returns the exponential of a matrix, defined as the infinite
  918.      Taylor series
  919.           expm(a) = I + a + a^2/2! + a^3/3! + ...
  920.      The Taylor series is *not* the way to compute the matrix
  921.      exponential; see Moler and Van Loan, `Nineteen Dubious Ways to
  922.      Compute the Exponential of a Matrix', SIAM Review, 1978.  This
  923.      routine uses Ward's diagonal Pade' approximation method with three
  924.      step preconditioning (SIAM Journal on Numerical Analysis, 1977).
  925.      Diagonal Pade'  approximations are rational polynomials of matrices
  926.                -1
  927.           D (a)   N (a)
  928.      whose Taylor series matches the first `2q+1' terms of the Taylor
  929.      series above; direct evaluation of the Taylor series (with the
  930.      same preconditioning steps) may be desirable in lieu of the Pade'
  931.      approximation when `Dq(a)' is ill-conditioned.
  932. `logm (A)'
  933.      Compute the matrix logarithm of the square matrix A.  Note that
  934.      this is currently implemented in terms of an eigenvalue expansion
  935.      and needs to be improved to be more robust.
  936. `sqrtm (A)'
  937.      Compute the matrix square root of the square matrix A.  Note that
  938.      this is currently implemented in terms of an eigenvalue expansion
  939.      and needs to be improved to be more robust.
  940. `kron (A, B)'
  941.      Form the kronecker product of two matrices, defined block by block
  942.      as
  943.           x = [a(i, j) b]
  944. `qzhess (A, B)'
  945.      Compute the Hessenberg-triangular decomposition of the matrix
  946.      pencil `(a, b)'.  This function returns `aa = q * a * z', `bb = q
  947.      * b * z', `q', `z' orthogonal.  For example,
  948.           [aa, bb, q, z] = qzhess (a, b)
  949.      The Hessenberg-triangular decomposition is the first step in Moler
  950.      and Stewart's QZ decomposition algorithm.  (The QZ decomposition
  951.      will be included in a later release of Octave.)
  952.      Algorithm taken from Golub and Van Loan, `Matrix Computations, 2nd
  953.      edition'.
  954. `qzval (A, B)'
  955.      Compute generalized eigenvalues.
  956. `syl (A, B, C)'
  957.      Solve the Sylvester equation
  958.           A X + X B + C = 0
  959.      using standard LAPACK subroutines.
  960. File: octave.info,  Node: Polynomial Manipulations,  Next: Nonlinear Equations,  Prev: Linear Algebra,  Up: Top
  961. Polynomial Manipulations
  962. ************************
  963.    In Octave, a polynomial is represented by its coefficients (arranged
  964. in descending order).  For example, a vector C of length N+1
  965. corresponds to the following N-th order polynomial
  966.      p(x) = c(1) x^n + ... + c(n) x + c(n+1).
  967. `compan (C)'
  968.      Compute the companion matrix corresponding to polynomial
  969.      coefficient vector C.
  970.      The companion matrix is
  971.                _                                                        _
  972.               |  -c(2)/c(1)   -c(3)/c(1)  ...  -c(n)/c(1)  -c(n+1)/c(1)  |
  973.               |       1            0      ...       0             0      |
  974.               |       0            1      ...       0             0      |
  975.           A = |       .            .   .            .             .      |
  976.               |       .            .       .        .             .      |
  977.               |       .            .           .    .             .      |
  978.               |_      0            0      ...       1             0     _|
  979.      The eigenvalues of the companion matrix are equal to the roots of
  980.      the polynomial.
  981. `conv (A, B)'
  982.      Convolve two vectors.
  983.      `y = conv (a, b)' returns a vector of length equal to `length (a)
  984.      + length (b) - 1'.  If A and B are polynomial coefficient vectors,
  985.      `conv' returns the coefficients of the product polynomial.
  986. `deconv (Y, A)'
  987.      Deconvolve two vectors.
  988.      `[b, r] = deconv (y, a)' solves for B and R such that `y = conv
  989.      (a, b) + r'.
  990.      If Y and A are polynomial coefficient vectors, B will contain the
  991.      coefficients of the polynomial quotient and R will be a remander
  992.      polynomial of lowest order.
  993. `poly (A)'
  994.      If A is a square N-by-N matrix, `poly (A)' is the row vector of
  995.      the coefficients of `det (z * eye (n) - a)', the characteristic
  996.      polynomial of A.  If X is a vector, `poly (X)' is a vector of
  997.      coefficients of the polynomial whose roots are the elements of X.
  998. `polyderiv (C)'
  999.      Returns the coefficients of the derivative of the polynomial whose
  1000.      coefficients are given by vector C.
  1001. `polyinteg (C)'
  1002.      Returns the coefficients of the integral the polynomial whose
  1003.      coefficients are represented by the vector C.
  1004.      The constant of integration is set to zero.
  1005. `polyreduce (C)'
  1006.      Reduces a polynomial coefficient vector to a minimum number of
  1007.      terms by stripping off any leading zeros.
  1008. `polyval (C, X)'
  1009.      Evaluate a polynomial.
  1010.      `polyval (C, X)' will evaluate the polynomial at the specified
  1011.      value of X.
  1012.      If X is a vector or matrix, the polynomial is evaluated at each of
  1013.      the elements of X.
  1014. `polyvalm (C, X)'
  1015.      Evaluate a polynomial in the matrix sense.
  1016.      `polyvalm (C, X)' will evaluate the polynomial in the matrix
  1017.      sense, i.e. matrix multiplication is used instead of element by
  1018.      element multiplication as is used in polyval.
  1019.      The argument X must be a square matrix.
  1020. `residue (B, A, TOL)'
  1021.      If B and A are vectors of polynomial coefficients, then residue
  1022.      calculates the partial fraction expansion corresponding to the
  1023.      ratio of the two polynomials.
  1024.      The function `residue' returns R, P, K, and E, where the vector R
  1025.      contains the residue terms, P contains the pole values, K contains
  1026.      the coefficients of a direct polynomial term (if it exists) and E
  1027.      is a vector containing the powers of the denominators in the
  1028.      partial fraction terms.
  1029.      Assuming B and A represent polynomials  P (s) and Q(s)  we have:
  1030.            P(s)    M       r(m)         N
  1031.            ---- = SUM -------------  + SUM k(n)*s^(N-n)
  1032.            Q(s)   m=1 (s-p(m))^e(m)    n=1
  1033.      where M is the number of poles (the length of the R, P, and E
  1034.      vectors) and N is the length of the K vector.
  1035.      The argument TOL is optional, and if not specified, a default
  1036.      value of 0.001 is assumed.  The tolerance value is used to
  1037.      determine whether poles with small imaginary components are
  1038.      declared real.  It is also used to determine if two poles are
  1039.      distinct.  If the ratio of the imaginary part of a pole to the
  1040.      real part is less than TOL, the imaginary part is discarded.  If
  1041.      two poles are farther apart than TOL they are distinct.  For
  1042.      example,
  1043.      Example:
  1044.            b = [1, 1, 1];
  1045.            a = [1, -5, 8, -4];
  1046.           
  1047.            [r, p, k, e] = residue (b, a)
  1048.      returns
  1049.           r = [-2, 7, 3]
  1050.           
  1051.           p = [2, 2, 1]
  1052.           
  1053.           k = [](0x0)
  1054.           
  1055.           e = [1, 2, 1]
  1056.      which implies the following partial fraction expansion
  1057.                   s^2 + s + 1       -2        7        3
  1058.              ------------------- = ----- + ------- + -----
  1059.              s^3 - 5s^2 + 8s - 4   (s-2)   (s-2)^2   (s-1)
  1060. `roots (V)'
  1061.      For a vector V with N components, return the roots of the
  1062.      polynomial
  1063.           v(1) * z^(n-1) + ... + v(n-1) * z + v(n).
  1064. File: octave.info,  Node: Nonlinear Equations,  Next: Differential Equations,  Prev: Polynomial Manipulations,  Up: Top
  1065. Nonlinear Equations
  1066. *******************
  1067.    Octave can solve sets of nonlinear equations of the form
  1068.      F (x) = 0
  1069. using the function `fsolve', which is based on the MINPACK subroutine
  1070. `hybrd'.
  1071.    For example, to solve the set of equations
  1072.      -2x^2 + 3xy   + 4 sin(y) = 6
  1073.       3x^2 - 2xy^2 + 3 cos(x) = -4
  1074. you first need to write a function to compute the value of the given
  1075. function.  For example:
  1076.      function y = f (x)
  1077.      
  1078.        y(1) = -2*x(1)^2 + 3*x(1)*x(2)   + 4*sin(x(2)) - 6;
  1079.        y(2) =  3*x(1)^2 - 2*x(1)*x(2)^2 + 3*cos(x(1)) + 4;
  1080.      
  1081.      endfunction
  1082.    Then, call `fsolve' with a specified initial condition to find the
  1083. roots of the system of equations.  For example, given the function `f'
  1084. defined above,
  1085.      [x, info] = fsolve ("f", [1; 2])
  1086. results in the solution
  1087.      x =
  1088.      
  1089.        0.57983
  1090.        2.54621
  1091.      
  1092.      info = 1
  1093.    A value of `info = 1' indicates that the solution has converged.
  1094.    The function `perror' may be used to print English messages
  1095. corresponding to the numeric error codes.  For example,
  1096.      perror ("fsolve", 1)
  1097. prints
  1098.      solution converged to requested tolerance
  1099.    Tolerances and other options for `fsolve' may be specified using the
  1100. function `fsolve_options'.
  1101. File: octave.info,  Node: Differential Equations,  Next: Optimization,  Prev: Nonlinear Equations,  Up: Top
  1102. Differential Equations
  1103. **********************
  1104.    Octave has two built-in functions for solving differential equations.
  1105. Both are based on reliable ODE solvers written in Fortran.
  1106. * Menu:
  1107. * Ordinary Differential Equations::
  1108. * Differential-Algebraic Equations::
  1109.