ans = 
However, you need to be careful about assumptions. All levels of MATLAB code share the same assumptions, and using syms on a variable resets assumptions.
syms x positive
assumptions
f = sin(x)+x^2
testit(f, x)
assumptions
function testit(f, var)
assumptions
syms x
assumptions
diff(f, x)
diff(f, var)
end

