The Risch algorithm for one exponential monomial is correct and complete full
This proof shows: correctness.
Setting. Let Qˉ be an algebraic closure of Q, k=Qˉ(x) with x′=1, b∈Q[x] of degree m+1≥1, and t with t′=b′t. The integrand is f=∑kfktk with fk∈Q(x) and finitely many k∈Z. An elementary integral of f is an element F of an elementary extension of k(t), with the same constants Qˉ, such that F′=f.
Theorem. (a) If the algorithm returns (y,R,A∗/D∗), then f=(∑k=0yktk+R)′+A∗/D∗ with D∗ squarefree, and so f has the elementary integral ∑kyktk+R+∑cclogvc, where the last sum is the Rothstein-Trager logarithmic part of ∫A∗/D∗. (b) If the algorithm returns FAIL, then f has no elementary integral.
Lemma 1 (t is a monomial)
t is transcendental over k, and k(t) has the constants Qˉ. Every monic irreducible p∈k[t] other than t satisfies p∤p′.
Proof. First, no nonzero z∈k satisfies z′/z=nb′ with n∈Z, n=0. Indeed, for z=c∏α(x−α)eα we have z′/z=∑αeα/(x−α), a proper rational function, while nb′ is a nonzero polynomial.
Transcendence. Suppose t=0 is algebraic over k, with monic minimal polynomial P=∑i=0dpiTi. Differentiating P(t)=0 and subtracting db′P(t)=0 gives ∑i<d(pi′−(d−i)b′pi)ti=0, a polynomial relation of degree less than d, so all its coefficients vanish. A nonzero pi with i<d would satisfy pi′/pi=(d−i)b′, which is impossible. So P=Td and t=0, a contradiction.
Normal factors. Let p=t be monic irreducible of degree d≥1. Then p′=∑i(pi′+ib′pi)ti has degree at most d, with coefficient db′ at td. If p∣p′, then p′=db′p, and the constant coefficients give p0′=db′p0. Here p0=0, since otherwise t∣p and p=t. This is impossible.
Constants. Let F∈k(t) with F′=0 and F=0. If F had a pole of order e≥1 at some p=t, then F′ would have a pole of order e+1 there (the computation in Lemma 2 below), so it has none, and the same holds for 1/F. So F=ctl with c∈k∗, and 0=F′=(c′+lb′c)tl. If l=0, then c′/c=−lb′, which is impossible. So F=c with c′=0, that is, c∈Qˉ. □
Lemma 2 (the shape of an elementary integral)
If f=∑kfktk has an elementary integral, then for every k=0 the equation y′+kb′y=fk has a solution y∈Qˉ(x).
Proof. By Liouville's theorem (see the page on it), there are v∈k(t), constants c1,…,cr∈Qˉ and u1,…,ur∈k(t)∗ with
f=v′+i=1∑rciuiui′.(1) Let p=t be a monic irreducible in k[t]. By Lemma 1, p∤p′. If v has a pole of order e≥1 at p, then v′ has a pole of order e+1≥2 there: with v=A/(peB) and p∤AB, the numerator of v′ over pe+1B2 is ≡−eAp′B≡0(modp). The sum ∑iciui′/ui has at most a simple pole at p, and f has none. So v has no pole at p. Then the part of (1) with a pole at p is (∑iciνp(ui))p′/p, which must vanish, so ∑iciνp(ui)=0. Write ui=hitki∏p=tpνp(ui) with hi∈k∗. Then
i∑ciuiui′=i∑cihihi′+(i∑ciki)b′+p=t∑(i∑ciνp(ui))pp′∈k, and v∈k[t,t−1], say v=∑kvktk. Since (vktk)′=(vk′+kb′vk)tk, comparing the coefficients of tk for k=0 in (1) gives fk=vk′+kb′vk. □
Lemma 3 (the Risch differential equation, steps L4 and L5)
Let k=0, ϕ=kb′∈Q[x] of degree m≥0, and g=a/d∈Q(x) reduced and nonzero. The equation y′+ϕy=g has at most one solution in Qˉ(x). It has one if and only if the code returns one, and then the code returns it.
Proof. Uniqueness: the difference z of two solutions satisfies z′=−ϕz. If z=0, then z′/z=−ϕ is a nonzero polynomial, but z′/z for a rational function z is a sum of terms e/(x−α) and tends to 0 at infinity. So z=0.
Denominator: let y be a solution and α∈Qˉ. If y has a pole of order e≥1 at α, then y′ has a pole of order e+1 and ϕy of order at most e, so g has a pole of order exactly e+1≥2 at α. If y has no pole at α, neither does g. So g has no simple poles, and y has a pole of order ν−1 wherever g has a pole of order ν. With the squarefree factorization d=∏idii, this says d1 is constant, which is the condition d∣ah2 for h=gcd(d,d′)=∏idii−1 (as gcd(a,d)=1), and that y=q/h for a polynomial q. If the condition fails, there is no solution and the code returns None.
Polynomial equation: substituting y=q/h and multiplying by h2 gives
hq′+(ϕh−h′)q=c,c=ah2/d∈Q[x].(2) Let ℓ=ϕh−h′. Since deg(ϕh)=m+degh>degh′, ℓ has degree s=m+degh and leading coefficient lc(ϕ)lc(h), and deg(h(xj)′)≤degh+j−1<j+s. So the operator L(q)=hq′+ℓq maps xj to a polynomial of degree exactly j+s with leading coefficient lc(ℓ). The loop of L5 is division by this triangular operator: if c=0 and degc<s, no q has L(q)=c, since degL(q)=degq+s≥s for q=0. Otherwise the top term of q is forced to be lc(c)/lc(ℓ)xdegc−s, and the loop subtracts its image and continues with a polynomial of lower degree. It stops after at most degc−s+1 rounds, with c=0 and $\mathcal{L}(q) = $ the original c, or with None when no solution exists. A solution over Qˉ is also forced term by term in the same way, so it exists exactly when the loop succeeds, and it has rational coefficients. □
Lemma 4 (Hermite reduction, steps L6 and L7)
For A,D∈Q[x], D=0, hermite_reduce returns R and A∗/D∗ with A/D=R′+A∗/D∗ and D∗ squarefree.
Proof. The polynomial part P of A/D is integrated term by term. For the proper part, the loop is the linear version of Hermite reduction (Mack; Bronstein, Symbolic Integration I, Section 2.2): with D−=gcd(D,D′) and D∗=D/D−, the invariant is A/D=R′+A/(D−D∗). In a round with D−∗=D−/gcd(D−,D−′), the polynomials D∗D−′/D− and D−∗ are coprime, so the extended Euclidean step finds B,C with −BD∗D−′/D−+CD−∗=A, and then
D−D∗A=(D−B)′+D∗gcd(D−,D−′)C−B′D∗/D−∗, as a direct differentiation shows. Each round removes one from every multiplicity in D−, so the loop ends with D−=1 and the remainder A/D∗, where D∗ is the squarefree part of D. □
Proof of the theorem
(a) For each k=0, Lemma 3 gives yk′+kb′yk=fk, so (yktk)′=fktk. Lemma 4 gives f0=R′+A∗/D∗ with D∗ squarefree. Summing gives the identity. The integral of A∗/D∗ with squarefree D∗ is a sum ∑cclogvc over the roots c of the Rothstein-Trager resultant, which is elementary.
(b) The algorithm fails only in L3, when for some k=0 the equation y′+kb′y=fk has no solution in Q(x). By Lemma 3 it then has no solution in Qˉ(x) either, and by Lemma 2 f has no elementary integral. ■