Skip to content

Commit

Permalink
watch out for negative args of log in evalf
Browse files Browse the repository at this point in the history
  • Loading branch information
smichr committed Apr 27, 2014
1 parent 79e5d90 commit 04aa71c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sympy/core/evalf.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,8 @@ def evalf_log(expr, prec, options):
arg = C.Add(S.NegativeOne, arg, evaluate=False)
xre, xim, _, _ = evalf_add(arg, prec, options)
prec2 = workprec - fastlog(xre)
re = mpf_log(mpf_add(xre, fone, prec2), prec, rnd)
# xre is now x - 1 so we add 1 back here to calculate x
re = mpf_log(mpf_abs(mpf_add(xre, fone, prec2)), prec, rnd)

re_acc = prec

Expand Down
1 change: 1 addition & 0 deletions sympy/core/tests/test_evalf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def test_evalf_complex_cancellation():
def test_evalf_logs():
assert NS("log(3+pi*I)", 15) == '1.46877619736226 + 0.808448792630022*I'
assert NS("log(pi*I)", 15) == '1.14472988584940 + 1.57079632679490*I'
assert NS('log(-1 + 0.00001)', 2) == '-1.0e-5 + 3.1*I'


def test_evalf_trig():
Expand Down

0 comments on commit 04aa71c

Please sign in to comment.