[sympy] f'(x) evaluated at x_0

2013-01-16 Thread David Ketcheson
Is there any way in sympy to express the derivative of an abstract function evaluated at a point? I can do import sympy x,x0 = sympy.var(('x','x0')) f=sympy.Function('f') (x) sympy.diff(f) to get the derivative w.r.t. x evaluated at x. If I do sympy.diff(f).subs(x,x0) then I get the derivati

Re: [sympy] f'(x) evaluated at x_0

2013-01-16 Thread Aaron Meurer
Try Subs(diff(f, x), x, x0). Note that mathematically, this should be the same as diff(f, x).subs(x, x0), because x is a bound (not free) variable in this expression, it doesn't matter if a different one is used, or if an expression is used that doesn't use it at all. Note that if you use a non-v

Re: [sympy] f'(x) evaluated at x_0

2013-01-19 Thread David Ketcheson
Thanks, Aaron. That works, though I had hoped for something prettier than: Subs(Derivative(f(_x), _x), (_x,), (x0,)) It would be really great if sympy knew how to print this kind of thing nicely (say, in an IPython notebook). -David On Wed, Jan 16, 2013 at 9:25 PM, Aaron Meurer wrote: > Try

Re: [sympy] f'(x) evaluated at x_0

2013-01-22 Thread Aaron Meurer
It does. What you have is the string form, which is designed to be readable, but also copy-pastable. Like almost all SymPy objects, there are pretty printers for Subs, including ASCII, Unicode, and LaTeX. For ASCII/Unicode, you get the bar notation: In [3]: pprint(Subs(diff(f(x), x), x, 0)) ⎛d

Re: [sympy] f'(x) evaluated at x_0

2013-01-23 Thread David Ketcheson
Actually, that's what I was already trying: import sympy %load_ext sympy.interactive.ipythonprinting x,x0 = sympy.var(('x','x0')) f=sympy.Function('f') (x) sympy.Subs(sympy.diff(f, x), x, x0) That just gives (in an IPython notebook): Subs(Derivative(f(x), x), (x,), (x0,)) which is strange beca

Re: [sympy] f'(x) evaluated at x_0

2013-01-23 Thread Aaron Meurer
I guess there is some bug with it. It works for me if you reload the extension after loading it, like import sympy %load_ext sympy.interactive.ipythonprinting %reload_ext sympy.interactive.ipythonprinting Maybe this is the same as http://code.google.com/p/sympy/issues/detail?id=3566. Aaron Meure