help-octave
[Top][All Lists]

## Re: Applying function to vector by index

 From: Schloegl Alois Subject: Re: Applying function to vector by index Date: Tue, 10 Dec 2002 10:38:48 +0100 (MET) User-agent: IMP/PHP IMAP webmail program 2.2.8

```

> I've got most of a patch in place, but there's all
> sorts of weird side cases.
>
> For example, what should sparse(eye(2)).^(1+1i) give?
>
> Matlab gives:
> >> full(sparse(eye(2)).^(1+1i))
>
> ans =
>
>      1     0
>      0     1
>
> >> full(full(eye(2)).^(1+1i))
>
> ans =
>
>    1.0000             NaN +    NaNi
>       NaN +    NaNi   1.0000
>
>
> That's because a^(b+ci) = e^(ln(a))*(b+ci)
> and ln(a) is NaN

It should be
a^(b+ci) = e^(ln(a)*(b+ci))
= e^(ln(a)*b + ln(a)*ci)
= e^(ln(a)*b)*e^(ln(a)*ci)

ln(a) = [0,-inf;-inf,0]

Because e^(ln(a)*i) is limited (abs(e^(ln(a)*i)<=1) and b>0, the result
converges. Hence, the result [1,0;0,1] is correct.

Alois

-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------

```