Complex Numbers Formula’s with Simple Conjugate Converter Part 1

Basics:

i = √(-1)
i2 = -1
i3 = i2 * i = -1 * i = -i
i4 = i2 * i2 = -1 * -1 = 1

Complex Number Representation,

We usually represent complex number with z,
z = x + iy ( In Cartesian or Rectangular Form )
Here, x is the real part and y is the imaginary part.
Example,
3 + 2i
here, 3 is the real part and 2 is the imaginary part.

In a plane real part is drawn or represented by x axis and imaginary part is drawn on y axis.
magnitude of a complex number, r = mod(z) = |z| = √(x2 + y2)
Angle, Arg(z) = tan-1(y/x)


Conjugate of Complex Number,

Conjugate of complex number is represented with z prime or z bar. For conjugate of complex number just change the sign of imaginary part ( Do not change the sign of real part but change only imaginary part sign ).

Example,

x + iy
Conjugate, x – iy

3/2 + 4i
Conjugate, 3/2 – 4i


Polar form of a complex number,

z = r * ( cos(Θ) + i * sin(Θ) )
We can also write this as, z = r * cis(Θ)
From Euler’s formula we can also write, z = re

(Proof’s for these can be found on wikipedia)

De Moivre’s Formula,

(cos(Θ) + sin(Θ))n = cos(nΘ) + sin(nΘ)

Example,
(cos(Θ) + sin(Θ))15 = cos(15Θ) + sin(15Θ)


 

Simple Code to Find Conjugate of Complex Number:

/**
 * @author  Quickgrid ( Asif Ahmed )
 * @link    https://quickgrid.wordpress.com
 */

#include<stdio.h>

static char s[16];

int main(){
	register unsigned n, i;

	printf("How many times do you want to run the program?\n");
	scanf("%u", &n); getchar();

	while (n--){

        printf("Enter complex number to find conjugate:\n");
        gets(s);

        for (i = 0; s[i]; ++i){
            /*
             * A simple check to see if it is a valid complex number or not
             * This code is not full proof, easily breakable for many input instances
             */
            if ((s[i] >= '0' && s[i] <= '9') || s[i] == 'i' || s[i] == '+' || s[i] == '-' || s[i] == '/' ){
                if (s[i] == '+'){
                    s[i] = '-';
                    break;
                }
                else if (s[i] == '-'){
                    s[i] = '+';
                    break;
                }
            }
        }

        printf("Conjugate: %s\n", s);
	}
	return 0;
}