On Sat, Mar 22, 2008 at 10:25 PM, Alasdair McAndrew <amca01 at gmail.com>
wrote:
> I think if your factorization is not over the rationals, you have to tell
> Maxima what field extension to use. This sort of works:
>
> p:partfrac(1/factor(x^3+2,a^3-2),x);
> subst(2^(1/3),a,p);
>
>
The code above works well, the code below is another solution of the problem
(slight modification of factor_with_solve from
/maxima/share/contrib/solve_rec/simplify_sum.mac)
------------------------------------------------------------- begin
factor_with_solve_real(expr, n) := block(
[sol, fac, expr1],
sol : solve(expr, n),
expr : ratexpand(expr),
fac : ratcoef(expr, n, hipow(expr, n)),
for i:1 thru length(sol) do (
if not(freeof(n, rhs(sol[i]))) then error(),
if imagpart(rectform(rhs(sol[i])))=0 then
fac : fac * (n - rhs(sol[i]))^multiplicities[i]
else
(if imagpart(rectform(rhs(sol[i])))>0 then
fac:
fac*(ratsimp(expand((n-rhs(sol[i]))*(n-conjugate(rhs(sol[i]))))))^multiplicities[i])
),
if expand(expr)#expand(fac) then error(),
fac
)$
factor_with_solve_real(x^3+2,x);
partfrac(1/factor_with_solve_real(x^3+2,x),x);
------------------------------------------------------------ end
I am not sure if rectform is necessary.
ratsimp is necessary, since otherwise the test expand(expr)#expand(fac) is
true and error occurs for x^2+2.
Robert M.