juicy

编程语言如何实现复数的开方运算?

  •  
  •   juicy · Dec 29, 2014 · 3231 views
    This topic created in 4169 days ago, the information mentioned may be changed or developed.
    最近看到了一个对复数开方的方法,例如运行

    >sqrt(1 + 2i)

    得到:

    >1.272019649514069 + 0.7861513777574233i

    当时就在想求复数开方是如何实现,于是在网上搜到了个方法

    http://www.qc.edu.hk/math/Advanced%20Level/Finding%20the%20square%20root%20of%20a%20complex%20number.htm

    编程语言应该不是通过上述方法来求解的吧,有做过研究的童鞋么?

    我之前有写过一篇编程语言用牛顿迭代法实现实数的开方运算的方法

    http://melon.github.io/blog/2014/11/25/recursive-algorithm-of-square-root/

    但是如果换成复数,还能用这种方法?
    10 replies    2014-12-29 21:45:03 +08:00
    invite
        1
    invite  
       Dec 29, 2014
    matlab 吧。
    ChanneW
        2
    ChanneW  
       Dec 29, 2014
    ```
    a = 1+3j
    b = a ** (0.5)

    ```
    ruoyu0088
        3
    ruoyu0088  
       Dec 29, 2014   ❤️ 1
    复数开平方就是模开平方,相角除以2,下面是演示代码:

    import math
    a = 1.0
    b = 2.0
    r = math.sqrt(math.hypot(a, b))
    theta = math.atan2(b, a) * 0.5
    print r * math.cos(theta), r * math.sin(theta)

    sqrt, hypot, atan2, cos, sin都是C语言的标准库中间的函数。
    IamI
        4
    IamI  
       Dec 29, 2014
    Complex a + bi
    a = rcosx
    b = rsinx
    (rcosx + irsinx)^n = r^n(cosnx+isinnx)
    n = 1/2
    IamI
        5
    IamI  
       Dec 29, 2014
    n = p/q, 若q > 1
    x = x + 2k * pi, k = 0, 1, ... q - 1
    juicy
        6
    juicy  
    OP
       Dec 29, 2014
    @IamI 恩,刚看到这公式
    est
        7
    est  
       Dec 29, 2014
    python

    >>> (6.0+3.0j)**(1.0/3.0)
    (1.863493910707937+0.29031663618281145j)
    juicy
        9
    juicy  
    OP
       Dec 29, 2014
    @shmilyin 不过这篇文章只讲了求实数的平方根
    shmilyin
        10
    shmilyin  
       Dec 29, 2014
    @juicy 抱歉,没看清
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3039 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 78ms · UTC 03:03 · PVG 11:03 · LAX 20:03 · JFK 23:03
    ♥ Do have faith in what you're doing.