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
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
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
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
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
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