关于FORTRAN对复数的计算问题
Hi, I think your question has been solved by me, desipte I am not familiar with complex number. So I cannot explain what is wrong in your code in detail. Especially you attempted to compare the numerial and anyalitical results.
--------------------
Note: the compiler might be confused by your valiable setting, if you don't uniform this variable assignment. So my suggestion is try to only use complex as your variable type, which should give you an expected result!
Here is the code:
--------------------
program cpx
implicit none
complex :: c = ( 5.0,3.0 )
complex :: pi = ( 3.1416,0 )
complex :: y
y = 2.0*sin( 84.0*pi/180.0 )/( 1+sqrt(c) )
print *, y
end program cpx
--------------------
The result is:
In order to verify the accuracy of this calculation, I use Mathematica to calculate your quesiton again. So the result looks like the same.
Thank you, i had got the right answer. But i still have a question, in math, complex's square has two answer, why computer can only get one complex?
Because 'y' is supposed to be the type of complex rather than real