Operators#

class sage.symbolic.operators.DerivativeOperator[source]#

Bases: object

Derivative operator.

Acting with this operator onto a function gives a new operator (of type FDerivativeOperator) representing the function differentiated with respect to one or multiple of its arguments.

This operator takes a list of indices specifying the position of the arguments to differentiate. For example, D[0, 0, 1] is an operator that differentiates a function twice with respect to its first argument and once with respect to its second argument.

EXAMPLES:

sage: x, y = var('x,y'); f = function('f')
sage: D[0](f)(x)
diff(f(x), x)
sage: D[0](f)(x, y)
diff(f(x, y), x)
sage: D[0, 1](f)(x, y)
diff(f(x, y), x, y)
sage: D[0, 1](f)(x, x^2)
D[0, 1](f)(x, x^2)
x, y = var('x,y'); f = function('f')
D[0](f)(x)
D[0](f)(x, y)
D[0, 1](f)(x, y)
D[0, 1](f)(x, x^2)
>>> from sage.all import *
>>> x, y = var('x,y'); f = function('f')
>>> D[Integer(0)](f)(x)
diff(f(x), x)
>>> D[Integer(0)](f)(x, y)
diff(f(x, y), x)
>>> D[Integer(0), Integer(1)](f)(x, y)
diff(f(x, y), x, y)
>>> D[Integer(0), Integer(1)](f)(x, x**Integer(2))
D[0, 1](f)(x, x^2)
class DerivativeOperatorWithParameters(parameter_set)[source]#

Bases: object

class sage.symbolic.operators.FDerivativeOperator(function, parameter_set)[source]#

Bases: object

Function derivative operators.

A function derivative operator represents a partial derivative of a function with respect to some variables.

The underlying data are the function, and the parameter set, a list recording the indices of the variables with respect to which the partial derivative is taken.

change_function(new)[source]#

Return a new function derivative operator with the same parameter set but for a new function.

EXAMPLES:

sage: from sage.symbolic.operators import FDerivativeOperator
sage: f = function('foo')
sage: b = function('bar')
sage: op = FDerivativeOperator(f, [0, 1])
sage: op.change_function(bar)
D[0, 1](bar)
from sage.symbolic.operators import FDerivativeOperator
f = function('foo')
b = function('bar')
op = FDerivativeOperator(f, [0, 1])
op.change_function(bar)
>>> from sage.all import *
>>> from sage.symbolic.operators import FDerivativeOperator
>>> f = function('foo')
>>> b = function('bar')
>>> op = FDerivativeOperator(f, [Integer(0), Integer(1)])
>>> op.change_function(bar)
D[0, 1](bar)
function()[source]#

Return the function associated to this function derivative operator.

EXAMPLES:

sage: from sage.symbolic.operators import FDerivativeOperator
sage: f = function('foo')
sage: op = FDerivativeOperator(f, [0, 1])
sage: op.function()
foo
from sage.symbolic.operators import FDerivativeOperator
f = function('foo')
op = FDerivativeOperator(f, [0, 1])
op.function()
>>> from sage.all import *
>>> from sage.symbolic.operators import FDerivativeOperator
>>> f = function('foo')
>>> op = FDerivativeOperator(f, [Integer(0), Integer(1)])
>>> op.function()
foo
parameter_set()[source]#

Return the parameter set of this function derivative operator.

This is the list of indices of variables with respect to which the derivative is taken.

EXAMPLES:

sage: from sage.symbolic.operators import FDerivativeOperator
sage: f = function('foo')
sage: op = FDerivativeOperator(f, [0, 1])
sage: op.parameter_set()
[0, 1]
from sage.symbolic.operators import FDerivativeOperator
f = function('foo')
op = FDerivativeOperator(f, [0, 1])
op.parameter_set()
>>> from sage.all import *
>>> from sage.symbolic.operators import FDerivativeOperator
>>> f = function('foo')
>>> op = FDerivativeOperator(f, [Integer(0), Integer(1)])
>>> op.parameter_set()
[0, 1]
sage.symbolic.operators.add_vararg(first, *rest)[source]#

Return the sum of all the arguments.

INPUT:

  • first, *rest – arguments to add

OUTPUT: sum of the arguments

EXAMPLES:

sage: from sage.symbolic.operators import add_vararg
sage: add_vararg(1, 2, 3, 4, 5, 6, 7)
28
sage: x = SR.var('x')
sage: s = 1 + x + x^2  # symbolic sum
sage: bool(s.operator()(*s.operands()) == s)
True
from sage.symbolic.operators import add_vararg
add_vararg(1, 2, 3, 4, 5, 6, 7)
x = SR.var('x')
s = 1 + x + x^2  # symbolic sum
bool(s.operator()(*s.operands()) == s)
>>> from sage.all import *
>>> from sage.symbolic.operators import add_vararg
>>> add_vararg(Integer(1), Integer(2), Integer(3), Integer(4), Integer(5), Integer(6), Integer(7))
28
>>> x = SR.var('x')
>>> s = Integer(1) + x + x**Integer(2)  # symbolic sum
>>> bool(s.operator()(*s.operands()) == s)
True
sage.symbolic.operators.mul_vararg(first, *rest)[source]#

Return the product of all the arguments.

INPUT:

  • first, *rest – arguments to multiply

OUTPUT: product of the arguments

EXAMPLES:

sage: from sage.symbolic.operators import mul_vararg
sage: mul_vararg(9, 8, 7, 6, 5, 4)
60480
sage: x = SR.var('x')
sage: p = x * cos(x) * sin(x)  # symbolic product
sage: bool(p.operator()(*p.operands()) == p)
True
from sage.symbolic.operators import mul_vararg
mul_vararg(9, 8, 7, 6, 5, 4)
x = SR.var('x')
p = x * cos(x) * sin(x)  # symbolic product
bool(p.operator()(*p.operands()) == p)
>>> from sage.all import *
>>> from sage.symbolic.operators import mul_vararg
>>> mul_vararg(Integer(9), Integer(8), Integer(7), Integer(6), Integer(5), Integer(4))
60480
>>> x = SR.var('x')
>>> p = x * cos(x) * sin(x)  # symbolic product
>>> bool(p.operator()(*p.operands()) == p)
True