Re: Complex square root of -1 : zsqrt(-1)

Liste des GroupesRevenir à cl forth 
Sujet : Re: Complex square root of -1 : zsqrt(-1)
De : melahi_ahmed (at) *nospam* yahoo.fr (ahmed)
Groupes : comp.lang.forth
Date : 06. Sep 2024, 08:11:18
Autres entêtes
Organisation : novaBBS
Message-ID : <cda10f433a87be85af9d9487f58f8f43@www.novabbs.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Rocksolid Light
Hi,
Here is another definition for |z|.
It is based on the formula : z = |z| * exp(i*arg(z)).
One can get: |z| = z * exp(-i*arg(z)).
Here is the code:
: zarg ( z: a+bi -- ) ( f: -- theta)
    fswap fatan2
;
: |z| ( z: a+bi -- ) ( f: -- |z|)
    zdup zarg 0e 0e -1e z* ( z: -i*arg[z])
    zexp z*  ( z: z*exp(-i*arg[z])
    fdrop    ( z: --) ( f: |z|)
;
But it is slower than the defintion using pythag( about 3-6 times
(tested gforth)).
Ahmed

Date Sujet#  Auteur
25 Aug 24 * Complex square root of -1 : zsqrt(-1)22ahmed
25 Aug 24 +- Re: Complex square root of -1 : zsqrt(-1)1Ron AARON
25 Aug 24 +- Re: Complex square root of -1 : zsqrt(-1)1minforth
25 Aug 24 +* Re: Complex square root of -1 : zsqrt(-1)17Anton Ertl
25 Aug 24 i`* Re: Complex square root of -1 : zsqrt(-1)16ahmed
25 Aug 24 i +- Re: Complex square root of -1 : zsqrt(-1)1Krishna Myneni
28 Aug 24 i `* Re: Complex square root of -1 : zsqrt(-1)14Anton Ertl
28 Aug 24 i  `* Re: Complex square root of -1 : zsqrt(-1)13ahmed
28 Aug 24 i   `* Re: Complex square root of -1 : zsqrt(-1)12ahmed
28 Aug 24 i    `* Re: Complex square root of -1 : zsqrt(-1)11mhx
28 Aug 24 i     `* Re: Complex square root of -1 : zsqrt(-1)10ahmed
28 Aug 24 i      `* Re: Complex square root of -1 : zsqrt(-1)9ahmed
28 Aug 24 i       +* Re: Complex square root of -1 : zsqrt(-1)7mhx
28 Aug 24 i       i`* Re: Complex square root of -1 : zsqrt(-1)6ahmed
28 Aug 24 i       i +- Re: Complex square root of -1 : zsqrt(-1)1ahmed
29 Aug 24 i       i `* Re: Complex square root of -1 : zsqrt(-1)4mhx
6 Sep 24 i       i  `* Re: Complex square root of -1 : zsqrt(-1)3ahmed
6 Sep 24 i       i   `* Re: Complex square root of -1 : zsqrt(-1)2minforth
6 Sep 24 i       i    `- Re: Complex square root of -1 : zsqrt(-1)1minforth
28 Aug 24 i       `- Re: Complex square root of -1 : zsqrt(-1)1ahmed
25 Aug 24 `* Re: Complex square root of -1 : zsqrt(-1)2Krishna Myneni
25 Aug 24  `- Re: Complex square root of -1 : zsqrt(-1)1Krishna Myneni

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal