Example #1
0
        public override Complex Putere(int x)
        {
            ComplexD A = new ComplexD();

            A.r  = Math.Pow(r, x);
            A.fi = x * fi;
            double re = Math.Sqrt(A.r * A.r / (1 + Math.Tan(A.fi) * Math.Tan(A.fi)));
            double im = Math.Tan(A.fi) * re;

            return(new Complex(re, im));
        }
Example #2
0
        static void Main(string[] args)
        {
            //1
            Complex a = new Complex((double)r.Next(10), (double)r.Next(10));
            Complex b = new Complex((double)r.Next(10), (double)r.Next(10));
            int     x = r.Next(10);

            Console.WriteLine("a: {0}, b: {1}", a, b);
            Console.WriteLine("{0} - {1} = {2}", a, b, a - b);
            Console.WriteLine("{0} + {1} = {2}", a, b, a + b);
            Console.WriteLine("{0} * {1} = {2}", a, b, a * b);
            Console.WriteLine("({0})^{1} = {2}", a, x, a.Putere(x));
            b.Trigonometric();
            Console.WriteLine();

            //2
            Rational r1 = new Rational(r.Next(100), r.Next(100));
            Rational r2 = new Rational(r.Next(100), r.Next(100));

            Console.WriteLine("r1: {0}, r2: {1}", r1, r2);
            Console.WriteLine("{0} - {1} = {2}", r1, r2, r1 - r2);
            Console.WriteLine("{0} + {1} = {2}", r1, r2, r1 + r2);
            Console.WriteLine("{0} * {1} = {2}", r1, r2, r1 * r2);
            Console.WriteLine("{0} / {1} = {2}", r1, r2, r1 / r2);
            Console.WriteLine("{0}^{1} = {2}; {3}^{1} = {4}", r1, x, r1.Putere(x), r2, r2.Putere(x));
            Rational R1 = r1; R1.Ireductibil();
            Rational R2 = r2; R2.Ireductibil();

            Console.WriteLine("{0} = {1}; {2} = {3}", r1, R1, r2, R2);
            Console.WriteLine("{0} < {1}: {2}", r1, r2, r1 < r2);
            Console.WriteLine("{0} > {1}: {2}", r1, r2, r1 > r2);
            Console.WriteLine("{0} <= {1}: {2}", r1, r2, r1 <= r2);
            Console.WriteLine("{0} >= {1}: {2}", r1, r2, r1 >= r2);
            Console.WriteLine("{0} == {1}: {2}", r1, r2, r1 == r2);
            Console.WriteLine("{0} != {1}: {2}", r1, r2, r1 != r2);
            Console.WriteLine();

            //3
            Matrice A = new Matrice(3, 3);
            Matrice B = new Matrice(3, 3);

            A.Afisare(); B.Afisare();
            Matrice C = new Matrice(3, 3);

            C = A.Adunare(B); C.Afisare();
            C = A.Scadere(B); C.Afisare();
            C = A.Inmultire(B); C.Afisare();
            C = A.Putere(3); C.Afisare();
            C = B.Inversa(); C.Afisare();

            //1'
            ComplexD zd = new ComplexD(5, 3);
            Complex  D  = new Complex();

            D = zd.Putere(2);
            Console.WriteLine(D);
            Complex[] v = new Complex[2];
            v[0] = new Complex(1, 1);
            v[1] = new Complex(5, 2);
            double d = zd.Distanta(v);

            Console.WriteLine(d);
            Console.ReadKey();
        }