
import qiskit






def   lowerCamelCase__							(							__lowerCAmelCase    :    int       ,				__lowerCAmelCase    :    int							):




			"""simple docstring"""


			lowerCAmelCase_         =      qiskit.Aer.get_backend("aer_simulator"							)

			lowerCAmelCase_         =      qiskit.QuantumCircuit(4       ,				2							)
			# encode inputs in qubits 0 and 1
			if bita == 1:
						qc_ha.x(0							)
			if bita == 1:
						qc_ha.x(1							)
			qc_ha.barrier()

			# use cnots to write XOR of the inputs on qubit2
			qc_ha.cx(0       ,				2							)
			qc_ha.cx(1       ,				2							)

			# use ccx / toffoli gate to write AND of the inputs on qubit3
			qc_ha.ccx(0       ,				1       ,				3							)
			qc_ha.barrier()

			# extract outputs
			qc_ha.measure(2       ,				0							)  # extract XOR value
			qc_ha.measure(3       ,				1							)  # extract AND value

			# Execute the circuit on the qasm simulator
			lowerCAmelCase_         =      qiskit.execute(__lowerCAmelCase       ,				__lowerCAmelCase       ,				shots=1000							)

			# Return the histogram data of the results of the experiment
			return job.result().get_counts(__lowerCAmelCase							)


if __name__ == "__main__":
			_A  =	half_adder(1, 1)
			print(f"""Half Adder Output Qubit Counts: {counts}""")





from collections.abc import Callable






def   lowerCamelCase__							(							__lowerCAmelCase    :    Callable[[float], float]       ,				__lowerCAmelCase    :    float       ,				__lowerCAmelCase    :    float							):




			"""simple docstring"""


			lowerCAmelCase_         =      a
			lowerCAmelCase_         =      b
			if function(__lowerCAmelCase							) == 0:  # one of the a or b is a root for the function
						return a
			elif function(__lowerCAmelCase							) == 0:
						return b
			elif (
			    function(__lowerCAmelCase							) * function(__lowerCAmelCase							) > 0
			):  # if none of these are root and they are both positive or negative,
						# then this algorithm can't find the root
						raise ValueError("could not find root in given interval."							)
			else:
						lowerCAmelCase_         =      start + (end - start) / 2.0
						while abs(start - mid							) > 10**-7:  # until precisely equals to 10^-7
									if function(__lowerCAmelCase							) == 0:
												return mid
									elif function(__lowerCAmelCase							) * function(__lowerCAmelCase							) < 0:
												lowerCAmelCase_         =      mid
									else:
												lowerCAmelCase_         =      mid
									lowerCAmelCase_         =      start + (end - start) / 2.0
						return mid






def   lowerCamelCase__							(							__lowerCAmelCase    :    float							):




			"""simple docstring"""


			return x**3 - 2 * x - 5


if __name__ == "__main__":
			print(bisection(f, 1, 10_00))

			import doctest

			doctest.testmod()



