Namensräume
Varianten
Aktionen

clogf, clog, clogl

Von cppreference.com
< c‎ | numeric‎ | complex
Definiert im Header <complex.h>
float complex       clogf( float complex z );
(1) (seit C99)
double complex      clog( double complex z );
(2) (seit C99)
long double complex clogl( long double complex z );
(3) (seit C99)
Definiert in Header <tgmath.h>
#define log( z )
(4) (seit C99)
1-3) Berechnet den komplexen natürlichen (Basis-e) Logarithmus von z mit dem Schnitt entlang der negativen reellen Achse.
4) Typgenerische Makrodefinition: Wenn z vom Typ long double complex ist, wird clogl aufgerufen. Wenn z vom Typ double complex ist, wird clog aufgerufen. Wenn z vom Typ float complex ist, wird clogf aufgerufen. Wenn z reell oder ganzzahlig ist, ruft das Makro die entsprechende reelle Funktion (logf, log, logl) auf. Wenn z imaginär ist, wird die entsprechende komplexe Version aufgerufen.

Inhalt

[edit] Parameter

z - complex argument

[edit] Rückgabewert

Wenn keine Fehler auftreten, wird der komplexe natürliche Logarithmus von z zurückgegeben, im Bereich eines Streifens im Intervall [−iπ, +iπ] entlang der imaginären Achse und mathematisch unbeschränkt entlang der reellen Achse.

[edit] Fehlerbehandlung und Sonderwerte

Fehler werden konsistent mit math_errhandling gemeldet.

Wenn die Implementierung IEEE-Gleitkomma-Arithmetik unterstützt,

  • Die Funktion ist kontinuierlich auf dem Schnitt, unter Berücksichtigung des Vorzeichens des Imaginärteils
  • clog(conj(z)) == conj(clog(z))
  • Wenn z -0+0i ist, ist das Ergebnis -∞+πi und FE_DIVBYZERO wird ausgelöst.
  • Wenn z +0+0i ist, ist das Ergebnis -∞+0i und FE_DIVBYZERO wird ausgelöst.
  • Wenn z x+∞i ist (für jedes endliche x), ist das Ergebnis +∞+πi/2.
  • Wenn z x+NaNi ist (für jedes endliche x), ist das Ergebnis NaN+NaNi und FE_INVALID kann ausgelöst werden.
  • Wenn z -∞+yi ist (für jedes endliche positive y), ist das Ergebnis +∞+πi.
  • Wenn z +∞+yi ist (für jedes endliche positive y), ist das Ergebnis +∞+0i.
  • Wenn z -∞+∞i ist, ist das Ergebnis +∞+3πi/4.
  • Wenn z +∞+∞i ist, ist das Ergebnis +∞+πi/4.
  • Wenn z ±∞+NaNi ist, ist das Ergebnis +∞+NaNi.
  • Wenn z NaN+yi ist (für jedes endliche y), ist das Ergebnis NaN+NaNi und FE_INVALID kann ausgelöst werden.
  • Wenn z NaN+∞i ist, ist das Ergebnis +∞+NaNi.
  • Wenn z NaN+NaNi ist, ist das Ergebnis NaN+NaNi.

[edit] Hinweise

Der natürliche Logarithmus einer komplexen Zahl z mit den Polarkoordinatenkomponenten (r,θ) ist gleich ln r + i(θ+2nπ), wobei der Hauptwert ln r + iθ ist.

[edit] Beispiel

#include <stdio.h>
#include <math.h>
#include <complex.h>
 
int main(void)
{
    double complex z = clog(I); // r = 1, θ = pi/2
    printf("2*log(i) = %.1f%+fi\n", creal(2*z), cimag(2*z));
 
    double complex z2 = clog(sqrt(2)/2 + sqrt(2)/2*I); // r = 1, θ = pi/4
    printf("4*log(sqrt(2)/2+sqrt(2)i/2) = %.1f%+fi\n", creal(4*z2), cimag(4*z2));
 
    double complex z3 = clog(-1); // r = 1, θ = pi
    printf("log(-1+0i) = %.1f%+fi\n", creal(z3), cimag(z3));
 
    double complex z4 = clog(conj(-1)); // or clog(CMPLX(-1, -0.0)) in C11
    printf("log(-1-0i) (the other side of the cut) = %.1f%+fi\n", creal(z4), cimag(z4));
}

Ausgabe

2*log(i) = 0.0+3.141593i
4*log(sqrt(2)/2+sqrt(2)i/2) = 0.0+3.141593i
log(-1+0i) = 0.0+3.141593i
log(-1-0i) (the other side of the cut) = 0.0-3.141593i

[edit] Referenzen

  • C11-Standard (ISO/IEC 9899:2011)
  • 7.3.7.2 Die clog-Funktionen (S. 195)
  • 7.25 Typ-generische Mathematik <tgmath.h> (S. 373-375)
  • G.6.3.2 Die clog-Funktionen (S. 543-544)
  • G.7 Type-generic math <tgmath.h> (S: 545)
  • C99-Standard (ISO/IEC 9899:1999)
  • 7.3.7.2 Die clog-Funktionen (S. 176-177)
  • 7.22 Typ-generische Mathematik <tgmath.h> (S. 335-337)
  • G.6.3.2 Die clog-Funktionen (S. 478-479)
  • G.7 Type-generic math <tgmath.h> (S: 480)

[edit] Siehe auch

(C99)(C99)(C99)
berechnet die komplexe Eulersche Exponentialfunktion
(Funktion) [bearbeiten]
(C99)(C99)
berechnet den natürlichen (Basis-e) Logarithmus (ln(x))
(Funktion) [bearbeiten]