typesetting partial derivatives

242 views
Skip to first unread message

Burcin Erocal

unread,
Jun 14, 2009, 3:38:05 PM6/14/09
to sage-...@googlegroups.com
Hi again,

There were long discussion about the typesetting of partial derivatives
in the new system, but I don't think we got to a conclusion yet. The
previous thread is here:

http://groups.google.com/group/sage-devel/browse_thread/thread/7479c3eeb96348a2


I agree that this is annoying and trivial to typeset better:

sage: version()
'Sage Version 4.0.1, Release Date: 2009-06-06'
sage: f = function('f')
sage: f(x).derivative(x,5)
D[0, 0, 0, 0, 0](f)(x)


However, how to typeset these is not so clear:

sage: f(x+2*y).derivative(x,2)
D[0, 0](f)(x + 2*y)
sage: f(x+2*y).derivative(y,2)
4*D[0, 0](f)(x + 2*y)

In these examples, keep in mind that we did not define what the first
argument of the function is called, so we can't just replace D[0, 0]
with d/dx.

The power of this notation is seen mainly with more than one argument:

sage: f(x+y, x-y).derivative(y)
D[0](f)(x + y, x - y) - D[1](f)(x + y, x - y)


Here is what MMA does:

In[1]:= D[F[x], x]

Out[1]= F'[x]

In[2]:= TeXForm[%]

Out[2]//TeXForm= F'(x)

In[3]:= D[F[x], x, x, x, x, x]

(5)
Out[3]= F [x]

In[4]:= TeXForm[%]

Out[4]//TeXForm= F^{(5)}(x)

In[5]:= D[F[x+2*y], x, x]

Out[5]= F''[x + 2 y]

In[6]:= TeXForm[%]

Out[6]//TeXForm= F''(x+2 y)

In[7]:= D[F[x+2*y], y, y]

Out[7]= 4 F''[x + 2 y]

In[8]:= TeXForm[%]

Out[8]//TeXForm= 4 F''(x+2 y)

In[9]:= D[F[x+y, x-y], y]

(0,1) (1,0)
Out[9]= -F [x + y, x - y] + F [x + y, x - y]

In[10]:= TeXForm[%]

Out[10]//TeXForm= F^{(1,0)}(x+y,x-y)-F^{(0,1)}(x+y,x-y)


And Maple:

> diff(f(x),x);
d
-- f(x)
dx

> diff(f(x),x$5);
5
d
--- f(x)
5
dx

> diff(f(x+2*y), y$2);
(2)
4 (D )(f)(x + 2 y)

> convert(%, diff);
/ 2 \|
| d ||
4 |---- f(t1)||
| 2 ||
\dt1 /|t1 = x + 2 y

> diff(f(x+y, x-y), y);
D[1](f)(x + y, x - y) - D[2](f)(x + y, x - y)

> convert(%, diff);
D[1](f)(x + y, x - y) - D[2](f)(x + y, x - y)

I like the way MMA handles this. It's compact and consistent. So I
suggest we change things to use the MMA convention.


Comments?


Cheers,
Burcin

John Cremona

unread,
Jun 14, 2009, 3:45:11 PM6/14/09
to sage-...@googlegroups.com
2009/6/14 Burcin Erocal <bur...@erocal.org>:
The MMA convention seems to include as a special case a prime (') for
derivatives of functions of one variable Is that right? Seems good
to me.

John

>
>
> Comments?
>
>
> Cheers,
> Burcin
>
> >
>

Tim Lahey

unread,
Jun 14, 2009, 4:01:30 PM6/14/09
to sage-...@googlegroups.com

My preference is the Maple diff way because that reduces to traditional
partial derivatives when you have f(x,y).

Cheers,

Tim.

---
Tim Lahey
PhD Candidate, Systems Design Engineering
University of Waterloo
http://www.linkedin.com/in/timlahey

Burcin Erocal

unread,
Jun 14, 2009, 4:08:59 PM6/14/09
to sage-...@googlegroups.com
On Sun, 14 Jun 2009 20:45:11 +0100
John Cremona <john.c...@gmail.com> wrote:

>
> 2009/6/14 Burcin Erocal <bur...@erocal.org>:
<snip>


> >
> > Here is what MMA does:
> >
> > In[1]:= D[F[x], x]
> >
> > Out[1]= F'[x]
> >
> > In[2]:= TeXForm[%]
> >
> > Out[2]//TeXForm= F'(x)
> >
> > In[3]:= D[F[x], x, x, x, x, x]
> >
> >         (5)
> > Out[3]= F   [x]
> >
> > In[4]:= TeXForm[%]
> >
> > Out[4]//TeXForm= F^{(5)}(x)

<snip>
> >
> > And Maple:
<snip>


> >
> > I like the way MMA handles this. It's compact and consistent. So I
> > suggest we change things to use the MMA convention.
>
> The MMA convention seems to include as a special case a prime (') for
> derivatives of functions of one variable Is that right? Seems good
> to me.

MMA has ' and '' as a special case:

In[1]:= D[F[x],x]

Out[1]= F'[x]

In[2]:= D[%, x]

Out[2]= F''[x]

In[3]:= D[%, x]

(3)


Out[3]= F [x]


Thanks.

Burcin

William Stein

unread,
Jun 14, 2009, 4:19:57 PM6/14/09
to sage-...@googlegroups.com

Personally, I prefer the Mathematica notation because I can actually
read it. I have (serious!) trouble reading the current notation that
Sage uses and I can barely read the Maple notation either. With the
Mathematica notation it is totally completely obvious to me what is
going on.

-- William

Golam Mortuza Hossain

unread,
Jun 14, 2009, 5:03:59 PM6/14/09
to sage-...@googlegroups.com
Hi

On Sun, Jun 14, 2009 at 4:38 PM, Burcin Erocal<bur...@erocal.org> wrote:
> There were long discussion about the typesetting of partial derivatives
> in the new system, but I don't think we got to a conclusion yet.

I am afraid, we might never reach a conclusion in this regard :-)
It seems to be a classic case where we are trying to fit one size
for all.

Given the previous arguments for/against any specific scheme
for derivative typesetting and my own experience while experimenting
with sage typesetting code, I am now more inclined to follow
the strategy as outlined below.

(1) Let there be options such that one can use either typesetting
scheme by choice in run-time.

(2) By default, we follow a rather hybrid approach:

(a) If we all agree that there is no ambiguity when the particular
argument is a "symbolic variable" or "symbolic function" then
we should typeset them as those found in text-books.

Ex:
(1) D[0,0,0] (f)(x,y) => \frac{\partial^3}{\partial x^3} f(x,y)
(2) D[0] (f)(g(x,y), h(z)) => \frac{\partial}{\partial
g(x,y)} f(g(x,y), h(y))

(b) I guess, the main objective for this thread is now to decided
what should be the default scheme when the argument itself is an
"expression"

Ex: (from Burcin's mail)
(1) D[0](f)(x + y, x - y) => ? [ (i) MMA-like (ii)
Maple-like (iii) Others ]

My vote: (ii) Maple-like


Thats my two cents.

Cheers,
Golam

Nick Alexander

unread,
Jun 14, 2009, 5:04:29 PM6/14/09
to sage-...@googlegroups.com
> Personally, I prefer the Mathematica notation because I can actually
> read it. I have (serious!) trouble reading the current notation that
> Sage uses and I can barely read the Maple notation either. With the
> Mathematica notation it is totally completely obvious to me what is
> going on.

+1

Nick

John H Palmieri

unread,
Jun 14, 2009, 6:31:32 PM6/14/09
to sage-devel
On Jun 14, 12:38 pm, Burcin Erocal <bur...@erocal.org> wrote:
> Hi again,
>
> There were long discussion about the typesetting of partial derivatives
> in the new system, but I don't think we got to a conclusion yet. The
> previous thread is here:
>
> http://groups.google.com/group/sage-devel/browse_thread/thread/7479c3...
I don't like the D[1] notation at all. By the way, when we have a
function f of two variables, should we automatically assume that the
mixed partials are equal? Does this affect our choice of notation?
(Another notation I've seen: f_n is the derivative with respect to the
nth variable, so f_12 is (f_1)_2: if the variables are x and y, take
partial with respect to x, then y; in contrast, the other mixed
partial is f_21.)

John

William Stein

unread,
Jun 15, 2009, 6:30:56 AM6/15/09
to sage-...@googlegroups.com
On Sun, Jun 14, 2009 at 11:03 PM, Golam Mortuza
Hossain<gmho...@gmail.com> wrote:
>
> Hi
>
> On Sun, Jun 14, 2009 at 4:38 PM, Burcin Erocal<bur...@erocal.org> wrote:
>> There were long discussion about the typesetting of partial derivatives
>> in the new system, but I don't think we got to a conclusion yet.
>
> I am afraid, we might never reach a conclusion in this regard :-)

Yes we will. It doesn't have to be unanimous, but we will reach a conclusion.

-- William

William Stein

unread,
Jun 16, 2009, 12:34:19 PM6/16/09
to sage-...@googlegroups.com

The vote was:

Maple style D[...] notation: 2 votes
Mathematica style exponent notation: 4 votes

So the conclusion is that we will go with the Mathematica style notation.

William

kcrisman

unread,
Jun 16, 2009, 1:20:40 PM6/16/09
to sage-devel
> So the conclusion is that we will go with the Mathematica style notation.

Does that also apply to Golam's earlier comment

(a) If we all agree that there is no ambiguity when the particular
argument is a "symbolic variable" or "symbolic function" then
we should typeset them as those found in text-books.
Ex:
(1) D[0,0,0] (f)(x,y) => \frac{\partial^3}{\partial x^3} f
(x,y)
(2) D[0] (f)(g(x,y), h(z)) => \frac{\partial}{\partial
g(x,y)} f(g(x,y), h(y))

so that we will no longer see nicely typeset partial derivatives even
in case (a)(1) (or even Leibniz notation at all?), or is it only in
the case (b) "when the argument is an expression"? Thanks for the
clarification.

- kcrisman

William Stein

unread,
Jun 16, 2009, 2:08:49 PM6/16/09
to sage-...@googlegroups.com

I don't know. It didn't seem to me that people voted on that more refined point.

-- William

Golam Mortuza Hossain

unread,
Jun 16, 2009, 6:42:46 PM6/16/09
to sage-...@googlegroups.com
Hi,

As Burcin pointed out that even MMA uses different Tex-ing scheme
for some situations such as F'[x] for D[F[x],x]. So strictly speaking even
MMA uses hybrid approach.

I guess, we should aim for doing better than MMA/Maple.


Cheers,
Golam

Robert Bradshaw

unread,
Jun 17, 2009, 2:23:00 AM6/17/09
to sage-...@googlegroups.com
On Jun 14, 2009, at 1:19 PM, William Stein wrote:

> Personally, I prefer the Mathematica notation because I can actually
> read it. I have (serious!) trouble reading the current notation that
> Sage uses and I can barely read the Maple notation either. With the
> Mathematica notation it is totally completely obvious to me what is
> going on.

If it wasn't obvious from my previous comments in former threads, I
am of this opinion as well. I would actually be for disallowing the
bare function('f') from the global namespace altogether and forcing
the user to provide named, ordered dummy variables (what does it
actually mean?)

- Robert

William Stein

unread,
Jun 17, 2009, 3:20:31 AM6/17/09
to sage-...@googlegroups.com

I'm not opposed to that suggestion. I have no idea what
"function('f')" even means.

William

Burcin Erocal

unread,
Jun 17, 2009, 8:01:59 AM6/17/09
to sage-...@googlegroups.com

I don't think forcing the user to provide dummy variables when creating
the function is a good approach. I don't see where the variables
would be needed, other than printing differentials. If we go with the
MMA notation we won't need them even then.

It makes sense to provide a function that takes the variables as
arguments, and pretty prints differentials with the df/dx notation
though. We already have the code to do this, afair first written by
Jason, and now Golam.


Cheers,

Burcin

Burcin Erocal

unread,
Jun 23, 2009, 8:00:41 PM6/23/09
to sage-...@googlegroups.com
On Tue, 16 Jun 2009 19:42:46 -0300

Golam Mortuza Hossain <gmho...@gmail.com> wrote:

I don't think what MMA does can really be called a hybrid approach. It
just represents first and second derivatives of single argument
functions with F' and F'', instead of F^{(1)} and F^{(2)} respectively.

John Palmieri wrote in a different thread:


> I don't like the D[1] notation at all. By the way, when we have a
> function f of two variables, should we automatically assume that the
> mixed partials are equal? Does this affect our choice of notation?

I guess we assume that they commute:

sage: var('x,y,z')
(x, y, z)
sage: t = f(x,y)
sage: diff(t,x,y)
D[0, 1](f)(x, y)
sage: diff(t,y)
D[1](f)(x, y)
sage: diff(t,y,x)
D[0, 1](f)(x, y)


> I guess, we should aim for doing better than MMA/Maple.

What would the hybrid approach be in this case? Use Maple convention,
but use MMA style F^{(4, 0} instead of D[1,1,1,1]F[x+y,y] or F^{(3,1)}
instead of D[1,1,1,2]F[x+y,y]?


I would like to settle this vote and get rid of the D[...] notation as
soon as possible, but William's count of 4 votes for MMA notation to 2
votes for Maple notation doesn't look decisive. At least I can't
believe there were so few responses. :)

Can people who care about this please comment and vote?

If there are no objections to the above definition of "hybrid approach",
the options for default printing are:

1) Mathematica style
2) Maple style
3) hybrid

For all cases, we would need to provide a function that takes the names
of the arguments of the given symbolic function as a parameter and
typesets the expression in "textbook style"


I still vote for 1, MMA style. To state the reasons again, it's
consistent, and concise.


Cheers,
Burcin

Golam Mortuza Hossain

unread,
Jun 24, 2009, 10:58:19 AM6/24/09
to sage-...@googlegroups.com
Hi

On Tue, Jun 23, 2009 at 9:00 PM, Burcin Erocal<bur...@erocal.org> wrote:
> If there are no objections to the above definition of "hybrid approach",
> the options for default printing are:
>
> 1) Mathematica style
> 2) Maple style
> 3) hybrid
>

> I still vote for 1, MMA style. To state the reasons again, it's
> consistent, and concise.

Burcin, I am giving you my vote also, for implementing MMA
style typesetting as the default one for partial derivatives. Please
have those {'} and {''} and may be even {'''} notations.

So I would urge you to go ahead with the implementation.

It wouldn't be difficult to add other choices later as options
to users (some of the codes are already there).

Cheers,
Golam

Jason Grout

unread,
Jun 24, 2009, 11:10:15 AM6/24/09
to sage-...@googlegroups.com


+1 for the MMA style.

Jason

Nick Alexander

unread,
Jun 24, 2009, 12:19:35 PM6/24/09
to sage-...@googlegroups.com
> +1 for the MMA style.


I am +1 for mathematica style, but can someone explain why

In[5]:= D[F[x+2*y], x, x]

Out[5]= F''[x + 2 y]

Why is x somehow considered special and y not?

Nick

John Cremona

unread,
Jun 24, 2009, 12:42:04 PM6/24/09
to sage-...@googlegroups.com
2009/6/24 Nick Alexander <ncale...@gmail.com>:
F is a function of one variable. F'' is its second derivative. It's
nothing to do with x and y being special.

John

>
> Nick
>
> >
>

Nick Alexander

unread,
Jun 24, 2009, 1:43:26 PM6/24/09
to sage-...@googlegroups.com

I missed that.

Thanks,
Nick

Burcin Erocal

unread,
Jun 24, 2009, 5:54:18 PM6/24/09
to sage-...@googlegroups.com
Hi Golam,

On Wed, 24 Jun 2009 11:58:19 -0300


Golam Mortuza Hossain <gmho...@gmail.com> wrote:

> On Tue, Jun 23, 2009 at 9:00 PM, Burcin Erocal<bur...@erocal.org>
> wrote:
> > If there are no objections to the above definition of "hybrid
> > approach", the options for default printing are:
> >
> > 1) Mathematica style
> > 2) Maple style
> > 3) hybrid
> >
> > I still vote for 1, MMA style. To state the reasons again, it's
> > consistent, and concise.
>
> Burcin, I am giving you my vote also, for implementing MMA
> style typesetting as the default one for partial derivatives. Please
> have those {'} and {''} and may be even {'''} notations.
>
> So I would urge you to go ahead with the implementation.

:) I was hoping you'd implement it, since you did it in #5711 once.

I attached a patch to the trac ticket that contains an initial attempt
at the MMA notation:

http://trac.sagemath.org/sage_trac/ticket/6344


It doesn't work well for text mode:

sage: f = function('f')

sage: f(x).derivative(x,3)
f^{(3)}(x)


Comments, suggestions and patches are welcome.


Thanks.

Burcin

Golam Mortuza Hossain

unread,
Jun 25, 2009, 10:43:44 AM6/25/09
to sage-...@googlegroups.com
Hi Burcin,

On Wed, Jun 24, 2009 at 6:54 PM, Burcin Erocal<bur...@erocal.org> wrote:

> I attached a patch to the trac ticket that contains an initial attempt
> at the MMA notation:
>
> http://trac.sagemath.org/sage_trac/ticket/6344
>
>
> It doesn't work well for text mode:
>
> sage: f = function('f')
> sage: f(x).derivative(x,3)
> f^{(3)}(x)

My suggestion would be to split out "text-mode" (repr) output
for another ticket. Current text-mode output expression from Sage
in this case is not a valid input expression of Sage. For example,
if I do copy-n-paste output like "D[0](f)(x)" to another cell then
Sage doesn't recognize it.

I guess, implementing latex output would be easier one. I did
a quick-hack MMA style. It worked fine and with primes
it appears to be in "textbook style".

Cheers,
Golam

Jason Grout

unread,
Jul 18, 2009, 7:49:41 PM7/18/09
to sage-...@googlegroups.com
Burcin Erocal wrote:

> I attached a patch to the trac ticket that contains an initial attempt
> at the MMA notation:
>
> http://trac.sagemath.org/sage_trac/ticket/6344
>

FYI, a few days ago Burcin uploaded a new patch on 6344 and asked for
review. Here are the examples:

OLD:


sage: var('x,y')


sage: f = function('f')

sage: f(x).derivative(x)
D[0](f)(x)
sage: f(x,x).derivative(x,2)
D[0, 0](f)(x, x) + 2*D[0, 1](f)(x, x) + D[1, 1](f)(x, x)


NEW:

sage: f(x).derivative(x)
D[1](f)(x)
sage: f(x,x).derivative(x,2)
D[2, 0](f)(x, x) + 2*D[1, 1](f)(x, x) + D[0, 2](f)(x, x)

NEW LATEX:

sage: latex(f(x).derivative(x))
f'\left(x\right)
sage: latex(f(x,x).derivative(x,2))
f^{(2,0)}\left(x, x\right) + 2 \, f^{(1,1)}\left(x, x\right) +
f^{(0,2)}\left(x, x\right)


More examples:

sage: binomial(x,y).derivative(x)
<boom>
sage: latex(floor(x).derivative(x))
D[0]\left \lfloor x \right \rfloor
sage: latex(ceil(x).derivative(x))
D[0]\left \lceil x \right \rceil


If you have an issue with the above printing, please speak now! If you
like this, it'd be great if you'd chime in as well.

Burcin indicates that this is a stepping stone, not necessarily a final
implementation. However, Burcin points out that we ought to settle on a
suitable output soon and move on from this issue.

Thanks,

Jason

William Stein

unread,
Jul 18, 2009, 7:54:34 PM7/18/09
to sage-...@googlegroups.com
On Sat, Jul 18, 2009 at 4:49 PM, Jason Grout<jason...@creativetrax.com> wrote:
>
> Burcin Erocal wrote:
>
>> I attached a patch to the trac ticket that contains an initial attempt
>> at the MMA notation:
>>
>> http://trac.sagemath.org/sage_trac/ticket/6344
>>
>
> FYI, a few days ago Burcin uploaded a new patch on 6344 and asked for
> review.  Here are the examples:
>
> OLD:
>
>
> sage: var('x,y')
> sage: f = function('f')
> sage: f(x).derivative(x)
> D[0](f)(x)
> sage: f(x,x).derivative(x,2)
> D[0, 0](f)(x, x) + 2*D[0, 1](f)(x, x) + D[1, 1](f)(x, x)
>
>
> NEW:
>
> sage: f(x).derivative(x)
> D[1](f)(x)
> sage: f(x,x).derivative(x,2)
> D[2, 0](f)(x, x) + 2*D[1, 1](f)(x, x) + D[0, 2](f)(x, x)

(1) So the non-latex isn't supposed to change?

(2) Why are these different?

D[0, 0](f)(x, x) + 2*D[0, 1](f)(x, x) + D[1, 1](f)(x, x)

and

D[2, 0](f)(x, x) + 2*D[1, 1](f)(x, x) + D[0, 2](f)(x, x)

In particular, why is it 2*D[0,1] in one and 2*D[1,1] in another?

-- William

>
> NEW LATEX:
>
> sage: latex(f(x).derivative(x))
> f'\left(x\right)
> sage: latex(f(x,x).derivative(x,2))
> f^{(2,0)}\left(x, x\right) + 2 \, f^{(1,1)}\left(x, x\right) +
> f^{(0,2)}\left(x, x\right)
>
>
> More examples:
>
> sage: binomial(x,y).derivative(x)
> <boom>
> sage: latex(floor(x).derivative(x))
> D[0]\left \lfloor x \right \rfloor
> sage: latex(ceil(x).derivative(x))
> D[0]\left \lceil x \right \rceil
>
>
> If you have an issue with the above printing, please speak now!  If you
> like this, it'd be great if you'd chime in as well.
>
> Burcin indicates that this is a stepping stone, not necessarily a final
> implementation.  However, Burcin points out that we ought to settle on a
> suitable output soon and move on from this issue.
>
> Thanks,
>
> Jason
>
>
>
>
>
>
> >
>



--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Tim Lahey

unread,
Jul 18, 2009, 8:00:56 PM7/18/09
to sage-...@googlegroups.com

Is standard partial derivative notation going to be used ever?
Say in latex(f(x,y).derivative(x,2))?

Also, is it possible to have some intelligence on when to use
\left and \right? Certainly for (x) they aren't really needed.

>
>
> If you have an issue with the above printing, please speak now! If
> you
> like this, it'd be great if you'd chime in as well.
>
> Burcin indicates that this is a stepping stone, not necessarily a
> final
> implementation. However, Burcin points out that we ought to settle
> on a
> suitable output soon and move on from this issue.
>
> Thanks,
>
> Jason
>

---

Golam Mortuza Hossain

unread,
Jul 19, 2009, 8:32:03 AM7/19/09
to sage-...@googlegroups.com
Hi,

On Sat, Jul 18, 2009 at 8:49 PM, Jason Grout<jason...@creativetrax.com> wrote:
> OLD:
>
> sage: var('x,y')
> sage: f = function('f')
> sage: f(x).derivative(x)
> D[0](f)(x)
> sage: f(x,x).derivative(x,2)
> D[0, 0](f)(x, x) + 2*D[0, 1](f)(x, x) + D[1, 1](f)(x, x)
>
>
> NEW:
>
> sage: f(x).derivative(x)
> D[1](f)(x)
> sage: f(x,x).derivative(x,2)
> D[2, 0](f)(x, x) + 2*D[1, 1](f)(x, x) + D[0, 2](f)(x, x)


The latex version looks good to me. Also, new text-mode
output is compact compared to the previous one.

My concern however is that above text mode output (like the previous
one) is not recognized by Sage as valid input.

Consider a user's perspective who is seeing "D[0](f)(x)" for
the first time.

(1) As Sage recommends, the user will try "D?"
----
sage: D?
Object `D` not found.
----

(2) User thinks may be docstring is not there. He then
tries to figure out what does it really do. So he tries
"sin" in place of "f"
-----
sage: D[0](sin)(x)
...
NameError: name 'D' is not defined
-----

Now you can imagine the kind of "first impression" it makes
to an user.

My 2 cents:

(1) Text-mode output for the proposed "D[2, 0](f)(x, x)" be of the form

D( f(x, x), [2, 0] )


(2) Add a new derivative function "D" which is exposed to users. This
will be similar to current "diff" but instead it will act using parameters
"[2,0]".


Cheers,
Golam

Burcin Erocal

unread,
Jul 19, 2009, 1:20:20 PM7/19/09
to sage-...@googlegroups.com
On Sat, 18 Jul 2009 16:54:34 -0700
William Stein <wst...@gmail.com> wrote:

>
> On Sat, Jul 18, 2009 at 4:49 PM, Jason
> Grout<jason...@creativetrax.com> wrote:
> >
> > Burcin Erocal wrote:
> >
> >> I attached a patch to the trac ticket that contains an initial
> >> attempt at the MMA notation:
> >>
> >> http://trac.sagemath.org/sage_trac/ticket/6344
> >>
> >
> > FYI, a few days ago Burcin uploaded a new patch on 6344 and asked
> > for review.  Here are the examples:
> >
> > OLD:
> >
> >
> > sage: var('x,y')
> > sage: f = function('f')
> > sage: f(x).derivative(x)
> > D[0](f)(x)
> > sage: f(x,x).derivative(x,2)
> > D[0, 0](f)(x, x) + 2*D[0, 1](f)(x, x) + D[1, 1](f)(x, x)
> >
> >
> > NEW:
> >
> > sage: f(x).derivative(x)
> > D[1](f)(x)
> > sage: f(x,x).derivative(x,2)
> > D[2, 0](f)(x, x) + 2*D[1, 1](f)(x, x) + D[0, 2](f)(x, x)
>
> (1) So the non-latex isn't supposed to change?

It is supposed to change, see below.

> (2) Why are these different?
>
> D[0, 0](f)(x, x) + 2*D[0, 1](f)(x, x) + D[1, 1](f)(x, x)
>
> and
>
> D[2, 0](f)(x, x) + 2*D[1, 1](f)(x, x) + D[0, 2](f)(x, x)
>
> In particular, why is it 2*D[0,1] in one and 2*D[1,1] in another?

In the old representation, D[0, 0](f)(x, y) meant d^2/dx^2 f(x,y). If
you wanted d^5/dx^5 you'd write D[0, 0, 0, 0, 0](f)(x, y). That is now
D[5, 0](f)(x,y).

This also corresponds to the tuple printed as an exponent of the
function in latex mode:


> > NEW LATEX:
> >
> > sage: latex(f(x).derivative(x))
> > f'\left(x\right)
> > sage: latex(f(x,x).derivative(x,2))
> > f^{(2,0)}\left(x, x\right) + 2 \, f^{(1,1)}\left(x, x\right) +
> > f^{(0,2)}\left(x, x\right)


> > More examples:

I did not present these lines below as examples of the new style
printing. These are the bugs we need to fix at some point. They are
present in the current system too.

> > sage: binomial(x,y).derivative(x)
> > <boom>
> > sage: latex(floor(x).derivative(x))
> > D[0]\left \lfloor x \right \rfloor
> > sage: latex(ceil(x).derivative(x))
> > D[0]\left \lceil x \right \rceil
> >
> >
> > If you have an issue with the above printing, please speak now!  If
> > you like this, it'd be great if you'd chime in as well.
> >
> > Burcin indicates that this is a stepping stone, not necessarily a
> > final implementation.  However, Burcin points out that we ought to
> > settle on a suitable output soon and move on from this issue.

In light of the discussion that took place in this thread, I consider
this the final style, not a stepping stone.

In my comments to the trac ticket, I just indicated that there are
problems with printing even with this patch. Since I don't have time to
fix all these now, and the printing of partial derivatives should be
standardized soon, I suggest that this patch is reviewed, and hopefully
merged for 4.1.1.


Cheers,
Burcin

Robert Bradshaw

unread,
Jul 20, 2009, 7:29:16 PM7/20/09
to sage-...@googlegroups.com

Just a sec, I thought we were going to move away from the D[i,j,...]
notation for text as well as latex, and it my mind

sage: f(x,y).derivative(x,2)

is much more evocative of (df/dx^2)(x,y) than as used above. Golam
brings up a good point about paste-ability as well, and though this
could be fixed by introducing a D object with __getitem__ I would
much prefer the default to be the admittedly less powerful but much
more intuitive diff(f(x), x) and df/dx notations.

- Robert

Reply all
Reply to author
Forward
0 new messages