On Mar 16, 1:10 pm, tvn <[email protected]> wrote:
> I wrote something like below, it seems to do what I want - though not sure
> if it's correct or not.
>
> def simplify_common_factors_(p):
> common_factors = [f**occurences for (f,occurences) in p.factor_list()
> if f.number_of_operands()==0]
> rs = p.divide_both_sides(prod(common_factors))
> rs = rs.expand()
> return rs
>
> sage: simplify_common_factors_(3*x^2*y*z + x*y*z + y*z == 0)
> 3*x^2 + x + 1 == 0
Seems plausible, and if that fixes your problem, well done!
I don't know that I personally would promote it to a full-fledged Sage
function. This is because of the following.
sage: var('y,z')
(y, z)
sage: F = (x+2)^2*(y^2+x^2+1)*(x^2-2*x+1)
sage: G = F.expand() == 0
sage: simplify_common_factors_(G)
x^6 + x^4*y^2 + 2*x^5 + 2*x^3*y^2 - 2*x^4 - 3*x^2*y^2 - 2*x^3 -
4*x*y^2 + x^2 + 4*y^2 - 4*x + 4 == 0
You only are getting rid of factors which are symbols. What is
special about those, as opposed to if you happen to know that x-1 is
nonzero below? Or the third factor, which is always nonzero for real
x,y? (Though Sage does not assume real variables.)
sage: G.factor_list()
[(x - 1, 2), (x + 2, 2), (x^2 + y^2 + 1, 1)]
Good luck! For further treats, you may want to try
sage: G.maxima_methods
to access many of the more unusual Maxima simplification and expansion
stuff.
- kcrisman
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org