Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Based on the source code which delegates to this implementation among others, base.diff((x, n)) means to compute the n-th derivative of base with respect to x. Any arguments to diff which aren't tu...
Answer
#1: Initial revision
Based on the [source code](https://github.com/sympy/sympy/blob/4c9630723d6d76a356ff6e4cc65e994783c54bd1/sympy/polys/polytools.py#L2337) which delegates to [this implementation](https://github.com/sympy/sympy/blob/4c9630723d6d76a356ff6e4cc65e994783c54bd1/sympy/polys/polyclasses.py#L601) among others, `base.diff((x, n))` means to compute the `n`-th derivative of `base` with respect to `x`. Any arguments to `diff` which aren't tuples get tupled with 1, e.g. `base.diff(x)` is more or less equivalent to `base.diff((x, 1))`. Multiple arguments essentially correspond to repeated differentiation, e.g. `base.diff((x, m), (y, n))` is more or less the same as `base.diff((x, m).diff((y, n))`. Numeric arguments are indexes into the array of generators provided when the polynomial was created. That is, if `base` is defined by `Poly(..., x, y)`, then `base.diff((0, n))` and `base.diff((x, n))` are more or less the same. Similarly, `base.diff((1, n))` and `base.diff((y, n))`. This is handled by the method [_gen_to_level](https://github.com/sympy/sympy/blob/4c9630723d6d76a356ff6e4cc65e994783c54bd1/sympy/polys/polytools.py#L1810). That method also allows negative numbers to index backwards into the array of generators, i.e. `base.diff((-1, n))` is also equivalent to `base.diff((y, n))`. The example from the other answer of `base.diff(y, 2)` gets interpreted as `base.diff((y, 1), (2, 1))`, however, since there is only 2 generators (`x` and `y`), this should lead to an exception being thrown in `_gen_to_level` as 2 is not a valid index into the array of generators. That said, the example in the documentation is rather cryptic, and it is a bit bizarre to have `base.diff((0,0))` which would mean "take the 0-th derivative of the first generator" which is well-defined but corresponds to doing nothing.