/usr/share/doc/octave-optim/html/polyfitinf.html is in octave-optim 1.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | <html lang="en">
<head>
<title>polyfitinf - optim_doc</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="optim_doc">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Residual-optimization.html#Residual-optimization" title="Residual optimization">
<link rel="prev" href="expfit.html#expfit" title="expfit">
<link rel="next" href="wpolyfit.html#wpolyfit" title="wpolyfit">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Additional documentation for the optim package for Octave.
Copyright (C) <Olaf Till <i7tiol@t-online.de>>
You can redistribute this documentation and/or modify it under the terms
of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any
later version.
This documentation is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.
You should have received a copy of the GNU General Public License along
with this documentation; if not, see <http://www.gnu.org/licenses/>.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="polyfitinf"></a>
<p>
Next: <a rel="next" accesskey="n" href="wpolyfit.html#wpolyfit">wpolyfit</a>,
Previous: <a rel="previous" accesskey="p" href="expfit.html#expfit">expfit</a>,
Up: <a rel="up" accesskey="u" href="Residual-optimization.html#Residual-optimization">Residual optimization</a>
<hr>
</div>
<h3 class="section">2.9 Function polyfitinf for polynomial fitting.</h3>
<p><a name="index-polyfitinf-53"></a>
<h4 class="subheading">Helptext:</h4>
<p><a name="XREFpolyfitinf"></a>
<pre class="verbatim">function [A,REF,HMAX,H,R,EQUAL] = polyfitinf(M,N,K,X,Y,EPSH,MAXIT,REF0)
Best polynomial approximation in discrete uniform norm
INPUT VARIABLES:
M : degree of the fitting polynomial
N : number of data points
X(N) : x-coordinates of data points
Y(N) : y-coordinates of data points
K : character of the polynomial:
K = 0 : mixed parity polynomial
K = 1 : odd polynomial ( X(1) must be > 0 )
K = 2 : even polynomial ( X(1) must be >= 0 )
EPSH : tolerance for leveling. A useful value for 24-bit
mantissa is EPSH = 2.0E-7
MAXIT : upper limit for number of exchange steps
REF0(M2): initial alternating set ( N-vector ). This is an
OPTIONAL argument. The length M2 is given by:
M2 = M + 2 , if K = 0
M2 = integer part of (M+3)/2 , if K = 1
M2 = 2 + M/2 (M must be even) , if K = 2
OUTPUT VARIABLES:
A : polynomial coefficients of the best approximation
in order of increasing powers:
p*(x) = A(1) + A(2)*x + A(3)*x^2 + ...
REF : selected alternating set of points
HMAX : maximum deviation ( uniform norm of p* - f )
H : pointwise approximation errors
R : total number of iterations
EQUAL : success of failure of algorithm
EQUAL=1 : succesful
EQUAL=0 : convergence not acheived
EQUAL=-1: input error
EQUAL=-2: algorithm failure
Relies on function EXCH, provided below.
Example:
M = 5; N = 10000; K = 0; EPSH = 10^-12; MAXIT = 10;
X = linspace(-1,1,N); % uniformly spaced nodes on [-1,1]
k=1; Y = abs(X).^k; % the function Y to approximate
[A,REF,HMAX,H,R,EQUAL] = polyfitinf(M,N,K,X,Y,EPSH,MAXIT);
p = polyval(A,X); plot(X,Y,X,p) % p is the best approximation
Note: using an even value of M, e.g., M=2, in the example above, makes
the algorithm to fail with EQUAL=-2, because of collocation, which
appears because both the appriximating function and the polynomial are
even functions. The way aroung it is to approximate only the right half
of the function, setting K = 2 : even polynomial. For example:
N = 10000; K = 2; EPSH = 10^-12; MAXIT = 10; X = linspace(0,1,N);
for i = 1:2
k = 2*i-1; Y = abs(X).^k;
for j = 1:4
M = 2^j;
[~,~,HMAX] = polyfitinf(M,N,K,X,Y,EPSH,MAXIT);
approxerror(i,j) = HMAX;
end
end
disp('Table 3.1 from Approximation theory and methods, M.J.D.POWELL, p. 27');
disp(' ');
disp(' n K=1 K=3');
disp(' '); format short g;
disp([(2.^(1:4))' approxerror']);
ALGORITHM:
Computation of the polynomial that best approximates the data (X,Y)
in the discrete uniform norm, i.e. the polynomial with the minimum
value of max{ | p(x_i) - y_i | , x_i in X } . That polynomial, also
known as minimax polynomial, is obtained by the exchange algorithm,
a finite iterative process requiring, at most,
n
( ) iterations ( usually p = M + 2. See also function EXCH ).
p
since this number can be very large , the routine may not converge
within MAXIT iterations . The other possibility of failure occurs
when there is insufficient floating point precision for the input
data chosen.
CREDITS: This routine was developed and modified as
computer assignments in Approximation Theory courses by
Prof. Andrew Knyazev, University of Colorado Denver, USA.
Team Fall 98 (Revision 1.0):
Chanchai Aniwathananon
Crhistopher Mehl
David A. Duran
Saulo P. Oliveira
Team Spring 11 (Revision 1.1): Manuchehr Aminian
The algorithm and the comments are based on a FORTRAN code written
by Joseph C. Simpson. The code is available on Netlib repository:
http://www.netlib.org/toms/501
See also: Communications of the ACM, V14, pp.355-356(1971)
NOTES:
1) A may contain the collocation polynomial
2) If MAXIT is exceeded, REF contains a new reference set
3) M, EPSH and REF can be altered during the execution
4) To keep consistency to the original code , EPSH can be
negative. However, the use of REF0 is *NOT* determined by
EPSH< 0, but only by its inclusion as an input parameter.
Some parts of the code can still take advantage of vectorization.
Revision 1.0 from 1998 is a direct human translation of
the FORTRAN code http://www.netlib.org/toms/501
Revision 1.1 is a clean-up and technical update.
Tested on MATLAB Version 7.11.0.584 (R2010b) and
GNU Octave Version 3.2.4
</pre>
<!-- -->
</body></html>
|