Jump to content

File:One dimensional quantum random walk.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 576 × 432 pixels, file size: 29 KB)

Summary

Description
English: Probability distribution resulting from one dimensional discrete time random walks. The quantum walk created using the Hadamard coin is plotted (orange) vs a classical walk (blue) after 50 time steps. The average is marked with a vertical line in the same color. Starting conditions were (1*|↑⟩+0*|↓⟩)*|0⟩.
Date
Source File:One_dimensional_quantum_random_walk.png
Author shoyer
  1. Code, python3.7:
import numpy as np
import math
import matplotlib.pyplot as plt
import time
import colorsys
import cmath
size=1000

def run_classical_randwalk(itersteps,initsim_mat):
    simmat=initsim_mat
    for iterstep in range(itersteps):
        newsimmat=np.zeros((2*size+1,2), dtype=complex)
        for matindex in range(2*size+1):
            to_right=0.5*simmat[matindex][0]
            to_left=0.5*simmat[matindex][0]
            if(matindex-1>=0):
                newsimmat[matindex-1][0]+=to_left
            if(matindex+1<=2*size):
                newsimmat[matindex+1][0]+=to_right
        simmat=newsimmat

    psisquared=np.zeros(2*size+1)
    for matindex in range(2*size+1):
        psisquared[matindex]+=abs(newsimmat[matindex][0])

    average_x=0
    min_x=0
    max_x=0
    datastartflag=0
    for matindex in range(2*size+1):
        if(datastartflag==0):
            min_x=matindex
        if(psisquared[matindex]>0):
            datastartflag=1
            max_x=matindex
        average_x+=psisquared[matindex]*(matindex-(size+1))
    print(f"validdatarange {max_x-min_x}")
    return(range(min_x-(size+1),max_x-size,2),psisquared[min_x:max_x+1:2],average_x)

def run_quantum_randwalk(itersteps,initsim_mat):
    simmat=initsim_mat
    for iterstep in range(itersteps):
        newsimmat=np.zeros((2*size+1,2), dtype=complex)
        for matindex in range(2*size+1):
            hadamard_spinup=1/math.sqrt(2)*(simmat[matindex][0]+simmat[matindex][1])
            hadamard_spindown=1/math.sqrt(2)*(simmat[matindex][0]-simmat[matindex][1])
            if(matindex-1>=0):
                newsimmat[matindex-1][1]+=hadamard_spindown
            if(matindex+1<=2*size):
                newsimmat[matindex+1][0]+=hadamard_spinup
        simmat=newsimmat

    psisquared=np.zeros(2*size+1)
    for matindex in range(2*size+1):
        psisquared[matindex]+=abs(newsimmat[matindex][0])**2+abs(newsimmat[matindex][1])**2

    average_x=0
    min_x=0
    max_x=0
    datastartflag=0
    for matindex in range(2*size+1):
        if(datastartflag==0):
            min_x=matindex
        if(psisquared[matindex]>0):
            datastartflag=1
            max_x=matindex
        average_x+=psisquared[matindex]*(matindex-(size+1))
    print(f"validdatarange {max_x-min_x}")
    return(range(min_x-(size+1),max_x-size,2),psisquared[min_x:max_x+1:2],average_x)

simmat=np.zeros((2*size+1,2), dtype=complex)
#(-size, ....,-1,0,1, size)
#first index spin up, second index spin down
simmat[size+1][0]=1.0
simmat[size+1][1]=0.0#1.0#1.0j

fig=plt.figure()
plt.xlabel("position")
plt.ylabel("probability of occurence")
q_list_return_50=run_quantum_randwalk(50,simmat)
c_list_return_50=run_classical_randwalk(50,simmat)
plt.plot(q_list_return_50[0],q_list_return_50[1],color="#e67300")
plt.plot(c_list_return_50[0],c_list_return_50[1],color="#0000a0")
xlim=plt.gca().get_xlim()
ylim=plt.gca().get_ylim()
plt.vlines(q_list_return_50[2],*ylim,color="#e67300",alpha=.7)
plt.vlines(c_list_return_50[2],*ylim,color="#0000a0",alpha=.7)
print(fig.axes)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.gca().grid(color='grey', linestyle='-', linewidth=0.25, alpha=0.5)
plt.show()
fig.savefig("One_dimensional_quantum_random_walk.svg")

Licensing

w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Probability distribution resulting from one dimensional discrete time random walks. The quantum walk created using the Hadamard coin is plotted (orange) vs a classical walk (blue) after 50 time steps.

Items portrayed in this file

depicts

28 November 2008

image/svg+xml

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current18:23, 12 September 2020Thumbnail for version as of 18:23, 12 September 2020576 × 432 (29 KB)Benjamin RenzUploaded a work by shoyer from https://commons.wikimedia.org/wiki/File:One_dimensional_quantum_random_walk.png with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

Metadata