Detecting highest order derivative of a function in an equation

asked 2016-07-26 15:41:17 -0500

jupsal gravatar image

updated 2016-07-26 15:45:14 -0500

I am working with some code that generates an equation with a number of derivatives. I do not know the order of the derivatives or the order. If I was working with something algebraic, for example:

a, b, c = var('a,b,c')
eqn = a**2 + 3*b + c

I could use something like

coeffs = eqn.coefficients(a)
highest_order = coeffs[-1][1]

to find out the highest order of a. It would also be okay if i could figure out the order of every derivative of a given function in an equation. I can do this if I know before-hand what the order of the derivative is

eqn += f(a,b,c).diff(a,b)

and see that in fact that derivative is there somewhere. But what I really want, is for

eqn = f(a,b,c).diff(a,b) + b*f(a,b,c).diff(b,3) + c

to have something that (a) tells me 'eqn has [D[0,1](f)(a,b,c), D[1,1,1](f)(a,b,c)]' or, (b) 'the highest order derivative of eqn is D[1,1,1](f)(a,b,c)'.

edit retag flag offensive close merge delete


eqn.operands() comes close to (a). But, it will still take some work to get what you want.

calc314 gravatar imagecalc314 ( 2016-07-27 08:36:22 -0500 )edit