On Tue, Nov 25, 2014 at 11:30 AM, Bill Page <bill.p...@newsynthesis.org> wrote: > On 25 November 2014 at 01:11, Ondřej Čertík <ondrej.cer...@gmail.com> wrote: >> On Mon, Nov 24, 2014 at 10:23 PM, Bill Page <bill.p...@newsynthesis.org> >> wrote: >>> ... >>> I am not very interested in real numbers. I am interested in the >>> algebra. Would you say that >>> >>> sqrt(x^2).diff(x) = sqrt(x^2)/x >>> >>> is OK? >> >> I think so, using the following calculation: >> >> sqrt(x^2).diff(x) = exp(1/2*log(x^2)).diff(x) = exp(1/2*log(x^2)) * >> 1/2 * 1/x^2 * 2*x = sqrt(x^2)/x >> >> The function exp(1/2*log(x^2)) that we differentiate is analytic, so I >> don't see any issue here. >> > > I did not ask whether it was technically correct or not. What I meant > was is this expression what you would expect given the rest of the > machinery of differentiation in any given computer algebra system?
Ah ok. I would actually expect to get x/sqrt(x^2), which is equivalent. > >> >>> But I don't want to be forced to make a choice of branch until >>> I actually need to evaluate an expression numerically. >> >> I understand that's what you want. I am just trying to understand how >> exactly this works. >> > > OK. > >>> ... >>> I think what you are trying to say is >>> >>> (A) log(exp(z)) = { z + 2*pi*i*n | for all n in Integer} >> >> Exactly, that's what I meant. >> ... >>> >>> Although it may seem simple in this case, in general implementing >>> sets with comprehension like this requires logic and takes us >>> outside of algebra as such into the realm of theorem proving. >> >> Sure. But that's what you want, correct? >> > > No, not at all. I want this to be "algebraic", not some theorem of > predicate calculus. That is what I meant by taking > > x + conjugate(x) > > as the definition of a real valued variable. Ok. > >> ... >>> >>>> >>>> This is precisely the part that I don't understand with the approach >>>> (A). log(a*b), log(a) and log(b) are all multivalued, so you would >>>> naively think, that log(a*b)-log(a)-log(b) = 0 + 2*pi*i*n, for all >>>> "n". But I think this is not the case, I think the "n" in log(a*b) is >>>> coupled to the implicit "n" in log(a) and log(b) in such a way, that >>>> the result is exactly 0. Can you clarify exactly how this works? >>> >>> Try it this way: >>> >>> a*b = exp(?1) >>> a = exp(?2) >>> b = exp(?3) >>> >>> I think 'normalize' is saying that there is a solution that makes >>> >>> ?1 - ?2 - ?3 = 0. >> >> Ok, but why wouldn't normalize return 2*pi*i instead? Or 4*pi*i? > > These are equivalent in the sense of having the same number of > algebraically independent transcendental kernels, i.e. none. I don't understand that. Is the result of normalize() multivalued? Or how else could 0 be equivalent to 2*pi*i or 4*pi*i? > >> >> In other words, how exactly are the operations on the multivalued >> sets log(x) defined? > > FriCAS does not perform operations on multivalued sets to determine the above. Ok. Though my question stands, how are the operations defined in your approach? > >>> >>> I meant that I did not understand what you are proposing for how to >>> represent the value of 'log(z)' symbolically, i.e. when the value of z >>> is unknown. >> >> Ah ok. I would represent it by the approach (B). But then, as we >> talked about, it's not true that conjugate(log(z)) = log(conjugate(z)). >> Since you want this property to hold, then the approach (B) does >> not work for you, obviously. So I am trying to understand how >> exactly are all the operations defined in your approach. You said >> your approach is not (A) exactly. So I am just trying to understand. >> > > OK. > >> >> This discussion is about how a CAS should handle (complex) >> differentiation. Since it started here, I would finish it here, so >> that the whole thread is in one mailinglist for future reference. >> > > OK. It would be nice to know if other sage-devel subscribers actually > remain interested... > > Let's return to differentiation for a moment. Using your definitions > what would you say is the correct result for > > log(exp(z-conjugate(z))).diff(z) > > My patched version of FriCAS based your definition in this thread > currently returns 0. Do you get the same result? No, the derivative is most definitely not zero: log(exp(z-conjugate(z))).diff(z) = exp(z-conjugate(z))/exp(z-conjugate(z)) * [1 - 1*exp(-2*i*theta)] = 1 - exp(-2*i*theta) In other words, the two Wirtinger derivatives are 1 and -1. You can easily check numerically that this formula is correct for all complex "x" and angles theta, I've done it here: https://github.com/certik/theoretical-physics/blob/f9406a02ef8e04b2daa669f444148186b6b892e8/src/math/code/test_complex_diff.py#L118 and it works. > > Since the derivative is 0 would we want to say therefore that > > log(exp(z-conjugate(z))) > > is a constant? If you got 0, then I think you can say that the function is constant. We didn't get 0, so the function is not constant. > If not, isn't this an argument for needing another > derivative? In some of your previous emails you wrote that this theta factor "still looks ugly to you". Maybe it's ugly, but it's correct, as you fell into this trap yourself: if you omit theta and implicitly assume theta=0, then you don't know if what you got is analytic or not. Perhaps this comment in a sympy issue might help: https://github.com/sympy/sympy/issues/8502#issuecomment-64415017 Essentially the formula with theta is equivalent to just returning a tuple of the two Wirtinger derivatives. So what holds for one approach holds for the other one. > The result of this test currently causes a problem during > manipulations of expressions of this form. Check the two Wirtinger > derivatives for this case. If we have both derivatives we can avoid > this problem quite easily as my previous version of the patch showed. My current best solution is to define a function `diff(x, theta=0)`, where the theta argument is 0 by default, but you can pass any angle into it, or a symbol theta if you want. That way you won't get the theta factors by default, but if in doubt, you can always get them. Let me know if you have a better proposal. Ondrej > > Bill. > > -- > 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. -- 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.