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
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
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