I'm very glad to announce today that my quantum circuit simulator , after a devepment process for a month, can now support the simulation of four basic quantum algorithms:

1. Grover: Search the element from an unstructured database.

2.Simon: Determine a hidden s.

3.Deutsch josa algorithm: Determine whether a function is constant or balanced.

4.Berstein Varizani: For a given function f(x)=ax+b, determine a,b.

You can see the code examples in page

I have written unittest for all of the four algorithms to make sure that they run correctly.

I wish the readers of this page can play around and give me some feedback!

This is an exmple of using Duetch Josa algorithm in my simulator.

First, you need to import the Algorithm module. All quantum algorithms are implemented in this module.

Next, define your own DuetchJosa quantum algorithm class. The input parameter is the number of qubits.

A very important feature of my alorithm class is that I will compile the quantum circuit of each algorithm for you. You only need to pass the function definition to me.

For example, if the function is a constant function whose values all equal one. You only need to give me a function list [1,1,1,1,1,1,1,1]. And then call the "construct_circuit()" method.

```
import Algorithm
alg = Algorithm.DuetchJosa(4)
uf = [1, 1, 1, 1, 1, 1, 1, 1]
alg.set_input(uf)
alg.construct_circuit()
alg.compute_result()
if(alg.balance):
print("Balance")
else:
print("Constant")
alg.circuit.state.show_state_dirac()
```

This is the screen shot of the output after excuting the above code:

For using BV algorithm in my simulator, the code structure is the same. The only difference is that you should pass two value a and b as input.

```
import Algorithm
alg = Algorithm.BVAlgorithm(9)
# Initialize a random a and b, such that the input function is
# f(x)=ax+b
a=0b10101001
b=1
alg.set_input([a,b])
alg.construct_circuit()
alg.compute_result()
print(f"The result is a={alg.computed_a_value}")
alg.circuit.state.show_state_dirac()
```

This is the output:

For using Grover algorithm in my simulator, the code structure is the same. The only difference is that you should the values of your database as input.

```
import Algorithm
gvalg = Algorithm.Grover(4)
# Here, db_uf represent a database. Only the third value is 1
db_uf = [0,0,1,0,0,0,0,0]
gvalg.set_input(db_uf)
gvalg.construct_circuit()
gvalg.compute_result()
result = gvalg.solutionprint(f"The key {x} has value one")
```

This is the output:

For using Simon algorithm in my simulator, the code structure is the same. The only difference is that you should the values of your function as input.

```
qubit_num=6
inputsize = 6 // 2
n = (1 << (inputsize))
# We set s=0b101=5 s = 0b101
# uf represent the function f(x)=uf[x]
uf = [7, 5, 0, 6, 5, 7, 6, 0]
simonalg = Algorithm.Simon(qubit_num)
simonalg.set_input(uf)
simonalg.construct_circuit()
simonalg.compute_result()
print(f"The solution is {simonalg.solution}")
```

The output is

## Comments