Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3226 by [email protected]: high-order derivatives should be cse-simplified
http://code.google.com/p/sympy/issues/detail?id=3226

In http://groups.google.com/group/sympy/t/9e7c4a7faa3e65b1 there was a discussion about the long result obtained from sympy relative to a shorter result obtained from Maxima when taking the 5th derivative:

s = diff(sqrt((a+b*t)**2+(c+d*t)**2),t, 5)

All that is needed to obtain a much more compact result is to apply cse-simplification to the result. Perhaps csesimp should be added to simplify.py. Perhaps this should automatically be called for higher-order derivatives.

def csesimp(e):

...   r, e = cse(e)
...   return e[0].subs(reversed(r))
...
print filldedent(str(csesimp(s)))

15*(b*(a + b*t) + d*(c + d*t))*(3*(b**2 + d**2)**2 - 10*(b**2 +
d**2)*(b*(a + b*t) + d*(c + d*t))**2/((a + b*t)**2 + (c + d*t)**2) +
7*(b*(a + b*t) + d*(c + d*t))**4/((a + b*t)**2 + (c + d*t)**2)**2)/((a
+ b*t)**2 + (c + d*t)**2)**(5/2)


Here is a comparison of the op-count of the nth derivative of the expression that is differentiated above. The columns are n, nth-deriv of the expression, and csesimp(nth-deriv):

1 17 17
2 40 30
3 84 32
4 172 77
5 335 65
6 633 80
7 1170 86
8 2128 154
9 3822 113


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to