From: Dmitry A. Kazakov on
On Tue, 29 Jun 2010 13:22:55 -0700 (PDT), Adam Beneschan wrote:

> On Jun 29, 12:31�pm, Warren <ve3...(a)gmail.com> wrote:
>>
>>> So, what is the "missing" function?
>>
>>> <http://www.adaic.com/standards/05rm/html/RM-G-1-2.html>
>>
>> 1) The "inverse" of a complex number.
>
> Isn't that just 1.0 / X?

-X ? (additive inverse)

Re - j Im ? (complex conjugate)

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Warren on
Adam Beneschan expounded in news:73a0af1d-7213-44af-90fa-ed6de4c64ce8
@b4g2000pra.googlegroups.com:

> On Jun 29, 12:31�pm, Warren <ve3...(a)gmail.com> wrote:
>>
>> > So, what is the "missing" function?
>>
>> > <http://www.adaic.com/standards/05rm/html/RM-G-1-2.html>
>>
>> 1) The "inverse" of a complex number.
>
> Isn't that just 1.0 / X?

Ok, it seems to be, as the GSL (Gnu Scientific Library)
defines it as:

gsl_complex
gsl_complex_inverse (gsl_complex a)
{ /* z=1/a */
double s = 1.0 / gsl_complex_abs (a);

gsl_complex z;
GSL_SET_COMPLEX (&z, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) * s);
return z;
}

But is this (GSL code) computationally more accurate
than a simple 1/Z? Faster? I don't know, as I am currently
porting to Ada and avoiding analysis at this point (a huge
task). But I do know that accuracy can be a good reason to
implement something as a specialized function (like ATAN2
for example).

Warren
From: Warren on
Warren expounded in news:Xns9DA6AC2A2C8BWarrensBlatherings(a)81.169.183.62:

> Adam Beneschan expounded in news:73a0af1d-7213-44af-90fa-ed6de4c64ce8
> @b4g2000pra.googlegroups.com:
>
>> On Jun 29, 12:31�pm, Warren <ve3...(a)gmail.com> wrote:
>>>
>>> > So, what is the "missing" function?
>>>
>>> > <http://www.adaic.com/standards/05rm/html/RM-G-1-2.html>
>>>
>>> 1) The "inverse" of a complex number.
>>
>> Isn't that just 1.0 / X?
>
> Ok, it seems to be, as the GSL (Gnu Scientific Library)
> defines it as:
>
> gsl_complex
> gsl_complex_inverse (gsl_complex a)
> { /* z=1/a */
> double s = 1.0 / gsl_complex_abs (a);
>
> gsl_complex z;
> GSL_SET_COMPLEX (&z, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) *
s);
> return z;
> }

Apologies for following up my own post, but
looking at the GSL implementation of complex
division:

gsl_complex
gsl_complex_div (gsl_complex a, gsl_complex b)
{ /* z=a/b */
double ar = GSL_REAL (a), ai = GSL_IMAG (a);
double br = GSL_REAL (b), bi = GSL_IMAG (b);

double s = 1.0 / gsl_complex_abs (b);

double sbr = s * br;
double sbi = s * bi;

double zr = (ar * sbr + ai * sbi) * s;
double zi = (ai * sbr - ar * sbi) * s;

gsl_complex z;
GSL_SET_COMPLEX (&z, zr, zi);
return z;
}

Given a=1.0, the inverse function is definitely
higher performance. It's simpler calculation
probably implies more accuracy as well.

Warren
From: Jeffrey R. Carter on
On 06/29/2010 01:55 PM, Warren wrote:
>
> gsl_complex
> gsl_complex_inverse (gsl_complex a)
> { /* z=1/a */
> double s = 1.0 / gsl_complex_abs (a);
>
> gsl_complex z;
> GSL_SET_COMPLEX (&z, (GSL_REAL (a) * s) * s, -(GSL_IMAG (a) * s) * s);
> return z;
> }

IIUC, the multiplicative inverse of z is

(z*)/(|z|**2)

where z* is the conjugate of z. Maybe this is the same thing.

--
Jeff Carter
"Blessed is just about anyone with a vested interest in the status quo."
Monty Python's Life of Brian
73
From: John B. Matthews on
In article <Xns9DA69DDA9F2AWarrensBlatherings(a)81.169.183.62>,
Warren <ve3wwg(a)gmail.com> wrote:

> >> I was looking for the inverse of a complex number function.
[...]
> > So, what is the "missing" function?
> >
> > <http://www.adaic.com/standards/05rm/html/RM-G-1-2.html>
>
> 1) The "inverse" of a complex number.

Ah, the multiplicative inverse. I thought you meant inverse of a
complex valued function, such as Exp/Log or Sin/Arcsin. As Adam
and Damien suggested, 1.0 / Z looks right:

function "/" (Left : Real'Base; Right : Complex) return Complex;

<http://www.adaic.com/standards/05rm/html/RM-G-1-1.html>

> 2) Also, math libraries usually include atan2(y,x),
> since the error can be large with certain ranges
> of x in the tan(x) form:
>
> #include <math.h>
>
> double atan2(double y, double x);
> float atan2f(float y, float x);
> long double atan2l(long double y, long double x);

Adam also mentioned Arctan for real values:

<http://www.adaic.com/standards/05rm/html/RM-A-5-1.html>

For complex values, you may want "the principal value of the
argument of the complex number x + iy."

<http://en.wikipedia.org/wiki/Inverse_trigonometric_functions>

function Argument (X : Complex) return Real'Base;

<http://www.adaic.com/standards/05rm/html/RM-G-1-1.html>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>