关于FORTRAN对复数的计算问题

 我来答
Miafifi
推荐于2017-09-03 · TA获得超过451个赞
知道小有建树答主
回答量:277
采纳率:93%
帮助的人:171万
展开全部

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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式