Derivative by recursive

import re
while 1:
\x09o=""
\x09for t in re.findall(r"(-?\d*)x(\^(-?[.0-9]+))?",raw_input()):e=float(t[2]or 1);c=int(t[0]+(t[0]in"-")*"1")*e;E=e!=1;o+=("+%.1f "%c)[:-1-3*E*(abs(c)==1)]+E*("x"+(e!=2)*("^%.1f"%(e-1)))
\x09print o[1:].replace(".0","").replace("+-","-")or 0

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page