Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/* * This file: * http://anggtwu.net/MAXIMA/2024-2-C2-partfrac.mac.html * http://anggtwu.net/MAXIMA/2024-2-C2-partfrac.mac * (find-angg "MAXIMA/2024-2-C2-partfrac.mac") * Author: Eduardo Ochs <eduardoochs@gmail.com> * * (defun e () (interactive) (find-angg "MAXIMA/2024-2-C2-partfrac.mac")) * (find-es "maxima" "2024.2-C2-P1") * (c2m242p1p 9 "gab-2") * (c2m242p1a "gab-2") * * «.test-solve» (to "test-solve") * «.test-build» (to "test-build") * «.test-solve2» (to "test-solve2") * «.test-ratcoeff» (to "test-ratcoeff") */ partfrac_all() := ( [q,r] : divide(fup, fdn, x), fup2 : fdn*q + r, fdn2 : factor(fdn), f1 : fup/fdn, f2 : fup2/fdn, f3 : (fdn*q)/fdn + r/fdn, f4 : (fdn*q)/fdn + r/fdn2, f5 : (fdn*q)/fdn + partfrac(r/fdn2, x), F1 : 'integrate(f1,x), F2 : 'integrate(f5,x), F3 : integrate(f5,x), M : align_eqss([[fup, fup2], [fdn, fdn2], [f1,f2,f3,f4,f5], [F1,F2,F3] ]))$ /* «test-solve» (to ".test-solve") * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("2024-2-C2-partfrac.mac"); f : (x^3 + 6*x^2 - 22*x - 55) / (x^2 + 4*x - 21); fup : (x^3 + 6*x^2 - 22*x - 55); fdn : (x^2 + 4*x - 21); partfrac_all()$ M; ** «test-build» (to ".test-build") ** (c2m242vrp1p) ** (c2m242vrp1a) F : 2/(x+7) + 4/(x-3) - 2 + x; F : radcan(F); fup : num(F); fdn : denom(F); partfrac_all()$ M; */ /* «test-solve2» (to ".test-solve2") * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("2024-2-C2-partfrac.mac"); F : (x^4 -10*x^2 + 3*x + 1) / (x^2 - 4); F : (2*x^3 - 6*x^2 - 15*x + 55) / (x^2 - 2*x - 15); fup : num(F); fdn : denom(F); partfrac_all()$ M; */ /* «test-ratcoeff» (to ".test-ratcoeff") * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load("2024-2-C2-partfrac.mac"); F : (4*x+5) / ((x+2)*(x-3)); G : A/(x+2) + B/(x-3); F = G; G2 : radcan(G); [numF, numG] : [num(F), num(G2)]; eq : numF=numG; solve(eq, [A,B]); "bad: mentions x,%r1,%r2"$ eq1 : ratcoeff(numF=numG, x, 1); eq0 : ratcoeff(numF=numG, x, 0); sol : solve([eq1,eq0], [A,B]); "good"$ sol2 : subst(sol, F=G); radcan(sol2); */