Build a Calculus Interpreter I
Mathematica, 159 Bytes
ToString@Expand@ToExpression[StringReplace[#,&quot;(&quot;~~a__~~&quot;)'&quot;-&gt;&quot;d[&quot;~~ a ~~&quot;]&quot;]&lt;&gt;&quot;//.{d[a_ x^n-&gt;a n x^(n-1),d[x]-&gt;1,d[a__]/;a~FreeQ~x-&gt;0,d[a__+b__]-&gt;d[a]+d[b]}&quot;]&amp;

NOTE: While this works on all the examples it won't currently work on all sensible differentiable input because it doesn't balance brackets when looking for derivatives. I'll change this once I've had the time to think of a sufficiently concise way of doing it. I'm sure there's some other stuff that goes wrong too, so please let me know if you spot something! There are a few bytes that are easily golfed off too, I'll get to those..