1 | initial version |
I see. You are using a symbolic equation in the latter case, which will definitely barf at dividing by zero, but the things you are putting in are "real literals".
sage: type(a) <type 'sage.symbolic.expression.expression'=""> sage: type(vdict[a]) <type 'sage.rings.real_mpfr.realliteral'="">
As such, they obey 'usual' division rules for floating-point things like
sage: vdict[x]/vdict[x] NaN
So if you don't want mathematically correct behavior, I suggest not using a symbolic variable!
sage: eq_y = y == z sage: def mysubs(a=.1,x=0.,eq=eq_y): ....: t = a/x ....: return eq.subs(z=t) ....: sage: mysubs() y == +infinity sage: mysubs(.0,.0) y == NaN
Indeed, we get
sage: vdict = {} sage: vdict['a'] = 0. sage: vdict['x'] = 0. sage: mysubs(**vdict) y == NaN
2 | No.2 Revision |
I see. You are using a symbolic equation in the latter case, which will definitely barf at dividing by zero, but the things you are putting in are "real literals".
sage: type(a)
<type As such, they obey 'usual' division rules for floating-point things like
sage: vdict[x]/vdict[x]
So if you don't want mathematically correct behavior, I suggest not using a symbolic variable!
sage: eq_y = y == z
sage: def mysubs(a=.1,x=0.,eq=eq_y):
....: t = a/x
....: return eq.subs(z=t)
....:
sage: mysubs()
y == +infinity
sage: mysubs(.0,.0)
y == Indeed, we get
sage: vdict = {}
sage: vdict['a'] = 0.
sage: vdict['x'] = 0.
sage: mysubs(**vdict)
y ==