Sympy : Exp(-i.H.t)

江枫思渺然 提交于 2021-02-11 14:00:03

问题


I am trying to compute Hamiltonian time evolution in sympy.

H is a matrix (Hamiltonian). For example : Matrix([[1, 2], [2, 2]]

t is a symbol : t=Symbol('t')

How can I easily compute A = exp (-i.H.t) ?

I try many things but without success : Calculation of eigenvalues, eigenvectors ...


回答1:


Should be able to do something like this:

import sympy

t = sympy.symbols('t')
H = sympy.Matrix([[1, 2], [2, 2]])
A = sympy.exp(-sympy.I * H * t) # sympy.I is imaginary constant

A returns a complex sympy Matrix as expected.




回答2:


Is this what you want?

In [1]: M = Matrix([[1, 2], [2, 2]])                                                                                                                                                                        

In [2]: (I*M*t).exp()                                                                                                                                                                                       
Out[2]: 
⎡          3⋅ⅈ⋅t   √17⋅ⅈ⋅t       3⋅ⅈ⋅t   √17⋅ⅈ⋅t             √17⋅ⅈ⋅t   3⋅ⅈ⋅t         √17⋅ⅈ⋅t   3⋅ⅈ⋅t             3⋅ⅈ⋅t   √17⋅ⅈ⋅t       3⋅ⅈ⋅t   √17⋅ⅈ⋅t         √17⋅ⅈ⋅t   3⋅ⅈ⋅t            √17⋅ⅈ⋅t   3⋅ⅈ⋅t⎤
⎢          ───── + ───────       ───── + ───────           - ─────── + ─────       - ─────── + ─────             ───── + ───────       ───── + ───────       - ─────── + ─────          - ─────── + ─────⎥
⎢            2        2            2        2                   2        2              2        2                 2        2            2        2               2        2                 2        2  ⎥
⎢   4⋅√17⋅ℯ                + 68⋅ℯ                + 13⋅√17⋅ℯ                  + 85⋅ℯ                       2⋅√17⋅ℯ                + 18⋅ℯ                - 18⋅ℯ                  - 2⋅√17⋅ℯ                 ⎥
⎢   ────────────────────────────────────────────────────────────────────────────────────────────────      ───────────────────────────────────────────────────────────────────────────────────────────────⎥
⎢                                             17⋅√17 + 153                                                                                           17 + 9⋅√17                                          ⎥
⎢                                                                                                                                                                                                        ⎥
⎢ ⎛          3⋅ⅈ⋅t   √17⋅ⅈ⋅t       3⋅ⅈ⋅t   √17⋅ⅈ⋅t         √17⋅ⅈ⋅t   3⋅ⅈ⋅t             √17⋅ⅈ⋅t   3⋅ⅈ⋅t⎞                       3⋅ⅈ⋅t   √17⋅ⅈ⋅t      3⋅ⅈ⋅t   √17⋅ⅈ⋅t        √17⋅ⅈ⋅t   3⋅ⅈ⋅t                ⎥
⎢ ⎜          ───── + ───────       ───── + ───────       - ─────── + ─────           - ─────── + ─────⎟                       ───── + ───────      ───── + ───────      - ─────── + ─────                ⎥
⎢ ⎜            2        2            2        2               2        2                  2        2  ⎟                         2        2           2        2              2        2                  ⎥
⎢-⎝- 18⋅√17⋅ℯ                - 34⋅ℯ                + 34⋅ℯ                  + 18⋅√17⋅ℯ                 ⎠                  √17⋅ℯ                + 9⋅ℯ                + 8⋅ℯ                                 ⎥
⎢───────────────────────────────────────────────────────────────────────────────────────────────────────                 ────────────────────────────────────────────────────────────────                ⎥
⎣                                              17⋅√17 + 153                                                                                          √17 + 17                                            ⎦


来源:https://stackoverflow.com/questions/61460662/sympy-exp-i-h-t

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!