Ask Your Question

Revision history [back]

Hi,

In Sage, the syntax diff(g,x,m) where x and m are two symbolic variables, does not stand for the m-th derivative of g with respect to x, but for the second order partial derivative of g with one derivative taken with respect to x and the other one with respect to m, i.e. in LaTeX notation \frac{\partial^2 g}{\partial x \partial m}. This explains why example 1 returns 0 (m does not appear in g), while example 2 returns something nonzero ((x^2-1)^n is a function of both x and n).

If, instead of a symbolic variable, the third argument of diff is a non-negative integer m, then the outcome is the m-th derivative of g with respect to x: for instance

sage: g = x^2 + 3/2*(x^2 - 1)*x
sage: m = 3   # m is now an integer, not a symbolic variable
sage: diff(g, x, m)
9