$ maple -b . -B test-install.mpl |\^/| Maple 2018 (X86 64 LINUX) ._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2018 \ MAPLE / All rights reserved. Maple is a trademark of <____ ____> Waterloo Maple Inc. | Type ? for help. # The present script will test that redct has been installed properly and can # be used as an example to treat other integrals. Run this using (on a Unix # platform) # maple -b -B # where is the directory where the files have been installed. # (Tested 2018/11/21 with Maple2017 and Maple2018.) # The script will stop on error if any of the ASSERTs below detects a problem. > kernelopts(assertlevel = 1): > interface(errorbreak = 2): > read "redct.mpl"; > ASSERT(assigned(GB_to_matrices), "source files cannot be loaded"); # Example of the paper. > f := exp(-p*x) * ChebyshevT(n,x) / sqrt(1-x^2): # New creative-telescoping algorithm, based on generalized Hermite reduction. > time(assign( > ghred_ct = redct(Int(f, x = -1..1), [n::shift, p::diff]))); memory used=3.6MB, alloc=8.3MB, time=0.07 0.101 > ghred_ct; 2 [p D[n] + p D[p] - n, p D[n] - 2 n D[n] - p - 2 D[n]] > ASSERT(assigned(ghred_ct), "reduction-based algorithm did not work"); # For comparison sake, old creative-telescoping algorithm, based on rational # LODE solving. > with(Mgfun): > time(assign( > ratsol_ct = creative_telescoping(f, [n::shift, p::diff], x::diff))); 0.100 > ratsol_ct; memory used=37.6MB, alloc=79.3MB, time=0.41 /d \ [[p _F(n + 1, p) + p |-- _F(n, p)| - n _F(n, p), \dp / x _f(n, p, x) - _f(n + 1, p, x)], [ -p _F(n, p) + p _F(n + 2, p) + (-2 n - 2) _F(n + 1, p), -2 x _f(n + 1, p, x) + 2 _f(n, p, x)]] > ASSERT(assigned(ratsol_ct), "rational-solving-based algorithm did not work"); # Both implementations rely on the following generation of equations. > time(assign( > sys = dfinite_expr_to_sys(f, y(n::shift, p::diff, x::diff)))); 0.029 > sys; /d \ 2 {x y(n, p, x) + |-- y(n, p, x)|, (-p x - n x + p - x) y(n, p, x) \dp / 2 /d \ + n y(n + 1, p, x) + (-x + 1) |-- y(n, p, x)|, \dx / / 2 \ 2 2 2 2 2 |d | (p x - n - p + 3 p x + 1) y(n, p, x) + (x - 1) |--- y(n, p, x)| | 2 | \dx / 2 /d \ + (2 p x - 2 p + 3 x) |-- y(n, p, x)|} \dx / # Mgfun:-creative_telescoping has returned pairs [q[1], q[2]] satisfying # q[1] = diff(q[2], x). # Check the obtained telescopers (q[1]) by using the certificates (q[2]): > map(q -> q[1] - diff(q[2], x), > eval(ratsol_ct, {_F = unapply(f, n, p), _f = unapply(f, n, p, x)})); n exp(-p x) ChebyshevT(n, x) exp(-p x) ChebyshevT(n, x) [- ---------------------------- - -------------------------- 2 1/2 2 1/2 (-x + 1) (-x + 1) / n x ChebyshevT(n, x) n ChebyshevT(n - 1, x)\ x exp(-p x) |- -------------------- + ----------------------| | 2 2 | \ -x + 1 -x + 1 / - ------------------------------------------------------------- 2 1/2 (-x + 1) 2 x exp(-p x) ChebyshevT(n, x) - ----------------------------- 2 3/2 (-x + 1) / (n + 1) x ChebyshevT(n + 1, x) (n + 1) ChebyshevT(n, x)\ exp(-p x) |- ------------------------------ + ------------------------| | 2 2 | \ -x + 1 -x + 1 / + ----------------------------------------------------------------------- 2 1/2 (-x + 1) exp(-p x) ChebyshevT(n + 1, x) x p exp(-p x) ChebyshevT(n, x) + --------------------------------, ---------------------------- 2 3/2 2 1/2 (-x + 1) (-x + 1) p exp(-p x) ChebyshevT(n + 2, x) + -------------------------------- 2 1/2 (-x + 1) (-2 n - 2) exp(-p x) ChebyshevT(n + 1, x) + ----------------------------------------- 2 1/2 (-x + 1) 2 exp(-p x) ChebyshevT(n + 1, x) 2 x p exp(-p x) ChebyshevT(n + 1, x) + -------------------------------- - ------------------------------------ 2 1/2 2 1/2 (-x + 1) (-x + 1) + 2 x exp(-p x) / (n + 1) x ChebyshevT(n + 1, x) (n + 1) ChebyshevT(n, x)\ / |- ------------------------------ + ------------------------| / | 2 2 | / \ -x + 1 -x + 1 / 2 2 1/2 2 x exp(-p x) ChebyshevT(n + 1, x) (-x + 1) + ----------------------------------- 2 3/2 (-x + 1) / n x ChebyshevT(n, x) n ChebyshevT(n - 1, x)\ 2 exp(-p x) |- -------------------- + ----------------------| | 2 2 | \ -x + 1 -x + 1 / - ------------------------------------------------------------- 2 1/2 (-x + 1) 2 exp(-p x) ChebyshevT(n, x) x - ------------------------------] 2 3/2 (-x + 1) > simplify(subs(n = 10, %)); [0, 0] > ASSERT(% = [0, 0], "bug in creative_telescoping"); # redct has obtained the same telescopers as creative_telescoping: > ratsol_telescopers := map(q -> q[1], ratsol_ct); /d \ ratsol_telescopers := [p _F(n + 1, p) + p |-- _F(n, p)| - n _F(n, p), \dp / -p _F(n, p) + p _F(n + 2, p) + (-2 n - 2) _F(n + 1, p)] > ghred_telescopers := map(Ore_algebra:-applyopr, ghred_ct, _F(n, p), > Ore_algebra:-skew_algebra(shift = [D[n], n], diff = [D[p], p])); /d \ ghred_telescopers := [p _F(n + 1, p) + p |-- _F(n, p)| - n _F(n, p), \dp / -p _F(n, p) + p _F(n + 2, p) + (-2 n - 2) _F(n + 1, p)] > ASSERT(ratsol_telescopers = ghred_telescopers, "equations differ (are they equivalent?)"); > print("All is fine."); "All is fine." > quit memory used=41.5MB, alloc=79.3MB, time=0.46