Derivative With Respect to Function

asked 2022-04-12 18:20:58 +0200

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) = x^2$. Running

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

gives me what I would expect, i.e. $2 x\left(t\right) \frac{\partial}{\partial t}x\left(t\right)$. 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.

edit retag flag offensive close merge delete