I'm now practicing pattern matching by implementing a self-defined differentiation operator.
ClearAll[diff]
diff[fx_ + gx_, x_] := diff[fx, x] + diff[gx, x]
diff[c_*fx_, x_] /; FreeQ[c, x] := c*diff[fx, x]
diff[x_^n_., x_] /; FreeQ[n, x] := n*(x^(n - 1))
I test it with
diff[9^a, x]
diff[3, x]
But these two expressions do not further evaluate to the "correct" result. Where is the mistake?