Skip to content

Qubit (Class)

themaddoctor1 edited this page Nov 16, 2014 · 1 revision

The Qubit class is used to allow the user to create objects that represent qubits. Each Qubit object has an X, Y, and Z variable, all of which are doubles. In Quantum Physics, the values range from 0 to 1, but the variables range from -1 to 1 in order to simplify calculations. Each method is described below.

#####public Qubit()

This is a constructor that is used for creating random Qubits. It accesses the other constructor in order to create the Qubit.

#####public Qubit(double x, double y, double z)

This constructor is used to create Qubits with a predetermined ratio. When setting the values to what they need to be, they are all divided by the Pythagorean sum of all three numbers (x^2 + y^2 + z^2). In Quantum mechanics, x, y and z are all between 0 and 1, but to make calculations simple, they can range from -1 to 1. It doesn't matter if this is followed with the input, but the values of X, Y, and Z never exceed the [-1,1] domain.

#####public int measureX()

This method is used to simulate the act of measuring Qubit on the x-axis. This is done by calculating the probability of either measurement, and then randomly choosing an outcome. It also makes changes that are part of Entanglement before returning the result.

#####public int measureY()

This method is used to simulate the act of measuring Qubit on the y-axis. This is done by calculating the probability of either measurement, and then randomly choosing an outcome. It also makes changes that are part of Entanglement before returning the result.

#####public int measureZ()

This method is used to simulate the act of measuring Qubit on the z-axis. This is done by calculating the probability of either measurement, and then randomly choosing an outcome. It also makes changes that are part of Entanglement before returning the result.

#####public static void random(int tier)

This method recursively calls itself with a value of tier - 1, and repeatedly generates random numbers. It is intended to generate more random numbers, although there could be a better way to write the method.

Clone this wiki locally