Comment #14 on issue 3226 by smi...@gmail.com: high-order derivatives
should be cse-simplified
http://code.google.com/p/sympy/issues/detail?id=3226
Here is the corrected `di` function...but it is still slower.
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 = [(ri[0], ri[0](*ri[1].free_symbols)) for ri in r]
... rv = e.xreplace(dict(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).doit()
... return factor_terms(signsimp(rv))
...
di(eq,t).equals(eq.diff(t))
True
_t=time();ok1=di(sqrt((a+c*t)**2+(x+t)*(a+c*t)**2+a*(x+t)),t,10).doit();time()-_t;ok1.count_ops()
31.639999866485596
531
_t=time();ok=eq.diff(t,10);time()-_t
12.116999864578247
ok.count_ops()
530
test_numerically(ok,ok1)
True
--
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 sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.