I am trying to create a function that take a function as input that return a tuple with the function and its derivative. In all my attempt the derivative of the function is evaluated to zero or one even if it is a symbolic function: I simplified the code to return only its derivative:
t = var("t")
q = function("q")(t)
print("Expected",diff(q,t)) # return diff(q(t), t) as expected
Gamma(a) = diff(a)
print("Unexpected_v1 ",Gamma(q)) # return 1
Gamma(a) = diff(a,a.arguments()[0])
print("Unexpected_v2 ", Gamma(q)) # return 1
Gamma(a,b) = diff(a,b)
print("Unexpected_v3 ", Gamma(q,t)) # return 0
How can this be achieved?