2 * Functions and Variables for Limits::
5 @c -----------------------------------------------------------------------------
6 @node Functions and Variables for Limits, , Limits, Limits
7 @section Functions and Variables for Limits
8 @c -----------------------------------------------------------------------------
10 @c -----------------------------------------------------------------------------
12 @defvr {Option variable} lhospitallim
15 @code{lhospitallim} is the maximum number of times L'Hospital's
16 rule is used in @mref{limit}. This prevents infinite looping in cases like
17 @code{limit (cot(x)/csc(x), x, 0)}.
19 @opencatbox{Categories:}
24 @c -----------------------------------------------------------------------------
26 @deffn {Function} limit @
27 @fname{limit} (@var{expr}, @var{x}, @var{val}, @var{dir}) @
28 @fname{limit} (@var{expr}, @var{x}, @var{val}) @
29 @fname{limit} (@var{expr})
31 Computes the limit of @var{expr} as the real variable @var{x} approaches the
32 value @var{val} from the direction @var{dir}. @var{dir} may have the value
33 @code{plus} for a limit from above, @code{minus} for a limit from below, or
34 may be omitted (implying a two-sided limit is to be computed).
36 @code{limit} uses the following special symbols: @code{inf} (positive infinity)
37 and @mref{minf} (negative infinity). On output it may also use @mref{und}
38 (undefined), @mref{ind} (indefinite but bounded) and @mref{infinity} (complex
41 @code{infinity} (complex infinity) is returned when the limit of
42 the absolute value of the expression is positive infinity, but
43 the limit of the expression itself is not positive infinity or
44 negative infinity. This includes cases where the limit of the
45 complex argument is a constant, as in @code{limit(log(x), x, minf)},
46 cases where the complex argument oscillates, as in
47 @code{limit((-2)^x, x, inf)}, and cases where the complex
48 argument is different for either side of a two-sided limit, as in
49 @code{limit(1/x, x, 0)} and @code{limit(log(x), x, 0)}.
51 @mref{lhospitallim} is the maximum number of times L'Hospital's rule
52 is used in @code{limit}. This prevents infinite looping in cases like
53 @code{limit (cot(x)/csc(x), x, 0)}.
55 @mref{tlimswitch} when true will allow the @code{limit} command to use
56 Taylor series expansion when necessary.
58 @mref{limsubst} prevents @code{limit} from attempting substitutions on
59 unknown forms. This is to avoid bugs like @code{limit (f(n)/f(n+1), n, inf)}
60 giving 1. Setting @code{limsubst} to @code{true} will allow such
63 @code{limit} with one argument is often called upon to simplify constant
64 expressions, for example, @code{limit (inf-1)}.
66 @c MERGE EXAMPLES INTO THIS FILE
67 @code{example (limit)} displays some examples.
69 For the method see Wang, P., "Evaluation of Definite Integrals by Symbolic
70 Manipulation", Ph.D. thesis, MAC TR-92, October 1971.
72 @opencatbox{Categories:}
77 @c -----------------------------------------------------------------------------
79 @defvr {Option variable} limsubst
80 Default value: @code{false}
82 prevents @mref{limit} from attempting substitutions on unknown forms. This is
83 to avoid bugs like @code{limit (f(n)/f(n+1), n, inf)} giving 1. Setting
84 @code{limsubst} to @code{true} will allow such substitutions.
86 @opencatbox{Categories:}
91 @c -----------------------------------------------------------------------------
93 @deffn {Function} tlimit @
94 @fname{tlimit} (@var{expr}, @var{x}, @var{val}, @var{dir}) @
95 @fname{tlimit} (@var{expr}, @var{x}, @var{val}) @
96 @fname{tlimit} (@var{expr})
98 Take the limit of the Taylor series expansion of @code{expr} in @code{x}
99 at @code{val} from direction @code{dir}.
101 @opencatbox{Categories:}
106 @c -----------------------------------------------------------------------------
108 @defvr {Option variable} tlimswitch
109 Default value: @code{true}
111 When @code{tlimswitch} is @code{true}, the @mref{limit} command will use a
112 Taylor series expansion if the limit of the input expression cannot be computed
113 directly. This allows evaluation of limits such as
114 @code{limit(x/(x-1)-1/log(x),x,1,plus)}. When @code{tlimswitch} is @code{false}
115 and the limit of input expression cannot be computed directly, @code{limit} will
116 return an unevaluated limit expression.
118 @opencatbox{Categories:}
123 @c -----------------------------------------------------------------------------
125 @deffn {Function} gruntz @
126 @fname{gruntz} (@var{expr}, @var{var}, @var{value}) @
127 @fname{gruntz} (@var{expr}, @var{var}, @var{value}, @var{direction})
129 Compute limit of expression @var{expr} with respect to variable @var{var} at @var{value}.
130 When @var{value} is not infinite (i.e., not @code{inf} or @code{minf}),
131 @var{direction} must be supplied,
132 either @code{plus} for a limit from above,
133 or @code{minus} for a limit from below.
135 If @code{gruntz} cannot find the limit,
136 an unevaluated expression @code{gruntz(...)} is returned.
138 @code{gruntz} implements the method described in the dissertation of
139 Dominik Gruntz, "On Computing Limits in a Symbolic Manipulation System"
142 The algorithm identifies the most rapidly varying subexpression,
143 replaces it with a new variable, rewrites the expression in terms
144 of the new variable, and then repeats.
146 The algorithm doesn't handle oscillating functions, so it can't do things like
147 @code{limit(sin(x)/x, x, inf)}.
149 To handle limits involving functions such as @code{gamma(x)} and @code{erf(x)},
150 the Gruntz algorithm requires them to be written in terms of asymptotic expansions,
151 which Maxima cannot currently do.
153 The Gruntz algorithm assumes that variables and expressions are real,
154 so, for example, it can't handle @code{limit((-2)^x, x, inf)}.
156 @code{gruntz} is one of the methods called from @code{limit}.
158 @opencatbox{Categories:}