Say I have an expression
g=Sin[q];
It is easy to turn it into a function, and to perform manipulations on this function (this and variants of this were discussed many times on this site):
f[q_] = g;
fprime = Derivative[1][f];
fprime[3]
(*Output: Cos[3]*)
However, if I want to pass g as an argument to a function that will do that, this no longer works:
calculateDerivativeAt3[func_] := Block[{f, fprime},
f[q_] = func;
fprime = Derivative[1][f];
fprime[3]
]
calculateDerivativeAt3[Sin[q]]
(*Output: 0 *)
How can I make this work in a similar way? The ultimate goal is to pass an expression into a function, and in the function to perform various functional manipulations, including derivatives, integrations, and more.
I'm pretty sure this question has an answer somewhere in this site, but I couldn't find it.


calcDerAtq[func_, q_] := Derivative[1][func][q]and use it ascalcDerAtq[Sin[#] Log[#^2/2] &, 10]? – b.gates.you.know.what Aug 04 '15 at 13:43f[x_] = g(withxinstead of aq). – Michael E2 Aug 04 '15 at 13:49