import numpy as np
import math
from qiskit.circuit import Parameter
from qiskit import *
from math import pi,cos,sin,tan,atan

from qiskit import QuantumCircuit, transpile, Aer, IBMQ
from qiskit.tools.jupyter import *
from qiskit.visualization import *
from qiskit.providers.aer import QasmSimulator
def execute_circuit_sv(quantum_circuit):
    statevector_simulator = Aer.get_backend('statevector_simulator')
    result = execute(quantum_circuit, statevector_simulator).result()
    statevector_results = result.get_statevector(quantum_circuit)
    circuit_diagram = quantum_circuit.draw('mpl')
    b_sphere = plot_bloch_multivector(statevector_results)
    
    return statevector_results, circuit_diagram, b_sphere


param_theta = Parameter('θ')
n = int(input("Enter the number of qubits(Max no. 5):  "))
bell = QuantumCircuit(n, name='entanglement')
rot = int(input("Press 1 to select RX gate, 2 for RY gate"))
if rot==1:
   bell.rx(param_theta,0)
elif rot==2:
    bell.ry(param_theta,0)
else:
    print("Please Enter the correct option")

control = int(input("Press 1 to use CNOT gate and 2 for CY gate"))
if control==1:
    for i in range (0,n-1):
        bell.cx(i,i+1)
elif control==2:
    for j in range(0,n-1):
        bell.cy(j,j+1)
else:
    print("Please press the correct option")

import numpy as np
from math import pi,cos,sin,tan,atan
x = float(input("Enter the angle multiplier: "))

bell = bell.bind_parameters({param_theta:  (x * np.pi)})


result, img, bsphere = execute_circuit_sv(bell)
img

bsphere

print(result)

from qiskit.quantum_info import DensityMatrix

D = DensityMatrix(bell)
print(D)


from qiskit.quantum_info import entropy
vn_entropy = entropy(D, base=2)
print(vn_entropy)

r = x / 0.5
if x % 0.5 == 0 and r % 2 != 0:
    print("Maximal Entanglement")
else:
    print("Partial Entanglement")









