# Complex Numbers in Java

• May 18th, 2011, 06:07 PM
JavaNovice03355
Complex Numbers in Java
Hello Everyone,

I am new to programming in Java. Been a Matlab programmer for the past 8-9 years. I have a question (This might look like a very dumb question to many of you Java programmers)?

Let say Z(n) is an array of complex number defined as (3+4*i)/(9-(7*i)*n); where for simplicity n=0,1,23,.....9;

T(n) is an array of complex number defined as (2.25-(9*i)*n)/(8+11.34*i); where n=0,1,23,.....9;

1. Now how do i store this complex numbers into an array using Java?

I prefer using a "for" loop
for (int n=0, n<10,n++){
Z[n]=(3+4*i)/(9-(7*i)*n);}

But i know Java don't recognize "i" which is sqrt(-1). How to go about creating a Z array then?

2. Next, how do i find the product of Z*T; lets say Z is saved as "nx1" vector (matrix) and T is saved as "1xn" vector (matrix)? I want the result to be "nxn" matrix.

I have looked at Michael Flanagan's Java library on Complex (Michael Thomas Flanagan's Java Scientific and Numerical Library), but still can't figure out. Any suggestions would be greatly appreciated.

Thanks!
Derrick
• May 18th, 2011, 07:30 PM
Norm
Re: Complex Numbers in Java
You've sort of hidden you posting in the Member Introduction part of the forum.