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 Meurer

On Wed, Jan 23, 2013 at 1:22 AM, David Ketcheson <[email protected]> wrote:
> 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 because the ASCII and latex versions work as you say.  Am I
> doing something wrong?
>
>
> -David
>
>
> On Wed, Jan 23, 2013 at 7:50 AM, Aaron Meurer <[email protected]> wrote:
>>
>> 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       ⎞│
>> ⎜──(f(x))⎟│
>> ⎝dx      ⎠│x=0
>>
>> In LaTeX, you get
>>
>> In [1]: latex(Subs(f(x), x, 0))
>> Out[1]: \left. \operatorname{f}{\left (x \right )} \right|_{\substack{ x=0
>> }}
>>
>> which is the same thing.  If you want this in the IPython notebook,
>> just use the SymPy printing extension, which will make everything
>> print with LaTeX using MathJax.  Just run
>>
>> %load_ext sympy.interactive.ipythonprinting
>>
>> at the top of the notebook (init_printing(use_latex=True) should work
>> too).
>>
>> Aaron Meurer
>>
>> On Sat, Jan 19, 2013 at 10:00 AM, David Ketcheson <[email protected]>
>> wrote:
>> > 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 <[email protected]>
>> > wrote:
>> >>
>> >> 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-variable instead of x0, it will automatically give you the Subs
>> >> form (in particular, if you use a number, like diff(f, x).subs(x,
>> >> 10)).  It will also give you the Subs form if you later substitute x0
>> >> for a number (in terms of x0, but it doesn't matter because x0 serves
>> >> as a dummy variable in this case).
>> >>
>> >> Aaron Meurer
>> >>
>> >> On Wed, Jan 16, 2013 at 5:06 AM, David Ketcheson <[email protected]>
>> >> wrote:
>> >> > 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 derivative w.r.t. x0 evaluated at x0.  Can I get the
>> >> > derivative w.r.t. x evaluated at x0?
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "sympy" group.
>> >> > To view this discussion on the web visit
>> >> > https://groups.google.com/d/msg/sympy/-/cQScvWEPp9MJ.
>> >> > To post to this group, send email to [email protected].
>> >> > To unsubscribe from this group, send email to
>> >> > [email protected].
>> >> > For more options, visit this group at
>> >> > http://groups.google.com/group/sympy?hl=en.
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "sympy" group.
>> >> To post to this group, send email to [email protected].
>> >> To unsubscribe from this group, send email to
>> >> [email protected].
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/sympy?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "sympy" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> > http://groups.google.com/group/sympy?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/sympy?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sympy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to