Question on partial derivative of "f(x, x)" w.r.t. "x"

4 views
Skip to first unread message

Golam Mortuza Hossain

unread,
Aug 8, 2009, 6:50:06 AM8/8/09
to sage-...@googlegroups.com
Hi,

If I compute partial derivative of f(x, x) w.r.t. x in Sage
then I get
-----
sage: f(x, x).diff(x)
D[0](f)(x, x) + D[1](f)(x, x)
-----

Now if I say "f(x, x) = x" then from the output above I would
get "2". On the other hand, had I computed it directly, I
would get "1"
------
sage: (x).diff(x)
1
------

I encountered this issue while testing out new "diff" derivative
implementation. So it would be good to know the right approach
for handling this issue.

Cheers,
Golam

William Stein

unread,
Aug 9, 2009, 2:24:56 PM8/9/09
to sage-...@googlegroups.com
What do *you* think the right approach is? You probably have more
experience with the question at hand than anybody else around here.

-- William

>
> Cheers,
> Golam
>
> >
>



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

Simon King

unread,
Aug 9, 2009, 3:24:44 PM8/9/09
to sage-devel
Hi!

On Aug 8, 11:50 am, Golam Mortuza Hossain <gmhoss...@gmail.com> wrote:
...
> Now if I say "f(x, x) = x"  then from the output above I would
> get "2".

Is it *possible* to say "f(x,x)=x"? What is it supposed to mean?

- A function on one variable x, written down in an odd way?
- A function whose domain is the diagonal in CC^2 ?
- Or is it "get two input parameters, pick one and return it"?

Apparently, it is the third option:
sage: f(x,x)=x
sage: f
(x, x) |--> x
sage: f(2,1)
1

This seems odd to me.

Why is the definition
sage: f(x,x)=x
not resulting in an error?

Or, if f(x,x)=x is really intended to be a function on the diagonal,
then f(2,1) should result in an error.

Cheers,
Simon

William Stein

unread,
Aug 9, 2009, 4:37:39 PM8/9/09
to sage-...@googlegroups.com

Good point.  I am very surprised this isn't just an error. 

William

Golam Mortuza Hossain

unread,
Aug 9, 2009, 4:42:23 PM8/9/09
to sage-...@googlegroups.com
Hi William,

On Sun, Aug 9, 2009 at 3:24 PM, William Stein<wst...@gmail.com> wrote:
>>
>> I encountered this issue while testing out new "diff" derivative
>> implementation. So it would be good to know the right approach
>> for handling this issue.
>
> What do *you* think the right approach is?


Frankly, I am not too sure either. However, it seems reasonable to me
to not to apply chain rule here as one is supposed to freeze
the "other" variable (which happens to be same here) while applying chain rule.

Even Maple and Wolfram alpha gives the same answer!! Maxima
behaves rather gracefully as it does not evaluate anyway.

Cheers,
Golam

Golam Mortuza Hossain

unread,
Aug 9, 2009, 4:58:56 PM8/9/09
to sage-...@googlegroups.com
Hi Simon,

On Sun, Aug 9, 2009 at 4:24 PM, Simon King<simon...@nuigalway.ie> wrote:
>> Now if I say "f(x, x) = x"  then from the output above I would
>> get "2".
>
> Is it *possible* to say "f(x,x)=x"? What is it supposed to mean?

I came there starting from "f(x,y) = (x+y)/2". So f(x,x) = x.

However, as you have clearly demonstrated, this issue goes
deeper than what I had in my mind earlier.


> - A function on one variable x, written down in an odd way?
> - A function whose domain is the diagonal in CC^2 ?
> - Or is it "get two input parameters, pick one and return it"?
>
> Apparently, it is the third option:
> sage: f(x,x)=x
> sage: f
> (x, x) |--> x
> sage: f(2,1)
> 1
>
> This seems odd to me.

Yes, this clearly looks like a bug to me!

Cheers,
Golam

Simon King

unread,
Aug 9, 2009, 5:06:28 PM8/9/09
to sage-devel
Hi Golam!

On 9 Aug., 22:58, Golam Mortuza Hossain <gmhoss...@gmail.com> wrote:
> Hi Simon,
>
> On Sun, Aug 9, 2009 at 4:24 PM, Simon King<simon.k...@nuigalway.ie> wrote:
> >> Now if I say "f(x, x) = x"  then from the output above I would
> >> get "2".
>
> > Is it *possible* to say "f(x,x)=x"? What is it supposed to mean?
>
> I came there starting from "f(x,y) = (x+y)/2". So f(x,x) = x.

Do you mean f(x,x)==x ?
f(x,x)=x is a definition, that, as I pointed out, is perhaps not much
meaningful.

Cheers,
Simon
Reply all
Reply to author
Forward
0 new messages