(* instalar el paquete QuantumFramework, necesario para visualizar la esfera de Bloch *)
PacletInstall["Wolfram/QuantumFramework"]
Needs["Wolfram`QuantumFramework`"]
                
                
qBloch[q_] := QuantumState[q]["BlochPlot"]

qNormalized[q_] := q / Norm[q]

qMeasure[q_] := (#^2 &) /@ Norm /@ q

ket0 = {1,0}
ket1 = {0,1}

(* compuertas de Pauli *)
X = {{0, 1}, {1, 0}}; Y = {{0, -I}, {I, 0}}; Z = {{1, 0}, {0, -1}};Id = {{1, 0}, {0, 1}};

(* Rotaciones *)
Rx[t_]:=MatrixExp[-I t /2 X]
Ry[t_]:=MatrixExp[-I t /2 Y]
Rz[t_]:=MatrixExp[-I t /2 Z]


H = {{1, 1}, {1, -1}}/ Sqrt[2]; H // MatrixForm 


(* para chequear si dos vectores corresponden al mismo estado cuántico *)
qCollinear[U_, V_] := Solve[U == coef V, coef, Complexes]

qEq[U_, V_] := Module[{solution, c},
solution = qCollinear[U, V];
If[solution == {}, {},
c = solution[[1, 1, -1]];
{re^i\[Theta] -> c, r -> Abs[c], \[Theta] -> Arg[c]}
]]

A = {{a, -b\[Conjugate]}, {b, a\[Conjugate]}}; A // TraditionalForm 
B = {{c, -d\[Conjugate]}, {d, c\[Conjugate]}}; B // TraditionalForm 

(* para verificar que una matriz es unitaria especial *)
qSpecial[X_] :=  X[[1, 1]] == Conjugate[X[[2, 2]]] &&  X[[1, 2]] == -Conjugate[X[[2, 1]]]

qSpecial[A . B] 

$Assumptions = {\[Theta] \[Element] Reals}

qSpecial[Rx[\[Theta]]]