sage: ((a*b - (1/2)*a*(b - c))/a).simplify_radical()
(c + b)/2
which works fine. Maybe it's a bug in maxima. I don't see why you
would need simplify_radical() at all here, since your expression
contains no radicals.
John Cremona
2008/10/24 Stan Schymanski <schy...@gmail.com>:
Here's an approach which does not use maxima at all, but rather more
"pure" algebra:
sage: R.<a,b,c> = QQ[]
sage: (a*b - (1/2)*a*(b - c))//a
1/2*b + 1/2*c
Here, R is the set of all polynomials in a,b,c with rational
coefficients, and // does an exact division. (If you use / instead
the answer looks the same but lies in a different place:
sage: parent((a*b - (1/2)*a*(b - c))/a)
Fraction Field of Multivariate Polynomial Ring in a, b, c over Rational Field
sage: parent((a*b - (1/2)*a*(b - c))//a)
Multivariate Polynomial Ring in a, b, c over Rational Field
Now, whether or not you like this solution seems to depend on whether
or not you are a pure mathematician who is used to rings and fields,
as opposed so someone who just deals with symbolic expressions. The
former are much faster (and, as in this case, more accurate!) but are
conceptually harder -- and do not allow things like radicals and
exponentials.
John Cremona
In this case, expand seems to do what you want. I don't know if it will help
you with more complex expressions.
sage: var("a,b,c")
(a, b, c)
sage: e = ((a*b - (1/2)*a*(b - c))/a); e
(a*b - a*(b - c)/2)/a
sage: e.expand()
c/2 + b/2
or with float coefficients:
sage: e = ((a*b - (.5)*a*(b - c))/a); e
(a*b - 0.500000000000000*a*(b - c))/a
sage: e.expand()
0.500000000000000*c + 0.500000000000000*b
In general, I find that expand will end up simplifying things a lot more
than the simplify functions will.
I suppose it's like our secondary school math: when in doubt, multiply
everything out and then see what cancels.
Jason
Eventually, yes.
To be able to extend / improve / customize such maxima functions is one of the
main reasons behind the pynac backed symbolics effort.
Cheers,
Burcin