Derivative With Respect to Function

asked 3 years ago

Ross gravatar image

Hi, I have the following problem. Say I have some variable x which depends on t. Now let's say I have some function of x, say f(x)=x2. Running

t = var('t')
x = function('x', nargs=1)(t)
f = x^2
diff(f, t)

gives me what I would expect, i.e. 2x(t)tx(t). However, if I run

diff(f, x)

I get the error message "TypeError: argument symb must be a symbol". Is there a way for me to differentiate f with respect to x such that it just gives 2x(t) as the output?

I hope this question isn't too basic; I'm pretty new to SageMath, but I have spent a decent amount of time trying to solve this issue and have found nothing useful.

Preview: (hide)