4 test_solve_rec([eq]) := block(
5 [sol:apply(solve_rec,eq)],
6 ev(radcan(minfactorial(rhs(first(eq))-lhs(first(eq)))), subst(":=", "=", sol))),
7 test_solve_rec_rat([eq]) := block(
8 [sol:apply(solve_rec_rat,eq)],
9 ev(radcan(minfactorial(rhs(first(eq))-lhs(first(eq)))), subst(":=", "=", sol))),
14 test_solve_rec(a[n]=n/(n+1)*a[n-1], a[n]);
17 test_solve_rec(a[n]=n/(n+1)*a[n-1], a[n], a[1]=1);
20 test_solve_rec((n+1)*(2*n+1)*a[n+1]-(n+3)*(2*n-1)*a[n], a[n]);
22 test_solve_rec(a[n]=n*a[n-1]/(n-2)+1, a[n]);
25 test_solve_rec(a[n+1]=n*a[n]/(n-3) + 1/(n-5), a[n]);
28 test_solve_rec(a[n]=a[n-1]-a[n-2]+(n^2-1)/4^n, a[n]);
31 test_solve_rec(a[n]=a[n-1]-a[n-2]+(n^2-1)/4^n, a[n], a[1]=1);
34 test_solve_rec(a[n]=a[n-1]-a[n-2]+(n^2-1)/4^n, a[n], a[1]=1, a[2]=1);
37 test_solve_rec(a[n]=2*a[n-1]-a[n-2]+n, a[n]);
40 test_solve_rec(a[n]=3*a[n-1]-3*a[n-2]+a[n-3]+n+n*2^n, a[n]);
43 test_solve_rec(a[n+4]-a[n+3]-13*a[n+2]+a[n+1]+12*a[n]+n^2+2^(2*n+1)-1, a[n]);
46 test_solve_rec(a[n]=a[n+1]-a[n-1]-1, a[n]);
49 test_solve_rec(a[n]-4*a[n-1]+5*a[n-2]-2*a[n-3]=2^n, a[n], a[0]=1, a[1]=9, a[2]=33);
52 test_solve_rec((n+4)*s[n+2] + s[n+1] - (n+1)*s[n], s[n]);
55 test_solve_rec(9*(n+2)*s[n+2] - 3*(n+4)*s[n+1] - 2*(n+3)*s[n], s[n]);
58 test_solve_rec(a[x+2]-2*(x+5)*(x-4)/((x+6)*(x-3))*a[x+1]+(x+4)*(x-5)/((x+6)*(x-3))*a[x], a[x]);
61 test_solve_rec(2*x*(x+1)*y[x] - (x^2+3*x-2)*y[x+1] + (x-1)*y[x+2], y[x]);
64 test_solve_rec(2*x*(x+1)*y[x] - (x^2+3*x-2)*y[x+1] + (x-1)*y[x+2], y[x], y[1]=1, y[3]=3);
67 test_solve_rec((-n-5)*s[n+3]+(6*n+22)*s[n+2]+(-9*n-17)*s[n+1]+4*n*s[n],s[n]);
70 test_solve_rec((n+3)*s[n+2]-3*(n+2)*s[n+1]+2*(n+1)*s[n],s[n]);
73 test_solve_rec((x^6+5*x^5+5*x^4-5*x^3-6*x^2)*z[x+2]+(2*x^4+7*x^3+9*x^2+6*x)*z[x+1]+(x^2+4*x+3)*z[x], z[x]);
76 test_solve_rec(n*(n+1)*a[n+2]-2*n*(n+k+1)*a[n+1]+(n+k)*(n+k+1)*a[n], a[n]);
79 test_solve_rec(a[n+2]-(2*n+1)*a[n+1]+(n^2-u)*a[n], a[n]), hyper_factor_solve=true, assume_pos=true;
82 test_solve_rec((n^2-n-2)*f[n+2]+(-n^3-3*n^2+2*n+8)*f[n+1]+(2*n^3+4*n^2-2*n-4)*f[n], f[n]);
85 test_solve_rec((n^5+8*n^4+23*n^3+29*n^2+16*n+4)*f[n+2]+(-n^6-9*n^5-32*n^4-61*n^3-65*n^2-36*n-8)*f[n+1]+(-n^6-8*n^5-21*n^4-23*n^3-9*n^2)*f[n], f[n]);
88 test_solve_rec((2*n^6+18*n^5+57*n^4+74*n^3+32*n^2-3*n)*f[n+3]+(-2*n^7-24*n^6-115*n^5-285*n^4-386*n^3-275*n^2-95*n-18)*f[n+2]+(2*n^6+26*n^5+123*n^4+280*n^3+326*n^2+181*n+36)*f[n+1]+(2*n^7+24*n^6+111*n^5+255*n^4+308*n^3+187*n^2+45*n)*f[n], f[n]);
91 test_solve_rec_rat(a[x+2]-2*(x+5)*(x-4)/((x+6)*(x-3))*a[x+1]+(x+4)*(x-5)/((x+6)*(x-3))*a[x], a[x]);
94 test_solve_rec_rat(a[x+2]-2*((x-99)*(x+101))/((x-98)*(x+102))*a[x+1]+((x-100)*(x+100))/((x-98)*(x+102))*a[x], a[x]);
97 test_solve_rec((x+4)*a[x+3] + (x+3)*a[x+2] - x*a[x+1] + (x^2-1)*a[x]=(x+2)/(x+1), a[x]);
100 /* Sage bug #30520: "Error in the sign of a product"
101 * see: https://trac.sagemath.org/ticket/30520
104 simplify_product ('product (1 - f(k), k, 1, N));
105 (-1)^N*'product(f(k) - 1, k, 1, N);
107 simplify_product ('product (1 - q^k, k, 1, N));
108 (-1)^N*'product(q^k - 1, k, 1, N);
110 simplify_product ('product (-x**2, x, 1, n));
113 /* this one triggers Sage bug #31557: "Fix product(-x, x, 1, SR.var('n')) to return (-1)^n*factorial(n)"
114 * see: https://trac.sagemath.org/ticket/31557
116 simplify_product ('product (-x, x, 1, n));