1 @c -*- mode: texinfo -*-
3 * Introduction to Integration::
4 * Functions and Variables for Integration::
5 * Introduction to QUADPACK::
6 * Functions and Variables for QUADPACK::
9 @c -----------------------------------------------------------------------------
10 @node Introduction to Integration, Functions and Variables for Integration, Integration, Integration
11 @section Introduction to Integration
12 @c -----------------------------------------------------------------------------
14 Maxima has several routines for handling integration.
15 The @mref{integrate} function makes use of most of them. There is also the
16 @mref{antid} package, which handles an unspecified function (and its
17 derivatives, of course). For numerical uses,
18 there is a set of adaptive integrators from QUADPACK, named @mrefcomma{quad_qag}
19 @mrefcomma{quad_qags} etc., which are described under the heading @code{QUADPACK}.
20 Hypergeometric functions are being worked on,
21 see @mref{specint} for details.
22 Generally speaking, Maxima only handles integrals which are
23 integrable in terms of the "elementary functions" (rational functions,
24 trigonometrics, logs, exponentials, radicals, etc.) and a few
25 extensions (error function, dilogarithm). It does not handle
26 integrals in terms of unknown functions such as @code{g(x)} and @code{h(x)}.
28 @c end concepts Integration
30 @c -----------------------------------------------------------------------------
31 @node Functions and Variables for Integration, Introduction to QUADPACK, Introduction to Integration, Integration
32 @section Functions and Variables for Integration
33 @c -----------------------------------------------------------------------------
37 @c -----------------------------------------------------------------------------
39 @deffn {Function} changevar (@var{expr}, @var{f(x,y)}, @var{y}, @var{x})
41 Makes the change of variable given by @code{@var{f(x,y)} = 0} in all integrals
42 occurring in @var{expr} with integration with respect to @var{x}.
43 The new variable is @var{y}.
45 The change of variable can also be written @code{@var{f(x)} = @var{g(y)}}.
47 @c HMM, THIS EXAMPLE YIELDS A CORRECT BUT SLIGHTLY STRANGE RESULT...
50 @c 'integrate (%e**sqrt(a*y), y, 0, 4);
51 @c changevar (%, y-z^2/a, z, y);
56 (%i2) 'integrate (%e**sqrt(a*y), y, 0, 4);
66 (%i3) changevar (%, y-z^2/a, z, y);
74 (%o3) - ----------------------------
79 An expression containing a noun form, such as the instances of @code{'integrate}
80 above, may be evaluated by @code{ev} with the @code{nouns} flag.
81 For example, the expression returned by @code{changevar} above may be evaluated
82 by @code{ev (%o3, nouns)}.
84 @code{changevar} may also be used to make changes in the indices of a sum or
85 product. However, it must be realized that when a change is made in a
86 sum or product, this change must be a shift, i.e., @code{i = j+ ...}, not a
87 higher degree function. E.g.,
90 @c sum (a[i]*x^(i-2), i, 0, inf);
91 @c changevar (%, i-2-n, n, i);
95 (%i4) sum (a[i]*x^(i-2), i, 0, inf);
105 (%i5) changevar (%, i-2-n, n, i);
116 @opencatbox{Categories:}
117 @category{Integral calculus}
121 @c THIS ITEM IS A MESS, BUT DON'T BOTHER TO CLEAN IT UP:
122 @c THE GAUSS-KRONROD FUNCTIONS (QUADPACK) MAKE THIS OBSOLETE
124 @c -----------------------------------------------------------------------------
126 @deffn {Function} dblint (@var{f}, @var{r}, @var{s}, @var{a}, @var{b})
128 A double-integral routine which was written in
129 top-level Maxima and then translated and compiled to machine code.
130 Use @code{load ("dblint")} to access this package. It uses the Simpson's rule
131 method in both the x and y directions to calculate
134 $$\int_a^b \int_{r\left(x\right)}^{s\left(x\right)} f\left(x,y\right) \, dy \, dx.$$
148 The function @var{f} must be a translated or compiled function of two variables,
149 and @var{r} and @var{s} must each be a translated or compiled function of one
150 variable, while @var{a} and @var{b} must be floating point numbers. The routine
151 has two global variables which determine the number of divisions of the x and y
152 intervals: @code{dblint_x} and @code{dblint_y}, both of which are initially 10,
153 and can be changed independently to other integer values (there are
154 @code{2*dblint_x+1} points computed in the x direction, and @code{2*dblint_y+1}
155 in the y direction). The routine subdivides the X axis and then for each value
156 of X it first computes @code{@var{r}(x)} and @code{@var{s}(x)}; then the Y axis
157 between @code{@var{r}(x)} and @code{@var{s}(x)} is subdivided and the integral
158 along the Y axis is performed using Simpson's rule; then the integral along the
159 X axis is done using Simpson's rule with the function values being the
160 Y-integrals. This procedure may be numerically unstable for a great variety of
161 reasons, but is reasonably fast: avoid using it on highly oscillatory functions
162 and functions with singularities (poles or branch points in the region). The Y
163 integrals depend on how far apart @code{@var{r}(x)} and @code{@var{s}(x)} are,
164 so if the distance @code{@var{s}(x) - @var{r}(x)} varies rapidly with X, there
165 may be substantial errors arising from truncation with different step-sizes in
166 the various Y integrals. One can increase @code{dblint_x} and @code{dblint_y}
167 in an effort to improve the coverage of the region, at the expense of
168 computation time. The function values are not saved, so if the function is very
169 time-consuming, you will have to wait for re-computation if you change anything
170 (sorry). It is required that the functions @var{f}, @var{r}, and @var{s} be
171 either translated or compiled prior to calling @code{dblint}. This will result
172 in orders of magnitude speed improvement over interpreted code in many cases!
174 @code{demo ("dblint")} executes a demonstration of @code{dblint} applied to an
176 @c demo (dblint_1) FAILS WITH Could not find `fltdfnk.mc' -- DON'T BOTHER TO MENTION IT. !!!
177 @c @code{demo (dblint_1)} executes another demonstration.
179 @opencatbox{Categories:}
180 @category{Integral calculus}
184 @c -----------------------------------------------------------------------------
186 @deffn {Function} defint (@var{expr}, @var{x}, @var{a}, @var{b})
188 Attempts to compute a definite integral. @code{defint} is called by
189 @code{integrate} when limits of integration are specified, i.e., when
190 @code{integrate} is called as
191 @code{integrate (@var{expr}, @var{x}, @var{a}, @var{b})}.
192 Thus from the user's point of view, it is sufficient to call @code{integrate}.
193 @c SHOULD WE BOTHER TO DOCUMENT defint ??? NO FUNCTIONALITY HERE THAT IS NOT ALREADY PRESENT IN integrate !!!
195 @code{defint} returns a symbolic expression, either the computed integral or the
196 noun form of the integral. See @mref{quad_qag} and related functions for
197 numerical approximation of definite integrals.
199 @opencatbox{Categories:}
200 @category{Integral calculus}
204 @c -----------------------------------------------------------------------------
206 @defvr {Option variable} erfflag
207 Default value: @code{true}
209 When @code{erfflag} is @code{false}, prevents @code{risch} from introducing the
210 @code{erf} function in the answer if there were none in the integrand to
213 @opencatbox{Categories:}
214 @category{Integral calculus}
220 @c -----------------------------------------------------------------------------
222 @deffn {Function} ilt (@var{expr}, @var{s}, @var{t})
224 Computes the inverse Laplace transform of @var{expr} with
225 respect to @var{s} and parameter @var{t}. @var{expr} must be a ratio of
226 polynomials whose denominator has only linear and quadratic factors;
227 there is an extension of @code{ilt}, called @mref{pwilt} (Piece-Wise
228 Inverse Laplace Transform) that handles several other cases where
231 By using the functions @code{laplace} and @code{ilt} together with the
232 @code{solve} or @code{linsolve} functions the user can solve a single
233 differential or convolution integral equation or a set of them.
236 @c 'integrate (sinh(a*x)*f(t-x), x, 0, t) + b*f(t) = t**2;
237 @c laplace (%, t, s);
238 @c linsolve ([%], ['laplace(f(t), t, s)]);
239 @c ilt (rhs (first (%)), s, t);
244 (%i1) 'integrate (sinh(a*x)*f(t-x), x, 0, t) + b*f(t) = t**2;
248 (%o1) I f(t - x) sinh(a x) dx + b f(t) = t
254 (%i2) laplace (%, t, s);
255 a laplace(f(t), t, s) 2
256 (%o2) b laplace(f(t), t, s) + --------------------- = --
261 (%i3) linsolve ([%], ['laplace(f(t), t, s)]);
264 (%o3) [laplace(f(t), t, s) = --------------------]
269 (%i4) ilt (rhs (first (%)), s, t);
270 Is a b (a b - 1) positive, negative, or zero?
273 sqrt(a b (a b - 1)) t
274 2 cosh(---------------------) 2
276 (%o4) - ----------------------------- + -------
287 @opencatbox{Categories:}
288 @category{Laplace transform}
292 @c -----------------------------------------------------------------------------
294 @defvr {Option variable} intanalysis
295 Default value: @code{true}
297 When @code{true}, definite integration tries to find poles in the integrand in
298 the interval of integration. If there are, then the integral is evaluated
299 appropriately as a principal value integral. If intanalysis is @code{false},
300 this check is not performed and integration is done assuming there are no poles.
302 See also @mrefdot{ldefint}
306 Maxima can solve the following integrals, when @mref{intanalysis} is set to
310 @c integrate(1/(sqrt(x+1)+1),x,0,1);
311 @c integrate(1/(sqrt(x)+1),x,0,1),intanalysis:false;
312 @c integrate(cos(a)/sqrt((tan(a))^2+1),a,-%pi/2,%pi/2);
313 @c intanalysis:false$
314 @c integrate(cos(a)/sqrt((tan(a))^2 +1),a,-%pi/2,%pi/2);
317 (%i1) integrate(1/(sqrt(x)+1),x,0,1);
321 (%o1) I ----------- dx
326 (%i2) integrate(1/(sqrt(x)+1),x,0,1),intanalysis:false;
329 (%i3) integrate(cos(a)/sqrt((tan(a))^2 +1),a,-%pi/2,%pi/2);
330 The number 1 isn't in the domain of atanh
331 -- an error. To debug this try: debugmode(true);
333 (%i4) intanalysis:false$
334 (%i5) integrate(cos(a)/sqrt((tan(a))^2+1),a,-%pi/2,%pi/2);
340 @opencatbox{Categories:}
341 @category{Integral calculus}
345 @c -----------------------------------------------------------------------------
347 @deffn {Function} integrate @
348 @fname{integrate} (@var{expr}, @var{x}) @
349 @fname{integrate} (@var{expr}, @var{x}, @var{a}, @var{b})
351 Attempts to symbolically compute the integral of @var{expr} with respect to
352 @var{x}. @code{integrate (@var{expr}, @var{x})} is an indefinite integral,
353 while @code{integrate (@var{expr}, @var{x}, @var{a}, @var{b})} is a definite
354 integral, with limits of integration @var{a} and @var{b}. The limits should
355 not contain @var{x}, although @code{integrate} does not enforce this
356 restriction. @var{a} need not be less than @var{b}.
357 If @var{b} is equal to @var{a}, @code{integrate} returns zero.
359 See @mref{quad_qag} and related functions for numerical approximation of
360 definite integrals. See @mref{residue} for computation of residues
361 (complex integration). See @mref{antid} for an alternative means of computing
362 indefinite integrals.
364 The integral (an expression free of @code{integrate}) is returned if
365 @code{integrate} succeeds. Otherwise the return value is
366 the noun form of the integral (the quoted operator @code{'integrate})
367 or an expression containing one or more noun forms.
368 The noun form of @code{integrate} is displayed with an integral sign.
370 In some circumstances it is useful to construct a noun form by hand, by quoting
371 @code{integrate} with a single quote, e.g.,
372 @code{'integrate (@var{expr}, @var{x})}. For example, the integral may depend
373 on some parameters which are not yet computed.
374 The noun may be applied to its arguments by @code{ev (@var{i}, nouns)}
375 where @var{i} is the noun form of interest.
377 @c BEGIN EXPOSITION ON HEURISTICS
378 @code{integrate} handles definite integrals separately from indefinite, and
379 employs a range of heuristics to handle each case. Special cases of definite
380 integrals include limits of integration equal to zero or infinity (@mref{inf} or
381 @mref{minf}), trigonometric functions with limits of integration equal to zero
382 and @code{%pi} or @code{2 %pi}, rational functions, integrals related to the
383 definitions of the @mref{beta} and @mref{psi} functions, and some logarithmic
384 and trigonometric integrals. Processing rational functions may include
385 computation of residues. If an applicable special case is not found, an attempt
386 will be made to compute the indefinite integral and evaluate it at the limits of
387 integration. This may include taking a limit as a limit of integration goes to
388 infinity or negative infinity; see also @mrefdot{ldefint}
390 Special cases of indefinite integrals include trigonometric functions,
391 exponential and logarithmic functions,
392 and rational functions.
393 @code{integrate} may also make use of a short table of elementary integrals.
395 @code{integrate} may carry out a change of variable
396 if the integrand has the form @code{f(g(x)) * diff(g(x), x)}.
397 @code{integrate} attempts to find a subexpression @code{g(x)} such that
398 the derivative of @code{g(x)} divides the integrand.
399 This search may make use of derivatives defined by the @code{gradef} function.
400 See also @mref{changevar} and @mrefdot{antid}
402 If none of the preceding heuristics find the indefinite integral, the Risch
403 algorithm is executed. The flag @mref{risch} may be set as an @mrefcomma{evflag}
404 in a call to @code{ev} or on the command line, e.g.,
405 @code{ev (integrate (@var{expr}, @var{x}), risch)} or
406 @code{integrate (@var{expr}, @var{x}), risch}. If @code{risch} is present,
407 @code{integrate} calls the @mref{risch} function without attempting heuristics
408 first. See also @mrefdot{risch}
409 @c END EXPOSITION ON HEURISTICS
411 @code{integrate} works only with functional relations represented explicitly
412 with the @code{f(x)} notation. @code{integrate} does not respect implicit
413 dependencies established by the @mref{depends} function.
415 @code{integrate} may need to know some property of a parameter in the integrand.
416 @code{integrate} will first consult the @mref{assume} database,
417 and, if the variable of interest is not there,
418 @code{integrate} will ask the user.
419 Depending on the question,
420 suitable responses are @code{yes;} or @code{no;},
421 or @code{pos;}, @code{zero;}, or @code{neg;}.
423 @code{integrate} is not, by default, declared to be linear. See @code{declare}
426 @code{integrate} attempts integration by parts only in a few special cases.
432 Elementary indefinite and definite integrals.
435 @c integrate (sin(x)^3, x);
436 @c integrate (x/ sqrt (b^2 - x^2), x);
437 @c integrate (cos(x)^2 * exp(x), x, 0, %pi);
438 @c integrate (x^2 * exp(-x^2), x, minf, inf);
442 (%i1) integrate (sin(x)^3, x);
445 (%o1) ------- - cos(x)
449 (%i2) integrate (x/ sqrt (b^2 - x^2), x);
454 (%i3) integrate (cos(x)^2 * exp(x), x, 0, %pi);
461 (%i4) integrate (x^2 * exp(-x^2), x, minf, inf);
469 Use of @code{assume} and interactive query.
473 @c integrate (x**a/(x+1)**(5/2), x, 0, inf);
478 (%i1) assume (a > 1)$
480 (%i2) integrate (x**a/(x+1)**(5/2), x, 0, inf);
482 Is ------- an integer?
486 Is 2 a - 3 positive, negative, or zero?
490 (%o2) beta(a + 1, - - a)
496 Change of variable. There are two changes of variable in this example:
497 one using a derivative established by @mrefcomma{gradef} and one using the
498 derivation @code{diff(r(x))} of an unspecified function @code{r(x)}.
501 @c gradef (q(x), sin(x**2));
502 @c diff (log (q (r (x))), x);
507 (%i3) gradef (q(x), sin(x**2));
511 (%i4) diff (log (q (r (x))), x);
513 (-- (r(x))) sin(r (x))
515 (%o4) ----------------------
519 (%i5) integrate (%, x);
525 Return value contains the @code{'integrate} noun form. In this example, Maxima
526 can extract one factor of the denominator of a rational function, but cannot
527 factor the remainder or otherwise find its integral. @mref{grind} shows the
528 noun form @code{'integrate} in the result. See also
529 @mref{integrate_use_rootsof} for more on integrals of rational functions.
532 @c expand ((x-4) * (x^3+2*x+1));
533 @c integrate (1/%, x);
538 (%i1) expand ((x-4) * (x^3+2*x+1));
540 (%o1) x - 4 x + 2 x - 7 x - 4
543 (%i2) integrate (1/%, x);
548 log(x - 4) / x + 2 x + 1
549 (%o2) ---------- - ------------------
554 log(x-4)/73-('integrate((x^2+4*x+18)/(x^3+2*x+1),x))/73$
559 Defining a function in terms of an integral. The body of a function is not
560 evaluated when the function is defined. Thus the body of @code{f_1} in this
561 example contains the noun form of @code{integrate}. The quote-quote operator
562 @code{'@w{}'} causes the integral to be evaluated, and the result becomes the
566 @c f_1 (a) := integrate (x^3, x, 1, a);
567 @c ev (f_1 (7), nouns);
568 @c /* Note parentheses around integrate(...) here */ f_2 (a) := ''(integrate (x^3, x, 1, a));
573 (%i1) f_1 (a) := integrate (x^3, x, 1, a);
575 (%o1) f_1(a) := integrate(x , x, 1, a)
578 (%i2) ev (f_1 (7), nouns);
582 (%i3) /* Note parentheses around integrate(...) here */
583 f_2 (a) := ''(integrate (x^3, x, 1, a));
586 (%o3) f_2(a) := -- - -
596 @opencatbox{Categories:}
597 @category{Integral calculus}
601 @c -----------------------------------------------------------------------------
602 @anchor{integration_constant}
603 @defvr {System variable} integration_constant
604 Default value: @code{%c}
606 When a constant of integration is introduced by indefinite integration of an
607 equation, the name of the constant is constructed by concatenating
608 @code{integration_constant} and @code{integration_constant_counter}.
610 @code{integration_constant} may be assigned any symbol.
615 @c integrate (x^2 = 1, x);
616 @c integration_constant : 'k;
617 @c integrate (x^2 = 1, x);
621 (%i1) integrate (x^2 = 1, x);
628 (%i2) integration_constant : 'k;
632 (%i3) integrate (x^2 = 1, x);
640 @opencatbox{Categories:}
641 @category{Integral calculus}
645 @c -----------------------------------------------------------------------------
646 @anchor{integration_constant_counter}
647 @defvr {System variable} integration_constant_counter
650 When a constant of integration is introduced by indefinite integration of an
651 equation, the name of the constant is constructed by concatenating
652 @code{integration_constant} and @code{integration_constant_counter}.
654 @code{integration_constant_counter} is incremented before constructing the next
655 integration constant.
660 @c integrate (x^2 = 1, x);
661 @c integrate (x^2 = 1, x);
662 @c integrate (x^2 = 1, x);
663 @c reset (integration_constant_counter);
664 @c integrate (x^2 = 1, x);
668 (%i1) integrate (x^2 = 1, x);
675 (%i2) integrate (x^2 = 1, x);
682 (%i3) integrate (x^2 = 1, x);
689 (%i4) reset (integration_constant_counter);
690 (%o4) [integration_constant_counter]
693 (%i5) integrate (x^2 = 1, x);
701 @opencatbox{Categories:}
702 @category{Integral calculus}
706 @c -----------------------------------------------------------------------------
707 @anchor{integrate_use_rootsof}
708 @defvr {Option variable} integrate_use_rootsof
709 Default value: @code{false}
711 When @code{integrate_use_rootsof} is @code{true} and the denominator of
712 a rational function cannot be factored, @mref{integrate} returns the integral
713 in a form which is a sum over the roots (not yet known) of the denominator.
715 For example, with @code{integrate_use_rootsof} set to @code{false},
716 @code{integrate} returns an unsolved integral of a rational function in noun
720 @c integrate_use_rootsof: false$
721 @c integrate (1/(1+x+x^5), x);
724 (%i1) integrate_use_rootsof: false$
726 (%i2) integrate (1/(1+x+x^5), x);
729 I ------------ dx 2 x + 1
730 ] 3 2 2 5 atan(-------)
731 / x - x + 1 log(x + x + 1) sqrt(3)
732 (%o2) ----------------- - --------------- + ---------------
737 Now we set the flag to be true and the unsolved part of the integral will be
738 expressed as a summation over the roots of the denominator of the rational
742 @c integrate_use_rootsof: true$
743 @c integrate (1/(1+x+x^5), x);
746 (%i3) integrate_use_rootsof: true$
748 (%i4) integrate (1/(1+x+x^5), x);
750 \ (%r4 - 4 %r4 + 5) log(x - %r4)
751 > -------------------------------
755 %r4 in rootsof(%r4 - %r4 + 1, %r4)
756 (%o4) ----------------------------------------------------------
761 log(x + x + 1) sqrt(3)
762 - --------------- + ---------------
767 Alternatively the user may compute the roots of the denominator separately,
768 and then express the integrand in terms of these roots, e.g.,
769 @code{1/((x - a)*(x - b)*(x - c))} or @code{1/((x^2 - (a+b)*x + a*b)*(x - c))}
770 if the denominator is a cubic polynomial.
771 Sometimes this will help Maxima obtain a more useful result.
773 @opencatbox{Categories:}
774 @category{Integral calculus}
778 @c -----------------------------------------------------------------------------
780 @deffn {Function} laplace (@var{expr}, @var{t}, @var{s})
782 Attempts to compute the Laplace transform of @var{expr} with respect to the
783 variable @var{t} and transform parameter @var{s}. The Laplace
784 transform of the function @code{f(t)} is the one-sided transform defined by
786 <<<F(s) = \int_0^{\infty} f(t) e^{-st} dt>>>,
789 F(s) = integrate(f(t) * exp(-s*t), t, 0, inf)
793 where @math{F(s)} is the transform of @math{f(t)}, represented by @var{expr}.
795 @code{laplace} recognizes in @var{expr} the functions @mrefcomma{delta} @mrefcomma{exp}
796 @mrefcomma{log} @mrefcomma{sin} @mrefcomma{cos} @mrefcomma{sinh} @mrefcomma{cosh} and @mrefcomma{erf}
797 as well as @code{derivative}, @mrefcomma{integrate} @mrefcomma{sum} and @mrefdot{ilt} If
798 @code{laplace} fails to find a transform the function @mref{specint} is called.
799 @mref{specint} can find the laplace transform for expressions with special
800 functions like the bessel functions @mrefcomma{bessel_j} @mrefcomma{bessel_i} @dots{}
801 and can handle the @mref{unit_step} function. See also @mrefdot{specint}
803 If @mref{specint} cannot find a solution too, a noun @code{laplace} is returned.
806 @var{expr} may also be a linear, constant coefficient differential equation in
807 which case @mref{atvalue} of the dependent variable is used.
808 @c "used" -- USED HOW ??
809 The required atvalue may be supplied either before or after the transform is
810 computed. Since the initial conditions must be specified at zero, if one has
811 boundary conditions imposed elsewhere he can impose these on the general
812 solution and eliminate the constants by solving the general solution
813 for them and substituting their values back.
815 @code{laplace} recognizes convolution integrals of the form
817 <<<\int_0^t f(x) g(t-x) dx>>>,
820 integrate (f(x) * g(t - x), x, 0, t)
824 Other kinds of convolutions are not recognized.
826 Functional relations must be explicitly represented in @var{expr};
827 implicit relations, established by @mrefcomma{depends} are not recognized.
828 That is, if @math{f} depends on @math{x} and @math{y},
829 @math{f (x, y)} must appear in @var{expr}.
831 See also @mrefcomma{ilt} the inverse Laplace transform.
836 @c laplace (exp (2*t + a) * sin(t) * t, t, s);
837 @c laplace ('diff (f (x), x), x, s);
838 @c diff (diff (delta (t), t), t);
839 @c laplace (%, t, s);
841 @c declare(a, integer)$
842 @c laplace(gamma_incomplete(a,t),t,s),gamma_expand:true;
843 @c factor(laplace(gamma_incomplete(1/2,t),t,s));
844 @c assume(exp(%pi*s)>1)$
845 @c laplace(sum((-1)^n*unit_step(t-n*%pi)*sin(t),n,0,inf),t,s),
849 (%i1) laplace (exp (2*t + a) * sin(t) * t, t, s);
852 (%o1) ---------------
855 (%i2) laplace ('diff (f (x), x), x, s);
856 (%o2) s laplace(f(x), x, s) - f(0)
857 (%i3) diff (diff (delta (t), t), t);
863 (%i4) laplace (%, t, s);
866 (%o4) - -- (delta(t))! + s - delta(0) s
870 (%i6) laplace(gamma_incomplete(a,t),t,s),gamma_expand:true;
873 (%o6) -------- - -----------------
877 (%i7) factor(laplace(gamma_incomplete(1/2,t),t,s));
879 sqrt(%pi) (sqrt(s) sqrt(-----) - 1)
881 (%o7) -----------------------------------
885 (%i8) assume(exp(%pi*s)>1)$
886 (%i9) laplace(sum((-1)^n*unit_step(t-n*%pi)*sin(t),n,0,inf),t,s),
890 ------------------------ - ------------------------
892 (s + %i) (1 - %e ) (s - %i) (1 - %e )
893 (%o9) ---------------------------------------------------
899 (%o9) -------------------------------
901 (s - %i) (s + %i) (%e - 1)
905 @opencatbox{Categories:}
906 @category{Laplace transform}
907 @category{Differential equations}
913 @c -----------------------------------------------------------------------------
915 @deffn {Function} ldefint (@var{expr}, @var{x}, @var{a}, @var{b})
917 Attempts to compute the definite integral of @var{expr} by using @mref{limit}
918 to evaluate the indefinite integral of @var{expr} with respect to @var{x}
919 at the upper limit @var{b} and at the lower limit @var{a}.
920 If it fails to compute the definite integral,
921 @code{ldefint} returns an expression containing limits as noun forms.
923 @code{ldefint} is not called from @mrefcomma{integrate} so executing
924 @code{ldefint (@var{expr}, @var{x}, @var{a}, @var{b})} may yield a different
925 result than @code{integrate (@var{expr}, @var{x}, @var{a}, @var{b})}.
926 @code{ldefint} always uses the same method to evaluate the definite integral,
927 while @code{integrate} may employ various heuristics and may recognize some
930 @opencatbox{Categories:}
931 @category{Integral calculus}
935 @c UMM, IS THERE SOME TEXT MISSING HERE ???
936 @c WHAT IS THIS ABOUT EXACTLY ??
938 @c -----------------------------------------------------------------------------
940 @deffn {Function} pwilt (@var{expr}, @var{s}, @var{t})
942 Computes the inverse Laplace transform of @var{expr} with
943 respect to @var{s} and parameter @var{t}. Unlike @mrefcomma{ilt}
944 @code{pwilt} is able to return piece-wise and periodic functions
945 and can also handle some cases with polynomials of degree greater than 3
948 Two examples where @code{ilt} fails:
950 @c pwilt (exp(-s)*s/(s^3-2*s-s+2), s, t);
951 @c pwilt ((s^2+2)/(s^2-1), s, t);
954 (%i1) pwilt (exp(-s)*s/(s^3-2*s-s+2), s, t);
957 (%o1) hstep(t - 1) (--------------- - ---------------)
960 (%i2) pwilt ((s^2+2)/(s^2-1), s, t);
963 (%o2) delta(t) + ----- - -------
967 @opencatbox{Categories:}
968 @category{Laplace transform}
972 @c -----------------------------------------------------------------------------
974 @deffn {Function} potential (@var{givengradient})
976 The calculation makes use of the global variable @code{potentialzeroloc[0]}
977 which must be @code{nonlist} or of the form
980 [indeterminatej=expressionj, indeterminatek=expressionk, ...]
983 the former being equivalent to the nonlist expression for all right-hand
984 sides in the latter. The indicated right-hand sides are used as the
985 lower limit of integration. The success of the integrations may
986 depend upon their values and order. @code{potentialzeroloc} is initially set
990 @c -----------------------------------------------------------------------------
992 @defvr {Option variable} prefer_d
993 Default value: @code{false}
995 When @code{prefer_d} is @code{true}, @mref{specint} will prefer to
996 express solutions using @mref{parabolic_cylinder_d} rather than
997 hypergeometric functions.
999 In the example below, the solution contains @mref{parabolic_cylinder_d}
1000 when @code{prefer_d} is @code{true}.
1004 @c factor(ex:specint(%e^-(t^2/8)*exp(-s*t),t));
1005 @c specint(ex,t),prefer_d=true;
1013 (%i2) factor(specint(ex:%e^-(t^2/8)*exp(-s*t),t));
1016 (%o2) - sqrt(2) sqrt(%pi) %e (erf(sqrt(2) s) - 1)
1019 (%i3) specint(ex,t),prefer_d=true;
1024 parabolic_cylinder_d(- 1, -------) %e
1026 (%o3) ---------------------------------------
1032 @opencatbox{Categories:}
1033 @category{Laplace transform}
1034 @category{Special functions}
1038 @c -----------------------------------------------------------------------------
1040 @deffn {Function} residue (@var{expr}, @var{z}, @var{z_0})
1042 Computes the residue in the complex plane of the expression @var{expr} when the
1043 variable @var{z} assumes the value @var{z_0}. The residue is the coefficient of
1044 @code{(@var{z} - @var{z_0})^(-1)} in the Laurent series for @var{expr}.
1047 @c residue (s/(s**2+a**2), s, a*%i);
1048 @c residue (sin(a*x)/x**4, x, 0);
1052 (%i1) residue (s/(s**2+a**2), s, a*%i);
1058 (%i2) residue (sin(a*x)/x**4, x, 0);
1066 @opencatbox{Categories:}
1067 @category{Integral calculus}
1068 @category{Complex variables}
1072 @c -----------------------------------------------------------------------------
1074 @deffn {Function} risch (@var{expr}, @var{x})
1076 Integrates @var{expr} with respect to @var{x} using the
1077 transcendental case of the Risch algorithm. (The algebraic case of
1078 the Risch algorithm has not been implemented.) This currently
1079 handles the cases of nested exponentials and logarithms which the main
1080 part of @code{integrate} can't do. @mref{integrate} will automatically apply
1081 @code{risch} if given these cases.
1083 @code{erfflag}, if @code{false}, prevents @code{risch} from introducing the
1084 @code{erf} function in the answer if there were none in the integrand to begin
1088 @c risch (x^2*erf(x), x);
1089 @c diff(%, x), ratsimp;
1093 (%i1) risch (x^2*erf(x), x);
1096 %pi x erf(x) + (sqrt(%pi) x + sqrt(%pi)) %e
1097 (%o1) -------------------------------------------------
1101 (%i2) diff(%, x), ratsimp;
1107 @opencatbox{Categories:}
1108 @category{Integral calculus}
1113 @deffn {Function} specint (exp(- s*@var{t}) * @var{expr}, @var{t})
1115 Compute the Laplace transform of @var{expr} with respect to the variable @var{t}.
1116 The integrand @var{expr} may contain special functions. The
1117 parameter @var{s} maybe be named something else; it is determined
1118 automatically, as the examples below show where @var{p} is used in
1121 The following special functions are handled by @code{specint}: incomplete gamma
1122 function, error functions (but not the error function @code{erfi}, it is easy to
1123 transform @code{erfi} e.g. to the error function @code{erf}), exponential
1124 integrals, bessel functions (including products of bessel functions), hankel
1125 functions, hermite and the laguerre polynomials.
1127 Furthermore, @code{specint} can handle the hypergeometric function
1128 @code{%f[p,q]([],[],z)}, the Whittaker function of the first kind
1129 @code{%m[u,k](z)} and of the second kind @code{%w[u,k](z)}.
1131 The result may be in terms of special functions and can include unsimplified
1132 hypergeometric functions. If variable @mref{prefer_d} is @code{true}
1133 then the @mref{parabolic_cylinder_d} function may be used in the result
1134 in preference to hypergeometric functions.
1136 When @mref{laplace} fails to find a Laplace transform, @code{specint} is called.
1137 Because @mref{laplace} knows more general rules for Laplace transforms, it is
1138 preferable to use @mref{laplace} and not @code{specint}.
1140 @code{demo("hypgeo")} displays several examples of Laplace transforms computed by
1145 @c assume (p > 0, a > 0)$
1146 @c specint (t^(1/2) * exp(-a*t/4) * exp(-p*t), t);
1147 @c specint (t^(1/2) * bessel_j(1, 2 * a^(1/2) * t^(1/2))
1151 (%i1) assume (p > 0, a > 0)$
1153 (%i2) specint (t^(1/2) * exp(-a*t/4) * exp(-p*t), t);
1161 (%i3) specint (t^(1/2) * bessel_j(1, 2 * a^(1/2) * t^(1/2))
1165 (%o3) ---------------
1171 Examples for exponential integrals:
1174 (%i4) assume(s>0,a>0,s-a>0)$
1175 (%i5) ratsimp(specint(%e^(a*t)
1176 *(log(a)+expintegral_e1(a*t))*%e^(-s*t),t));
1182 (%i7) gamma_expand:true$
1184 radcan(specint((cos(t)*expintegral_si(t)
1185 -sin(t)*expintegral_ci(t))*%e^(-s*t),t));
1190 ratsimp(specint((2*t*log(a)+2/a*sin(a*t)
1191 -2*t*expintegral_ci(a*t))*%e^(-s*t),t));
1199 Results when using the expansion of @mref{gamma_incomplete} and when changing
1200 the representation to @mref{expintegral_e1}:
1204 (%i11) specint(1/sqrt(%pi*t)*unit_step(t-k)*%e^(-s*t),t);
1206 gamma_incomplete(-, k s)
1208 (%o11) ------------------------
1211 (%i12) gamma_expand:true$
1212 (%i13) specint(1/sqrt(%pi*t)*unit_step(t-k)*%e^(-s*t),t);
1213 erfc(sqrt(k) sqrt(s))
1214 (%o13) ---------------------
1217 (%i14) expintrep:expintegral_e1$
1218 (%i15) ratsimp(specint(1/(t+a)^2*%e^(-s*t),t));
1220 a s %e expintegral_e1(a s) - 1
1221 (%o15) - ---------------------------------
1225 @opencatbox{Categories:}
1226 @category{Laplace transform}
1230 @c NEEDS EXPANSION, CLARIFICATION, AND EXAMPLES
1232 @c -----------------------------------------------------------------------------
1234 @deffn {Function} tldefint (@var{expr}, @var{x}, @var{a}, @var{b})
1236 Equivalent to @code{ldefint} with @code{tlimswitch} set to @code{true}.
1238 @opencatbox{Categories:}
1239 @category{Integral calculus}
1245 @c -----------------------------------------------------------------------------
1246 @node Introduction to QUADPACK, Functions and Variables for QUADPACK, Functions and Variables for Integration, Integration
1247 @section Introduction to QUADPACK
1248 @c -----------------------------------------------------------------------------
1250 @c FOLLOWING TEXT ADAPTED WITH HEAVY MODIFICATION FROM https://www.netlib.org/slatec/src/qpdoc.f
1252 QUADPACK is a collection of functions for the numerical
1253 computation of one-dimensional definite integrals.
1254 It originated from a joint project of
1255 R. Piessens @footnote{Applied Mathematics and Programming Division, K.U. Leuven},
1256 E. de Doncker @footnote{Applied Mathematics and Programming Division, K.U. Leuven},
1257 C. Ueberhuber @footnote{Institut f@"ur Mathematik, T.U. Wien},
1258 and D. Kahaner @footnote{National Bureau of Standards, Washington, D.C., U.S.A}.
1260 The QUADPACK library included in Maxima is an automatic translation (via the
1261 program @code{f2cl}) of the Fortran source code of QUADPACK as it appears in
1262 the SLATEC Common Mathematical Library, Version 4.1 @footnote{@url{https://www.netlib.org/slatec}}.
1263 The SLATEC library is dated July 1993, but the QUADPACK functions
1264 were written some years before.
1265 There is another version of QUADPACK at Netlib @footnote{@url{https://www.netlib.org/quadpack}};
1266 it is not clear how that version differs from the SLATEC version.
1268 The QUADPACK functions included in Maxima are all automatic, in the sense that
1269 these functions attempt to compute a result to a specified accuracy, requiring
1270 an unspecified number of function evaluations. Maxima's Lisp translation of
1271 QUADPACK also includes some non-automatic functions, but they are not exposed
1272 at the Maxima level.
1274 Further information about QUADPACK can be found in the QUADPACK book
1275 @footnote{R. Piessens, E. de Doncker-Kapenga, C.W. Uberhuber, and D.K. Kahaner.
1276 @i{QUADPACK: A Subroutine Package for Automatic Integration.}
1277 Berlin: Springer-Verlag, 1983, ISBN 0387125531.}.
1279 @c -----------------------------------------------------------------------------
1280 @subsection Overview
1281 @c -----------------------------------------------------------------------------
1284 @item @mref{quad_qag}
1285 Integration of a general function over a finite interval.
1286 @mref{quad_qag} implements a simple globally adaptive integrator using the
1287 strategy of Aind (Piessens, 1973).
1288 The caller may choose among 6 pairs of Gauss-Kronrod quadrature
1289 formulae for the rule evaluation component.
1290 The high-degree rules are suitable for strongly oscillating integrands.
1292 @item @mref{quad_qags}
1293 Integration of a general function over a finite interval.
1294 @mref{quad_qags} implements globally adaptive interval subdivision with
1295 extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn, 1956).
1297 @item @mref{quad_qagi}
1298 Integration of a general function over an infinite or semi-infinite interval.
1299 The interval is mapped onto a finite interval and
1300 then the same strategy as in @code{quad_qags} is applied.
1302 @item @mref{quad_qawo}
1305 m4_math(<<<\cos(\omega x) f(x)>>>,<<<@math{cos(omega x) f(x)}>>>)
1307 m4_math(<<<\sin(\omega x) f(x)>>>,<<<@math{sin(omega x) f(x)}>>>)
1309 finite interval, where
1310 m4_math(\omega, @math{omega})
1312 The rule evaluation component is based on the modified Clenshaw-Curtis
1313 technique. @mref{quad_qawo} applies adaptive subdivision with extrapolation,
1314 similar to @mrefdot{quad_qags}
1316 @item @mref{quad_qawf}
1317 Calculates a Fourier cosine or Fourier sine transform on a semi-infinite
1318 interval. The same approach as in @mref{quad_qawo} is applied on successive
1319 finite intervals, and convergence acceleration by means of the Epsilon algorithm
1320 (Wynn, 1956) is applied to the series of the integral contributions.
1322 @item @mref{quad_qaws}
1324 m4_math(w(x)f(x), @math{w(x) f(x)})
1325 over a finite interval @math{[a, b]}, where
1326 @math{w} is a function of the form
1327 m4_math((x-a)^\alpha (b-x)^\beta v(x), @math{(x - a)^alpha (b -
1331 m4_math(\log(x-a), @math{log(x - a)})
1333 m4_math(\log(b-x), @math{log(b - x)})
1335 m4_mathcomma(\log(x-a)\log(b-x), @math{log(x - a) log(b - x)})
1337 m4_math(\alpha > -1, @math{alpha > -1})
1339 m4_mathdot(\beta > -1, @math{beta > -1})
1341 A globally adaptive subdivision strategy is applied, with modified
1342 Clenshaw-Curtis integration on the subintervals which contain @math{a}
1345 @item @mref{quad_qawc}
1346 Computes the Cauchy principal value of @math{f(x)/(x - c)} over a finite
1347 interval @math{(a, b)} and specified @math{c}.
1348 The strategy is globally adaptive, and modified
1349 Clenshaw-Curtis integration is used on the subranges
1350 which contain the point @math{x = c}.
1352 @item @mref{quad_qagp}
1353 Basically the same as @mref{quad_qags} but points of singularity or
1354 discontinuity of the integrand must be supplied. This makes it easier
1355 for the integrator to produce a good solution.
1359 @opencatbox{Categories:}
1360 @category{Integral calculus}
1361 @category{Numerical methods}
1362 @category{Share packages}
1363 @category{Package quadpack}
1366 @c -----------------------------------------------------------------------------
1367 @node Functions and Variables for QUADPACK, , Introduction to QUADPACK, Integration
1368 @section Functions and Variables for QUADPACK
1369 @c -----------------------------------------------------------------------------
1371 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
1372 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
1374 @c -----------------------------------------------------------------------------
1376 @deffn {Function} quad_qag @
1377 @fname{quad_qag} (@var{f(x)}, @var{x}, @var{a}, @var{b}, @var{key}, [@var{epsrel}, @var{epsabs}, @var{limit}]) @
1378 @fname{quad_qag} (@var{f}, @var{x}, @var{a}, @var{b}, @var{key}, [@var{epsrel}, @var{epsabs}, @var{limit}])
1380 Integration of a general function over a finite interval. @code{quad_qag}
1381 implements a simple globally adaptive integrator using the strategy of Aind
1382 (Piessens, 1973). The caller may choose among 6 pairs of Gauss-Kronrod
1383 quadrature formulae for the rule evaluation component. The high-degree rules
1384 are suitable for strongly oscillating integrands.
1386 @code{quad_qag} computes the integral
1389 <<<\int_a^b f(x)\, dx>>>,
1390 @math{integrate (f(x), x, a, b)}>>>)
1392 The function to be integrated is @math{f(x)}, with dependent
1393 variable @math{x}, and the function is to be integrated between the
1394 limits @math{a} and @math{b}. @var{key} is the integrator to be used
1395 and should be an integer between 1 and 6, inclusive. The value of
1396 @var{key} selects the order of the Gauss-Kronrod integration rule.
1397 High-order rules are suitable for strongly oscillating integrands.
1399 The integrand may be specified as the name of a Maxima or Lisp function or
1400 operator, a Maxima lambda expression, or a general Maxima expression.
1402 The numerical integration is done adaptively by subdividing the
1403 integration region into sub-intervals until the desired accuracy is
1406 The keyword arguments are optional and may be specified in any order.
1407 They all take the form @code{key=val}. The keyword arguments are:
1411 Desired relative error of approximation. Default is 1d-8.
1413 Desired absolute error of approximation. Default is 0.
1415 Size of internal work array. @var{limit} is the
1416 maximum number of subintervals to use. Default is 200.
1419 @code{quad_qag} returns a list of four elements:
1423 an approximation to the integral,
1425 the estimated absolute error of the approximation,
1427 the number integrand evaluations,
1432 The error code (fourth element of the return value) can have the values:
1436 if no problems were encountered;
1438 if too many sub-intervals were done;
1440 if excessive roundoff error is detected;
1442 if extremely bad integrand behavior occurs;
1444 if the input is invalid.
1448 @c NEED CROSS REFS HERE -- EITHER CROSS REF A QUADPACK OVERVIEW, OR CROSS REF EACH OF THE quad_* FUNCTIONS
1453 @c quad_qag (x^(1/2)*log(1/x), x, 0, 1, 3, 'epsrel=5d-8);
1454 @c integrate (x^(1/2)*log(1/x), x, 0, 1);
1458 (%i1) quad_qag (x^(1/2)*log(1/x), x, 0, 1, 3, 'epsrel=5d-8);
1459 (%o1) [.4444444444492108, 3.1700968502883E-9, 961, 0]
1462 (%i2) integrate (x^(1/2)*log(1/x), x, 0, 1);
1469 @opencatbox{Categories:}
1470 @category{Numerical methods}
1471 @category{Package quadpack}
1475 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
1476 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
1478 @c -----------------------------------------------------------------------------
1480 @deffn {Function} quad_qags @
1481 @fname{quad_qags} (@var{f(x)}, @var{x}, @var{a}, @var{b}, [@var{epsrel}, @var{epsabs}, @var{limit}]) @
1482 @fname{quad_qags} (@var{f}, @var{x}, @var{a}, @var{b}, [@var{epsrel}, @var{epsabs}, @var{limit}])
1484 Integration of a general function over a finite interval.
1485 @code{quad_qags} implements globally adaptive interval subdivision with
1486 extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn, 1956).
1488 @code{quad_qags} computes the integral
1491 <<<\int_a^b f(x)\, dx>>>,
1492 @math{integrate (f(x), x, a, b)}>>>)
1494 The function to be integrated is @math{f(x)}, with
1495 dependent variable @math{x}, and the function is to be integrated
1496 between the limits @math{a} and @math{b}.
1498 The integrand may be specified as the name of a Maxima or Lisp function or
1499 operator, a Maxima lambda expression, or a general Maxima expression.
1501 The keyword arguments are optional and may be specified in any order.
1502 They all take the form @code{key=val}. The keyword arguments are:
1506 Desired relative error of approximation. Default is 1d-8.
1508 Desired absolute error of approximation. Default is 0.
1510 Size of internal work array. @var{limit} is the
1511 maximum number of subintervals to use. Default is 200.
1514 @code{quad_qags} returns a list of four elements:
1518 an approximation to the integral,
1520 the estimated absolute error of the approximation,
1522 the number integrand evaluations,
1527 The error code (fourth element of the return value) can have the values:
1531 no problems were encountered;
1533 too many sub-intervals were done;
1535 excessive roundoff error is detected;
1537 extremely bad integrand behavior occurs;
1541 integral is probably divergent or slowly convergent
1543 if the input is invalid.
1546 @c NEED CROSS REFS HERE -- EITHER CROSS REF A QUADPACK OVERVIEW, OR CROSS REF EACH OF THE quad_* FUNCTIONS
1551 @c quad_qags (x^(1/2)*log(1/x), x, 0, 1, 'epsrel=1d-10);
1555 (%i1) quad_qags (x^(1/2)*log(1/x), x, 0, 1, 'epsrel=1d-10);
1556 (%o1) [.4444444444444448, 1.11022302462516E-15, 315, 0]
1560 Note that @code{quad_qags} is more accurate and efficient than @code{quad_qag} for this integrand.
1562 @opencatbox{Categories:}
1563 @category{Numerical methods}
1564 @category{Package quadpack}
1568 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
1569 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
1571 @c -----------------------------------------------------------------------------
1573 @deffn {Function} quad_qagi @
1574 @fname{quad_qagi} (@var{f(x)}, @var{x}, @var{a}, @var{b}, [@var{epsrel}, @var{epsabs}, @var{limit}]) @
1575 @fname{quad_qagi} (@var{f}, @var{x}, @var{a}, @var{b}, [@var{epsrel}, @var{epsabs}, @var{limit}])
1577 Integration of a general function over an infinite or semi-infinite interval.
1578 The interval is mapped onto a finite interval and
1579 then the same strategy as in @code{quad_qags} is applied.
1581 @code{quad_qagi} evaluates one of the following integrals
1584 <<<\int_a^\infty f(x) \, dx>>>,
1585 <<<@math{integrate (f(x), x, a, inf)}>>>)
1588 <<<\int_\infty^a f(x) \, dx>>>,
1589 <<<@math{integrate (f(x), x, minf, a)}>>>)
1592 <<<\int_{-\infty}^\infty f(x) \, dx>>>,
1593 <<<@math{integrate (f(x), x, minf, inf)}>>>)
1595 using the Quadpack QAGI routine. The function to be integrated is
1596 @math{f(x)}, with dependent variable @math{x}, and the function is to
1597 be integrated over an infinite range.
1599 The integrand may be specified as the name of a Maxima or Lisp function or
1600 operator, a Maxima lambda expression, or a general Maxima expression.
1602 One of the limits of integration must be infinity. If not, then
1603 @code{quad_qagi} will just return the noun form.
1605 The keyword arguments are optional and may be specified in any order.
1606 They all take the form @code{key=val}. The keyword arguments are:
1610 Desired relative error of approximation. Default is 1d-8.
1612 Desired absolute error of approximation. Default is 0.
1614 Size of internal work array. @var{limit} is the
1615 maximum number of subintervals to use. Default is 200.
1618 @code{quad_qagi} returns a list of four elements:
1622 an approximation to the integral,
1624 the estimated absolute error of the approximation,
1626 the number integrand evaluations,
1631 The error code (fourth element of the return value) can have the values:
1635 no problems were encountered;
1637 too many sub-intervals were done;
1639 excessive roundoff error is detected;
1641 extremely bad integrand behavior occurs;
1645 integral is probably divergent or slowly convergent
1647 if the input is invalid.
1651 @c NEED CROSS REFS HERE -- EITHER CROSS REF A QUADPACK OVERVIEW, OR CROSS REF EACH OF THE quad_* FUNCTIONS
1656 @c quad_qagi (x^2*exp(-4*x), x, 0, inf, 'epsrel=1d-8);
1657 @c integrate (x^2*exp(-4*x), x, 0, inf);
1661 (%i1) quad_qagi (x^2*exp(-4*x), x, 0, inf, 'epsrel=1d-8);
1662 (%o1) [0.03125, 2.95916102995002E-11, 105, 0]
1665 (%i2) integrate (x^2*exp(-4*x), x, 0, inf);
1672 @opencatbox{Categories:}
1673 @category{Numerical methods}
1674 @category{Package quadpack}
1678 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
1679 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
1681 @c -----------------------------------------------------------------------------
1683 @deffn {Function} quad_qawc @
1684 @fname{quad_qawc} (@var{f(x)}, @var{x}, @var{c}, @var{a}, @var{b}, [@var{epsrel}, @var{epsabs}, @var{limit}]) @
1685 @fname{quad_qawc} (@var{f}, @var{x}, @var{c}, @var{a}, @var{b}, [@var{epsrel}, @var{epsabs}, @var{limit}])
1687 Computes the Cauchy principal value of @math{f(x)/(x - c)} over a finite
1688 interval. The strategy is globally adaptive, and modified
1689 Clenshaw-Curtis integration is used on the subranges
1690 which contain the point @math{x = c}.
1692 @code{quad_qawc} computes the Cauchy principal value of
1695 <<<\int_{a}^{b}{{{f\left(x\right)}\over{x-c}}\>dx}>>>,
1696 <<<@math{integrate (f(x)/(x - c), x, a, b)}>>>)
1698 using the Quadpack QAWC routine. The function to be integrated is
1699 @math{f(x)/(x-c)}, with dependent variable @math{x}, and the
1700 function is to be integrated over the interval @math{a} to @math{b}.
1702 The integrand may be specified as the name of a Maxima or Lisp function or
1703 operator, a Maxima lambda expression, or a general Maxima expression.
1705 The keyword arguments are optional and may be specified in any order.
1706 They all take the form @code{key=val}. The keyword arguments are:
1710 Desired relative error of approximation. Default is 1d-8.
1712 Desired absolute error of approximation. Default is 0.
1714 Size of internal work array. @var{limit} is the
1715 maximum number of subintervals to use. Default is 200.
1718 @code{quad_qawc} returns a list of four elements:
1722 an approximation to the integral,
1724 the estimated absolute error of the approximation,
1726 the number integrand evaluations,
1731 The error code (fourth element of the return value) can have the values:
1735 no problems were encountered;
1737 too many sub-intervals were done;
1739 excessive roundoff error is detected;
1741 extremely bad integrand behavior occurs;
1743 if the input is invalid.
1750 @c quad_qawc (2^(-5)*((x-1)^2+4^(-5))^(-1), x, 2, 0, 5, 'epsrel=1d-7);
1751 @c integrate (2^(-alpha)*(((x-1)^2 + 4^(-alpha))*(x-2))^(-1), x, 0, 5);
1752 @c ev (%, alpha=5, numer);
1756 (%i1) quad_qawc (2^(-5)*((x-1)^2+4^(-5))^(-1), x, 2, 0, 5,
1758 (%o1) [- 3.130120337415925, 1.306830140249558E-8, 495, 0]
1761 (%i2) integrate (2^(-alpha)*(((x-1)^2 + 4^(-alpha))*(x-2))^(-1),
1766 4 log(------------- + -------------)
1769 (%o2) (-----------------------------------------
1776 2 4 atan(4 4 ) 2 4 atan(4 ) alpha
1777 - --------------------------- - -------------------------)/2
1782 (%i3) ev (%, alpha=5, numer);
1783 (%o3) - 3.130120337415917
1787 @opencatbox{Categories:}
1788 @category{Numerical methods}
1789 @category{Package quadpack}
1793 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
1794 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
1796 @c -----------------------------------------------------------------------------
1798 @deffn {Function} quad_qawf @
1799 @fname{quad_qawf} (@var{f(x)}, @var{x}, @var{a}, @var{omega}, @var{trig}, [@var{epsabs}, @var{limit}, @var{maxp1}, @var{limlst}]) @
1800 @fname{quad_qawf} (@var{f}, @var{x}, @var{a}, @var{omega}, @var{trig}, [@var{epsabs}, @var{limit}, @var{maxp1}, @var{limlst}])
1802 Calculates a Fourier cosine or Fourier sine transform on a semi-infinite
1803 interval using the Quadpack QAWF function. The same approach as in
1804 @code{quad_qawo} is applied on successive finite intervals, and convergence
1805 acceleration by means of the Epsilon algorithm (Wynn, 1956) is applied to the
1806 series of the integral contributions.
1808 @code{quad_qawf} computes the integral
1811 <<<\int_a^\infty f(x) \, w(x) \, dx>>>,
1812 <<<@math{integrate (f(x)*w(x), x, a, inf)}>>>)
1814 The weight function @math{w} is selected by @var{trig}:
1818 m4_math(w(x) = \cos\omega x, @math{w(x) = cos (omega x)})
1820 m4_math(w(x) = \sin\omega x, @math{w(x) = sin (omega x)})
1823 The integrand may be specified as the name of a Maxima or Lisp function or
1824 operator, a Maxima lambda expression, or a general Maxima expression.
1826 The keyword arguments are optional and may be specified in any order.
1827 They all take the form @code{key=val}. The keyword arguments are:
1831 Desired absolute error of approximation. Default is 1d-10.
1833 Size of internal work array. (@var{limit} - @var{limlst})/2 is the
1834 maximum number of subintervals to use. Default is 200.
1836 Maximum number of Chebyshev moments. Must be greater than 0. Default
1839 Upper bound on the number of cycles. Must be greater than or equal to
1843 @code{quad_qawf} returns a list of four elements:
1847 an approximation to the integral,
1849 the estimated absolute error of the approximation,
1851 the number integrand evaluations,
1856 The error code (fourth element of the return value) can have the values:
1860 no problems were encountered;
1862 too many sub-intervals were done;
1864 excessive roundoff error is detected;
1866 extremely bad integrand behavior occurs;
1868 if the input is invalid.
1875 @c quad_qawf (exp(-x^2), x, 0, 1, 'cos, 'epsabs=1d-9);
1876 @c integrate (exp(-x^2)*cos(x), x, 0, inf);
1881 (%i1) quad_qawf (exp(-x^2), x, 0, 1, 'cos, 'epsabs=1d-9);
1882 (%o1) [.6901942235215714, 2.84846300257552E-11, 215, 0]
1885 (%i2) integrate (exp(-x^2)*cos(x), x, 0, inf);
1888 (%o2) -----------------
1892 (%i3) ev (%, numer);
1893 (%o3) .6901942235215714
1897 @opencatbox{Categories:}
1898 @category{Numerical methods}
1899 @category{Package quadpack}
1903 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
1904 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
1906 @c -----------------------------------------------------------------------------
1908 @deffn {Function} quad_qawo @
1909 @fname{quad_qawo} (@var{f(x)}, @var{x}, @var{a}, @var{b}, @var{omega}, @var{trig}, [@var{epsrel}, @var{epsabs}, @var{limit}, @var{maxp1}, @var{limlst}]) @
1910 @fname{quad_qawo} (@var{f}, @var{x}, @var{a}, @var{b}, @var{omega}, @var{trig}, [@var{epsrel}, @var{epsabs}, @var{limit}, @var{maxp1}, @var{limlst}])
1913 m4_math(<<<\cos(\omega x) f(x)>>>,<<<@math{cos (omega x) f(x)}>>>)
1915 m4_math(<<<\sin(\omega x)>>>, <<<@math{sin (omega x) f(x)}>>>)
1916 over a finite interval,
1918 m4_math(\omega, @math{omega})
1920 The rule evaluation component is based on the modified
1921 Clenshaw-Curtis technique. @code{quad_qawo} applies adaptive subdivision with
1922 extrapolation, similar to @code{quad_qags}.
1924 @code{quad_qawo} computes the integral using the Quadpack QAWO
1928 <<<\int_a^b f(x) \, w(x) \, dx>>>,
1929 <<<@math{integrate (f(x)*w(x), x, a, b)}>>>)
1931 The weight function @math{w} is selected by @var{trig}:
1935 m4_math(w(x) = \cos\omega x, @math{w(x) = cos (omega x)})
1937 m4_math(w(x) = \sin\omega x, @math{w(x) = sin (omega x)})
1940 The integrand may be specified as the name of a Maxima or Lisp function or
1941 operator, a Maxima lambda expression, or a general Maxima expression.
1943 The keyword arguments are optional and may be specified in any order.
1944 They all take the form @code{key=val}. The keyword arguments are:
1948 Desired relative error of approximation. Default is 1d-8.
1950 Desired absolute error of approximation. Default is 0.
1952 Size of internal work array. @var{limit}/2 is the
1953 maximum number of subintervals to use. Default is 200.
1955 Maximum number of Chebyshev moments. Must be greater than 0. Default
1958 Upper bound on the number of cycles. Must be greater than or equal to
1962 @code{quad_qawo} returns a list of four elements:
1966 an approximation to the integral,
1968 the estimated absolute error of the approximation,
1970 the number integrand evaluations,
1975 The error code (fourth element of the return value) can have the values:
1979 no problems were encountered;
1981 too many sub-intervals were done;
1983 excessive roundoff error is detected;
1985 extremely bad integrand behavior occurs;
1987 if the input is invalid.
1994 @c quad_qawo (x^(-1/2)*exp(-2^(-2)*x), x, 1d-8, 20*2^2, 1, cos);
1995 @c rectform (integrate (x^(-1/2)*exp(-2^(-alpha)*x) * cos(x), x, 0, inf));
1997 @c ev (%, alpha=2, numer);
2001 (%i1) quad_qawo (x^(-1/2)*exp(-2^(-2)*x), x, 1d-8, 20*2^2, 1, cos);
2002 (%o1) [1.376043389877692, 4.72710759424899E-11, 765, 0]
2005 (%i2) rectform (integrate (x^(-1/2)*exp(-2^(-alpha)*x) * cos(x),
2007 alpha/2 - 1/2 2 alpha
2008 sqrt(%pi) 2 sqrt(sqrt(2 + 1) + 1)
2009 (%o2) -----------------------------------------------------
2014 (%i3) ev (%, alpha=2, numer);
2015 (%o3) 1.376043390090716
2019 @opencatbox{Categories:}
2020 @category{Numerical methods}
2021 @category{Package quadpack}
2025 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
2026 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
2028 @c -----------------------------------------------------------------------------
2030 @deffn {Function} quad_qaws @
2031 @fname{quad_qaws} (@var{f(x)}, @var{x}, @var{a}, @var{b}, @var{alpha}, @var{beta}, @var{wfun}, [@var{epsrel}, @var{epsabs}, @var{limit}]) @
2032 @fname{quad_qaws} (@var{f}, @var{x}, @var{a}, @var{b}, @var{alpha}, @var{beta}, @var{wfun}, [@var{epsrel}, @var{epsabs}, @var{limit}])
2034 Integration of @math{w(x) f(x)} over a finite interval, where @math{w(x)} is a
2035 certain algebraic or logarithmic function. A globally adaptive subdivision
2036 strategy is applied, with modified Clenshaw-Curtis integration on the
2037 subintervals which contain the endpoints of the interval of integration.
2039 @code{quad_qaws} computes the integral using the Quadpack QAWS routine:
2042 <<<\int_a^b f(x) \, w(x) \, dx>>>,
2043 <<<@math{integrate (f(x)*w(x), x, a, b)}>>>)
2045 The weight function @math{w} is selected by @var{wfun}:
2049 m4_math(w(x) = (x - a)^\alpha (b - x)^\beta, @math{w(x) = (x - a)^alpha (b - x)^beta})
2051 m4_math(w(x) = (x - a)^\alpha (b - x)^\beta \log(x - a),
2052 @math{w(x) = (x - a)^alpha (b - x)^beta log(x - a)})
2054 m4_math(w(x) = (x - a)^\alpha (b - x)^\beta \log(b - x), @math{w(x) = (x - a)^alpha (b - x)^beta log(b - x)})
2056 m4_math(w(x) = (x - a)^\alpha (b - x)^\beta \log(x - a) \log(b - x),
2057 @math{w(x) = (x - a)^alpha (b - x)^beta log(x - a) log(b - x)})
2060 The integrand may be specified as the name of a Maxima or Lisp function or
2061 operator, a Maxima lambda expression, or a general Maxima expression.
2063 The keyword arguments are optional and may be specified in any order.
2064 They all take the form @code{key=val}. The keyword arguments are:
2068 Desired relative error of approximation. Default is 1d-8.
2070 Desired absolute error of approximation. Default is 0.
2072 Size of internal work array. @var{limit}is the
2073 maximum number of subintervals to use. Default is 200.
2076 @code{quad_qaws} returns a list of four elements:
2080 an approximation to the integral,
2082 the estimated absolute error of the approximation,
2084 the number integrand evaluations,
2089 The error code (fourth element of the return value) can have the values:
2093 no problems were encountered;
2095 too many sub-intervals were done;
2097 excessive roundoff error is detected;
2099 extremely bad integrand behavior occurs;
2101 if the input is invalid.
2108 @c quad_qaws (1/(x+1+2^(-4)), x, -1, 1, -0.5, -0.5, 1, 'epsabs=1d-9);
2109 @c integrate ((1-x*x)^(-1/2)/(x+1+2^(-alpha)), x, -1, 1);
2111 @c ev (%, alpha=4, numer);
2115 (%i1) quad_qaws (1/(x+1+2^(-4)), x, -1, 1, -0.5, -0.5, 1,
2117 (%o1) [8.750097361672832, 1.24321522715422E-10, 170, 0]
2120 (%i2) integrate ((1-x*x)^(-1/2)/(x+1+2^(-alpha)), x, -1, 1);
2122 Is 4 2 - 1 positive, negative, or zero?
2126 2 %pi 2 sqrt(2 2 + 1)
2127 (%o2) -------------------------------
2132 (%i3) ev (%, alpha=4, numer);
2133 (%o3) 8.750097361672829
2137 @opencatbox{Categories:}
2138 @category{Numerical methods}
2139 @category{Package quadpack}
2143 @c THERE ARE OPTIONAL ARGUMENTS WHICH MAKES LISTING THE VARIANTS A LITTLE TEDIOUS
2144 @c NEED A MORE CONVENIENT (AND NONAMBIGUOUS) NOTATION FOR OPTIONAL ARGUMENTS
2146 @c -----------------------------------------------------------------------------
2148 @deffn {Function} quad_qagp @
2149 @fname{quad_qagp} (@var{f(x)}, @var{x}, @var{a}, @var{b}, @var{points}, [@var{epsrel}, @var{epsabs}, @var{limit}]) @
2150 @fname{quad_qagp} (@var{f}, @var{x}, @var{a}, @var{b}, @var{points}, [@var{epsrel}, @var{epsabs}, @var{limit}])
2152 Integration of a general function over a finite interval.
2153 @code{quad_qagp} implements globally adaptive interval subdivision with
2154 extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn, 1956).
2156 @code{quad_qagp} computes the integral
2159 <<<\int_a^b f(x) \, dx>>>,
2160 <<<@math{integrate (f(x), x, a, b)}>>>)
2162 The function to be integrated is @math{f(x)}, with
2163 dependent variable @math{x}, and the function is to be integrated
2164 between the limits @math{a} and @math{b}.
2166 The integrand may be specified as the name of a Maxima or Lisp function or
2167 operator, a Maxima lambda expression, or a general Maxima expression.
2169 To help the integrator, the user must supply a list of points where
2170 the integrand is singular or discontinuous. The list is provided by
2171 @var{points}. It may be an empty list. The elements of the list must
2172 be between @var{a} and @var{b}, exclusive. An error is thrown if
2173 there are elements out of range. The list points may be in any order.
2175 The keyword arguments are optional and may be specified in any order.
2176 They all take the form @code{key=val}. The keyword arguments are:
2180 Desired relative error of approximation. Default is 1d-8.
2182 Desired absolute error of approximation. Default is 0.
2184 Size of internal work array. @var{limit} is the
2185 maximum number of subintervals to use. Default is 200.
2188 @code{quad_qagp} returns a list of four elements:
2192 an approximation to the integral,
2194 the estimated absolute error of the approximation,
2196 the number integrand evaluations,
2201 The error code (fourth element of the return value) can have the values:
2205 no problems were encountered;
2207 too many sub-intervals were done;
2209 excessive roundoff error is detected;
2211 extremely bad integrand behavior occurs;
2215 integral is probably divergent or slowly convergent
2217 if the input is invalid.
2220 @c NEED CROSS REFS HERE -- EITHER CROSS REF A QUADPACK OVERVIEW, OR CROSS REF EACH OF THE quad_* FUNCTIONS
2225 @c quad_qagp(x^3*log(abs((x^2-1)*(x^2-2))),x,0,3,[1,sqrt(2)]);
2226 @c quad_qags(x^3*log(abs((x^2-1)*(x^2-2))), x, 0, 3);
2230 (%i1) quad_qagp(x^3*log(abs((x^2-1)*(x^2-2))),x,0,3,[1,sqrt(2)]);
2231 (%o1) [52.74074838347143, 2.6247632689546663e-7, 1029, 0]
2234 (%i2) quad_qags(x^3*log(abs((x^2-1)*(x^2-2))), x, 0, 3);
2235 (%o2) [52.74074847951494, 4.088443219529836e-7, 1869, 0]
2239 The integrand has singularities at @code{1} and @code{sqrt(2)} so we supply
2240 these points to @code{quad_qagp}. We also note that @code{quad_qagp} is
2241 more accurate and more efficient that @mrefdot{quad_qags}
2243 @opencatbox{Categories:}
2244 @category{Numerical methods}
2245 @category{Package quadpack}
2249 @c -----------------------------------------------------------------------------
2250 @anchor{quad_control}
2251 @deffn {Function} quad_control (@var{parameter}, [@var{value}])
2253 Control error handling for quadpack. The parameter should be one of
2254 the following symbols:
2258 The current error number
2260 Controls if messages are printed or not. If it is set to zero or
2261 less, messages are suppressed.
2263 The maximum number of times any message is to be printed.
2266 If @var{value} is not given, then the current value of the
2267 @var{parameter} is returned. If @var{value} is given, the value of
2268 @var{parameter} is set to the given value.
2270 @opencatbox{Categories:}
2271 @category{Numerical methods}
2272 @category{Package quadpack}