Can you open an issue for this in the issue tracker? https://github.com/sympy/sympy/issues
Aaron Meurer On Wed, Feb 15, 2017 at 6:43 PM, Federico Halpern <[email protected]> wrote: > Hi everyone, > > I just started using sympy. I expect that I will use the finite differencing > routines to automatically generate arbitrary precision operators (for > example, the Arakawa bracket). This is for use in a plasma turbulence / > stability code. > > My thanks go to the developers for creating this package, it will save me > tons of effort and blood in developing my code. > > I wanted to raise an issue that I noticed in an example from the > documentation: > >>>> x = symbols('x') >>>> f, g = symbols('f g', cls=Function) >>>> differentiate_finite(f(x)*g(x)) > (-f(x - 1/2) + f(x + 1/2))⋅g(x) + (-g(x - 1/2) + g(x + 1/2))⋅f(x) > > Although it could be useful in some situations, this expression is not valid > for finite differences. The reason for this is that the continuous version > of the product rule > > d/dx(f(x)g(x)) = g(x)d/dx(f(x) + f(x)d/dx(g(x) > > does not apply in discrete systems. So one cannot just expand the expression > and then use the product rule. A large part of the applied mathematics > literature is devoted to designing numerical schemes that preserve a > "discrete product rule." Examples of this are summation-by-parts and mimetic > finite differences. > > A more reasonable behavior was also given in the documentation: > >>>> differentiate_finite(f(x)*g(x), evaluate=False) > -f(x - 1/2)⋅g(x - 1/2) + f(x + 1/2)⋅g(x + 1/2) > > In the last version, we get a finite difference of the product f(x)g(x), > which is correct. This should be the default behavior. > > Thanks again everyone, I look forward to creating some crazy numerical > schemes using this symbolic toolbox. Best, > > Federico > > -- > You received this message because you are subscribed to the Google Groups > "sympy" 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 https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/6646a62e-1895-4c15-b2b7-bc634fca6ea5%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" 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 https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6JZGgS-j6hz40eYiGMJOCg4_dPQ%3DX%2BUPUeE2MP1fzj1LA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
