f(x) = If[x < 5, cos(x), sin(x)]
f' = Derivative(f)
P = Point(f)
g = Tangent(P, f)