The difference between the simulator and quantum hardware is something that can't be avoided, there must be a difference, because of noise. The one thing that I noticed from the histograms is that the state with maximum probability for simulator was '11000' and for quantum hardware, the state with maximum probability was '10000'. I think this difference is caused by the small shots number. I have run the same circuit on ibmq_essex
with 8192 shots and here is what I obtained:

So shots number can help to improve the results. Measurement error mitigation will help a little bit to improve this result even farther, but maybe the final result will be still unsatisfactory. Also, I want to mention that CNOT gates are noisier then single-qubit gates and in the circuit, we have 4 CNOTs applied on the q[4]
qubit, so I guess this has its effect. If q[4]
is always '1', then we can just replace CNOTs with X gates applied to the corresponding qubits: this will reduce errors as well. Moreover if q[4]
is not linked with some q[n]
qubit the quantum compiler will introduce SWAP gates to be able to apply CNOT between q[4]
and q[n]
. This means that we will have even more CNOTs in the circuit then we have introduced (for more about SWAP and connectivity I recommend this video). Here is the connectivity of ibmq_essex
taken from this site:

If our q[4]
corresponds to 4th qubit in the picture (not sure about this) then I imagine that the quantum compiler will introduce a lot of SWAP gates and, thus, the error will increase just because of not optimally chosen qubit.
Here is the final circuit after optimization_level=3
(Note how many CNOTs are there):

From here, if I am not mistaken, we can deduce that q[4]
is the 3rd qubit from ibmq_essex
.
Here is the code that I have used:
from qiskit import *
from qiskit.visualization import *
%config InlineBackend.figure_format = 'svg'
provider = IBMQ.load_account()
qpu_backend = provider.get_backend('ibmq_essex')
quantum_register = QuantumRegister(4, 'q')
ancillary_qubit = QuantumRegister(1, 'a')
classical_register = ClassicalRegister(5, 'c')
circuit = QuantumCircuit(quantum_register, ancillary_qubit, classical_register)
circuit.h(quantum_register)
circuit.u1(-0.0707, quantum_register[0])
circuit.u1(-0.134, quantum_register[1])
circuit.u1(-0.236, quantum_register[2])
circuit.u1(-0.314, quantum_register[3])
circuit.x(ancillary_qubit[0])
circuit.cx(ancillary_qubit[0], quantum_register[0])
circuit.cx(ancillary_qubit[0], quantum_register[1])
circuit.cx(ancillary_qubit[0], quantum_register[2])
circuit.cx(ancillary_qubit[0], quantum_register[3])
circuit.u1(0.385, quantum_register[0])
circuit.u1(0.605, quantum_register[1])
circuit.u1(1.02, quantum_register[2])
circuit.u1(1.884, quantum_register[3])
circuit.h(quantum_register)
circuit.measure(quantum_register[0], classical_register[0])
circuit.measure(quantum_register[1], classical_register[1])
circuit.measure(quantum_register[2], classical_register[2])
circuit.measure(quantum_register[3], classical_register[3])
circuit.measure(ancillary_qubit[0], classical_register[4])
qpu_result = execute(circuit, backend=qpu_backend, shots=8192, optimization_level=3).result().get_counts()
plot_histogram(qpu_result, legend=[qpu_backend],figsize=(10,5))