# [GiNaC-list] conjugates of power objects

Richard B. Kreckel kreckel at ginac.de
Fri Apr 30 09:06:03 CEST 2010

```Hi!

Alexei Sheplyakov wrote:
> On Tue, Apr 27, 2010 at 03:16:00AM +0200, Burcin Erocal wrote:
>>> conjugate(sqrt(-3));
>> sqrt(-3)
>
> You are trying to compute the value of the function on the branch cut
> (which is ill defined), so you get the nonsense result.

Trying to argue that sqrt(-1) is ill-defined is going to rise an eyebrow
or two, I guess.  ;-)

Some background: GiNaC has been following the convention of counter
clockwise continuity (CCC) ever since. Functions are continuous as the
cut is approached coming around the finite endpoint of the cut in a
counter clockwise direction. GiNaC has inherited this from CLN, which
has followed Steele's CLTL2 in this respect. Later, the same convention
was adopted by C99 and C++. Most CAS follow it, too. (I haven't checked
yet, but I suppose this convention is also adopted by the LIA-3 standard.)

A popular extension due to this is the one advocated by W. Kahan and
standardized in IEEE754, where a distinction is made betweenn +0 and -0.
This is not a panacea because it opens the problem that one has to agree
on what an unqualified 0 is supposed to be. CLN/GiNaC (and all CASs I am
aware of) has no signed zero.

I heartily recommend the article "Function evaluation on branch cuts" by
Albert Rich and David Jeffrey. It is a short but very inspiring read!

Alas, I think that automatic evaluation of conjugation is too aggressive
in GiNaC. It just keeps giving incorrect results on branch cuts. Here
are some examples, using ginsh:

> conjugate(sqrt(x));
sqrt(conjugate(x))
> conjugate(sqrt(x))-sqrt(conjugate(x));
0
> conjugate(sqrt(-1))-sqrt(conjugate(-1));
-2*I
> conjugate(log(x));
log(conjugate(x))
> conjugate(log(x))-log(conjugate(x));
0
> conjugate(log(-1))-log(conjugate(-1));
-(2*I)*Pi

I suggest to disable automatic evaluateion of conjugation where these
kinds of problems can appear.

Opinions?

Best wishes
-richy.
--
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>
```