Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why is basic arithmetic disallowed on symbolic functions?

The documentation at http://www.sagemath.org/doc/reference/calculus/sage/symbolic/function_factory.html states: "In Sage 4.0, basic arithmetic with unevaluated functions is no longer supported" Why? What is the intended way of manipulating equations and then, at some point, taking derivatives with respect to some dependent variable? The following approach has an undesired side-effect:

var('B E H T_s')
eq_B_TS = B == H/E
diff(eq_B_TS.subs(B = function('B')(T_s), E = function('E')(T_s), H = function('H')(T_s)), T_s)

D0(T_s) == -H(T_s)*D0(T_s)/E(T_s)^2 + D0(T_s)/E(T_s)

Fine, but now my B, E and H are symbolic functions and I cannot do any basic arithmetic with them any more:

B*E

Traceback (click to the left of this block for traceback) ... TypeError: unsupported operand type(s) for *: 'NewSymbolicFunction' and 'NewSymbolicFunction'

There must be a better way. Thanks for your help already.

Why is basic arithmetic disallowed on symbolic functions?

The documentation at http://www.sagemath.org/doc/reference/calculus/sage/symbolic/function_factory.html states: "In states:

In Sage 4.0, basic arithmetic with unevaluated functions is no longer supported" supported

Why? What is the intended way of manipulating equations and then, at some point, taking derivatives with respect to some dependent variable? The following approach has an undesired side-effect:

sage: var('B E H T_s')
(B, E, H, T_s)
sage: eq_B_TS = B == H/E
sage: diff(eq_B_TS.subs(B = function('B')(T_s), E = function('E')(T_s), H = function('H')(T_s)), T_s)
D[0](B)(T_s) == -H(T_s)*D[0](E)(T_s)/E(T_s)^2 + D[0](H)(T_s)/E(T_s)

D0(T_s) == -H(T_s)*D0(T_s)/E(T_s)^2 + D0(T_s)/E(T_s)

Fine, but now my B, E and H are symbolic functions and I cannot do any basic arithmetic with them any more:

sage: B*E

Traceback (click to the left of this block for traceback) ... TypeError: unsupported operand type(s) for *: 'NewSymbolicFunction' and 'NewSymbolicFunction'

and 'NewSymbolicFunction'

There must be a better way. Thanks for your help already.