Welcome to Walking the Greek Islands


Welcome to islandwalking.com! This site contains travelling and trekking tips for the Greek islands as well as many other islands in or not too far from the Mediterranean. It is not intended to replace any tourist or walking guides that you might have, it is only a small supplement. And indeed, it is even a prerequisite for most of the descriptions of walks on these pages that you own the guide book(s) referred to in the text.

In this blog you can also expect rants about just about anything possibly related to walking as well as music or computers or beer or other “interesting” topics.

This site is dedicated to my parents Elsa (1934-2013) and Lars (1930-2020)

Categories: Uncategorized | Comments Off on Welcome to Walking the Greek Islands

Quantum Teleportation Part IV

Here you can see the program running:

The numbers can of course be complex, so let us try a different input:

Categories: Uncategorized | Comments Off on Quantum Teleportation Part IV

Quantum Teleportation Part III

Believe it or not, even with their strict limitations, the fairly simplistic functions from the last post are sufficient building blocks to demonstrate a simple quantum circuit. Now we just have to declare the necessary quantum gates and initialize the three input qubits and we are ready to actually “build” the circuit.

This is the matrix definition of the quantum gates needed (see the drawing in the first post, “I” is needed to expand the circuit to more bits as all the gates have either a one or two bit input):

X=[[0,1],[1,0]]
Z=[[1,0],[0,-1]]
I=[[1,0],[0,1]]
H=[[1/sqrt(2),1/sqrt(2)],[1/sqrt(2),-1/sqrt(2)]]
CNOT=[[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]

The usual suspects (aka “Alice” and “Bob”) can now start doing their qubit dance routine. Let us give Alice a nice little qubit, then initialize the inputs with it (other inputs are zeroed):

#Alice qubit
q=[[-1/sqrt(2)],[-1/sqrt(2)]]
print("Alice qubit:",q)

#Initialize inputs
q=[q[0],[0],[0],[0],q[1],[0],[0],[0]]

Creating the circuit:

#Build circuit
U=kron(I,kron(H,I))
U=mult(kron(I,CNOT),U)
U=mult(kron(CNOT,I),U)
U=mult(kron(H,kron(I,I)),U)

Running the circuit on the three inputs:

#Apply circuit
q=mult(U,q)

Alice now measures her qubits, the result will be made available to Bob:

#Alice measurements
b0=qbit(0,M(q))
q=qbitset(0,b0,q)
b1=qbit(1,M(q))
q=qbitset(1,b1,q)
print("Alice measurements:",b0,b1)

Bob now, based on the measurements from Alice, can do some operations on his entangled qubit (using a small one qubit input circuit, finally turning his qubit into something matching the one Alice started with):

#Bob qubit
r=[[0],[0]]
for i in range(len(q)):
  if i&1==1:
    r[1][0]+=q[i][0]
  else:
    r[0][0]+=q[i][0]

#Conditionally apply X and/or Z
if b1==1:
  r=mult(X,r)
if b0==1:
  r=mult(Z,r)
print("Bob qubit:",r)
Categories: Uncategorized | Comments Off on Quantum Teleportation Part III

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