



"""simple docstring"""





import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute




def 	UpperCAmelCase     (		A	:						int = 3       ):

		'''simple docstring'''


		if isinstance(A     ,				A       ):
				raise TypeError('number of qubits must be a integer.'       )
		if number_of_qubits <= 0:
				raise ValueError('number of qubits must be > 0.'       )
		if math.floor(A       ) != number_of_qubits:
				raise ValueError('number of qubits must be exact integer.'       )
		if number_of_qubits > 10:
				raise ValueError('number of qubits too large to simulate(>10).'       )

		_UpperCAmelCase							 =		QuantumRegister(A     ,				'qr'       )
		_UpperCAmelCase							 =		ClassicalRegister(A     ,				'cr'       )

		_UpperCAmelCase							 =		QuantumCircuit(A     ,				A       )

		_UpperCAmelCase							 =		number_of_qubits

		for i in range(A       ):
				quantum_circuit.h(number_of_qubits - i - 1       )
				counter -= 1
				for j in range(A       ):
						quantum_circuit.cp(np.pi / 2 ** (counter - j)     ,				A     ,				A       )

		for k in range(number_of_qubits // 2       ):
				quantum_circuit.swap(A     ,				number_of_qubits - k - 1       )

		# measure all the qubits
		quantum_circuit.measure(A     ,				A       )
		# simulate with 10000 shots
		_UpperCAmelCase							 =		Aer.get_backend('qasm_simulator'       )
		_UpperCAmelCase							 =		execute(A     ,				A     ,				shots=1_0000       )

		return job.result().get_counts(A       )


if __name__ == "__main__":
					print(
					    F'''Total count for quantum fourier transform state is: \
    {quantum_fourier_transform(3)}'''
					)







"""simple docstring"""





from __future__ import annotations

from cmath import sqrt




def 	UpperCAmelCase     (		A	:						int     ,				A	:						int     ,				A	:						int       ):

		'''simple docstring'''


		if a == 0:
				raise ValueError('Coefficient \'a\' must not be zero.'       )
		_UpperCAmelCase							 =		b * b - 4 * a * c

		_UpperCAmelCase							 =		(-b + sqrt(A       )) / (2 * a)
		_UpperCAmelCase							 =		(-b - sqrt(A       )) / (2 * a)

		return (
		    root_a.real if not root_a.imag else root_a,
		    root_a.real if not root_a.imag else root_a,
		)




def 	UpperCAmelCase     (		):

		'''simple docstring'''


		_UpperCAmelCase ,					_UpperCAmelCase							 =		quadratic_roots(a=5     ,				b=6     ,				c=1       )
		print(f'The solutions are: {solutiona} and {solutiona}'       )


if __name__ == "__main__":
					main()


