ceev
ceev

Reputation: 1

Controlling the 'levels' of differentiation in SageMath 9.1

Sage seems to want to evaluate derivatives as far as possible using the chain rule. A simple example is:

var('theta')
f = function('f')(theta)
g = function('g')(theta)

h = f*g
diff(h,theta)

which would display

g(theta)*diff(f(theta), theta) + f(theta)*diff(g(theta), theta)

My question is, is there a way to control just how far Sage will take derivatives? In the example above for instance, how would I get Sage to display instead:

diff(f(theta)*g(theta))

I'm working through some pretty intensive derivations in fluid mechanics, and being able to not evaluate derivatives all the way like discussed above would really help with this. Thanks in advance. Would appreciate any help on this.

Upvotes: 0

Views: 100

Answers (1)

Samuel Lelièvre
Samuel Lelièvre

Reputation: 3453

This would be called "holding" the derivative.

Adding this possibility to Sage has already been considered.

Progress on this is tracked at:

and the ticket even links to a branch with code implementing this.

Although progress on this is stalled, and the branch has not been merged, you could use the code from the branch.

Upvotes: 0

Related Questions