Skip to content

Commit

Permalink
Merge pull request #817 from GarkGarcia/sqrt-re-im-fix
Browse files Browse the repository at this point in the history
Implemented proper sympolic expantion for the `Re` and `Im` builtins
  • Loading branch information
GarkGarcia committed Sep 3, 2020
2 parents 3089801 + 7a29e41 commit b877bfb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mathics/builtin/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,11 @@ def apply_number(self, number, evaluation):

return number

def apply(self, number, evaluation):
'Re[number_]'

return from_sympy(sympy.re(number.to_sympy().expand(complex=True)))


class Im(SympyFunction):
"""
Expand Down Expand Up @@ -1127,6 +1132,11 @@ def apply_number(self, number, evaluation):

return Integer(0)

def apply(self, number, evaluation):
'Im[number_]'

return from_sympy(sympy.im(number.to_sympy().expand(complex=True)))


class Conjugate(_MPMathFunction):
"""
Expand Down

0 comments on commit b877bfb

Please sign in to comment.