Up | Next | Prev | PrevTail | Tail |
Author: Neil Langmead
This package was written when the author was a placement student at ZIB Berlin.
This package is an implementation of a new algorithm proposed by D. J. Jeffrey and A. D. Rich [JR94] to remove "spurious" discontinuities from integrals. Their paper focuses on the Weierstraß substitution, \(u=\tan (x/2)\), currently used in conjunction with the Risch algorithm in most computer algebra systems to evaluate trigonometric integrals. Expressions obtained using this substitution sometimes contain discontinuities, which limit the domain over which the expression is correct. The algorithm presented finds a better expression, in the sense that it is continous on wider intervals whilst still being an anti derivative of the integrand.
Consider the following problem: \[ \int \frac {3}{5-4\cos (x)}\,dx \]
REDUCE computes an anti derivative to the given function using the Weierstraß substitution \(u=\tan (\frac {x}{2})\), and then the Risch algorithm is used, returning: \[ \frac {2\arctan (3\tan (\frac {x}{2}))}{3}, \] which is discontinuous at all odd multiples of \(\pi \). Yet our original function is continuous everywhere on the real line, and so by the Fundamental Theorem of Calculus, any anti-derivative should also be everywhere continuous. The problem arises from the substitution used to transform the given trigonometric function to a rational function: often, the substituted function is discontinuous, and spurious discontinuities are introduced as a result.
Jeffery and Richs’ algorithm returns the following to the given problem: \[ \int \frac {3}{5-4\cos (x)}\,dx = 2\arctan \left (3\tan \left (\frac {x}{2}\right )\right )+2\pi \left \lfloor \frac {x-\pi }{2\pi } \right \rfloor \] which differs from (2) by the constant 2\(\pi \), and this is the correct way of removing the discontinuity.
We define a Weierstraß substitution to be one that uses a function \(u=\Phi (x)\) appearing in the following table:
Choice | \(\Phi (x)\) | \(\sin (x)\) | \(\cos (x)\) | \(dx\) | \(b\) | \(p\) |
\((a)\) | \(\tan (x/2)\) | \(\frac {2u}{1+u^{2}}\) | \( \frac {1-u^{2}}{1+u^{2}}\) | \(\frac {2du}{1+u^{2}}\) | \(\pi \) | \(2\pi \) |
\((b)\) | \(\tan (\frac {x}{2}+\frac {\pi }{4})\) | \(\frac {u^{2}-1}{u^{2}+1}\) | \(\frac {2u}{u^{2}+1} \) | \(\frac {2du}{1+u^{2}}\) | \(\frac {\pi }{2}\) | \(2\pi \) |
\((c)\) | \(\cot (x/2)\) | \(\frac {2u}{1+u^{2}}\) | \(\frac {u^{2}-1}{1+u^{2}}\) | \(\frac {-2du}{1+u^{2}}\) | \(0\) | \(2\pi \) |
\((d)\) | \(\tan (x)\) | \(\frac {u}{\sqrt {1+u^{2}}}\) | \(\frac {1}{\sqrt {1+u^{2}}}\) | \(\frac {du}{1+u^{2}}\) | \(\frac {\pi }{2}\) | \(\pi \) |
There are of course, other trigonometric substitutions, used by REDUCE, such as \(\sin \) and \(\cos \), but since these are never singular, they cannot lead to problems with discontinuities.
Given an integrable function \(f(\sin x,\cos x)\) whose indefinite integral is required, select one of the substitutions listed in the table. The choice is based on the following heuristics: choice (a) is used for integrands not containing \(\sin x\), choice (b) for integrands not containing \(\cos x\); (c) is useful in cases when (a) gives an integral that cannot be evaluated by REDUCE, and (d) is good for conditions described in Gradshteyn and Ryzhik (1979, sect 2.50). The integral is then transformed using the entries in the table,; for example, with choice (c), we have: \[ \int f(\sin x,\cos x)\, dx = \int f\left (\frac {2u}{1+u^{2}},\frac {u^{2}-1}{1+u^{2}}\right )\,\frac {-2\,du}{1+u^{2}} . \]
The integral in \(u\) is now evaluated using the standard routines of the system, then \(u\) is substituted for. Call the result \(\hat {g}(x)\). Next we calculate \[ K=\lim _{x \rightarrow b^{-}} \hat {g}(x) - \lim _{x \rightarrow b^{+}} \hat {g}(x), \] where the point \(b\) is given in the table. the corrected integral is then \[ g(x)=\int f(\sin x,\cos x)\,dx = \hat {g}(x)+K\left \lfloor \frac {x-b}{p} \right \rfloor , \] where the period \(p\) is taken from the table, and \(\lfloor x \rfloor \) is the floor function.
The name of the function used in REDUCE to implement these ideas is trigint, which has the following syntax:
where \(\langle \)exp\(\rangle \) is the expression to be integrated, and \(\langle \)var\(\rangle \) is the variable of integration.
If trigint is used to calculate the integrals of trigonometric functions for which no substitution is necessary, then non standard results may occur. For example, if we calculate trigint(cos(x), x), we obtain \[ \frac {2\tan \frac {x}{2}}{\tan ^{2}\frac {x}{2}+1} \] which, by using simple trigonometric identities, simplifies to: \[ \frac {2\tan \frac {x}{2}}{\tan ^{2}\frac {x}{2}+1} \rightarrow \frac {2\tan \frac {x}{2}}{\sec ^{2}\frac {x}{2}} \rightarrow 2\sin \frac {x}{2}\cos \frac {x}{2} \rightarrow \sin \left (2\frac {x}{2}\right ) \rightarrow \sin x, \] which is the answer we would normally expect. In the absence of a normal form for trigonometric functions though, both answers are equally valid, although most would prefer the simpler answer \(\sin x\). Thus, some interesting trigonometric identities could be derived from the program if one so wished.
Using our example in (1), we compute the corrected result, and show a few other examples as well:
REDUCE Development Version, 4-Nov-96 ... 1: trigint(3/(5-4*cos(x)),x); x - pi + x 2*(atan(3*tan(---)) + floor(-----------)*pi) 2 2*pi
2: trigint(3/(5+4*sin(x)),x); pi + 2*x 2*(atan(3*tan(----------)) 4 - pi + 2*x + floor(-------------)*pi) 4*pi 3: trigint(15/(cos(x)*(5-4*cos(x))),x); x - pi + x 8*atan(3*tan(---)) + 8*floor(-----------)*pi 2 2*pi x x - 3*log(tan(---) - 1) + 3*log(tan(---) + 1) 2 2
The corrected expressions can now be used to calculate some definite integrals, provided the region of integration lies between adjacent singularities. For example, using our earlier function, we can use the corrected primitive to calculate \begin {equation} \int _{0}^{4\pi } \frac {1}{2+\cos x}\,dx \end {equation} trigint returns the answer below to give an indefinite integral, \(F(x)\):
x tan(---) 2 - pi + x 2*sqrt(3)*(atan(----------) + floor(-----------)*pi) sqrt(3) 2*pi ------------------------------------------------------ 3
And now, we can apply the Fundamental Theorem of Calculus to give \begin {equation} \int _{0}^{4\pi } \frac {1}{2+\cos x}\,dx = F(4\pi )-F(0) \end {equation}
sub(x=4*pi,F)-sub(x=0,F); 4*sqrt(3)*pi ----------------- 3
and this is the correct value of the definite integral. Note that although the expression in (*) is continuous, the functions value at the points \(x=\pi ,3\pi \) etc. must be intepreted as a limit, and these values cannot substituted directly into the formula given in (*). Hence care should be taken to ensure that the definite integral is well defined, and that singularities are dealt with appropriately. For more details of this in REDUCE, please see the documentation for the cwi addition to the DEFINT package.
The package includes a facility to trace in some detail the inner workings of the trigint program. Messages are given at key points of the algorithm, together with the results obtained. These messages are displayed whenever the switch tracetrig is on, which is done in REDUCE with the command on tracetrig; This switch is off by default. In particular, the messages inform the user which substitution is being tried, and the result of that substitution. The error message
***** system cannot integrate after subs
means that REDUCE has tried all four of the Weierstraß substitutions, and the system’s standard integrator is unable to integrate after the substitution has been completed.
This program was written whilst the author was a placement student at ZIB Berlin.
Up | Next | Prev | PrevTail | Front |