The conjf()
function in C calculates the conjugate of a complex number. For example: for the complex number , the conjf()
function will return .
To use the conjf()
function, the program needs to include the complex.h
header file as shown below:
#include <complex.h>
The conjf()
function accepts a single parameter of type float complex
.
conjf()
returns a single value of type float complex
.
The following code demonstrates the use of conjf()
to calculate the conjugate of a complex number:
#include <stdio.h> #include <complex.h> int main() { // define complex number float complex num = 4.3 + 9.1*I; //get real part float real = crealf(num); //get imaginary part float imag = cimagf(num); printf("num is %.1f% + .1fi\n",real, imag ); //calculate conjugate. float complex conj_num= conjf(num); float conj_real = crealf(conj_num); float conj_imag = cimagf(conj_num); printf("Applying conjugation\n"); printf("num is %.1f% + .1fi\n",conj_real, conj_imag ); }
float
, then obtains the real part through crealf()
and the imaginary part through cimagf()
.conjf()
function calculates the conjugate of the complex number.RELATED TAGS
CONTRIBUTOR
View all Courses