This is primarily an issue of printing. The str() printer prints
things in a way that can be copy-pasted back into SymPy, and since
f'(0) isn't valid syntax, you end up with the more verbose
representation that is used for the expression.

It would be useful to have printers, at least pretty printers, that
printed f'(0) instead of the subs version. If a D object like Oscar
described existed, then the str printer could print that, since it
would be valid SymPy syntax.

It shouldn't be hard to make a printer that defines _print_Subs to
print things nicer for your use-case. I think some printers may
already exist that do this (perhaps in the mechanics module), though I
could be misremembering that.

Aaron Meurer

On Tue, Jun 4, 2019 at 1:08 PM Oscar Benjamin
<[email protected]> wrote:
>
> Yeah, it would be nice to be able to do that. Unfortunately SymPy has
> no notion of the derivative of an unapplied function. I'd like to have
> a differential operator so you could do something like `D(sin) == cos`
> etc. I believe there are some long-standing issues on Github about
> this.
>
> --
> Oscar
>
> On Tue, 4 Jun 2019 at 18:44, David Bailey <[email protected]> wrote:
> >
> > The ability to expand an expression containing unknown functions, about 
> > some point, is obviously very valuable, and it is nice that this is 
> > possible using SymPy, however if I expand f(x) about 0 I get this:
> >
> > f(0) + x*Subs(Derivative(f(_x), _x), _x, 0) + x**2*Subs(Derivative(f(_x), 
> > (_x, 2)), _x, 0)/2 + O(x**3)
> >
> > Is there any way to reduce that to something neater and more like textbook 
> > maths such as
> >
> > f(0)+x*f`(0)+x**2*f```(0)/2 + O(x**3)
> >
> > I chose f` rather than f' because as far as I know, the '`' character is 
> > not used in Python.
> >
> > Outputting the expression as Latex cleans it up a bit, but it is still not 
> > as neat as the usual notation for the derivative of a function notation.
> >
> > David
> >
> > --
> > 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/5bca2aa1-8b2b-4a3f-af18-6f9a42dc87cd%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/CAHVvXxQ-7iEgovJtmqaNm_5rudpwc2vdMObYkRqV71u5PhjFSg%40mail.gmail.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%3D6KX%2BwUPbOu4%2BqLfD6pd71zQ%2BwKPoy_TfbxaecCDp4BSRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to