Quantum Teleportation Part II

We will need a few functions to do necessary mathematical operations on qubits (or more specifically on the state vector or probability vector of a quantum system). Note that I follow what I believe is the most common numbering of inputs with qubit 0 being the first input from above in the circuit and the first bit from the left in the state vector index, i.e the opposite of how we usually number bits in binary, from right to left (e.g if probability[1] in a three qubit system is 100% then the bits in the binary representation are 001 with a 1 in bit number 0, which is qubit number 2). You can see this reversal when we are doing actual bit operations (bit shifts) in the following functions.

We need a matrix multiplication routine (dot product):

def mult(a,b):
  c=[[0 for x in range(len(b[0]))] for x in range(len(a))]
  for i in range(len(a)):
    for j in range(len(b[i])):
      for k in range(len(b)):
        c[i][j]+=a[i][k]*b[k][j]
  return c

We need a matrix tensor product routine (cross product or more specifically the Kronecker product):

def kron(a,b):
  c=[[0 for x in range(len(a[0])*len(b[0]))]\
     for x in range(len(a)*len(b))]
  for i in range(len(a)):
    for k in range(len(b)):
      for j in range(len(a[i])):
        for l in range(len(b[k])):
          c[i*len(b)+k][j*len(b[k])+l]=a[i][j]*b[k][l]
  return c

We need a routine for measuring qubits (or more specifically making a measurement on the probability vector, also note that this function for simplicity measures ALL qubits in the system, but that is ok as the state is not stored back, instead we can set wanted measurements back with a qbitset function, see later):

def M(a):
  c=[[0] for x in range(len(a))]
  r=random()
  j=len(a)-1
  s=0.0
  for i in range(j):
    s+=abs(a[i][0])**2
    if s>=r:
      j=i
      break
  c[j][0]=1
  return c

We need a routine for storing the measured state of a qubit (0 or 1) back into the probability vector (by zeroing out states we now know have probability zero, after which a normalization of the probabilities are needed, see later):

def qbitset(p,v,a):
  for i in range(len(a)):
    if (i>>round(log(len(a),2)-p-1))&1!=v:
      a[i]=[0]
  return norm(a)

We need a routine for normalizing a probability vector (the sum of the probabilities must be 1):

def norm(a):
  s=0.0
  for i in range(len(a)):
    s+=abs(a[i][0])**2
  t=sqrt(s)
  for i in range(len(a)):
    a[i][0]/=t
  return a

We need a function for returning the value of a qubit (0 or 1) after a measurement (by finding the state that now has probability 1, otherwise if the qubit is still in superposition just return -1) :

def qbit(p,a):
  for i in range(len(a)):
    if a[i][0]==1:
      if (i>>round(log(len(a),2)-p-1))&1==1:
        return 1
      else:
        return 0
  return -1
Categories: Uncategorized | Comments Off on Quantum Teleportation Part II

Quantum Teleportation Part I

Making quantum circuits in Python is trivial I hear you say, there are already several packages for this, like Qiskit. Nah, you did not think a calculator had a package manager now, did you? The calculator only has a few standard packages as well as a couple of TI specific ones.

We will need “random” because quantum measurements are probabilistic, and “math” because square root is used in several formulas:

from random import *
from math import *

Other than that we will have to do with basic matrices which in Python are just arrays of arrays. That means a qubit will be something like this:

q=[[1/sqrt(2)],[1/sqrt(2)]]

The qubit above is in superposition and if measured will collapse into either “0” or “1”. Given as “[[1],[0]]” or “[[0],[1]]” respectively in our particular Python qubit speak. We are truly inside The Matrix here.

Note that it is pretty cumbersome to key in programs on a calculator so like in the example above variable names will mostly be just one letter and hardly any extra spacing will be added for readability.

Categories: Uncategorized | Comments Off on Quantum Teleportation Part I

Quantum Teleportation Emulation on a TI-84 Plus CE-T

This is not useful. The only reason I would want to do it is because it is not so straightforward (awkward is maybe the right word) on a calculator. In my book that makes it fun. For us masochistic nerds. No-one in their right mind would want to waste their time on this. The circuit I am supposed to emulate is this:

My calculator has Python. I am not a Python programmer. I hate Python. I am an old-school C programmer. But it should be possible to do as Python can do actual (even multi-dimensional) arrays and has, unlike the even more horrible and basically (pun intended) useless TI-Basic that comes with the calculator, actual functions and subroutines. Follow my progress for the next few days. Or will this be the hill I die on?

Categories: Uncategorized | Comments Off on Quantum Teleportation Emulation on a TI-84 Plus CE-T

The TI Connect CE Software

Regardless how “modern” the TI-84 graphing calculator is, the software you are supposted to use to connect it to a PC (for backup and transfer of files) has not been updated for around 2 years and it plain does not work on Windows 11 on any of my machines. Yes, I have tried all their “troubleshooting”. Be aware of this, but what does still work is a third-party solution called TILP II. Using this software, in addition to Zadig to select a functioning driver, works fine for me. As a side note: It is incredible that others are able to interface their calculators but Texas Instruments themselves cannot. Laughable.

Categories: Uncategorized | Comments Off on The TI Connect CE Software

TI-84 Plus CE-T Python Edition

From the highschool days I always used a Texas Instruments calculator. Until I switched to Hewlett-Packard. For fun I recently bought a new (sort of) TI calculator. Do I have any use for it? No. But it was on sale and it’s interesting to test a modern (sort of) graphing calculator.

More information about the “sort of” later.

Categories: Uncategorized | Comments Off on TI-84 Plus CE-T Python Edition

Symi

I am in the process of updating and adding more walks to my Symi page.

Categories: Uncategorized | Comments Off on Symi

New Pictures from Symi

A new batch of photos has been added, see https://www.islandwalking.com/piwigo/index.php?/category/166.

Categories: Uncategorized | Comments Off on New Pictures from Symi

Limnos

A skeleton Limnos page has been made. Note that this page is is still under construction and more information about the few walks I did and some of the motivation for visiting Limnos in the first place will be added shortly.

Categories: Uncategorized | Comments Off on Limnos

Deer Spotting On Limnos

See pictures from a recent trip to the island of Limnos at https://www.islandwalking.com/piwigo/index.php?/category/164

Categories: Uncategorized | Comments Off on Deer Spotting On Limnos

Where it all started with Sunflower

Way back in 1997 I bought this book. The consequences of this are some of the reasons these pages exist today and have existed for more than 25 years. I recently bought a new much expanded and way better version of this book and immediately went on updating my old Fuerteventura Page, in the hope that some day soon I will be able to visit this island again and do even more walks here.

Categories: Uncategorized | Comments Off on Where it all started with Sunflower