On Friday, August 19, 2016 at 9:45:12 AM UTC-7, Bill Page wrote: > > On the contrary after reading the code for ExpressionNice carefully it > is clear that it does not do post-processing as such
class ExpressionNice(Expression): .... def _repr_(self): .... d = self._parent._repr_element_(self) .... d = d.replace(o, res) .... return d It's manipulating strings. Unless this code is only used on very simple expressions, people will start to find it's making false string replacements at some point. Anyway, we've found the proper way of doing this (thanks for digging that up out of Pynac!) and I'm sure that even if ExpressionNice is still felt to be needed, the authors will prefer to generate their representations in the same way. > My main question is whether we should try to replicate what is done by > ExpressionNice and thereby render it obsolete or should we try to > reach some other compromise? > Well, as is pointed out in the ExpressionNice documentation already, it produces some representations that just don't express the meaning of the underlying expression, so we definitely don't want to replicate that. Personally, I'm comfortable with the basic representation choices made in https://trac.sagemath.org/ticket/21286 . I'd be hesitant to go any further. Using leibnitz notation in general requires temporary variables, e.g. D[0,1](f)(x+y,x-y) = diff(f(t1,t2),t1,t2) |_[t1=x+y,t2=x-y] I don't think the RHS is more readable than the LHS after the small hurdle of understanding what D[0,1] means. This leaves general printing style. The latex side of things here is simple. D[0,1](f)(x,y) should just be typeset as \frac{\partial^2}{\partial x\partial y} f(x,y) (we can do \partial x\partial x -> (\partial x)^2 or more ambiguously \partial x^2 ) If the function is univariate we could replace \partial with "d". I'd be a little hesitant to use this notation in "repr" because the use of "d" as a variable is not so far fetched and would lead to a horrible representation repr( diff(f(d1,d2),d1,d2) ) = "(d^2/dd1 dd2)f(d1,d2)" and in general it leads to an uncomfortable number of parentheses in unfortunate places. So I'd probably gravitate towards producing "parsable" representations, i.e., just diff(f(d1,d2),d1,d2) perhaps not elegant, but certainly understandable and unsurprising, since it's what the user probably typed in. [we could check the symbol names for the presence of "d"s, but that would probably lead to code that's trying to be too smart for its own good. It would still leave us with an uncomfortable number of parentheses, since the operator (written as a fraction) would need parentheses to be delimited properly] First and second derivatives of univariate functions could easily be printed as f'(x) and f''(x) [or perhaps f"(x) ]. It does make it more tricky to cut/paste these into programming environments, though, because the quotes might need quoting. I think this covers the most important cases. Comments welcome on what styles peope would prefer. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.