Skip to content

Commit e544ab8

Browse files
Fix README wrt new nonlocality_threshold
1 parent 5af9a89 commit e544ab8

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ Let's say we want to characterise the nonlocality threshold obtained with the tw
3030
Using `BellPolytopes.jl`, here is what the code looks like.
3131

3232
```julia
33-
julia> using BellPolytopes, LinearAlgebra
33+
julia> using BellPolytopes, Ket, LinearAlgebra
3434

35-
julia> N = 2; # bipartite scenario
36-
37-
julia> rho = rho_GHZ(N) # two-qubit maximally entangled state
38-
4×4 Matrix{Float64}:
35+
julia> rho = state_phiplus(Float64) # two-qubit maximally entangled state
36+
4×4 Hermitian{Float64, Matrix{Float64}}:
3937
0.5 0.0 0.0 0.5
4038
0.0 0.0 0.0 0.0
4139
0.0 0.0 0.0 0.0
4240
0.5 0.0 0.0 0.5
4341

44-
julia> measurements_vec = icosahedron_vec() # Bloch vectors forming an icosahedron
42+
julia> φ = (1 + 5) / 2;
43+
44+
julia> v = [0 1 φ; 0 1 -φ; 1 φ 0; 1 -φ 0; φ 0 1; φ 0 -1] / sqrt(2 + φ) # Bloch vectors forming an icosahedron
4545
6×3 Matrix{Float64}:
4646
0.0 0.525731 0.850651
4747
0.0 0.525731 -0.850651
@@ -50,13 +50,11 @@ julia> measurements_vec = icosahedron_vec() # Bloch vectors forming an icosahedr
5050
0.850651 0.0 0.525731
5151
0.850651 0.0 -0.525731
5252

53-
julia> _, lower_bound, upper_bound, local_model, bell_inequality, _ =
54-
nonlocality_threshold(measurements_vec, N; rho = rho);
53+
julia> σ = gellmann(2);
5554

56-
julia> println([lower_bound, upper_bound])
57-
[0.7784, 0.7784]
55+
julia> mes = [[(σ[1] - v[i, 1] * σ[2] - v[i, 2] * σ[3] - v[i, 3] * σ[4]) / 2, (σ[1] + v[i, 1] * σ[2] + v[i, 2] * σ[3] + v[i, 3] * σ[4]) / 2] for i in axes(v, 1)];
5856

59-
julia> p = correlation_tensor(measurements_vec, N; rho = rho)
57+
julia> p = tensor_correlation(rho, mes, 2; marg = false)
6058
6×6 Matrix{Float64}:
6159
0.447214 -1.0 -0.447214 0.447214 0.447214 -0.447214
6260
-1.0 0.447214 -0.447214 0.447214 -0.447214 0.447214
@@ -65,13 +63,18 @@ julia> p = correlation_tensor(measurements_vec, N; rho = rho)
6563
0.447214 -0.447214 0.447214 0.447214 1.0 0.447214
6664
-0.447214 0.447214 0.447214 0.447214 0.447214 1.0
6765

68-
julia> final_iterate = sum(local_model.weights[i] * local_model.atoms[i] for i in 1:length(local_model));
66+
julia> lower_bound, upper_bound, local_model, bell_inequality = nonlocality_threshold(p);
67+
68+
julia> println([lower_bound, upper_bound])
69+
[0.778, 0.779]
70+
71+
julia> final_iterate = sum(weight * atom for (weight, atom) in local_model);
6972

7073
julia> norm(final_iterate - lower_bound * p) < 1e-3 # checking local model
7174
true
7275

7376
julia> local_bound(bell_inequality)[1] / dot(bell_inequality, p) # checking the Bell inequality
74-
0.7783914488195466
77+
0.7785490499446976
7578
```
7679

7780
## Under the hood

0 commit comments

Comments
 (0)