Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit f0fe6f4

Browse files
committed
17953: any symbolic function arg prevents forced result conversion to numeric
1 parent 52db42b commit f0fe6f4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/sage/functions/special.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,10 @@ def _maxima_init_evaled_(self, *args):
285285
correctly (see :trac:`7557`)::
286286
287287
sage: t = f(1.2+2*I*elliptic_kc(1-.5),.5)
288-
sage: t._maxima_init_(maxima) # abs tol 1e-13
289-
'0.88771548861928029 - 1.7301614091485560e-15*%i'
288+
sage: maxima(t) # abs tol 1e-13
289+
0.88771548861928029 - 1.7301614091485560e-15*%i
290290
sage: t.n() # abs tol 1e-13
291-
0.887715488619280 - 1.79195288804672e-15*I
292-
291+
0.887715488619280 - 1.73016140914856e-15*I
293292
"""
294293
args_maxima = []
295294
for a in args:

src/sage/symbolic/function.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,14 @@ cdef class Function(SageObject):
357357
array([ 0. , 0.84147098, 0.90929743, 0.14112001, -0.7568025 ])
358358
359359
Symbolic functions evaluate non-exact input numerically, and return
360-
symbolic expressions on exact input::
360+
symbolic expressions on exact input, or if any input is symbolic::
361361
362362
sage: arctan(1)
363363
1/4*pi
364364
sage: arctan(float(1))
365365
0.7853981633974483
366+
sage: type(lambert_w(SR(0)))
367+
<type 'sage.symbolic.expression.Expression'>
366368
367369
Precision of the result depends on the precision of the input::
368370
@@ -444,7 +446,7 @@ cdef class Function(SageObject):
444446

445447
# if the given input is a symbolic expression, we don't convert it back
446448
# to a numeric type at the end
447-
if len(args) == 1 and parent_c(args[0]) is SR:
449+
if any(parent_c(arg) is SR for arg in args):
448450
symbolic_input = True
449451
else:
450452
symbolic_input = False

0 commit comments

Comments
 (0)