comparison scripts/general/quadgk.m @ 9051:1bf0ce0930be

Grammar check TexInfo in all .m files Cleanup documentation sources to follow a few consistent rules. Spellcheck was NOT done. (but will be in another changeset)
author Rik <rdrider0-list@yahoo.com>
date Fri, 27 Mar 2009 22:31:03 -0700
parents eb63fbe60fab
children 8970b4b10e9f
comparison
equal deleted inserted replaced
9044:656ad518f385 9051:1bf0ce0930be
20 ## @deftypefn {Function File} {} quadgk (@var{f}, @var{a}, @var{b}, @var{abstol}, @var{trace}) 20 ## @deftypefn {Function File} {} quadgk (@var{f}, @var{a}, @var{b}, @var{abstol}, @var{trace})
21 ## @deftypefnx {Function File} {} quadgk (@var{f}, @var{a}, @var{b}, @var{prop}, @var{val}, @dots{}) 21 ## @deftypefnx {Function File} {} quadgk (@var{f}, @var{a}, @var{b}, @var{prop}, @var{val}, @dots{})
22 ## @deftypefnx {Function File} {[@var{q}, @var{err}] =} quadgk (@dots{}) 22 ## @deftypefnx {Function File} {[@var{q}, @var{err}] =} quadgk (@dots{})
23 ## Numerically evaluate integral using adaptive Guass-Konrod quadrature. 23 ## Numerically evaluate integral using adaptive Guass-Konrod quadrature.
24 ## The formulation is based on a proposal by L.F. Shampine, 24 ## The formulation is based on a proposal by L.F. Shampine,
25 ## @cite{"Vectorized adaptive quadrature in MATLAB", Journal of 25 ## @cite{"Vectorized adaptive quadrature in @sc{matlab}", Journal of
26 ## Computational and Applied Mathematics, pp131-140, Vol 211, Issue 2, 26 ## Computational and Applied Mathematics, pp131-140, Vol 211, Issue 2,
27 ## Feb 2008} where all function evalutions at an iteration are 27 ## Feb 2008} where all function evalutions at an iteration are
28 ## calculated with a single call to @var{f}. Therefore the function 28 ## calculated with a single call to @var{f}. Therefore the function
29 ## @var{f} must be of the form @code{@var{f} (@var{x})} and accept 29 ## @var{f} must be of the form @code{@var{f} (@var{x})} and accept
30 ## vector values of @var{x} and return a vector of the same length 30 ## vector values of @var{x} and return a vector of the same length
31 ## representing the function evalutaions at the given values of @var{x}. 31 ## representing the function evalutaions at the given values of @var{x}.
32 ## The function @var{f} can be defined in terms of a function handle, 32 ## The function @var{f} can be defined in terms of a function handle,
33 ## inline function or string. 33 ## inline function or string.
34 ## 34 ##
35 ## The bounds of the quadrature @code{[@var{a}, @var{b}]} can be finite 35 ## The bounds of the quadrature @code{[@var{a}, @var{b}]} can be finite
36 ## or infinite and contain weak end singularities. Variable 36 ## or infinite and contain weak end singularities. Variable
37 ## transformation will be used to treat infinite intervals and weaken 37 ## transformation will be used to treat infinite intervals and weaken
38 ## the singularities. For example 38 ## the singularities. For example
39 ## 39 ##
40 ## @example 40 ## @example
41 ## quadgk(@@(x) 1 ./ (sqrt (x) .* (x + 1)), 0, Inf) 41 ## quadgk(@@(x) 1 ./ (sqrt (x) .* (x + 1)), 0, Inf)
42 ## @end example 42 ## @end example
43 ## 43 ##
45 ## Note that the formulation of the integrand uses the 45 ## Note that the formulation of the integrand uses the
46 ## element-by-element operator @code{./} and all user functions to 46 ## element-by-element operator @code{./} and all user functions to
47 ## @code{quadgk} should do the same. 47 ## @code{quadgk} should do the same.
48 ## 48 ##
49 ## The absolute tolerance can be passed as a fourth argument in a manner 49 ## The absolute tolerance can be passed as a fourth argument in a manner
50 ## compatible with @code{quadv}. Equally the user can request that 50 ## compatible with @code{quadv}. Equally the user can request that
51 ## information on the convergence can be printed is the fifth argument 51 ## information on the convergence can be printed is the fifth argument
52 ## is logicallly true. 52 ## is logicallly true.
53 ## 53 ##
54 ## Alternatively, certain properties of @code{quadgk} can be passed as 54 ## Alternatively, certain properties of @code{quadgk} can be passed as
55 ## pairs @code{@var{prop}, @var{val}}. Valid properties are 55 ## pairs @code{@var{prop}, @var{val}}. Valid properties are
56 ## 56 ##
57 ## @table @code 57 ## @table @code
58 ## @item AbsTol 58 ## @item AbsTol
59 ## Defines the absolute error tolerance for the quadrature. The default 59 ## Defines the absolute error tolerance for the quadrature. The default
60 ## absolute tolerance is 1e-10. 60 ## absolute tolerance is 1e-10.
61 ## 61 ##
62 ## @item RelTol 62 ## @item RelTol
63 ## Defines the relative error tolerance for the quadrature. The default 63 ## Defines the relative error tolerance for the quadrature. The default
64 ## relative tolerance is 1e-5. 64 ## relative tolerance is 1e-5.
65 ## 65 ##
66 ## @item MaxIntervalCount 66 ## @item MaxIntervalCount
67 ## @code{quadgk} initially subdivides the interval on which to perform 67 ## @code{quadgk} initially subdivides the interval on which to perform
68 ## the quadrature into 10 intervals. Sub-intervals that have an 68 ## the quadrature into 10 intervals. Sub-intervals that have an
69 ## unacceptable error are sub-divided and re-evaluated. If the number of 69 ## unacceptable error are sub-divided and re-evaluated. If the number of
70 ## sub-intervals exceeds at any point 650 sub-intervals then a poor 70 ## sub-intervals exceeds at any point 650 sub-intervals then a poor
71 ## convergence is signaled and the current estimate of the integral is 71 ## convergence is signaled and the current estimate of the integral is
72 ## returned. The property 'MaxIntervalCount' can be used to alter the 72 ## returned. The property 'MaxIntervalCount' can be used to alter the
73 ## number of sub-intervals that can exist before exiting. 73 ## number of sub-intervals that can exist before exiting.
74 ## 74 ##
75 ## @item WayPoints 75 ## @item WayPoints
76 ## If there exists discontinuities in the first derivative of the 76 ## If there exists discontinuities in the first derivative of the
77 ## function to integrate, then these can be flagged with the 77 ## function to integrate, then these can be flagged with the
78 ## @code{"WayPoints"} property. This forces the ends of a sub-interval 78 ## @code{"WayPoints"} property. This forces the ends of a sub-interval
79 ## to fall on the breakpoints of the function and can result in 79 ## to fall on the breakpoints of the function and can result in
80 ## significantly improved estimated of the error in the integral, faster 80 ## significantly improved estimated of the error in the integral, faster
81 ## computation or both. For example, 81 ## computation or both. For example,
82 ## 82 ##
83 ## @example 83 ## @example
92 ## convergence of the quadrature at each iteration. 92 ## convergence of the quadrature at each iteration.
93 ##@end table 93 ##@end table
94 ## 94 ##
95 ## If any of @var{a}, @var{b} or @var{waypoints} is complex, then the 95 ## If any of @var{a}, @var{b} or @var{waypoints} is complex, then the
96 ## quadrature is treated as a contour integral along a piecewise 96 ## quadrature is treated as a contour integral along a piecewise
97 ## continuous path defined by the above. In this case the integral is 97 ## continuous path defined by the above. In this case the integral is
98 ## assuemd to have no edge singularities. For example 98 ## assuemd to have no edge singularities. For example
99 ## 99 ##
100 ## @example 100 ## @example
101 ## @group
101 ## quadgk (@@(z) log (z), 1+1i, 1+1i, "WayPoints", 102 ## quadgk (@@(z) log (z), 1+1i, 1+1i, "WayPoints",
102 ## [1-1i, -1,-1i, -1+1i]) 103 ## [1-1i, -1,-1i, -1+1i])
104 ## @end group
103 ## @end example 105 ## @end example
104 ## 106 ##
105 ## @noindent 107 ## @noindent
106 ## integrates @code{log (z)} along the square defined by @code{[1+1i, 108 ## integrates @code{log (z)} along the square defined by @code{[1+1i,
107 ## 1-1i, -1-1i, -1+1i]} 109 ## 1-1i, -1-1i, -1+1i]}