On Tue, Nov 18, 2014 at 1:19 PM, Ondřej Čertík <ondrej.cer...@gmail.com> wrote:
> On Tue, Nov 18, 2014 at 12:14 PM, Bill Page <bill.p...@newsynthesis.org> 
> wrote:
>> On 18 November 2014 13:41, Ondřej Čertík <ondrej.cer...@gmail.com> wrote:
>>> On Tue, Nov 18, 2014 at 11:08 AM, Bill Page <bill.p...@newsynthesis.org> 
>>> wrote:
>>>> ...
>>>> Have you had a chance to consider the issue of the chain-rule yet?
>>>
>>> Yes. Very straightforward, as I suggested in my last email. Just start with:
>>>
>>> D f / D z = df/dz + df/d conjugate(z) * e^{-2*i*theta}
>>>
>>> and then consider the chain rule for Wirtinger derivatives
>>> (http://en.wikipedia.org/wiki/Wirtinger_derivatives#Functions_of_one_complex_variable_2),
>>> I am sure that can be proven quite easily.
>>
>> Let me make sure I understand your proposal.  Are you saying that you
>> would introduce the symbolic expression
>>
>>    e^{-2*i*theta}
>>
>> with theta undefined in the result of all derivatives?  So that
>> diff(x) is always the sum of two terms. In particular
>>
>>   abs(x).diff(x)
>>
>> would return the symbolic expression
>>
>>   conjugate(x)/(2*abs(x)) + conjugate(x)/(2*abs(x))* e^{-2*i*theta}
>
> I think you made a mistake, the correct expression is:
>
> conjugate(x)/(2*abs(x)) + x/(2*abs(x)) * e^{-2*i*theta}
>
>>
>> If you are, then clearly one can recover both Wirtinger derivatives
>> from this expression and the rest holds.
>
> For now I just wanted to get the math right in the most general case.
> I wasn't even considering what a CAS should do.
>
>>
>>> Then you just calculate directly:
>>> ...
>>> So it exactly agrees, except that there is a theta dependence in the
>>> final answer and GiNaC implicitly chose theta=0.
>>>...
>>> I hope I didn't make some mistake somewhere, but it looks all
>>> straightforward to me.
>>>
>>
>> It looks OK to me but I must say, it probably seems rather peculiar
>> from the point of view expressed earlier by David Roe.
>>
>> How can you explain the presence of the e^theta term to someone
>> without experience in complex analysis or at least multi-variable
>> calculus?
>>
>> I thought rather that what you were proposing was to set theta=0 from
>> the start.  If you did that, then I think you still have problems with
>> the chain rule.
>
> For a CAS, I was leaning towards using theta=0. But given your
> objections, I first needed to figure out the most general case that
> covers everything. I think that's now sufficiently clarified.
>
>> Let me add that the kind of solution to this problem that I did
>> imagine was to implement two derivatives, for example both
>>
>>   f.diff(z) = df/dz + df/d conjugate(z)
>>
>> and
>>
>>   f.diff2(z) = df/dz - df/d conjugate(z)
>>
>> diff(z) would equal diff2(z) for all analytic functions and diff would
>> reduce to the derivative of real non-analytic functions as you desire.
>
> Right, diff() is for theta = 0. diff2() is for theta=pi/2, i.e. taking
> the derivative along the imaginary axis.
>
>> Note that for abs we have
>>
>>   abs(z).diff2(z) = 0
>
> Actually, for abs you have:
>
> abs(z).diff2(z) = (conjugate(z)-z)/(2*abs(z))
>
>> but not in general.  There would be no need to discuss this 2nd
>> derivative with less experienced users until they were ready to
>> consider more "advanced" mathematics.
>>
>> Clearly we could implement the chain rule given these two derivatives.
>
> So I think that functions can return their own correct derivative, for
> example analytic functions just return the unique complex derivative,
> for example:
>
> log(z).diff(z) = 1/z
>
> This holds for all cases. Non-analytic functions like abs(f) can return:
>
> abs(f).diff(z) = (conjugate(f)*f.diff(z) +
> f*conjugate(f).diff(z)*e^{-2*i*theta}) / (2*abs(f))

Actually, I think I made a mistake. Let's do abs(f).diff(x) again for
the most general case. We use:

D f(g) / D z =

= df/dg * (dg/dz + dg/d conjugate(z) * e^{-2*i*theta}) + df/d
conjugate(g) * (d conjugate(g)/dz + d conjugate(g)/d conjugate(z) *
e^{-2*i*theta}) =

= df/dg Dg/Dz + df/d conjugate(g) D conjugate(g) / Dz

Which we derived above. We have f(g) -> |g| and g(z) -> f(z). So we get:

D |f| / Dz = d|f|/df * Df/Dz + d|f|/d conjugate(f) * D conjugate(f) / Dz =

= (conjugate(f) * Df/Dz + f * D conjugate(f) / Dz) / (2*abs(f))

And then:

Df/Dz = f.diff(z)
D conjugate(f) / Dz = conjugate(f).diff(z)

So I think the formula:

abs(f).diff(z) = (conjugate(f)*f.diff(z) + f*conjugate(f).diff(z)) / (2*abs(f))

is the most general formula for any theta. The theta dependence is hidden
in conjugate(f).diff(z), since if "f" is analytic, like f=log(z), the
conjugate(f) is
not analytic, and so the derivative is theta dependent.

The below holds though:

>
> I think that's the correct application of the chain rule. We can set
> theta=0, so we would just return:
>
> abs(f).diff(z) = (conjugate(f)*f.diff(z) + f*conjugate(f).diff(z)) / 
> (2*abs(f))
>
> Which for real "f" (i.e. conjugate(f)=f) simplifies to (as a special case):
>
> abs(f).diff(z) = (f*f.diff(z) + f*f.diff(z)) / (2*abs(f)) = f/abs(f) *
> f.diff(z) = sign(f) * f.diff(z)
>
> So it all works.
>
> Unless there is some issue that I don't see, it seems to me we just
> need to have one diff(z) function, no need for diff2().
>
> Ondrej

-- 
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 http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to