Java Double Number Divide divideComplex(double realOne, double imagOne, double realTwo, double imagTwo)

Here you can find the source of divideComplex(double realOne, double imagOne, double realTwo, double imagTwo)

Description

Divides two complex values

License

Open Source License

Parameter

Parameter Description
realOne real part one
imagOne imaginary part one
realTwo real part two
imagTwo imaginary part two

Return

an array of two values: first entry is real, second imaginary

Declaration

public static double[] divideComplex(double realOne, double imagOne,
        double realTwo, double imagTwo) 

Method Source Code

//package com.java2s;
/*//  w ww.ja  va  2  s .co  m
 * Copyright (C) 2010-2014  Andreas Maier
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
 */

public class Main {
    /**
     * Divides two complex values
     * @param realOne real part one
     * @param imagOne imaginary part one
     * @param realTwo real part two
     * @param imagTwo imaginary part two
     * @return an array of two values: first entry is real, second imaginary
     */
    public static double[] divideComplex(double realOne, double imagOne,
            double realTwo, double imagTwo) {
        double[] revan = new double[2];
        double denominator = Math.pow(realTwo, 2) + Math.pow(imagTwo, 2);
        revan[0] = ((realOne * realTwo) + (imagOne * imagTwo))
                / denominator;
        revan[1] = ((imagOne * realTwo) - (realOne * imagTwo))
                / denominator;
        return revan;
    }
}

Related

  1. divide(String num1, String num2)
  2. divide(String num1, String num2, int scale)
  3. divide(String num1, String num2, int scale)
  4. divide(String thisVal, String addVal)
  5. divide4Money(Double value1, Double value2)
  6. divideDouble(double first, double second)
  7. divideDouble(double first, double second, int scale, int roundingMode)
  8. divideInts(int numerator, int denominator)
  9. divideNumber(Object divisor, Object dividend)