USING COMPLEX NUMBERS IN JAVA The Java math library lacks adequate support for real mathematical needs, such as working with Complex numbers. However, there are other math libraries available that assist with Complex numbers in Java calculations. For example, visit the Java Grande Forum and JavaNumerics Web sites. They have a collection of proposed standards to aid the Java numerically challenged, one of which happens to be a Complex number API implementation by Visual Numerics. http://clickthru.online.com/Click?q=02-qia9IljcNYED_11_XDdyr_zpb4ZR http://clickthru.online.com/Click?q=17-agitI5X-ebidaGFIzyZ3RTj37RsR http://clickthru.online.com/Click?q=2c-DatOIc0wqXEG1G2c-PAnBgWJQcuR This implementation, VisualNumerics.math.Complex, is simple and easy to use. It provides all the basic mathematical operations, trigonometric functions, and a handful of special complex functions. The style of implementation is similar to the style for java.lang.Math and java.lang.Integer. First, create the Complex numbers. The Complex class has 4 constructors: Complex c1 = new Complex(); // equivalent to 0 + 0i Complex c2 = new Complex(1.0); // equivalent to 1 + 0i Complex c3 = new Complex(c2); // copy c2 Complex c4 = new Complex(1.0, 1.0); // equivalent to 1 + 1i NOTE: While the constructors take arguments of type 'double', you can pass in integers or Double.NaN. The manipulation of a Complex number is easy. For example: Complex c1 = new Complex(5,5); // 5 + 5i Complex c2 = new Complex(2,-6); // 2 - 6i Complex c = null; c = c1.add(c2); System.out.println(c); // 7.0-1.0i // a static version c = Complex.add(c1, c2); // 7.0-1.0i System.out.println(c); c = c1.subtract(c2); System.out.println(c); // 3.0+11i c = c1.multply(c2); System.out.println(c); // 40.0-20.0i c = c1.divide(c2); System.out.println(c); // 5.0+5.0i In addition to these instance methods, there are many static methods available, such as static add, subtract, multiply, and divide methods. Static methods also include complex functions: Complex c = new Complex(3, 4); // 3+4i System.out.println( Complex.abs(c) ); // 5.0 System.out.println( Complex.argument(c) ); // 0.9272952180016122 System.out.println( Complex.conjugate(c) ); // 3.0-4.0i Besides these necessary complex functions, there are trigonometric and exponential functions. These examples cover most of the basic Complex number needs, and the adherence to the Java style and energies of the creators and standard-bearers should keep your code well placed for the arrival of future standards. ----------------------------------------