Risch’s algorithm for integration We want to integrate −ex − x + ln(x)x + ln(x)xex f := x(ex + x)2 The elementary field we obtain is Q(x)(θ1 , θ2 ) with θ1 = ex , θ2 = ln(x), and so the integrand becomes 1 1 + θ1 −θ1 − x + θ2 x + θ2 xθ1 = − + θ 2 x(θ1 + x) x(θ1 + x)2 (θ1 + x)2 We set A0 = − 1 1 + θ1 and A1 = and using x(θ1 + x) (θ1 + x)2 Z A0 + A1 θ2 = B0 + B1 θ2 + B2 θ22 obtain by differentiation the equations: 0 = B02 A1 = B01 + 2B2 θ02 = B01 + 2B2 A0 = B00 + B1 θ02 1 x Thus B2 is a constant. Integrating the second equation gives us that Z A1 dx − 2B2 θ2 = B1 − b1 where b1 is a constant. By a recursive call we find that Z Z A1 = 1 + θ1 = (θ1 + x)2 Z 1 + ex 1 1 = − = − ex + x θ1 + x (ex + x)2 As no θ2 -term is involved we find that B2 = 0, and we set B1 = B̄1 + b1 with 1 B̄1 = − , and b1 still an unevaluated constant. θ1 + x Now we integrate the third equation. We get: Z A0 − B1 θ02 dx = Z A0 − B̄1 θ02 dx − b1 θ2 = B0 + c (where c is a constant we will ignore – its the integration constant). Substituting values, we get A0 − B̄1 θ02 = − 1 1 1 − (− ) =0 x(θ1 + x) θ1 + x x This shows that b1 = 0 and also B0 = 0. The integral thus is Z f = θ2 B1 = −θ2 1 1 = − ln(x) x θ1 + x e +x Now for a more complicated example. We want to integrate the function !2 ( 12 ln(x + 12 ) − x) ln(x)2 − 4x 1 1 1 + 2 ln(x) f = x + + 2 (x + 12 ) ln(x + 12 ) x (x + 12 )2 ln(x + 12 )2 + ((x2 + x + 1) ln(x + 12 ) + x2 − 1) ln(x) (x + 12 )2 + (x − 1x ) ln(x + 12 ) x + 12 Our field extension now is Q(x)(θ1 , θ2 ) with θ1 = ln(x + 12 ) and θ2 = ln(x). Substituting yields: !2 ( θ21 − x)θ22 − 4x ((x2 + x + 1)θ1 + x2 − 1)θ2 (x − 1x )θ1 1 1 + 2θ2 x + + + + x 2(x + 12 )θ1 (x + 12 )2 θ21 (x + 12 )2 x + 12 We collect this as a polynomial in θ2 and obtain A2 θ22 + A1 θ2 + A0 with A2 := θ1 2 2 4 (x2 + x + 1)θ1 + x2 − 1 + + , (x + 12 )θ1 x (x + 12 )2 !2 (x − 1x )θ1 1 1 x A0 := x + + − . 2(x + 12 )θ1 x x + 12 4(x + 12 )2 θ21 −x 4 + , (x + 12 )2 θ21 x A1 := This gives us the equations: 0 = B03 A2 = B02 + 3B3 θ02 = B01 + 2B2 A1 = B01 + 2B2 θ02 A0 = B00 + B1 θ02 1 x We integrate recursively, and obtain (see below) Z x A2 = 4θ2 + (x + 12 )θ1 As (with B3 constant): Z A2 = B2 + 3B3 θ2 4 x and B2 = B̄2 + b2 with B̄2 = . The equation for A1 3 (x + 12 )θ1 thus gives after integration: Z 1 A1 − 2B̄2 dx = 2b2 θ2 + B1 x The integral on the left hand side is evaluated recursively again: we get that B3 = Z 4 (x2 + x + 1) ln(x + 12 ) + x2 − 1 x2 − 1 1 + dx = ln(x + ) + 4 ln(x) x 2 (x + 12 )2 x + 12 The only term involving θ2 is the second summand, thus we get that b2 = 4/2 = 2 and B1 = B̄1 + b1 with a constant b1 and (x2 − 1) B̄1 = θ1 x + 12 Finally we integrate the last equation and get: Z 1 A0 − B̄1 dx = b1 θ2 + B0 x The integral is Z 2x + 2x ln(x + 12 ) + ln(x + 12 ) x ln(x + 12 )(2x + 1) 1 dx = ln(x) + ln(ln(x + )) 2 and therefore b1 = 1 and B0 = ln(θ1 ) + c, where again c is the constant of integration. The result thus is Z 4 f = θ32 + (B̄2 + 2)θ22 + (B̄1 + 1)θ2 + B0 3 ! 4 1 3 x 1 2 = ln(x + ) + + 2 ln(x + ) 3 2 2 (x + 12 ) ln(x + 12 ) ! 1 2 (x − 1) ln(x + 2 ) 1 1 + + 1 ln(x + ) + ln(ln(x + )) + c. 2 2 x + 12 It remains to solve the recursive integrals. The first one was the integral of A2 = θ1 2 −x + 2 (x + 12 )2 θ1 2θ1 − 4x 4 4 = + x x (2x + 1)2 θ21 The polynomial part of this integrates easily to 4 ln(x). The fractional part simplifies to: 1 x 1 2 − 1 2 2θ1 x + 2 x+ 2 θ1 2 We deal with the quadratic term in θ1 first. Setting u= x x + 12 and v= 1 θ1 we have (chain rule for θ01 !) u0 = 1 2(x + 12 )2 v0 = − and 1 θ21 (x + 12 ) and we get by partial integration (this is essentially equation (∗∗)): Z − x 1 2 x+ 2 Z θ1 2 = 0 uv = uv − Z x − uv= (x + 12 )θ1 0 Z 1 2(x + 12 )2 θ1 Note that the integral subtracted is exactly the negative of the term only involving θ1 . This gives the claimed antiderivative The next integral to solve was that of 4 (x2 + x + 1)θ1 + x2 − 1 x2 + x + 1 4 x2 − 1 + = θ1 + + x x (x + 1/2)2 (x + 12 )2 (x + 12 )2 x2 + x + 1 4 x2 − 1 We thus have A1 = and A0 = + . x (x + 1/2)2 (x + 12 )2 Recursively we evaluate (using partial fractions): Z A1 = x − 3 2(2x + 1) 3 and thus B2 = 0, B1 = B̄1 + b1 , B̄1 = x − 2(2x+1) . The next integral is Z 1 = A0 − B̄1 x + 12 Z 7x + 4 1 1 = 4 ln(x) − ln(x + ) x(2x + 1) 2 2 Thus b1 = −1/2 and B0 = 4 ln(x). This gives the claimed integral 1 x2 − 1 3 − θ1 + 4 ln(x) = θ1 + 4 ln(x) (B̄1 + b1 )θ1 + B0 = x − 2(2x + 1) 2 x + 12 The third integral to be evaluated recursively is that of 2x + 2xθ1 + θ1 1 1 = + xθ1 (2x + 1) x θ1 (x + 12 The polynomial part yields the integral ln(x), the rational part has numerator 1 and denominator θ1 . x + 12 We set a := 1 x+ 12 θ01 =1 and get that a0 = 0, so a is constant. Thus the integral of the rational part is 1 a · ln(θ1 ) = ln(ln(x + )) 2 and we are done.