with snippet:
from sympy import * init_printing(use_latex='mathjax') a,b,c=symbols('a b c') ratsimp(a+1/b+1/c) i get
a + (b + c)/(b*c) while
(a*b*c + b + c)/(b*c) because need numerator of fraction.
is possible?
here screenshot, out[1] while out[2]:
as ratsimp documentation says, final step reduce rational function, extract polynomial part. since not want, should not use ratsimp. instead, use cancel on common denominator, , if want numerator , denominator separately, use .as_numer_denom()
>>> cancel(a+1/b+1/c) (a*b*c + b + c)/(b*c) >>> f, g = cancel(a+1/b+1/c).as_numer_denom() >>> f a*b*c + b + c >>> g b*c 
Comments
Post a Comment