Cluster States

In quantum information and quantum computing, a cluster state is a type of highly entangled state of multiple qubits. Cluster states are generated in lattices of qubits with Ising type interactions. A cluster C is a connected subset of a d-dimensional lattice, and a cluster state is a pure state of the qubits located on C. Another way of thinking of cluster states is as a particular instance of graph states, where the underlying graph is a connected subset of a d-dimensional lattice. Cluster states are especially useful in the context of the one-way quantum computer.

more ...

Renyi entropy of the wormholes

In information theory, the Rényi entropy generalizes the Hartley entropy, the Shannon entropy, the collision entropy and the min entropy. Entropies quantify the diversity, uncertainty, or randomness of a system. The Rényi entropy is named after Alfréd Rényi.

more ...

Geometrical Optics in Continuum

Fermat’s Principle

Fermat’s Principle is

$$\delta s=\delta\int n\dd \ell=0$$

If we choose the path …

more ...

Javascript 学习小记

研究了一下Linux平台做笔记的软件,发现为知笔记半死不活,bug很多。其他的笔记程序尝试了leanote等各种软件都感觉难以使用,要么功能太弱,要么没有linux客户端。总计一下我想要的笔记软件的要求:

  • 支持Markdown
    • 支持嵌入代码块的语法高亮
    • 支持latex输入一些基本的数学公式
  • 电脑上使用起来方便
  • 方便用手机查看
  • 方便分享给其他人
  • 软件稳定,无明显BUG,体积小,依赖少

最终我发现了NBViewer+Jupyter Notebook+Github/Gist的组合。

注:现在更倾向于用Jupyter Notebook+Pelican的组合了,参见Blogging with Jupyter and Pelican

  • 存在的问题:刷新麻烦,需要手动加?flush=true
  • 解决方案:UserScript脚本Refresh NBViewer Button。具体请看描述。

为了写这个脚本,特意学习了一点js

more ...

Jupyter Notebook的配置

# 默认目录

jupyter notebook --generate-config
vim /home/zpj/.jupyter/jupyter_notebook_config.py#查找dir设定notebook根目录

找到c.NotebookApp.notebook_dir条目,修改为启动jupyter后打开的目录,如/home/zpj/code

# 配置pylab, matplotlib默认载入

导入库,内联svg输出,需要运行:

%pylab
%matplotlib inline
%config InlineBackend.figure_format = 'svg'

# 配置ipython

# 目的

  • 设置pylab环境自动载入
  • 为notebook设置inline显示,使得图片嵌入在文档中
  • 设置矢量svg格式可以使生成的图像在任何屏幕下获得清晰的显示

# 步骤

创建配置文件

ipython profile create

编辑ipython_config.py

vim ~/.ipython/profile_default/ipython_config.py

修改内容为

c.InteractiveShellApp.pylab = "inline"
c.InlineBackend.figure_formats = ['svg']
c.InteractiveShellApp.pylab_import_all = True
more ...

最大子序列和系列问题

In [2]:
def maxsum(l):
    '''最大子序列和问题'''
    m=s=0
    for i in l:
        s=max(s, 0)
        s+=i
        m=max(m, s)
    return m
In [3]:
def maxprod(l):
    '''最大子序列积问题'''
    m=pos=0
    neg=0
    for i in l:
        pos=max(1, pos)*i
        neg=neg*i
        if i<0:
            pos, neg=neg, pos
        m=max(m, pos)
    return m
more ...

Invariance of Euler-Lagrange Equations

E-L is deduced from the Hamilton’s principle

$$\delta S=\delta\int L(\bm q, \dot{\bm q}, t)dt …
more ...


From d’Alembert to Lagrange

Nowtonian

Assume \(\bm F\) is active force and \(\bm R\) is constraint force. Then for …

more ...