Inde Nite Integration As Term Rewriting: Integrals Containing Tangent
Total Page:16
File Type:pdf, Size:1020Kb
Computer Algebra ÓÄÊ 519.61 Indenite integration as term rewriting: integrals containing tangent ⃝c 2012 ã. J. Hu, Y. Hou, A.D. Rich and D.J. Jerey, Department of Applied Mathematics, The University of Western Ontario 1151 Richmond St. London, Ontario, Canada N6A 5B7 E-mail: [email protected], [email protected], [email protected], [email protected] Ïîñòóïèëà â ðåäàêöèþ We describe the development of a term-rewriting system for indenite integration; it is also called a rule-based evaluation system. The development is separated into modules, and we describe the module for a wide class of integrands containing the tangent function. 1. Introduction correctness is not the only aim of the development. The quality of integral expressions is judged by a number of Programming styles in computer-algebra systems are criteria, which are used to decide whether an integration frequently described as either term-rewriting based, or rule should be accepted. Assume that an integrand f(x) computationally based. For example, Mathematica is has a proposed primitive F (x). Selection is based on widely recognized as a rewrite language [1], whereas the following criteria, which are discussed further in the Maple is rarely described this way. The distinction next section. is mostly one of emphasis, since all available systems include elements of both styles of programming. The • Correctness: we require F 0(x) = f(x). dichotomy can be seen more specically in programming • Simplicity: we seek the simplest form for an to evaluate indenite integrals, also called primitives integral. We adopt a pragmatic approach and aim or anti-derivatives. For symbolic integration, some of for the shortest expression length. the best-known approaches are computationally based. • Continuity: we aim to ensure that all of the Thus the Risch algorithm [8] and the Rothstein- expressions for integrals are continuous on domains Trager-Lazard-Rioboo algorithm [9, 10, 5] are both of maximum extent [4]. computational algorithms. These algorithms and others • Æsthetics: we employ a number of principles to like them are not universally applicable, however, and select for mathematical beauty where possible. for many integrals rule-based rewriting is needed and • Utility: the rules should facilitate the afore- has advantages, some of which we discuss below. mentioned `show-step' application. See Sec. 2.5. Doubts have been expressed about the viability of • Eciency: the path to a result should be as direct large-scale term rewriting [2]; the present scheme is as possible, and the set of rules should be compact. more algorithmic and deterministic than earlier term rewriting schemes, and we prefer the description rule- A more detailed description of the repository is given based scheme for the integration scheme presented below. here. A particular success of rule-based schemes is the popularity of software that can display the steps of a 2. Discussion of selection criteria calculation. This is variously called `display step' or `single step'. Examples of software oering this include The following example allows us to discuss several WolframAlpha and Derive, and many calculus aspects of our overall aim. We compare 5 possible tutorial programs. expressions for an integral. The rule-based integration scheme that is considered Z p ( p ) here [7, 6] consists of a public-domain repository of − − 1 − − − 2 tan x dx = 2 ln 2 2 tan x 2 2 tan x transformation rules for indenite integration, together (p ) with utility les that allow it to be utilized by various − arctan −2 tan x − 1 computer-algebra systems. The repository is not a table ( p ) + 1 ln 2 − 2 tan x + 2 −2 tan x of integrals; it is a compact set of rules, much smaller 2 (p ) than a table covering the same domain. Also simple − arctan −2 tan x + 1 ; (1) 1 Z p therefore algebraic manipulation alone cannot succeed −2 tan x dx = (2) in nding it. Secondly, branch cuts could make the given p ( h i −Tan[x] p p expression dier algebraically from the shortest form; p −2ArcTan 1 − 2 Tan[x] another way to say this is that the two expressions dier 2 Tan[x] h p p i by a piecewise constant. Therefore an integration system +2ArcTan 1 + 2 Tan[x] should aim to obtain the simplest form directly, since h p p i algebraic simplication is not likely to be successful. + Log 1 − 2 Tan[x] + Tan[x] This can be seen particularly in the results of Risch h p p ]) integration, which are obtained without regard for −Log 1 + 2 Tan[x] + Tan[x] ; (3) branch cuts. p = ln cos x + ln(1 + −2 tan x − tan x) 2.3. Continuity 1 + tan x + arctan p ; (4) p − The integrand − is singular at , p 2 tan x p 2 tan x x = nπ + π=2 −2 tan x −2 tan x and is otherwise continuous. At x = nπ the function = − arctan + arctanh ; (5) 1 + tan x 1 − tan x changes from real to imaginary, but is continuous 1 + tan x 1 − tan x at those points. Therefore expressions for its integral = arctan p + arctanh p : (6) should also be continuous except possibly at −2 tan x −2 tan x x = (n + 1=2)π. We see that expression (5) has discontinuities In the above equations, expression (1) comes from at tan x = ±1. Therefore the other expressions are Maple 16; (3) comes from Mathematica 8; (4) to (6) preferred. Combining continuity with simplicity, we can come from the present project. We now consider these therefore reduce our choice of preferred expressions to expressions under the headings listed above. (6) and (4). An additional point to note is that the integrand is integrable at its singular points, and one 2.1. Correctness could ask for the integral expression to be continuous there. None of the expressions has a dened value at With and denoting an integrand and primitive f F and therefore the evaluation of denite as above, we note that the test 0 requires x = nπ + π=2 F = f integrals with these endpoints must be evaluated as a a denition of dierentiation. Here, we choose it to one-sided limit. be complex dierentiation. This is reected in the It should be further noted that requirements for absence of absolute values around the arguments of the continuity and simplicity might conict. Consider a logarithm functions in the example. The debate between dierent example: the integral computer-algebra users over Z Z ( x2 + 2 x dx ln x ; Complex dx = arctan ; (8) = (7) x4 − 3x2 + 4 2 − x2 x ln jxj ; Real ( p ) ( p ) = arctan 2x + 7 + arctan 2x − 7 : (9) is of long standing. In the current repository, all transformation rules are valid for complex quantities. The discontinuous expression is shorter, and would be In the example the integrand itself becomes imaginary judged simpler by most users. This is a simple example for intervals (nπ; nπ + π=2) with n 2 Z. using the Lazard-Rioboo algorithm [5]; as the degrees of Note that the verication of the test F 0 = f by the polynomials grow, the dierence in length between a computer-algebra system is not itself a trivial step. the two expressions increases. Maple cannot complete a verication of (4) in any straightforward way, for example. 2.4. Æsthetics 2.2. Simplicity Beauty is the rst test. There is no permanent place in the world for ugly mathematics. The last 3 expressions are clearly shorter and simpler G. H. Hardy [3] than the rst two. A constant problem in computer- algebra systems is expression swell, and every part of If we compare (4) and (6), we see that (6) uses two such systems should be striving to keep results succinct. related functions, namely arctan and arctanh. Although This increases the utility of a system. we know that arctanh can be expressed in logarithms, Integral expressions cannot necessarily be simplied the look of (6) with its many symmetries has greater automatically into their shortest forms. There are mathematical beauty than the other expressions. two reasons for this. First, the shortest form may A similar principle concerns the relation between the dier by a constant from the given expression, and form of the integrand and the form of its integral. 2 Consider the following example, which comes from a transformation from left to right. Therefore the Maple 16. condition m + n + 1 =6 0 must be listed in the validity Z p eld of the rule. In addition, the transformation reduces p tan x cos x arccos (cos x − sin x) 2 tan x dx = p the exponent of T1 = tan(c + dx) from m to m − 1, cos x sin x and clearly this requires ≥ in order to qualify ( p p ) m 1 − ln cos x + 2 tan x cos x + sin x : (10) for a simplication. Thus this becomes a condition in the simplication eld. We can note in passing that the In contrast to (1), also from Maple, this form introduces case m + n + 1 = 0 does not invalidate the equation, a jumble of functions not seen in the integrand. Also the which now reduces to a simple exact integral, but simply prevents the equation being used as a transformation. obvious symmetry of x ! −x which relates problems (1) and (10) is not preserved in the answers. We prefer, then, A similar eect can be seen in transformation (18). to echo as much as possible the functional forms seen in Here, the case C = 0 reduces the transformation to a the integrand. trivial identity. 2.5. Utility 4. Functions containing tangent The way in which rules are encoded will be reected The new module for integration addresses functions of when a user single-steps through a derivation.