Updates:
Cc: [email protected]
Comment #10 on issue 3226 by [email protected]: high-order derivatives
should be cse-simplified
http://code.google.com/p/sympy/issues/detail?id=3226
I could be missing something here, but the pre-processing appears to take
longer than just post-processing:
def di(eq, *syms):
# find common subexpressions
r, e = cse(eq)
e = e[0]
# last must be first
r = list(reversed(r))
# for Xi, f(xi), replace x0 -> x0(xi) and diff and simplify
s2f = dict([(ri[0], ri[0](*ri[1].free_symbols)) for ri in r])
rv = factor_terms(e.xreplace(s2f).diff(*syms))
# replace generic derivatives w/ true cse expression derivatives and
# replace generic functions w/ true cse functions
f = [b for _, b in s2f]
F = [B for _, B in r]
f2F = dict(list(zip(f, F)))
reps = df2dF = dict([(f.diff(*syms), F.diff(*syms)) \
for f, F in f2F.iteritems()])
reps.update(f2F)
rv = rv.xreplace(reps)
return rv
_t=time();ok=di(sqrt((a+c*t)**2+(d+b*t)**2),t,5);time()-_t
0.31799983978271484
_t=time();ok=factor_terms(signsimp(diff(sqrt((a+c*t)**2+(d+b*t)**2),t,5)));time()-_t
0.34999990463256836
_t=time();ok=di(sqrt((a+c*t)**2+(d+b*t)**2),t,8);time()-_t
2.5510001182556152
_t=time();ok=factor_terms(signsimp(diff(sqrt((a+c*t)**2+(d+b*t)**2),t,8)));time()-_t
1.505000114440918
_t=time();ok=di(sqrt((a+c*t)**2+(d+b*t)**2),a,b,c,d,t);time()-_t
0.5239999294281006
_t=time();ok=factor_terms(signsimp(diff(sqrt((a+c*t)**2+(d+b*t)**2),a,b,c,d,t)));time()-_t
0.40599989891052246
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.