Alternatives :

sage: var("a, b, c")
(a, b, c)
sage: f=1/(a-b)+2/(b-c)+3/(c-a)
sage: g=f*(a-b)*(b-c)*(c-a)
sage: f
1/(a - b) - 3/(a - c) + 2/(b - c)
sage: f.factor()
(2*a^2 - 4*a*b + 3*b^2 - 2*b*c + c^2)/((a - b)*(a - c)*(b - c))
sage: g
-(a - b)*(a - c)*(b - c)*(1/(a - b) - 3/(a - c) + 2/(b - c))
sage: g.expand()
-a^2*b/(a - b) + 3*a^2*b/(a - c) - 2*a^2*b/(b - c) + a*b^2/(a - b) - 3*a*b^2/(a 
- c) + 2*a*b^2/(b - c) + a^2*c/(a - b) - 3*a^2*c/(a - c) + 2*a^2*c/(b - c) - 
b^2*c/(a - b) + 3*b^2*c/(a - c) - 2*b^2*c/(b - c) - a*c^2/(a - b) + 3*a*c^2/(a 
- c) - 2*a*c^2/(b - c) + b*c^2/(a - b) - 3*b*c^2/(a - c) + 2*b*c^2/(b - c)
sage: g.expand().factor()
-2*a^2 + 4*a*b - 3*b^2 + 2*b*c - c^2

And, indeed :

sage: R1.<t, u, v>=QQ[]
sage: fp = FractionField(R1)(f.subs(dict(zip((a,b,c),(t,u,v))))).numerator() ; 
fp
2*t^2 - 4*t*u + 3*u^2 - 2*u*v + v^2
sage: SR(fp).subs(dict(zip((t,u,v), (a,b,c))))
2*a^2 - 4*a*b + 3*b^2 - 2*b*c + c^2

HTH,
​
Le vendredi 26 novembre 2021 à 20:25:08 UTC+1, dim...@gmail.com a écrit :

> On Fri, Nov 26, 2021 at 7:19 PM Ricardo Fodra <ricard...@gmail.com> wrote:
> >
> > So I tried to do:
> >
> > var('a b c')
> > f = 1/(a-b) + 2/(b-c) + 3/(c-a)
> > # get rid of the denominators
> > g = f*(a-b)*(b-c)*(c-a)
> > g.expand()
> >
> > And I was hoping to get something like:
> >
> > -a*b + a*c + b*c - c^2 - 2*a - 2*b - c
> >
> > and instead I got:
> >
> > -a^2*b/(a - b) + 3*a^2*b/(a - c) - 2*a^2*b/(b - c) + a*b^2/(a - b) - 
> 3*a*b^2/(a - c) + 2*a*b^2/(b - c) + a^2*c/(a - b) - 3*a^2*c/(a - c) + 
> 2*a^2*c/(b - c) - b^2*c/(a - b) + 3*b^2*c/(a - c) - 2*b^2*c/(b - c) - 
> a*c^2/(a - b) + 3*a*c^2/(a - c) - 2*a*c^2/(b - c) + b*c^2/(a - b) - 
> 3*b*c^2/(a - c) + 2*b*c^2/(b - c)
> >
> > Are those equivalent? Am I doing something wrong?
>
> do the following:
>
> sage: g.simplify_rational()
> -2*a^2 + 4*a*b - 3*b^2 + 2*b*c - c^2
>
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "sage-support" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to sage-support...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-support/5d5f136d-637b-4dd9-9c9b-eb00b7609401n%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/c1edfa06-311f-458f-818b-e0e3fd3eed76n%40googlegroups.com.

Reply via email to