Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, welcome. Don't know how far the next goes, but if nobody answers consider:

var('x,y',domain=RR)
def csimp(complex_poly):    
    if type(imag_part(denominator(complex_poly))) == sage.symbolic.expression.Expression:
        return numerator(complex_poly)\
         *(conjugate(denominator(complex_poly)))/(norm(denominator(complex_poly))^2)
    else:
        return (complex_poly)

csimp(1/z) # (x - I*y)/(x^2 + y^2)^2

Hi, welcome. Don't know how far the next goes, works, but if while nobody answers answers, consider:

var('x,y',domain=RR)
def csimp(complex_poly):    
    if type(imag_part(denominator(complex_poly))) == sage.symbolic.expression.Expression:
        return numerator(complex_poly)\
         *(conjugate(denominator(complex_poly)))/(norm(denominator(complex_poly))^2)
    else:
        return (complex_poly)

csimp(1/z) # (x - I*y)/(x^2 + y^2)^2