home *** CD-ROM | disk | FTP | other *** search
/ Dream 60 / Amiga_Dream_60.iso / RedHat / RPMS / gsl-0.3b-4.i386.rpm / gsl-0.3b.4.cpio.gz / gsl-0.3b.4.cpio / usr / info / gsl-ref.info-2 (.txt) < prev    next >
GNU Info File  |  1998-09-11  |  51KB  |  953 lines

  1. This is Info file gsl-ref.info, produced by Makeinfo version 1.67 from
  2. the input file gsl-ref.texi.
  3. INFO-DIR-SECTION Scientific software
  4. START-INFO-DIR-ENTRY
  5. * gsl-ref: (gsl-ref).                   GNU Scientific Library - Reference
  6. END-INFO-DIR-ENTRY
  7.    This file documents the *GNU Scientific Library*.
  8.    Copyright (C) 1996, 1997, 1998 The GSL Project.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20. File: gsl-ref.info,  Node: Example of using mixed-radix FFT routines for complex data,  Prev: Mixed-radix FFT routines for complex data,  Up: FFTs of complex data
  21. Example of using mixed-radix FFT routines for complex data
  22. ----------------------------------------------------------
  23.    Here is an example program which computes the FFT of a short pulse
  24. in a sample of length 630 (=2*3*3*5*7) using the mixed-radix algorithm.
  25.      #include <stdio.h>
  26.      #include <math.h>
  27.      #include <gsl_errno.h>
  28.      #include <gsl_fft_complex.h>
  29.      
  30.      int main ()
  31.      {
  32.        int i;
  33.        const int n = 630 ;
  34.        complex data[n];
  35.      
  36.        gsl_fft_complex_wavetable wavetable;
  37.      
  38.        for (i = 0; i < n; i++)
  39.          {
  40.            data[i].real = 0.0 ;
  41.            data[i].imag = 0.0 ;
  42.          }
  43.      
  44.        data[0].real = 1.0 ;
  45.      
  46.        for (i = 1; i <= 10; i++)
  47.          {
  48.            data[i].real = data[n-i].real = 1.0 ;
  49.          }
  50.      
  51.        for (i = 0; i < n; i++)
  52.          {
  53.            printf ("%d: %e %e\n", i, data[i].real, data[i].imag);
  54.          }
  55.        printf ("\n");
  56.      
  57.        gsl_fft_complex_wavetable_alloc (n, &wavetable);
  58.        gsl_fft_complex_init (n, &wavetable);
  59.      
  60.        for (i = 0; i < wavetable.nf; i++)
  61.          {
  62.             printf("# factor %d: %d\n", i, wavetable.factor[i]);
  63.          }
  64.      
  65.        gsl_fft_complex_forward (data, n, &wavetable);
  66.      
  67.        for (i = 0; i < n; i++)
  68.          {
  69.            printf ("%d: %e %e\n", i, data[i].real, data[i].imag);
  70.          }
  71.      
  72.        gsl_fft_complex_wavetable_free (&wavetable);
  73.      
  74.      }
  75. Note that we have assumed that the program is using the default `gsl'
  76. error handler (which calls `abort' for any errors).  If you are not
  77. using a safe error handler you would need to check the return status of
  78. of all the `gsl' routines.
  79. File: gsl-ref.info,  Node: FFTs of real data,  Next: Test Signals,  Prev: FFTs of complex data,  Up: FFTs
  80. FFTs of real data
  81. =================
  82.    The functions for real data are similar to those for complex data.
  83. However, there is an important difference between forward and inverse
  84. transforms. The fourier transform of a real sequence is not real. It is
  85. a complex sequence with a special symmetry:
  86.      z_k = z_{N-k}^*
  87. A sequence with this symmetry is called "conjugate-complex" or
  88. "half-complex". This different structure requires different
  89. storage-layouts for the forward transform (from real to half-complex)
  90. and inverse transform (from half-complex back to real).  As a
  91. consequence the routines are divided into two sets: functions in
  92. `gsl_fft_real' which operate on real sequences and functions in
  93. `gsl_fft_halfcomplex' which operate on half-complex sequences.
  94.    Functions in `gsl_fft_real' compute the frequency coefficients of a
  95. real sequence. The half-complex coefficients c of a real sequence x are
  96. given by fourier analysis,
  97.      c_k = \sum_{j=0}^{N-1} x_k \exp(-2 \pi i j k /N)
  98. Functions in `gsl_fft_halfcomplex' compute inverse or backwards
  99. transforms. They reconstruct real sequences by fourier synthesis from
  100. their half-complex frequency coefficients, c,
  101.      x_j = {1 \over N} \sum_{k=0}^{N-1} c_k \exp(2 \pi i j k /N)
  102. The symmetry of the half-complex sequence implies that only half of the
  103. complex numbers in the output need to be stored. The remaining half can
  104. be reconstructed using the half-complex symmetry condition. (This works
  105. for all lengths, even and odd. When the length is even the middle value,
  106. where k=N/2, is also real). Thus only N real numbers are required to
  107. store the half-complex sequence, and the transform of a real sequence
  108. can be stored in the same size array as the original data.
  109.    The precise storage arrangements depend on the algorithm, and are
  110. different for radix-2 and mixed-radix routines. The radix-2 function
  111. operates in-place, which constrain the locations where each element can
  112. be stored. The restriction forces real and imaginary parts to be stored
  113. far apart. The mixed-radix algorithm does not have this restriction, and
  114. it stores the real and imaginary parts of a given term in neighboring
  115. locations. This is desirable for better locality of memory accesses.
  116. * Menu:
  117. * Radix-2 FFT routines for real data::
  118. * Mixed-radix FFT routines for real data::
  119. * Example of using mixed-radix FFT routines for real data::
  120. File: gsl-ref.info,  Node: Radix-2 FFT routines for real data,  Next: Mixed-radix FFT routines for real data,  Up: FFTs of real data
  121. Radix-2 FFT routines for real data
  122. ----------------------------------
  123.    This section describes radix-2 FFT algorithms for real data. They use
  124. the Cooley-Tukey algorithm to compute in-place FFTs for lengths which
  125. are a power of 2.
  126.    The radix-2 FFT functions for real data are declared in the header
  127. files `gsl_fft_real.h'
  128.  - Function: int gsl_fft_real_radix2 (double data[], const unsigned int
  129.           n)
  130.      This function computes an in-place radix-2 FFT of DATA, a real
  131.      array of length N. The output is a half-complex sequence, which is
  132.      stored in-place. The arrangement of the half-complex terms uses the
  133.      following scheme: for k < N/2 the real part of the k-th term is
  134.      stored in location k, and the corresponding imaginary part is
  135.      stored in location N-k. Terms with k > N/2 can be reconstructed
  136.      using the symmetry z_k = z^*_{N-k}. The terms for k=0 and k=N/2
  137.      are both purely real, and count as a special case. Their real
  138.      parts are stored in locations 0 and N/2 respectively, while their
  139.      imaginary parts which are zero are not stored.
  140.      The following table shows the correspondence between the output
  141.      DATA and the equivalent results obtained by considering the input
  142.      data as a complex sequence with zero imaginary part,
  143.           complex[0].real    =    data[0]
  144.           complex[0].imag    =    0
  145.           complex[1].real    =    data[1]
  146.           complex[1].imag    =    data[N-1]
  147.           ...............         ................
  148.           complex[k].real    =    data[k]
  149.           complex[k].imag    =    data[N-k]
  150.           ...............         ................
  151.           complex[N/2].real  =    data[N/2]
  152.           complex[N/2].real  =    0
  153.           ...............         ................
  154.           complex[k'].real   =    data[k]        k' = N - k
  155.           complex[k'].imag   =   -data[N-k]
  156.           ...............         ................
  157.           complex[N-1].real  =    data[1]
  158.           complex[N-1].imag  =   -data[N-1]
  159.    The radix-2 FFT functions for halfcomplex data are declared in the
  160. header file `gsl_fft_halfcomplex.h'.
  161.  - Function: int gsl_fft_halfcomplex_radix2_inverse (double data[],
  162.           const unsigned int n)
  163.  - Function: int gsl_fft_halfcomplex_radix2_backwards (double data[],
  164.           const unsigned int n)
  165.      These functions compute the inverse or backwards in-place radix-2
  166.      FFT of the half-complex sequence DATA, a real of length N stored
  167.      according the output scheme used by `gsl_fft_real_radix2'. The
  168.      result is a real array stored in natural order.
  169. File: gsl-ref.info,  Node: Mixed-radix FFT routines for real data,  Next: Example of using mixed-radix FFT routines for real data,  Prev: Radix-2 FFT routines for real data,  Up: FFTs of real data
  170. Mixed-radix FFT routines for real data
  171. --------------------------------------
  172.    This section describes mixed-radix FFT algorithms for real data. The
  173. mixed-radix functions work for FFTs of any length. They are a
  174. reimplementation of the real-FFT routines in the Fortran FFTPACK library
  175. by Paul Swarztrauber. The theory behind the algorithm is explained in
  176. the article `Fast Mixed-Radix Real Fourier Transforms' by Clive
  177. Temperton. The routines here use the same indexing scheme and basic
  178. algorithms as FFTPACK.
  179.    The functions use the FFTPACK storage convention for half-complex
  180. sequences. In this convention the half-complex transform of a real
  181. sequence is stored in with frequencies in increasing order, starting at
  182. zero, with the real and imaginary parts of each frequency in neighboring
  183. locations. When a value is known to be real the imaginary part is not
  184. stored. The imaginary part of the zero-frequency component is never
  185. stored. It is known to be zero (since the zero frequency component is
  186. simply the sum of the input data (all real)). For a sequence of even
  187. length the imaginary part of the frequency n/2 is not stored either,
  188. since the symmetry z_k = z_{N-k}^* implies that this is purely real too.
  189.    The storage scheme is best shown by some examples.  The table below
  190. shows the output for an odd-length sequence, n=5. The two columns give
  191. the correspondence between the 5 values in the half-complex sequence
  192. returned by `gsl_fft_real', HALFCOMPLEX[] and the values COMPLEX[] that
  193. would be returned if the same real input sequence were passed to
  194. `gsl_fft_complex_backward' as a complex sequence (with imaginary parts
  195. set to `0'),
  196.      complex[0].real  =  halfcomplex[0]
  197.      complex[0].imag  =  0
  198.      complex[1].real  =  halfcomplex[1]
  199.      complex[1].imag  =  halfcomplex[2]
  200.      complex[2].real  =  halfcomplex[3]
  201.      complex[2].imag  =  halfcomplex[4]
  202.      complex[3].real  =  halfcomplex[3]
  203.      complex[3].imag  = -halfcomplex[4]
  204.      complex[4].real  =  halfcomplex[1]
  205.      complex[4].imag  = -halfcomplex[2]
  206. The upper elements of the COMPLEX array, `complex[3]' and `complex[4]'
  207. are filled in using the symmetry condition.  The imaginary part of the
  208. zero-frequency term `complex[0].imag' is known to be zero by the
  209. symmetry.
  210.    The next table shows the output for an even-length sequence, n=5 In
  211. the even case both the there are two values which are purely real,
  212.      complex[0].real  =  halfcomplex[0]
  213.      complex[0].imag  =  0
  214.      complex[1].real  =  halfcomplex[1]
  215.      complex[1].imag  =  halfcomplex[2]
  216.      complex[2].real  =  halfcomplex[3]
  217.      complex[2].imag  =  halfcomplex[4]
  218.      complex[3].real  =  halfcomplex[5]
  219.      complex[3].imag  =  0
  220.      complex[4].real  =  halfcomplex[3]
  221.      complex[4].imag  = -halfcomplex[4]
  222.      complex[5].real  =  halfcomplex[1]
  223.      complex[5].imag  = -halfcomplex[2]
  224. The upper elements of the COMPLEX array, `complex[4]' and `complex[5]'
  225. are be filled in using the symmetry condition. Both `complex[0].imag'
  226. and `complex[3].imag' are known to be zero.
  227.    All these functions are declared in the header files
  228. `gsl_fft_real.h' and `gsl_fft_halfcomplex.h'.
  229.  - Function: int gsl_fft_real_wavetable_alloc (unsigned int N,
  230.           gsl_fft_real_wavetable * WAVETABLE);
  231.  - Function: int gsl_fft_halfcomplex_wavetable_alloc (unsigned int N,
  232.           gsl_fft_halfcomplex_wavetable * WAVETABLE);
  233.      These functions allocate space for a scratch area of size N real
  234.      elements and a trigonometric lookup table, of size n/2 complex
  235.      elements. The relevant components of WAVETABLE are modified to
  236.      point to the newly allocated memory.
  237.      These functions return a value of `0' if no errors were detected,
  238.      and `-1' in the case of error. The following `gsl_errno'
  239.      conditions are defined for these functions:
  240.     `GSL_EDOM'
  241.           The length of the data N is not a positive integer (i.e. N is
  242.           zero).
  243.     `GSL_ENOMEM'
  244.           The requested memory could not be allocated (`malloc' returned
  245.           a null pointer).
  246.  - Function: int gsl_fft_real_init (const unsigned int N,
  247.           gsl_fft_real_wavetable * WAVETABLE);
  248.  - Function: int gsl_fft_halfcomplex_init (const unsigned int N,
  249.           gsl_fft_halfcomplex_wavetable * WAVETABLE);
  250.      These functions initialize WAVETABLE.  They first select a
  251.      factorization of the length N into the implemented subtransforms,
  252.      storing the details of the factorization in WAVETABLE.
  253.      Using this factorization they then prepare a trigonometric lookup
  254.      table in the memory previously allocated by
  255.      `gsl_fft_real_wavetable_alloc' or
  256.      `gsl_fft_halfcomplex_wavetable_alloc'. The wavetable is computed
  257.      using direct calls to `sin' and `cos', for accuracy. It could be
  258.      computed faster using recursion relations if necessary. If an
  259.      application performs many FFTs of the same length then computing
  260.      the wavetable is a one-off overhead which does not affect the final
  261.      throughput.
  262.      The wavetable structure can be used repeatedly for any transform
  263.      of the same length. The table is not modified by calls to any of
  264.      the other FFT functions. The same wavetable can be used for both
  265.      forward and backward (or inverse) transforms of a given length.
  266.      The functions return a value of `0' if no errors were detected,
  267.      and `-1' in the case of error. The following `gsl_errno'
  268.      conditions are defined for these functions:
  269.     `GSL_EDOM'
  270.           The length of the data N is not a positive integer (i.e. N is
  271.           zero).
  272.     `GSL_EFACTOR'
  273.           The length N could not be factorized (this shouldn't happen).
  274.     `GSL_EFAILED'
  275.           A failure was detected in the wavetable generation. This
  276.           could be caused by an inconsistency in a user-supplied
  277.           WAVETABLE structure.
  278.  - Function: int gsl_fft_real_wavetable_free (gsl_fft_real_wavetable *
  279.           WAVETABLE);
  280.  - Function: int gsl_fft_halfcomplex_wavetable_free
  281.           (gsl_fft_halfcomplex_wavetable * WAVETABLE);
  282.      These functions free the blocks of memory previously allocated by
  283.      `gsl_fft_real_wavetable_alloc' or
  284.      `gsl_fft_halfcomplex_wavetable_alloc' and pointed to by the
  285.      components of WAVETABLE.
  286.      The wavetable should be freed if no further FFTs of the same
  287.      length will be needed.
  288.  - Function: int gsl_fft_real (double DATA[], const unsigned int N,
  289.           const gsl_fft_real_wavetable * WAVETABLE)
  290.  - Function: int gsl_fft_halfcomplex (double DATA[], const unsigned int
  291.           N, const gsl_fft_halfcomplex_wavetable * WAVETABLE)
  292.      These functions compute the FFT of DATA, a real or half-complex
  293.      array of length N, using a mixed radix decimation-in-frequency
  294.      algorithm. For `gsl_fft_real' DATA is an array of time-ordered
  295.      real data.  For `gsl_fft_halfcomplex' DATA contains fourier
  296.      coefficients in the half-complex ordering described above.
  297.      The caller must supply a WAVETABLE containing the chosen
  298.      factorization, trigonometric lookup tables and scratch area. The
  299.      wavetable can be easily prepared using the functions
  300.      `gsl_fft_real_alloc' and `gsl_fft_real_init' or
  301.      `gsl_fft_halfcomplex_alloc' and `gsl_fft_halfcomplex_init'.
  302.      There is no restriction on the length N.  Efficient modules are
  303.      provided for subtransforms of length 2, 3, 4 and 5. Any remaining
  304.      factors are computed with a slow, O(n^2), general-n module.
  305.      The functions return a value of `0' if no errors were detected,
  306.      and `-1' in the case of error. The following `gsl_errno'
  307.      conditions are defined for these functions:
  308.     `GSL_EDOM'
  309.           The length of the data N is not a positive integer (i.e. N is
  310.           zero).
  311.     `GSL_EINVAL'
  312.           The length of the data N and the length used to compute the
  313.           given WAVETABLE do not match.
  314.  - Function: int gsl_fft_real_unpack (const double real_coefficient[],
  315.           complex complex_coefficient[], const unsigned int n)
  316.      This function converts a single real array, REAL_COEFFICIENT into
  317.      an equivalent complex array, COMPLEX_COEFFICIENT, (with imaginary
  318.      part set to zero), suitable for `gsl_fft_complex' routines. The
  319.      algorithm for the conversion is simply,
  320.           for (i = 0; i < n; i++)
  321.               {
  322.                 complex_coefficient[i].real = real_coefficient[i];
  323.                 complex_coefficient[i].imag = 0.0;
  324.               }
  325.      The function returns a value of `0' if no errors were detected, and
  326.      `-1' in the case of error. There is only one `gsl_errno' condition
  327.      defined for this function:
  328.     `GSL_EDOM'
  329.           The length of the data N is not a positive integer (i.e. N is
  330.           zero).
  331.  - Function: int gsl_fft_halfcomplex_unpack (const double
  332.           halfcomplex_coefficient[], complex complex_coefficient[],
  333.           const unsigned int n)
  334.      This function converts HALFCOMPLEX_COEFFICIENT, an array of
  335.      half-complex coefficients as returned by `gsl_fft_real', into an
  336.      ordinary complex array, COMPLEX_COEFFICIENT. It fills in the
  337.      complex array using the symmetry z_k = z_{N-k}^* to reconstruct
  338.      the redundant elements. The algorithm for the conversion is,
  339.           complex_coefficient[0].real = halfcomplex_coefficient[0];
  340.           complex_coefficient[0].imag = 0.0;
  341.           
  342.           for (i = 1; i < n - i; i++)
  343.             {
  344.               const double hc_real = halfcomplex_coefficient[2 * i - 1];
  345.               const double hc_imag = halfcomplex_coefficient[2 * i];
  346.               complex_coefficient[i].real = hc_real;
  347.               complex_coefficient[i].imag = hc_imag;
  348.               complex_coefficient[n - i].real = hc_real;
  349.               complex_coefficient[n - i].imag = -hc_imag;
  350.             }
  351.            if (i == n - i)
  352.             {
  353.               complex_coefficient[i].real = halfcomplex_coefficient[n - 1];
  354.               complex_coefficient[i].imag = 0.0;
  355.             }
  356.      The function returns a value of `0' if no errors were detected, and
  357.      `-1' in the case of error. There is only one `gsl_errno' condition
  358.      defined for this function:
  359.     `GSL_EDOM'
  360.           The length of the data N is not a positive integer (i.e. N is
  361.           zero).
  362. File: gsl-ref.info,  Node: Example of using mixed-radix FFT routines for real data,  Prev: Mixed-radix FFT routines for real data,  Up: FFTs of real data
  363. Example of using mixed-radix FFT routines for real data
  364. -------------------------------------------------------
  365.    Here is an example program using `gsl_fft_real' and
  366. `gsl_fft_halfcomplex'. It generates a real signal in the shape of a
  367. square pulse. The pulse is fourier transformed to frequency space, and
  368. all but the lowest ten frequency components are removed from the array
  369. of fourier coefficients returned by `gsl_fft_real'.
  370.    The remaining fourier coefficients are transformed back to the
  371. time-domain, to give a filtered version of the square pulse. Since
  372. fourier coefficients are stored using the half-complex symmetry both
  373. positive and negative frequencies are removed and the final filtered
  374. signal is also real.
  375.      #include <stdio.h>
  376.      #include <math.h>
  377.      #include <gsl_errno.h>
  378.      #include <gsl_fft_real.h>
  379.      #include <gsl_fft_halfcomplex.h>
  380.      
  381.      int main ()
  382.      {
  383.        int i, n = 100;
  384.        double data[n];
  385.      
  386.        gsl_fft_real_wavetable real_wavetable;
  387.        gsl_fft_halfcomplex_wavetable halfcomplex_wavetable;
  388.      
  389.        for (i = 0; i < n; i++)
  390.          {
  391.            data[i] = 0.0;
  392.          }
  393.      
  394.        for (i = n / 3; i < 2 * n / 3; i++)
  395.          {
  396.            data[i] = 1.0;
  397.          }
  398.      
  399.        for (i = 0; i < n; i++)
  400.          {
  401.            printf ("%d: %e\n", i, data[i]);
  402.          }
  403.        printf ("\n");
  404.      
  405.        gsl_fft_real_wavetable_alloc (n, &real_wavetable);
  406.        gsl_fft_real_init (n, &real_wavetable);
  407.        gsl_fft_real (data, n, &real_wavetable);
  408.        gsl_fft_real_wavetable_free (&real_wavetable);
  409.      
  410.        for (i = 11; i < n; i++)
  411.          {
  412.            data[i] = 0;
  413.          }
  414.      
  415.        gsl_fft_halfcomplex_wavetable_alloc (n, &halfcomplex_wavetable);
  416.        gsl_fft_halfcomplex_init (n, &halfcomplex_wavetable);
  417.        gsl_fft_halfcomplex_inverse (data, n, &halfcomplex_wavetable);
  418.        gsl_fft_halfcomplex_wavetable_free (&halfcomplex_wavetable);
  419.      
  420.        for (i = 0; i < n; i++)
  421.          {
  422.            printf ("%d: %e\n", i, data[i]);
  423.          }
  424.      }
  425. File: gsl-ref.info,  Node: Test Signals,  Next: FFT References and Further Reading,  Prev: FFTs of real data,  Up: FFTs
  426. Test Signals
  427. ============
  428.    This section describes functions for generating simple test signals,
  429. such as unit pulses, constant signals, complex exponentials (sine and
  430. cosine waves) and pairs of complex exponentials with different
  431. frequencies. The Fourier transforms for these signals can be calculated
  432. analytically. Each function returns both the test signal and its Fourier
  433. transform.
  434.    There are also some routines for generating white noise. In this case
  435. the transform cannot be calculated analytically, and is computed using a
  436. brute-force discrete Fourier transform. This may be slow but it is easy
  437. to check and independent of all the other routines.
  438.    These functions are declared in the header file `gsl_fft_signals.h'.
  439.  - Function: int gsl_fft_signal_complex_pulse (const unsigned int t,
  440.           const unsigned int n, const double z_real, const double
  441.           z_imag, complex data[], complex fft[])
  442.      This function prepares a "delta-function" pulse of complex
  443.      amplitude (Z_REAL,Z_IMAG) at time T in the complex array DATA of
  444.      length N. The pulse only occupies one array element.  All other
  445.      elements of DATA are set to zero. The function also returns the
  446.      fourier transform of the pulse in the complex array FFT, also of
  447.      length N.
  448.      Writing z as (z_{real} + i z_{imag}), the mathematical definition
  449.      of the pulse is,
  450.           z_k =  z \delta_{kt},
  451.      where \delta_{kt}=1 if k=t, and 0 otherwise. The fourier transform
  452.      is,
  453.           x_j = \sum_{k=0}^{n-1} z \delta_{kt} \exp(-2\pi i j k/n)
  454.               = z \exp(-2\pi i j t/n)
  455.  - Function: int gsl_fft_signal_complex_constant (const unsigned int n,
  456.           const double z_real, const double z_imag, complex data[],
  457.           complex fft[])
  458.      This function prepares a constant complex signal of amplitude
  459.      (Z_REAL,Z_IMAG) in the complex array DATA of length N. The
  460.      function also returns the fourier transform of the constant in the
  461.      complex array FFT, also of length N.
  462.      The mathematical definition of the constant signal is,
  463.           z_k = z
  464.      and the fourier transform is,
  465.           x_j = \sum_{k=0}^{n-1} z \exp(-2\pi i j k/n)
  466.               = z n \delta_{j0}
  467.  - Function: int gsl_fft_signal_complex_exp (const int f, const
  468.           unsigned int n, const double z_real, const double z_imag,
  469.           complex data[], complex fft[])
  470.      This function prepares a complex exponential signal of amplitude
  471.      (Z_REAL,Z_IMAG) and frequency F in the complex array DATA of
  472.      length N. The function also returns the fourier transform of the
  473.      signal in the complex array FFT, also of length N.
  474.      The mathematical definition of the complex exponential signal is,
  475.           z_k = z \exp(2\pi i k f/n)
  476.      and the fourier transform is,
  477.           x_j = \sum_{k=0}^{n-1} z \exp(2\pi i k f/n) \exp(-2\pi i j k/n)
  478.               = z n \delta_{j,f}
  479.  - Function: int gsl_fft_signal_complex_exppair (const int f1, const
  480.           int f2, const unsigned int n, const double z1_real, const
  481.           double z1_imag, const double z2_real, const double z2_imag,
  482.           complex data[], complex fft[])
  483.      This function prepares a pair of exponential signals of amplitude
  484.      (Z1_REAL,Z1_IMAG) and (Z2_REAL,Z2_IMAG) with frequencies F1 and F2
  485.      in the complex array DATA of length N. The function also returns
  486.      the fourier transform of the signal in the complex array FFT, also
  487.      of length N.
  488.      The mathematical definition of the pair of exponential signals is,
  489.           z_k = z_1 \exp(2\pi i k f_1/n) + z_2 \exp(2\pi i k f_2/n)
  490.      and the fourier transform is,
  491.           x_j =  z_1 n \delta_{j,f_1}  + z_2 n \delta_{j,f_2}
  492.  - Function: int gsl_fft_signal_complex_noise (const unsigned int n,
  493.           complex data[], complex fft[])
  494.      This function prepares a complex white-noise signal in the complex
  495.      array DATA of length N. The real and imaginary components of each
  496.      array element are independent uniform distributed random values in
  497.      the range [0,1] (computed using the system `rand' function). The
  498.      function also returns the fourier transform of the signal in the
  499.      complex array FFT, also of length N. The fourier transform is
  500.      computed using the brute-force discrete fourier transform
  501.      `gsl_dft_complex_forward'. Note that the direct computation of the
  502.      discrete fourier transform has worse numerical stability than an
  503.      FFT, so the array FFT is only useful in detecting large errors.
  504.  - Function: int gsl_fft_signal_real_noise (const unsigned int n,
  505.           complex data[], complex fft[])
  506.      This function generates real white noise instead of complex white
  507.      noise.  It is the same as `gsl_fft_signal_complex_noise' but with
  508.      the imaginary parts of DATA explicitly set to zero.
  509.    All these functions return a value of `0' if no errors were
  510. detected, and `-1' in the case of error. There is only one `gsl_errno'
  511. condition defined for these functions:
  512. `GSL_EDOM'
  513.      The length of the data N is not a positive integer (i.e. N is
  514.      zero).
  515. File: gsl-ref.info,  Node: FFT References and Further Reading,  Prev: Test Signals,  Up: FFTs
  516. FFT References and Further Reading
  517. ==================================
  518. A good starting point for learning more about the FFT is the review
  519. article `Fast Fourier Transforms: A Tutorial Review and A State of the
  520. Art' by Duhamel and Vetterli,
  521.      P. Duhamel and M. Vetterli.  Fast fourier transforms: A tutorial
  522.      review and a state of the art.  `Signal Processing', 19:259-299,
  523.      1990.
  524. To find out about the algorithms used in the GSL routines you may want
  525. to consult the latex document `GSL FFT Algorithms' (it is included in
  526. GSL, as `doc/fftalgorithms.tex'). This has general information on FFTs
  527. and explicit derivations of the implementation for each routine. There
  528. are also references to the relevant literature. For convenience some of
  529. the more important references are reproduced below.
  530.    There are several introductory books on the FFT with example
  531. programs, such as `The Fast Fourier Transform' by Brigham and `DFT/FFT
  532. and Convolution Algorithms' by Burrus and Parks,
  533.      E. Oran Brigham.  `The Fast Fourier Transform'.  Prentice Hall,
  534.      1974.
  535.      C. S. Burrus and T. W. Parks.  `DFT/FFT and Convolution
  536.      Algorithms'.  Wiley, 1984.
  537. Both these introductory books cover the radix-2 FFT in some detail.
  538. The mixed-radix algorithm at the heart of the FFTPACK routines is
  539. reviewed in Clive Temperton's paper,
  540.      Clive Temperton.  Self-sorting mixed-radix fast fourier transforms.
  541.      `Journal of Computational Physics', 52(1):1-23, 1983.
  542. The derivation of FFTs for real-valued data is explained in the
  543. following two articles,
  544.      Henrik V. Sorenson, Douglas L. Jones, Michael T. Heideman, and C.
  545.      Sidney Burrus.  Real-valued fast fourier transform algorithms.
  546.      `IEEE Transactions on Acoustics, Speech, and Signal Processing',
  547.      ASSP-35(6):849-863, 1987.
  548.      Clive Temperton.  Fast mixed-radix real fourier transforms.
  549.      `Journal of Computational Physics', 52:340-350, 1983.
  550. In 1979 the IEEE published a compendium of carefully-reviewed Fortran
  551. FFT programs in `Programs for Digital Signal Processing'. It is a
  552. useful reference for implementations of many different FFT algorithms,
  553.      Digital Signal Processing Committee and IEEE Acoustics, Speech,
  554.      and Signal Processing Committee, editors.  `Programs for Digital
  555.      Signal Processing'.  IEEE Press, 1979.
  556. There is also an annotated bibliography of papers on the FFT and related
  557. topics by Burrus,
  558.      C. S. Burrus. Notes on the FFT.
  559. The notes are available from
  560. `http://www-dsp.rice.edu/res/fft/fftnote.asc'.
  561. File: gsl-ref.info,  Node: Root finding,  Next: Simulated Annealing,  Prev: FFTs,  Up: Top
  562. Root finding
  563. ************
  564.    This chapter describes functions for finding a root of an arbitrary
  565. function which you provide. It discusses proper use and possible
  566. pitfalls of each function and gives an overview of the algorithms
  567. involved.
  568.    The *GNU Scientific Library* provides two types of root finding
  569. functions: high-level functions which take few arguments and make most
  570. decisions for you, and low-level functions which take many arguments
  571. and can be precisely controlled. For most tasks, the simpler high-level
  572. functions will be sufficient, but the greater degree of control
  573. provided by the low-level functions is sometimes useful.
  574.    For examples of GSL root finding functions in action, look at the
  575. source code for the testing program which verifies that the they work
  576. correctly (it is run when you do a `make check'). It is in the file
  577. `roots/test.c' and implements one way of properly handling errors.
  578.    The header file `gsl_roots.h' contains prototypes for GSL root
  579. finding functions and some other related declarations.
  580.    *FIXME: add a note about performance.*
  581. * Menu:
  582. * Root Finding Overview::
  583. * High Level vs. Low Level::
  584. * High Level Root Finding Functions::
  585. * Low Level Root Finding Functions::
  586. * Root Finder Error Handling::
  587. File: gsl-ref.info,  Node: Root Finding Overview,  Next: High Level vs. Low Level,  Up: Root finding
  588. Root Finding Overview
  589. =====================
  590.    *FIXME: Insert discussion of numerical root finding here.*
  591.    GSL root finding functions operate on continous functions only.
  592.    While it is not absolutely required that f have a root within the
  593. search region, numerical root finding functions should not be used
  594. haphazardly to check for the *existence* of roots. There are better
  595. ways to do this! Because it is so easy to create situations where
  596. numerical root finders go awry, it is a bad idea to throw a root finder
  597. at a function you do not know much about.
  598.    Note that GSL root finding functions can only search for one root at
  599. a time. While their behavior in cases of multiple roots (several roots
  600. in the search area, not one root of degree greater than 1) is
  601. deterministic, it depends entirely on the algorithm and the function
  602. under search and is rather complex; it is therefore difficult to
  603. predict. *In most cases, no error will be reported if you try to find a
  604. root in an area where there is more than one.*
  605. File: gsl-ref.info,  Node: High Level vs. Low Level,  Next: High Level Root Finding Functions,  Prev: Root Finding Overview,  Up: Root finding
  606. High Level vs. Low Level
  607. ========================
  608.    *FIXME: fill in this section.*
  609.    In general, you should use high level functions unless there is a
  610. definite reason to use low level functions.
  611. File: gsl-ref.info,  Node: High Level Root Finding Functions,  Next: Low Level Root Finding Functions,  Prev: High Level vs. Low Level,  Up: Root finding
  612. High Level Root Finding Functions
  613. =================================
  614.    GSL provides three high level root finding functions. They are
  615. simple to use, robust, and adequate for most tasks, but certain
  616. situations require more control than the high level root finding
  617. functions provide.
  618. * Menu:
  619. * Root Finder Exit Values::           How to tell if an error occured and
  620.                                       how the root location is returned
  621. * Providing the Function to Search::  How to provide a function for the
  622.                                       root finder to operate on
  623. * Automatic Control Decisions::       How high level root finders set
  624.                                       parameters such as tolerance
  625. * High Level Functions::              Names and arguments of the high
  626.                                       level root finding functions
  627. File: gsl-ref.info,  Node: Root Finder Exit Values,  Next: Providing the Function to Search,  Up: High Level Root Finding Functions
  628. Root Finder Exit Values
  629. -----------------------
  630.    Since the return value of GSL root finding functions is reserved for
  631. the error status, you must provide storage for the location of the found
  632. root.
  633.  - Function Argument: double * root
  634.      A pointer to a place for the GSL root finder to store the location
  635.      of the found root. This must be a valid pointer; GSL root finders
  636.      will not allocate any memory for you.
  637.    If a GSL root finder succeeds, it will return `0' and store the
  638. location of the found root in `*root'.
  639.    If a GSL root finder fails, it will return `-1' and set `gsl_errno'
  640. to a diagnostic value. *Note Root Finder Error Handling::, for a
  641. discussion of possible error codes. Nothing useful will be stored in
  642. `*root' if the function failed.
  643. File: gsl-ref.info,  Node: Providing the Function to Search,  Next: Automatic Control Decisions,  Prev: Root Finder Exit Values,  Up: High Level Root Finding Functions
  644. Providing the Function to Search
  645. --------------------------------
  646.    You must provide a continous function of one variable for GSL root
  647. finder(s) to operate on, and, sometimes, its first derivative.
  648.    Recall that when passing pointers to functions, you give the name of
  649. the function you are passing. For example:
  650.      foo = i_take_a_function_pointer(my_function);
  651.  - Function Argument: double (* f)(double)
  652.      A pointer to the function whose root you are searching for. It is
  653.      called by the root finding function many times during its search.
  654.      It must be continous within the region of interest.
  655.      Here is an example function which you could pass to a GSL root
  656.      finder:
  657.           double
  658.           my_f (double x) {
  659.              return sin (2 * x) + 2 * cos (x);
  660.           }
  661.  - Function Argument: double (* df)(double)
  662.      A pointer to the first derivative of the function whose root you
  663.      are searching for.
  664.      If we were looking for a root of the function in the previous
  665.      example, this is what we would use for `df':
  666.           double
  667.           my_df (double x) {
  668.              return 2 * cos (2 * x) - 2 * sin (x);
  669.           }
  670.  - Function Argument: void (* fdf)(double *, double *, double, int, int)
  671.      A pointer to a function which calculates both the value of the
  672.      function under search and the value of its first derivative.
  673.      Because many terms of a function and its derivative are the same,
  674.      it is often faster to use this method as opposed to providing f(x)
  675.      and f'(x) separately. However, it is more complicated.
  676.      It stores f(x) in its first argument and f'(x) in its second.
  677.      Here's an example where f(x) = 2\sin(2x)\cos(x):
  678.           void
  679.           my_fdf (double * y, double * yprime, double x,
  680.                   int y_wanted, int yprime_wanted) {
  681.              double sin2x, cosx;
  682.           
  683.              sin2x = sin (2 * x);
  684.              cosx = cos (x);
  685.           
  686.              if (y_wanted)
  687.                 *y = 2 * sin2x * cos (x);
  688.              if (yprime_wanted)
  689.                 *yprime = 2 * sin2x * -sin (x) + 2 * cos (2 * x) * cosx);
  690.           }
  691. File: gsl-ref.info,  Node: Automatic Control Decisions,  Next: High Level Functions,  Prev: Providing the Function to Search,  Up: High Level Root Finding Functions
  692. Automatic Control Decisions
  693. ---------------------------
  694.    *FIXME: Coming soon...*
  695. File: gsl-ref.info,  Node: High Level Functions,  Prev: Automatic Control Decisions,  Up: High Level Root Finding Functions
  696. High Level Functions
  697. --------------------
  698.    *FIXME: Coming soon...*
  699. File: gsl-ref.info,  Node: Low Level Root Finding Functions,  Next: Root Finder Error Handling,  Prev: High Level Root Finding Functions,  Up: Root finding
  700. Low Level Root Finding Functions
  701. ================================
  702.    GSL provides several low level root finding functions which are more
  703. complicated to use than the high level function but provide more
  704. control. The following nodes explain how to use low level root finding
  705. functions.
  706.    Low level functions return errors and roots and are provided
  707. functions to search in the same manner as the high level functions; see
  708. *Note Root Finder Exit Values::, and *Note Providing the Function to
  709. Search::, respectively.
  710. * Menu:
  711. * Search Bounds and Guesses::   How to tell GSL where to search
  712. * Search Stopping Parameters::  How to tell GSL when to stop searching
  713. * Bisection::                   GSL's implementation of bisection
  714. * False Position::              GSL's implementation of false position
  715. * Secant Method::               GSL's implementation of secant method
  716. * Newtons Method::              GSL's implementation of Newton's Method
  717. File: gsl-ref.info,  Node: Search Bounds and Guesses,  Next: Search Stopping Parameters,  Up: Low Level Root Finding Functions
  718. Search Bounds and Guesses
  719. -------------------------
  720.    When using low level functions, you can specify and monitor the
  721. region being searched more precisely than you can when using high level
  722. functions. You provide either search bounds or one or two guesses; this
  723. node explains how search bounds and guesses work and how function
  724. arguments control them.
  725.    Search bounds are the endpoints of the search interval which is
  726. iterated smaller and smaller until the length of the interval is
  727. smaller than the requested precision or one of the endpoints converges;
  728. a guess is an x value which is iterated around until the it is within
  729. the desired precision of a root. Two guesses behave similarly to one;
  730. there are just two x values wandering about instead of one.
  731.    In low level functions, these arguments are defined as pointers to
  732. `double' rather than simply `double's for two reasons. First, if the
  733. root finding function fails, it is very useful to have the final values
  734. of your iterated variables available to help diagnose why it failed.
  735. Second, it makes it possible to preserve the state of the root finder,
  736. enabling it to be restarted in the same place if needed. A situation
  737. where this could be useful is if the function under search is very
  738. costly to evaluate. Pretend, for a moment, that you want to find a root
  739. of a function which takes several minutes to evaluate. Your program
  740. could chug away for a few iterations, then examine your mailbox to see
  741. if the number of flames about bogging down the machine is above a
  742. certain threshold. If it isn't, chug away for a few more iterations and
  743. repeat the process; if it is, depending on your temperament, your
  744. program could renice itself to a lower priority and mail back apologies
  745. before continuing, or it could mailbomb everyone who complained, spawn
  746. copies of itself endlessly, and dump garbage to `/dev/audio'.  (The
  747. latter approach is not recommended.)
  748.    Note that these arguments must be valid pointers; GSL root finders
  749. will not allocate any memory for you.
  750.  - Low Level Function Argument: double * lower_bound
  751.  - Low Level Function Argument: double * upper_bound
  752.      The initial upper and lower bounds of the interval in which to
  753.      search for a root. `lower_bound' must be less than `upper_bound'.
  754.      These arguments are modified during execution of the root finding
  755.      function; if you need to preserve their initial values, you must
  756.      make copies of them. See the third paragraph of this node for the
  757.      reasoning behind this behavior.
  758.  - Low Level Function Argument: double * guess
  759.  - Low Level Function Argument: double * guess2
  760.      One or two initial values for the guess(es) iterated by the root
  761.      finding function.
  762.      These arguments are modified during execution of the root finding
  763.      function; if you need to preserve their initial values, you must
  764.      make copies of them. See the third paragraph of this node for the
  765.      reasoning behind this behavior.
  766. File: gsl-ref.info,  Node: Search Stopping Parameters,  Next: Bisection,  Prev: Search Bounds and Guesses,  Up: Low Level Root Finding Functions
  767. Search Stopping Parameters
  768. --------------------------
  769.    *FIXME: clean up this section and add documentation for max_deltay.*
  770.    GSL root finding functions (and numerical root finding functions in
  771. general) stop when one of the following conditions is true:
  772.    * A root has been found to within the user-specified precision.
  773.    * A user-specified maximum number of iterations has executed.
  774.    * An error has occured.
  775.    Whenever you call a low level GSL root finding function, you must
  776. specify precisely absolute and/or relative tolerances and the maximum
  777. number of iterations.
  778.    GSL decides that two values a and b. with relative tolerance R and
  779. absolute tolerance A, are close enough if the following relation is
  780. true:
  781.      |a - b| \leq R \min(|a|,|b|) + A
  782.    You can set either R or A to zero, but be aware that GSL will signal
  783. an error if the search moves into an area where both R and A are
  784. meaningless; assuming a and b are the endpoints of the region of
  785. interest, the following must be true or GSL will signal an error:
  786.      R \min(|a|,|b|) + A \geq 10 \max(|a|,|b|) \times {\tt DBL\_EPSILON}
  787.    (We introduce a buffer of 10 to protect against roundoff error.)
  788.    For the sake of efficient resource use, do not ask for more precision
  789. than you need, especially if your function is costly to evaluate.
  790.  - Low Level Function Argument: double abs_epsilon
  791.      The maximum permissible absolute error in GSL root finder answers.
  792.      The only static limit on `abs_epsilon' is that it must be
  793.      positive; see above for other restrictions, however.
  794.  - Low Level Function Argument: double rel_epsilon
  795.      The maximum permissible relative error in GSL root finder answers.
  796.      `rel_epsilon' must be greater than or equal to {\tt DBL\_EPSILON}
  797.      \times 10 (note the buffer factor to protect against roundoff
  798.      error). See above for additional non-static restrictions.
  799.  - Function Argument: unsigned int max_iterations
  800.      The maximum number of iterations a root finder is allowed to
  801.      perform.  This must be greater than or equal to 1, as performing a
  802.      negative number of iterations is extremely difficult and not doing
  803.      any iterations is rather useless.
  804.      Do not set `max_iterations' too large. If there is a problem, you
  805.      want to know about it as soon as possible; you don't want your
  806.      program chugging away for many cycles in error.
  807.    In addition, GSL root finding functions which extrapolate (Newton's
  808. Method, (*Note Newtons Method::, and Secant Method, *Note Secant
  809. Method::) accept an additional argument:
  810.  - Function Argument: double max_step_size
  811.      The maximum step size an extrapolating algorithm is allowed to
  812.      take.  This is to prevents the algorithm from landing on a place
  813.      where the test function's derivative is very small and zooming off
  814.      to infinity or into a different solution basin.
  815.      *FIXME: talk about minimum value for max_step_size.*
  816.      For example, if while solving \sin(x) = 0, x_n of Newton's Method
  817.      (*note Newtons Method::.) landed on 1.570700000 (\pi/2 \approx
  818.      1.570796327), then x_{n+1} would be approximately -10000, which is
  819.      definitely not what we wanted! We want the root finder to
  820.      recognize this step as "too big" and flag an error.
  821.      The alarm bell will ring if the following relation in true:
  822.           |{{d} \over {dx}} f(x)| < |{{f(x)} \over {\tt max\_step\_size}}|
  823.      Note that while Secant Method (*note Secant Method::.) does not
  824.      deal with derivatives directly, when extrapolating it approximates
  825.      them numerically.
  826.      Do not set `max_step_size' too large; that will defeat its
  827.      purpose. In the \sin(x) = 0 example, \pi would be a good value for
  828.      `max_step_size'; any step larger than that would certainly be
  829.      headed astray. A good understanding of the problem is especially
  830.      important for `max_step_size'.
  831. File: gsl-ref.info,  Node: Bisection,  Next: False Position,  Prev: Search Stopping Parameters,  Up: Low Level Root Finding Functions
  832. Bisection
  833. ---------
  834.    Bisection is a simple and robust method of finding roots of a
  835. function f; when its arguments are valid, it cannot fail. However, it is
  836. the slowest algorithm implemented by GSL, and it cannot find roots of
  837. even degree. Its convergence is linear.
  838.    One begins the algorithm with an interval which is guaranteed by the
  839. Intermediate Value Theorem to contain a root: where a and b are the
  840. endpoints of the interval, f(a) must differ in sign from f(b). (If
  841. you're a bit fuzzy on the Intermediate Value Theorem, consult any
  842. elementary calculus textbook.)
  843.    Each iteration, bisection chops its interval in half and discards the
  844. interval which does not contain a root. Once the interval is smaller
  845. than the requested epsilon, iteration stops and the root location is
  846. returned.
  847.    (Often, root finding algorithms are better explained geometrically.
  848. The TeX version of this documentation contains an image illustrating
  849. bisection.)
  850.  - Function: int gsl_root_bisection (double * ROOT,
  851.           double (* F)(double), double * LOWER_BOUND,
  852.           double * UPPER_BOUND, double REL_EPSILON, double ABS_EPSILON,
  853.           unsigned int MAX_ITERATIONS, double MAX_DELTAY)
  854.      Search for a zero of `f' using bisection. Returns `0' if
  855.      successful, `-1' on error (*note Root Finder Error Handling::.).
  856.      `f(*lower_bound)' and `f(*upper_bound)' must differ in sign.
  857.      Arguments:
  858.     `root'
  859.           A place to store the root location once it is found. *Note
  860.           Root Finder Exit Values::.
  861.     `f'
  862.           A user defined function to search for a root. *Note Providing
  863.           the Function to Search::.
  864.     `lower_bound, upper_bound'
  865.           Lower and upper bounds of the interval to search. *Note
  866.           Search Bounds and Guesses::.
  867.     `rel_epsilon, abs_epsilon'
  868.           Maximum permitted relative and absolute error. *Note Search
  869.           Stopping Parameters::.
  870.     `max_iterations'
  871.           The maximum allowed number of iterations. *Note Search
  872.           Stopping Parameters::.
  873.     `max_deltay'
  874.           The maximum allowed difference between `f(*lower_bound)' and
  875.           `f(*upper_bound)'. *Note Search Stopping Parameters::.
  876. File: gsl-ref.info,  Node: False Position,  Next: Secant Method,  Prev: Bisection,  Up: Low Level Root Finding Functions
  877. False Position
  878. --------------
  879.    False position is a robust method of finding roots of a function f;
  880. if its arguments are valid, it cannot fail. However, it cannot find
  881. roots of even degree. Its convergence is linear, but it is usually
  882. faster than bisection.
  883.    One begins the algorithm with an interval which is guaranteed by the
  884. Intermediate Value Theorem to contain a root: where a and b are the
  885. endpoints of the interval, f(a) must differ in sign from f(b). (If
  886. you're a bit fuzzy on the Intermediate Value Theorem, consult any
  887. elementary calculus textbook.)
  888.    Each iteration, false position draws a line between f(a) and f(b);
  889. the x position where this line crosses the x axis is where the interval
  890. is split. The part of the interval which contains the root is taken to
  891. be the new interval, and the process is repeated until one of the
  892. following is true:
  893.      |a - b| \leq \varepsilon
  894.      a_n - a_{n-1} = 0 \;\;\;{\rm and}\;\;\; |b_n - b_{n-1}| \leq \varepsilon
  895.      b_n - b_{n-1} = 0 \;\;\;{\rm and}\;\;\;|a_n - a_{n-1}| \leq \varepsilon
  896.    (Often, root finding algorithms are better explained geometrically.
  897. The TeX version of this documentation contains an image illustrating
  898. false position.)
  899.  - Function: int gsl_root_falsepos (double * ROOT,
  900.           double (* F)(double), double * LOWER_BOUND,
  901.           double * UPPER_BOUND, double REL_EPSILON, double ABS_EPSILON,
  902.           unsigned int MAX_ITERATIONS, double MAX_DELTAY)
  903.      Search for a zero of `f' using false position. Return `0' if
  904.      successful, `-1' on error (*note Root Finder Error Handling::..
  905.      `f(*lower_bound)' and `f(*upper_bound)' must differ in sign.
  906.      Arguments:
  907.     `root'
  908.           A place to store the root location once it is found. *Note
  909.           Root Finder Exit Values::.
  910.     `f'
  911.           A user defined function to search for a root. *Note Providing
  912.           the Function to Search::.
  913.     `lower_bound, upper_bound'
  914.           Lower and upper bounds of the interval to search. *Note
  915.           Search Bounds and Guesses::.
  916.     `rel_epsilon, abs_epsilon'
  917.           Maximum permitted relative and absolute error. *Note Search
  918.           Stopping Parameters::.
  919.     `max_iterations'
  920.           The maximum allowed number of iterations. *Note Search
  921.           Stopping Parameters::.
  922.     `max_deltay'
  923.           The maximum allowed difference between `f(*lower_bound)' and
  924.           `f(*upper_bound)'. *Note Search Stopping Parameters::.
  925. File: gsl-ref.info,  Node: Secant Method,  Next: Newtons Method,  Prev: False Position,  Up: Low Level Root Finding Functions
  926. Secant Method
  927. -------------
  928.    Secant Method is a somewhat fragile method of finding roots. On
  929. single roots, its convergence is of order (1 + \sqrt 5)/2 (approximately
  930. 1.62). On multiple roots, converges linearly.
  931.    One begins the algorithm with two guesses for the value of the root,
  932. g_0 and g_1. The root may be either inside or outside the interval
  933. defined by g_0 and g_1.
  934.    Each iteration, Secant Method draws a line through f(g_{n - 1}) and
  935. f(g_n). The x position where this line crosses the x axis becomes g_{n
  936. + 1}. g_{n - 1} is discarded, n is incremented, and the process is
  937. repeated until:
  938.      |g_n - g_{n-1}| \leq \varepsilon
  939.    Note that g_{n + 1} may be obtained by either interpolation or
  940. extrapolation and that Secant Method cannot fail during interpolation.
  941.    Secant Method breaks in the same situations that Newton's Method
  942. does, though it is somewhat less sensitive. (*Note Newtons Method::.)
  943.    (Often, root finding algorithms are better explained geometrically.
  944. The TeX version of this documentation contains an image illustrating
  945. Secant Method.)
  946.  - Function: int gsl_root_secant (double * ROOT, double (* F)(double),
  947.           double * GUESS, double * GUESS2, double EPSILON,
  948.           unsigned int MAX_ITERATIONS, double MAX_STEP_SIZE)
  949.      Search for a zero of `f' using Secant Method, with `*guess' and
  950.      `*guess2' being the guesses.
  951.      arguments. *Note Root Finder Error Handling::, for a discussion of
  952.      possible error codes.
  953.