Help me with differential calculus!
Perl - 121 122

(+2 for -p)

s/(?&lt;![-\d.*^])-?[\d.]+(?![*^\d.])/0/g;s/(?&lt;!\^)x(?!\^)/1/g;s/x\^(-?[\d.]+)/"$1*x^".($1-1)/ge;s/([\d.]+)\^x/ln($1)*$&amp;/g


Test:

$ perl -p diff.pl &lt;&lt; EOF
&gt; -3
&gt; 8.5
&gt; x^0.5
&gt; x^-7
&gt; 0.5^x
&gt; 7^x
&gt; 3*x^5
&gt; -0.1*0.3^x
&gt; -5*x^2+10-3^x
&gt; EOF
0
0
0.5*x^-0.5
-7*x^-8
ln(0.5)*0.5^x
ln(7)*7^x
3*5*x^4
-0.1*ln(0.3)*0.3^x
-5*2*x^1+0-ln(3)*3^x