Mercurial > hg > octave-nkf
annotate doc/interpreter/poly.txi @ 8828:8463d1a2e544
Doc fixes.
* 2]$$. => 2].$$
* @var{extrapval} => @var{extrapval}.
* call helloworld.oct => called @file{helloworld.oct}
* @itemize => @table @code
* shows. => shows:
* save => @code{save}
* @ref{Breakpoints} => @pxref{Breakpoints}
* add @noindent following example
* which is computed => and compute it
* clarify wording
* remove comma
* good => well
* set => number
* by writing => with the command
* has the option of directly calling => can call
* [-like-] {+of the right size,+}
* solvers => routines
* handle => test for
* add introductory section
* add following
* {+the+} [0..bitmax] => [0,bitmax]
* of the => with
* number => value
* add usual
* Besides when doing comparisons, logical => Logical {+also+}
* array comparison => array, comparisons
* param => parameter
* works very similar => is similar
* strings, => strings
* most simple => simplest
* easier => more easily
* like => as
* called => called,
* clarify wording
* you should simply type => use
* clarify wording
* means => way
* equally => also
* [-way much-] {+way+}
* add with mean value parameter given by the first argument, @var{l}
* add Functions described as @dfn{mapping functions} apply the given
operation to each element when given a matrix argument.
* in this brief introduction => here
* It is worth noticing => Note
* add following
* means => ways
author | Brian Gough <bjg@network-theory.co.uk> |
---|---|
date | Fri, 20 Feb 2009 11:17:01 -0500 |
parents | 6f2d95255911 |
children | eb63fbe60fab |
rev | line source |
---|---|
7018 | 1 @c Copyright (C) 1996, 1997, 1999, 2000, 2002, 2007 John W. Eaton |
2 @c | |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
9 @c | |
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT | |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
14 @c | |
15 @c You should have received a copy of the GNU General Public License | |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
3294 | 18 |
4167 | 19 @node Polynomial Manipulations |
3294 | 20 @chapter Polynomial Manipulations |
21 | |
22 In Octave, a polynomial is represented by its coefficients (arranged | |
6850 | 23 in descending order). For example, a vector @var{c} of length |
24 @math{N+1} corresponds to the following polynomial of order | |
3294 | 25 @iftex |
26 @tex | |
27 $N$ | |
28 $$ | |
6850 | 29 p (x) = c_1 x^N + \ldots + c_N x + c_{N+1}. |
3294 | 30 $$ |
31 @end tex | |
32 @end iftex | |
33 @ifinfo | |
34 @var{N} | |
35 | |
36 @example | |
37 p(x) = @var{c}(1) x^@var{N} + ... + @var{c}(@var{N}) x + @var{c}(@var{N}+1). | |
38 @end example | |
39 @end ifinfo | |
40 | |
6850 | 41 @menu |
42 * Evaluating Polynomials:: | |
43 * Finding Roots:: | |
44 * Products of Polynomials:: | |
45 * Derivatives and Integrals:: | |
46 * Polynomial Interpolation:: | |
47 * Miscellaneous Functions:: | |
48 @end menu | |
49 | |
50 @node Evaluating Polynomials | |
51 @section Evaluating Polynomials | |
52 | |
53 The value of a polynomial represented by the vector @var{c} can be evaluated | |
8828 | 54 at the point @var{x} very easily, as the following example shows: |
6850 | 55 |
56 @example | |
57 N = length(c)-1; | |
58 val = dot( x.^(N:-1:0), c ); | |
59 @end example | |
60 | |
61 @noindent | |
62 While the above example shows how easy it is to compute the value of a | |
63 polynomial, it isn't the most stable algorithm. With larger polynomials | |
64 you should use more elegant algorithms, such as Horner's Method, which | |
65 is exactly what the Octave function @code{polyval} does. | |
66 | |
67 In the case where @var{x} is a square matrix, the polynomial given by | |
68 @var{c} is still well-defined. As when @var{x} is a scalar the obvious | |
69 implementation is easily expressed in Octave, but also in this case | |
70 more elegant algorithms perform better. The @code{polyvalm} function | |
71 provides such an algorithm. | |
72 | |
73 @DOCSTRING(polyval) | |
74 | |
75 @DOCSTRING(polyvalm) | |
76 | |
77 @node Finding Roots | |
78 @section Finding Roots | |
79 | |
80 Octave can find the roots of a given polynomial. This is done by computing | |
81 the companion matrix of the polynomial (see the @code{compan} function | |
82 for a definition), and then finding its eigenvalues. | |
83 | |
84 @DOCSTRING(roots) | |
85 | |
3368 | 86 @DOCSTRING(compan) |
3294 | 87 |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7640
diff
changeset
|
88 @DOCSTRING(mpoles) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7640
diff
changeset
|
89 |
6850 | 90 @node Products of Polynomials |
91 @section Products of Polynomials | |
92 | |
3368 | 93 @DOCSTRING(conv) |
3294 | 94 |
7640 | 95 @DOCSTRING(convn) |
96 | |
3368 | 97 @DOCSTRING(deconv) |
3294 | 98 |
6549 | 99 @DOCSTRING(conv2) |
100 | |
6850 | 101 @DOCSTRING(polygcd) |
102 | |
103 @DOCSTRING(residue) | |
104 | |
105 @node Derivatives and Integrals | |
106 @section Derivatives and Integrals | |
107 | |
108 Octave comes with functions for computing the derivative and the integral | |
6898 | 109 of a polynomial. The functions @code{polyderiv} and @code{polyint} |
6850 | 110 both return new polynomials describing the result. As an example we'll |
111 compute the definite integral of @math{p(x) = x^2 + 1} from 0 to 3. | |
112 | |
113 @example | |
114 c = [1, 0, 1]; | |
6898 | 115 integral = polyint(c); |
6850 | 116 area = polyval(integral, 3) - polyval(integral, 0) |
117 @result{} 12 | |
118 @end example | |
3294 | 119 |
3368 | 120 @DOCSTRING(polyderiv) |
3294 | 121 |
6502 | 122 @DOCSTRING(polyder) |
123 | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7640
diff
changeset
|
124 @DOCSTRING(polyinteg) |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7640
diff
changeset
|
125 |
6898 | 126 @DOCSTRING(polyint) |
3294 | 127 |
6850 | 128 @node Polynomial Interpolation |
129 @section Polynomial Interpolation | |
3294 | 130 |
6850 | 131 Octave comes with good support for various kinds of interpolation, |
132 most of which are described in @ref{Interpolation}. One simple alternative | |
133 to the functions described in the aforementioned chapter, is to fit | |
134 a single polynomial to some given data points. To avoid a highly | |
135 fluctuating polynomial, one most often wants to fit a low-order polynomial | |
136 to data. This usually means that it is necessary to fit the polynomial | |
137 in a least-squares sense, which is what the @code{polyfit} function does. | |
3294 | 138 |
6850 | 139 @DOCSTRING(polyfit) |
3294 | 140 |
6850 | 141 In situations where a single polynomial isn't good enough, a solution |
142 is to use several polynomials pieced together. The function @code{mkpp} | |
143 creates a piece-wise polynomial, @code{ppval} evaluates the function | |
144 created by @code{mkpp}, and @code{unmkpp} returns detailed information | |
145 about the function. | |
146 | |
147 The following example shows how to combine two linear functions and a | |
7001 | 148 quadratic into one function. Each of these functions is expressed |
6850 | 149 on adjoined intervals. |
3294 | 150 |
6850 | 151 @example |
152 x = [-2, -1, 1, 2]; | |
153 p = [ 0, 1, 0; | |
154 1, -2, 1; | |
155 0, -1, 1 ]; | |
156 pp = mkpp(x, p); | |
157 xi = linspace(-2, 2, 50); | |
158 yi = ppval(pp, xi); | |
159 plot(xi, yi); | |
160 @end example | |
6502 | 161 |
162 @DOCSTRING(ppval) | |
163 | |
164 @DOCSTRING(mkpp) | |
165 | |
166 @DOCSTRING(unmkpp) | |
6850 | 167 |
168 @node Miscellaneous Functions | |
169 @section Miscellaneous Functions | |
170 | |
171 @DOCSTRING(poly) | |
172 | |
173 @DOCSTRING(polyout) | |
174 | |
175 @DOCSTRING(polyreduce) | |
176 | |
177 | |
8286
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7640
diff
changeset
|
178 |
6f2d95255911
fix @seealso references to point to existing anchors
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7640
diff
changeset
|
179 |