fixes typos and a missing reference.
[maxima.git] / share / integration / rtest_hermite_reduce.mac
blobc2e2c0a7956692485f4c0bb1307bc3870f9b968b
1 (kill(all), 'done);
2 'done$
4 (load("hermite_reduce.mac"), 'done);
5 'done$
7 /* define a simple version of `rootsof' */
8 (rof(expr, var):= map('rhs, solve(expr, var)), 'done);
9 'done$
11 int_rational_function(1,x);
14 int_rational_function(x,x);
15 x^2/2$
18 Fails:
20 (%i1) int_rational_function(1/x,x);
21 part: argument must be a non-atomic expression; found t
22 #0: int_rational_log_part(a=1,d=x,var=x)(hermite_reduce.mac line 120)
23 #1: int_rational_function(f=1/x,var=x)(hermite_reduce.mac line 141)
24  -- an error. To debug this try: debugmode(true);
26 int_rational_function(1/x,x);
27 log(x)$
31 block([expr: x/(x^2+1), ans, ref, logexpand: all],
32   ans: ev(int_rational_function(expr, x), rootsof=rof),
33   ref: integrate(expr, x),
34   expand(ans - ref));
37 block([expr: x/(x^2+1), ans, ref, logexpand: all],
38   ans: ev(int_rational_function(expr, x), rootsof=rof),
39   ref: integrate(expr, x),
40   expand(ans - ref));
43 block([expr: 1/(x^3+x), ans, ref, logexpand: all],
44   ans: ev(int_rational_function(expr, x), rootsof=rof),
45   ref: integrate(expr, x),
46   expand(ans - ref));
47 log(2)/2$
49 /* from
50 Trager, B. M. Algebraic Factoring and Rational Function
51 Integration. in Proceedings of the Third ACM Symposium on Symbolic and
52 Algebraic Computation 219–226 (ACM, 1976). doi:10.1145/800205.806338
54 block([q: 7*x^13 + 10*x^8 + 4*x^7 - 7*x^6 - 4*x^3 - 4*x^2 + 3*x +
55   3, r: x^14 - 2*x^8 - 2*x^7 - 2*x^4 - 4*x^3 - x^2 + 2*x + 1, ans, ref],
56   ans: ev(int_rational_function(q/r, x), rootsof=rof),
57   ref: (sqrt(2)+1)*log(x^7-sqrt(2)*x^2-(sqrt(2)+1)*x-1)/2
58   -(sqrt(2)-1)*log(x^7+sqrt(2)*x^2+(sqrt(2)-1)*x-1)/2,
59   expand(ref - ans));
62 /* from comments in share/integration/hermite_reduce.mac */
63 int_rational_function((x^4-3*x^2+6)/(x^6-5*x^4+5*x^2+4),x);
64 'lsum(t*log(x^3+t*x^2-3*x-2*t)/2,t,rootsof(t^2+1,t))$