Inputting a Complex Number in Fortran 90 for DeMoivre's Theorem

In summary, the conversation discusses how to input a complex number in Fortran90 for a program on DeMoivres Theorem. The recommended approach is to use the complex function to combine the real and imaginary parts of the number. A Google search provides several useful resources on this topic.
  • #1
waver.
8
0
i have a a little problem in fortan90 i just wanted to know how to input a complex number ( input real and img part alone ) all i want to do is to make a simple program about DeMoivres Theorem i have been around in google
all i know how to declare a argument as complex
complex a
then how to let the user input the real and img part for argument a
i did read(*,*)a
every time it give runtime error :)
thanks in advance
 
Technology news on Phys.org
  • #3
A google search with fortran90 and complex returned quite a few links.

In any case, if you want to read a complex number straight into variable 'a', for example, as you show above, you need to enter your value as a complex number, i.e., enclosed in parenthesis, in other words, you type, say, "(1.43, 22.3)"
 
  • #4
thanks guys for helping specially gsal i used your idea and its works thank a lot
n7vc8.jpg
 

Related to Inputting a Complex Number in Fortran 90 for DeMoivre's Theorem

1. What is a complex number in Fortran 90?

A complex number in Fortran 90 is a data type that consists of a real and imaginary component. It is represented using the format (a,b), where a is the real part and b is the imaginary part.

2. How can I declare and initialize a complex number in Fortran 90?

To declare a complex number, you can use the complex keyword followed by the type of the real and imaginary components (e.g. real :: a; complex :: b). To initialize a complex number, you can use the format (a,b) or the cmplx function (e.g. b = cmplx(2.5, -3.2)).

3. What operations can be performed on complex numbers in Fortran 90?

Fortran 90 supports basic arithmetic operations (+, -, *, /) on complex numbers. It also has built-in functions for complex number operations such as conjugate, absolute value, and argument.

4. How do I convert a complex number to a real number in Fortran 90?

To convert a complex number to a real number, you can use the real function (e.g. real(b) will return the real component of the complex number b).

5. Can I use complex numbers in array operations in Fortran 90?

Yes, Fortran 90 allows complex numbers to be used in array operations. However, it is important to make sure that the dimensions of the arrays are compatible for the operations being performed.

Similar threads

  • Programming and Computer Science
Replies
25
Views
483
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
0
Views
564
  • Programming and Computer Science
Replies
2
Views
967
  • Programming and Computer Science
2
Replies
59
Views
9K
Replies
2
Views
298
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
5
Views
8K
Back
Top