EXAMPLES:
When you do arithmetic with:
sage: f(x, y, z) = sin(x+y+z)
sage: g(x, y) = y + 2*x
sage: f + g
(x, y, z) |--> 2*x + y + sin(x + y + z)
sage: f(x, y, z) = sin(x+y+z)
sage: g(w, t) = cos(w - t)
sage: f + g
(t, w, x, y, z) |--> cos(-t + w) + sin(x + y + z)
sage: f(x, y, t) = y*(x^2-t)
sage: g(x, y, w) = x + y - cos(w)
sage: f*g
(x, y, t, w) |--> (x^2 - t)*(x + y - cos(w))*y
sage: f(x,y, t) = x+y
sage: g(x, y, w) = w + t
sage: f + g
(x, y, t, w) |--> t + w + x + y
TESTS:
The arguments in the definition must be symbolic variables #10747:
sage: f(1)=2
Traceback (most recent call last):
...
SyntaxError: can't assign to function call
sage: f(x,1)=2
Traceback (most recent call last):
...
SyntaxError: can't assign to function call
sage: f(1,2)=3
Traceback (most recent call last):
...
SyntaxError: can't assign to function call
sage: f(1,2)=x
Traceback (most recent call last):
...
SyntaxError: can't assign to function call
sage: f(x,2)=x
Traceback (most recent call last):
...
SyntaxError: can't assign to function call
Bases: sage.categories.pushout.ConstructionFunctor
A functor which produces a CallableSymbolicExpressionRing from the SymbolicRing.
EXAMPLES:
sage: from sage.symbolic.callable import CallableSymbolicExpressionFunctor
sage: x,y = var('x,y')
sage: f = CallableSymbolicExpressionFunctor((x,y)); f
CallableSymbolicExpressionFunctor(x, y)
sage: f(SR)
Callable function ring with arguments (x, y)
sage: loads(dumps(f))
CallableSymbolicExpressionFunctor(x, y)
EXAMPLES:
sage: from sage.symbolic.callable import CallableSymbolicExpressionFunctor
sage: x,y = var('x,y')
sage: a = CallableSymbolicExpressionFunctor((x,y))
sage: a.arguments()
(x, y)
EXAMPLES:
sage: from sage.symbolic.callable import CallableSymbolicExpressionFunctor
sage: x,y = var('x,y')
sage: a = CallableSymbolicExpressionFunctor((x,))
sage: b = CallableSymbolicExpressionFunctor((y,))
sage: a.merge(b)
CallableSymbolicExpressionFunctor(x, y)
Takes the variable list from another CallableSymbolicExpression object and compares it with the current CallableSymbolicExpression object’s variable list, combining them according to the following rules:
Let a be self‘s variable list, let b be y‘s variable list.
Note
When used for arithmetic between CallableSymbolicExpression‘s, these rules ensure that the set of CallableSymbolicExpression‘s will have certain properties. In particular, it ensures that the set is a commutative ring, i.e., the order of the input variables is the same no matter in which order arithmetic is done.
INPUT:
OUTPUT: A tuple of variables.
EXAMPLES:
sage: from sage.symbolic.callable import CallableSymbolicExpressionFunctor
sage: x,y = var('x,y')
sage: a = CallableSymbolicExpressionFunctor((x,))
sage: b = CallableSymbolicExpressionFunctor((y,))
sage: a.unify_arguments(b)
(x, y)
AUTHORS:
Bases: sage.structure.factory.UniqueFactory
EXAMPLES:
sage: x,y = var('x,y')
sage: CallableSymbolicExpressionRing.create_key((x,y))
(x, y)
Returns a CallableSymbolicExpressionRing given a version and a key.
EXAMPLES:
sage: x,y = var('x,y')
sage: CallableSymbolicExpressionRing.create_object(0, (x, y))
Callable function ring with arguments (x, y)
Bases: sage.symbolic.ring.SymbolicRing
EXAMPLES:
We verify that coercion works in the case where x is not an instance of SymbolicExpression, but its parent is still the SymbolicRing:
sage: f(x) = 1
sage: f*e
x |--> e
Returns the arguments of self. The order that the variables appear in self.arguments() is the order that is used in evaluating the elements of self.
EXAMPLES:
sage: x,y = var('x,y')
sage: f(x,y) = 2*x+y
sage: f.parent().arguments()
(x, y)
sage: f(y,x) = 2*x+y
sage: f.parent().arguments()
(y, x)
Returns the arguments of self. The order that the variables appear in self.arguments() is the order that is used in evaluating the elements of self.
EXAMPLES:
sage: x,y = var('x,y')
sage: f(x,y) = 2*x+y
sage: f.parent().arguments()
(x, y)
sage: f(y,x) = 2*x+y
sage: f.parent().arguments()
(y, x)
EXAMPLES:
sage: f(x,y) = x^2 + y
sage: f.parent().construction()
(CallableSymbolicExpressionFunctor(x, y), Symbolic Ring)
Returns True if x is a callable symbolic expression.
EXAMPLES:
sage: from sage.symbolic.callable import is_CallableSymbolicExpression
sage: var('a x y z')
(a, x, y, z)
sage: f(x,y) = a + 2*x + 3*y + z
sage: is_CallableSymbolicExpression(f)
True
sage: is_CallableSymbolicExpression(a+2*x)
False
sage: def foo(n): return n^2
...
sage: is_CallableSymbolicExpression(foo)
False
Return True if x is a callable symbolic expression ring.
INPUT:
OUTPUT: bool
EXAMPLES:
sage: from sage.symbolic.callable import is_CallableSymbolicExpressionRing
sage: is_CallableSymbolicExpressionRing(QQ)
False
sage: var('x,y,z')
(x, y, z)
sage: is_CallableSymbolicExpressionRing(CallableSymbolicExpressionRing((x,y,z)))
True