myDrink, which is a character in superposition.
m means mineral water and t means tap water. Both values are in an equal superposition and have equal amplitudes.
Then, we define the variable yourDrink to have the value m.
yourDrink contains only one possible value, it is still represented by an amplitude. The amplitude is 1 for m and 0 for any other character.
The amplitudes of values of myDrink and yourDrink are:

Seeing a Joint Value
According to quantum theory, the variablesmyDrink and yourDrink also have a joint value. A joint value represents the possible combinations of the classical values in myDrink and yourDrink, together with their amplitudes.
In the classical world, this is an obvious thing, and usually we don’t spell it out. For example, if we have two marbles, a blue one and a green one, then we can consider the two marbles together, and their joint color value is (blue, green). There is nothing special about it, as each marble has exactly one color.
In the quantum world, the same idea applies. The joint value of our drinks contains all the possible combinations of the classical values in myDrink and yourDrink, as we can see below:

join() to tell the Rhyme simulator to consider these two values together, so that we can see their joint value in the debugger.
join() itself does not change the values or their amplitudes. In fact, it’s merely a simulation facility, intended mostly for education purposes. Omitting join() does not change the outcome of a Rhyme program. In nature, the joint value always exists, whether we have classical marbles or quantum drinks.
The debugger now displays the amplitudes of myDrink and yourDrink as part of their joint value:


('m', 'm') is:
Similarly, the amplitude of ('t', 'm') is also:
For all possible joint values, the amplitudes are calculated as:

Flipping One Drink
And now let’s do something really interesting. We’re going to flipyourDrink, but only when myDrink is t.
We use a classical function to describe this operation:
myDrink is t, it flips yourDrink, and if myDrink is m, it leaves yourDrink unchanged.
We now apply this operation to the joint value:
flip() swaps amplitudes between paired joint values. For this operation, the relevant values form reversible pairs.
In our example, ('t', 'm') and ('t', 't') form such a pair. Before the flip, the branch ('t', 'm') has amplitude , while ('t', 't') has amplitude 0. We can imagine that ('t', 't') has been there all along, but only with amplitude 0. The flip() exchanges these amplitudes.
So, ('t', 'm') now has amplitude 0, while ('t', 't') has amplitude . The ('m', 'm') branch remains unchanged.
Our function does not map every possible character combination back and forth. For example, both ('t', 't') and ('t', 'k') map to ('t', 'm'). This does not cause a problem here because ('t', 'k') is not a relevant joint value: it has amplitude 0. What matters is that the relevant pair ('t', 'm') and ('t', 't') maps back and forth consistently.
Let’s look at the joint amplitudes in the debugger.


What Is Entanglement?
Notice that the values ofmyDrink and yourDrink are now correlated.
The values are no longer independent. The value of one is connected to the value of the other.
This is called entanglement.
The important point is that the relationship between the two values is contained in the joint amplitudes.
We can no longer describe myDrink and yourDrink as independent quantum values.
Instead, we describe the possible combinations of the two values together.
Observing the Entangled Values
Let’s now observemyDrink.
There is a 50% chance that myDrink is observed as m, because the total probability of the branches containing m as the first character is one-half.
For similar reasons, there is a 50% chance of the outcome t.
As a reminder, the probability is just the absolute square of the amplitude.
And now, let’s see the outcome.

myDrink collapses to m.
Since only the branch containing m remains, the value of yourDrink is also m.
Both values now have definite classical values, and the simulator no longer treats them as a quantum superposition.
A Simple Coordination Task
This gives us a simple example of coordination. Imagine I am on Earth, and you are on the moon. When we observe our entangled variables, we get random results, but the results always follow the same relationship. So, if I getm, you get m as well.
If I get t, you get t as well.
It doesn’t matter who observes first. Once one value is observed, the other value is determined by the relationship between them.
That’s the basic idea of entanglement.
And that’s how you implemented Entanglement in Rhyme!