Click here to Skip to main content
15,879,535 members
Articles / General Programming / Algorithms

Quantum Computer and Algorithms 1

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
19 May 2014CPOL12 min read 16.1K   217   21   2

The aim of this essay is to explain what kind of hardware the quantum computer is going to have, how to write and compile quantum algorithms. First computers had single kernel. Later, the amount of kernels increased. However, intrinsically the logic of processing the codes rowed couldn’t be prevented. For instance, an f function inside the codes couldn’t be processed by segmenting. It was processed by a rowed logic. For instance, examining the function of f = sin (pi / 5) + log10 (3), first the value of sin (pi / 5) was computed, then the value of log10 (3) was computed and after that the sum of these two value was computed and the value of f function was found. Let’s think how a quantum computer should process this kind of functions. Once the program starts working, sin value is sent to an operator, log10 value is sent to another operator. There is another operator which adds these two values together and another which writes the value of f function. Thinking this way, a sequence of actions is degraded to dual actions at the lowest rank and these dual actions work up to by linking up with each other. Hereby, all the operators needed for the work, function at the same time and run for a conclusion. Running for a conclusion means there is not an absolute conclusion. In other words, for quantum computer there is not a certain conclusion but attaining it the fastest. For example, no computer can calculate the real, current or future value of the f function above. However, quantum computer attached to sufficient hardware power is going to calculate the Taylor expansion at sin and log fastest in an essential resolution. Now let’s give an example with an absolute outcome. Let’s consider a quantum computer which writes the lowest value in a numeral series like 12, 9, 4, 2, 7, 8. These numbers are dispersed to the operators and for instance 7 said it’s the lowest, and then 4 said that it’s the lowest and then 2 said it’s the lowest. For quantum computer there is no absolute value of the lowest, or no meaning in reality. The lowest affecting relevant states are the subject here. By “states” we mean a microprocessor or a group of microprocessor.

In the beginning, in the quantum computer there is no connection between states but physical connection is done completely. Just like the neurons in human brain having no connection at a certain time (the moment of birth or before) but contacting with the start of learning , software connection is built when the actions that quantum computer will perform comes up and outcomes are produced. Human brain designates what kind of connections will come up with the start of learning. The examples below include what kind of connections states should establish while the codes in quantum computer processed.

1. Example<o:p>

1) int a = 10;<o:p>

2) Cosole.Write(a);<o:p>

1. State

2. State (Screen)

When the program was compiled, the 1st State was left for a. It was told the change of the 1. State to affect the 2nd State and not to perform any actions other than affecting the 2nd State. When the program starts functioning, actions don’t occur in a row. For example, the 2nd State could have started working before the 1. State but no outcome is written on the monitor. Soon the value for 10 is given to the 1st State.

2. Example

1) int a = 10;<o:p>

2) a = 12;<o:p>

3) Console.Write(a);<o:p>

1.State

2.State (Screen)

When the program starts functioning, for instance the 2nd line processed first. Its written 12 to the 1st state, the change is reported to the 2nd state and its written 12 to the monitor. Then, 1st line is processed and 10 is written to the monitor. When the quantum algorithms are written, the action of codes is thought independent from the order of codes.

3. Example

1) int a = 5;<o:p>

2) int b = 10;<o:p>

3) int c = a * b;<o:p>

4) Console.Write(c);<o:p>

Image 1

For example, After some time the value of 10 was written on the 3rd state. But it was stated during the resilience that for the value of c to compose, it’s necessary that the value of a must appear.After a while, 5 was written on the 2nd state. So that the values of 2nd and 3rd states was obtained, it was said to the Quantum ALU unit to multiply these two action and inform the 1st state. The 1st state changed. 4th state was informed and it was written on the monitor.

4. Example

 

1) int x = 10;

2) double a = Math.PI / 4;<o:p>

3) double r = (5 – 20 / x) * (x * x + Math.Sin(a));<o:p>

4) Console.Write(r);

 

Image 2

Image 3

<o:p>

All calculations are degraded to dual actions. Like (Left State) – Action – (Right State). With the resilience of the program, response relation in the shape is subtracted. For example, at a certain time, the value of a was pi / 4. This value was reported to Quantum ALU state which will be affected. Quantum ALU starts to calculate the sin(a) value with Taylor expantion quickly. Later on, 12th state will report the photo of the value of sin(a) becomes clearer gradually to the 11th state considering the threshold value overflow of resolution. Right now, depending on the functioning of the program, x variable got the value of 10 and written to the 6th state. So that the value of 5th state is ready, the value of 20/10=2 that ALU calculated was written to the 4th state. So that the 3th state is ready,the value of 5-2=3 was written to the 2nd state. Perhaps before these actions, value for x was written to the 9th and 10th states. Independent from the ordering, Actions continued and value for r was calculated and written to the monitor. At this point let’s say, after a while user changed the value for a to pi/5. Value for a is reported to the 12th state that it will be affected and the new value for sin(a) starts to be calculated.In conclution, this change is made for all the states that are affected, not for all values for r. At this part, the change of a affects 12, 11, 7 and 1st states incrementally.

5. Example

 

1) int[] array = new int[] { 7, 2, 5, 3, 9, 8 };

2) int minValue = array.Min();<o:p>

3) Console.Write(minValue);

Image 4

Values for 1, 2, 3, 4, 5, 6 are written to these states. 7th states keep the minValue. When the program starts to work, for example 4th state evaluates its situation, sees that no value was given to 7th state and gives its own value, 3, to the 7th state as the minValue. The value for 7th state was changed, written on the monitor. Then it evaluates the 6th states situation but observes that 7th states value is lower. The value for 7th state doesn’t change. These actions continue until all states consider their situations. After a while, 2nd state has its situation evaluated and it appoints itself to the 7th state

6. Example

<o:p> 1) int[] array = new int[] { 7, 2, 5, 3, 9, 8 };

2) int[] array1 = array.OrderBy(p => p);<o:p>

3) Console.Write(array1);

 

Image 5

 

Image 6

All codes starts working at the same time. For instance, 2nd line started to function first. Ordering of the array set is required. It’s expected the array set executive to take position in its state first. The array set executive takes the 1st state.6 states which are necessary for the set tries to install itself to the components of the set. Perhaps at that precise moment array1 was asked to be sorted from the array set. Meanwhile the set components were installed, comparator connections are also set. This ordering process in reality is the quantum expansion of bubble sort. The only difference is that while the positions of set components are in motion in bubble sort, the positions and comparator connections are stabile in quantum sort. In bubble sort, (n - 1) * n / 2 comparator actions are done over one or more operators. In Quantum Sort, (n - 1) * n / 2 comparator makes a single comparison at the same time and aims to end the whole action in an instant. Array set starts the comparison action and for array1 1st zone of the 1st state is left. Similarly, for the components of array1; 2, 3, 4, 5, 6, 7th states increasing, decreasing and the amount of comparison number values are held in the 1st zones of 2, 3, 4, 5, 6, 7th states. As soon as all the comparators are installed, it starts the comparison action. For instance, 2nd and 6th states get compared. Increasing and decreasing values are empty for both two states. Because 6(9) > 2(7), the decreasing part of 6th state is made 2;the increasing part of 2nd state is made 6 and comparison number values get increased by one. The first comparison is done. Now, for example, 6th and 3th states are compared. According to 6(9) > 3(2), 6th state had a decreasing value before 2(7). Now, 3th and 2nd states are compared. According to 3(2) < 2(7), it is closer to the 6th state than it is to the 3th state, so that 6th state keeps its decreasing value safe, 3th state’s increasing value becomes 6. Comparison number values increases by one again. While actions keep going like this, for example, 4th state has completed ( n – 1 ) number of comparison. So the increasing and decreasing values for 4th state are obvious. The ordering of 5, 4, 2nd states are formed at the beginning. It is reported that the a piece of the photo became clearer to the (1.1) array1 set in the 1st zone of 1st state.Array1 reports this change to the monitor and sequence is written to the monitor with its values. (3, 5, 7). With the other pieces becoming clearer, whole picture is formed on the monitor. How this picture must be written on the monitor is not a subject of this essay. It is a subject of operating system which was formed by quantum substructure. (Quantum Operating System). It is possible with quantum computer that RAM, graphics card, hard-driver and real-time DAC cards will die out, maybe there will be millions of operators which floats in the light pool and linked together. And maybe instead of ordinary rectangular prism-shaped operator designs, the operators will be glued to a spheres surface proportionally and face each other by the help of laser.

7. Example

<o:p> 1) int[] array = new int[] { 7, 2, 5, 3, 9, 8 };

2) int[] array1 = array.OrderBy(p => (5 - 20 / p) * (p * p + Math.Sin(Math.PI / 5)));<o:p>

3) Console.Write(array1);

Image 7

In the previous example, while states were spared for array components, the increasing and decreasing values were written on zones, but for the new-formed array1 there was no zone value. Hence, the main array was considered for the zone values. Things explained in this part don’t occur in a sequence like they were written and behavior of zones are designated by kompi while zones are formed. Let’s say that 2nd state has 7 for value. For array1, decreasing value, increasing value, zone value records are opened in the 1st zone of the 2nd state. This zone value is written the 1st zone of 13, 16 and 17th states. Last, 8th state is calculated. Because 8th has changed, it writes this value to the 1st zone of 2nd state. So that, 1st zone of the 2nd state is ready for the comparators. Therefore, for the genetic system of the states, data are directed and the array1 picture formed is written to the monitor.

8. Example

 

 

1) int[] array = new int[] { 7, 2, 5, 3, 9, 8, 6, 11, 18, 12, 10 };

2) int sum = array.Sum();<o:p>

3) Console.Write(sum);<o:p>

4) Wait(5000)<o:p>

{<o:p>

array[2] = 1;<o:p>

}

Image 8

<o:p>

When the program works, the value of 92 is calculated in the 21st state and is written to the monitor.22th state is left for the code in the 4th line. This state makes the component in the 2nd index of the array 1 after 5 seconds, thereby the areas colored in the connections diagram are affected, outcome is achieved and the outcome, 88, is written on the monitor.

9. Example

<o:p>

1) int array = new int[]

{<o:p>

385697,<o:p>

237865,<o:p>

469318,<o:p>

127626,<o:p>

893461<o:p>

};<o:p>

2) int sum = array.Sum();<o:p>

3) Console.Write(sum);

 

Image 9

In this example, summing up five six-digit number and write it on the monitor is the subject. In the previous examples involving arithmetical operations, there was a problem. Before the operations of the states at the upper stages, the states at lower stages were not able to operate and got to wait state. Just like a flowing water easing down because of a barrage in front of a waterfall, the amount of actions in a unit of times was decreasing. In this example, upper stages reports the minimum interaction needed by lower stages and make sure that all states works at the same time. The work logic of these states is similar to teaching multi pickup for the first time in elementary school. 7 + 5 + 8 + 6 + 1 = 27. We go on like “7 from 27 and carry the 2.”

Review

<o:p>

Now let’s think a more complicated project beyond the searching engines. Let’s think that all the land, air and marine vehicles are out of human control and manipulated by a satellite sent to the space. Let’s think that this satellite also watches behaviors of humans, pets etc. other than vehicles. In addition, variables like road works, map updates, traffic regulations, vehicle care etc. are updated instantly. Let’s say that the aim of this project is zero accident, maximum speed and the safest travelling. Of course, it could be found much more complicated projects (space projects etc.) than this one. Right at this point, the computer in this satellite should be working with the reflexes of a brain. Computers close to the reaction and connection speed of brain at the moment of showing the necessary reflection when a person turns his/her ankle while walking and calculating how to stand should be developed. Otherwise, contrary to the people who succeed standing in a critical way, robots will crash to the floor.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionAny references or papers for your amazing code? Pin
Hassan201018-Sep-15 10:45
Hassan201018-Sep-15 10:45 
AnswerRe: Any references or papers for your amazing code? Pin
databaseobjectmodel20-Dec-15 16:21
databaseobjectmodel20-Dec-15 16:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.