@@ -194,3 +194,65 @@ def parameter_set(self):
194194 [0, 1]
195195 """
196196 return self ._parameter_set
197+
198+ class DerivativeOperator ():
199+ """
200+ Derivative operator.
201+
202+ Acting with this operator onto a function gives a new operator (of
203+ type :class:`FDerivativeOperator`) representing the function
204+ differentiated with respect to one or multiple of its arguments.
205+
206+ This operator takes a list of indices specifying the position of
207+ the arguments to differentiate. For example, D[0, 0, 1] is an
208+ operator that differentiates a function twice with respect to its
209+ first argument and once with respect to its second argument.
210+
211+ EXAMPLES::
212+
213+ sage: x, y = var('x,y'); f = function('f')
214+ sage: D[0](f)(x)
215+ diff(f(x), x)
216+ sage: D[0](f)(x, y)
217+ diff(f(x, y), x)
218+ sage: D[0, 1](f)(x, y)
219+ diff(f(x, y), x, y)
220+ sage: D[0, 1](f)(x, x^2)
221+ D[0, 1](f)(x, x^2)
222+
223+ """
224+ class DerivativeOperatorWithParameters ():
225+ def __init__ (self , parameter_set ):
226+ self ._parameter_set = parameter_set
227+ def __call__ (self , function ):
228+ return FDerivativeOperator (function , self ._parameter_set )
229+ def __repr__ (self ):
230+ """
231+ Return the string representation of this derivative operator.
232+
233+ EXAMPLES::
234+
235+ sage: D[0]
236+ D[0]
237+ sage: D[0, 1]
238+ D[0, 1]
239+ """
240+ return "D[%s]" % (", " .join (map (repr , self ._parameter_set )))
241+
242+ def __getitem__ (self , args ):
243+ """
244+ TESTS::
245+
246+ The order in which the indices are given should not matter
247+
248+ sage: x, y = var('x,y'); f = function('f')
249+ sage: bool(D[0, 1, 0](f)(x, y) == D[0, 0, 1](f)(x, y))
250+ True
251+ sage: bool(D[1, 0, 0](f)(x, y) == D[0, 0, 1](f)(x, y))
252+ True
253+ """
254+ if not isinstance (args , tuple ):
255+ args = (args ,)
256+ return self .DerivativeOperatorWithParameters (args )
257+
258+ D = DerivativeOperator ()
0 commit comments