@@ -316,21 +316,14 @@ This can be verified in :code:`toqito` as follows.
316316
317317 >> > # Calculate the unentangled value of the BB84 extended nonlocal game.
318318 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
319+ >> > import numpy as np
319320 >> >
320321 >> > # Define an ExtendedNonlocalGame object based on the BB84 game.
321322 >> > bb84 = ExtendedNonlocalGame(bb84_prob_mat, bb84_pred_mat)
322323 >> >
323324 >> > # The unentangled value is cos(pi/8)**2 \approx 0.85356
324- >> > ' %.2f ' % bb84.unentangled_value()
325- ' 0.85'
326-
327-
328- .. note::
329- You do not need to use `' %.2f ' % ` when you use this function.
330- We use this to format our output such that `doctest` compares the calculated output to the
331- expected output upto two decimal points only. The accuracy of the solvers can calculate the
332- `float ` output to a certain amount of precision such that the value deviates after a few digits
333- of accuracy.
325+ >> > np.around(bb84.unentangled_value(), decimals = 2 )
326+ 0.85
334327
335328 The BB84 game also exhibits strong parallel repetition. We can specify how many
336329parallel repetitions for :code: `toqito ` to run. The example below provides an
@@ -340,21 +333,14 @@ example of two parallel repetitions for the BB84 game.
340333
341334 >> > # The unentangled value of BB84 under parallel repetition.
342335 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
336+ >> > import numpy as np
343337 >> >
344338 >> > # Define the bb84 game for two parallel repetitions.
345339 >> > bb84_2_reps = ExtendedNonlocalGame(bb84_prob_mat, bb84_pred_mat, 2 )
346340 >> >
347341 >> > # The unentangled value for two parallel repetitions is cos(pi/8)**4 \approx 0.72855
348- >> > ' %.2f ' % bb84_2_reps.unentangled_value()
349- ' 0.73'
350-
351-
352- .. note::
353- You do not need to use `' %.2f ' % ` when you use this function.
354- We use this to format our output such that `doctest` compares the calculated output to the
355- expected output upto two decimal points only. The accuracy of the solvers can calculate the
356- `float ` output to a certain amount of precision such that the value deviates after a few digits
357- of accuracy.
342+ >> > np.around(bb84_2_reps.unentangled_value(), decimals = 2 )
343+ 0.73
358344
359345 It was shown in :cite: `Johnston_2016_Extended ` that the BB84 game possesses the property of strong
360346parallel repetition. That is,
@@ -374,21 +360,14 @@ using :code:`toqito` as well.
374360
375361 >> > # Calculate lower bounds on the standard quantum value of the BB84 extended nonlocal game.
376362 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
363+ >> > import numpy as np
377364 >> >
378365 >> > # Define an ExtendedNonlocalGame object based on the BB84 game.
379366 >> > bb84_lb = ExtendedNonlocalGame(bb84_prob_mat, bb84_pred_mat)
380367 >> >
381368 >> > # The standard quantum value is cos(pi/8)**2 \approx 0.85356
382- >> > ' %.2f ' % bb84_lb.quantum_value_lower_bound()
383- ' 0.85'
384-
385-
386- .. note::
387- You do not need to use `' %.2f ' % ` when you use this function.
388- We use this to format our output such that `doctest` compares the calculated output to the
389- expected output upto two decimal points only. The accuracy of the solvers can calculate the
390- `float ` output to a certain amount of precision such that the value deviates after a few digits
391- of accuracy.
369+ >> > np.around(bb84_lb.quantum_value_lower_bound(), decimals = 2 )
370+ 0.85
392371
393372 From :cite: `Johnston_2016_Extended `, it is known that :math: `\omega (G_{BB84 }) =
394373\omega ^*(G_{BB84 })`, however, if we did not know this beforehand, we could
@@ -409,20 +388,14 @@ Using :code:`toqito`, we can see that :math:`\omega_{ns}(G) = \cos^2(\pi/8)`.
409388
410389 >> > # Calculate the non-signaling value of the BB84 extended nonlocal game.
411390 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
391+ >> > import numpy as np
412392 >> >
413393 >> > # Define an ExtendedNonlocalGame object based on the BB84 game.
414394 >> > bb84 = ExtendedNonlocalGame(bb84_prob_mat, bb84_pred_mat)
415395 >> >
416396 >> > # The non-signaling value is cos(pi/8)**2 \approx 0.85356
417- >> > ' %.2f ' % bb84.nonsignaling_value()
418- ' 0.85'
419-
420- .. note::
421- You do not need to use `' %.2f ' % ` when you use this function.
422- We use this to format our output such that `doctest` compares the calculated output to the
423- expected output upto two decimal points only. The accuracy of the solvers can calculate the
424- `float ` output to a certain amount of precision such that the value deviates after a few digits
425- of accuracy.
397+ >> > np.around(bb84.nonsignaling_value(), decimals = 2 )
398+ 0.85
426399
427400 So we have the relationship that
428401
@@ -437,20 +410,14 @@ can observe this by the following snippet.
437410
438411 >> > # The non-signaling value of BB84 under parallel repetition.
439412 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
413+ >> > import numpy as np
440414 >> >
441415 >> > # Define the bb84 game for two parallel repetitions.
442416 >> > bb84_2_reps = ExtendedNonlocalGame(bb84_prob_mat, bb84_pred_mat, 2 )
443417 >> >
444418 >> > # The non-signaling value for two parallel repetitions is cos(pi/8)**4 \approx 0.73825
445- >> > ' %.2f ' % bb84_2_reps.nonsignaling_value()
446- ' 0.74'
447-
448- .. note::
449- You do not need to use `' %.2f ' % ` when you use this function.
450- We use this to format our output such that `doctest` compares the calculated output to the
451- expected output upto two decimal points only. The accuracy of the solvers can calculate the
452- `float ` output to a certain amount of precision such that the value deviates after a few digits
453- of accuracy.
419+ >> > np.around(bb84_2_reps.nonsignaling_value(), decimals = 2 )
420+ 0.74
454421
455422 Note that :math: `0.73825 \geq \cos (\pi /8 )^4 \approx 0.72855 ` and therefore we
456423have that
@@ -554,42 +521,29 @@ the unentangled value of :math:`G_{CHSH}`.
554521
555522 >> > # Calculate the unentangled value of the CHSH extended nonlocal game
556523 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
524+ >> > import numpy as np
557525 >> >
558526 >> > # Define an ExtendedNonlocalGame object based on the CHSH game.
559527 >> > chsh = ExtendedNonlocalGame(chsh_prob_mat, chsh_pred_mat)
560528 >> >
561529 >> > # The unentangled value is 3/4 = 0.75
562- >> > ' %.2f ' % chsh.unentangled_value()
563- ' 0.75'
564-
565- .. note::
566- You do not need to use `' %.2f ' % ` when you use this function.
567- We use this to format our output such that `doctest` compares the calculated output to the
568- expected output upto two decimal points only. The accuracy of the solvers can calculate the
569- `float ` output to a certain amount of precision such that the value deviates after a few digits
570- of accuracy.
530+ >> > np.around(chsh.unentangled_value(), decimals = 2 )
531+ 0.75
571532
572533 We can also run multiple repetitions of :math: `G_{CHSH}`.
573534
574535.. code-block :: python
575536
576537 >> > # The unentangled value of CHSH under parallel repetition.
577538 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
539+ >> > import numpy as np
578540 >> >
579541 >> > # Define the CHSH game for two parallel repetitions.
580542 >> > chsh_2_reps = ExtendedNonlocalGame(chsh_prob_mat, chsh_pred_mat, 2 )
581543 >> >
582544 >> > # The unentangled value for two parallel repetitions is (3/4)**2 \approx 0.5625
583- >> > ' %.2f ' % chsh_2_reps.unentangled_value()
584- ' 0.56'
585-
586-
587- .. note::
588- You do not need to use `' %.2f ' % ` when you use this function.
589- We use this to format our output such that `doctest` compares the calculated output to the
590- expected output upto two decimal points only. The accuracy of the solvers can calculate the
591- `float ` output to a certain amount of precision such that the value deviates after a few digits
592- of accuracy.
545+ >> > np.around(chsh_2_reps.unentangled_value(), decimals = 2 )
546+ 0.56
593547
594548 Note that strong parallel repetition holds as
595549
@@ -606,21 +560,14 @@ non-signaling value.
606560
607561 >> > # Calculate the non-signaling value of the CHSH extended nonlocal game.
608562 >> > from toqito.nonlocal_games.extended_nonlocal_game import ExtendedNonlocalGame
563+ >> > import numpy as np
609564 >> >
610565 >> > # Define an ExtendedNonlocalGame object based on the CHSH game.
611566 >> > chsh = ExtendedNonlocalGame(chsh_prob_mat, chsh_pred_mat)
612567 >> >
613568 >> > # The non-signaling value is 3/4 = 0.75
614- >> > ' %.2f ' % chsh.nonsignaling_value()
615- ' 0.75'
616-
617- .. note::
618- You do not need to use `' %.2f ' % ` when you use this function.
619- We use this to format our output such that `doctest` compares the calculated output to the
620- expected output upto two decimal points only. The accuracy of the solvers can calculate the
621- `float ` output to a certain amount of precision such that the value deviates after a few digits
622- of accuracy.
623-
569+ >> > np.around(chsh.nonsignaling_value(), decimals = 2 )
570+ 0.75
624571
625572 As we know that :math: `\omega (G_{CHSH}) = \omega _{ns}(G_{CHSH}) = 3 /4 ` and that
626573
@@ -739,18 +686,11 @@ Now that we have encoded :math:`G_{MUB}`, we can calculate the unentangled value
739686
740687.. code-block :: python
741688
689+ >> > import numpy as np
742690 >> > g_mub = ExtendedNonlocalGame(prob_mat, pred_mat)
743691 >> > unent_val = g_mub.unentangled_value()
744- >> > ' %.2f ' % unent_val
745- ' 0.65'
746-
747-
748- .. note::
749- You do not need to use `' %.2f ' % ` when you use this function.
750- We use this to format our output such that `doctest` compares the calculated output to the
751- expected output upto two decimal points only. The accuracy of the solvers can calculate the
752- `float ` output to a certain amount of precision such that the value deviates after a few digits
753- of accuracy.
692+ >> > np.around(unent_val, decimals = 2 )
693+ 0.65
754694
755695 That is, we have that
756696
@@ -763,18 +703,11 @@ obtain.
763703
764704.. code-block :: python
765705
706+ >> > import numpy as np
766707 >> > g_mub = ExtendedNonlocalGame(prob_mat, pred_mat)
767708 >> > q_val = g_mub.quantum_value_lower_bound()
768- >> > ' %.2f ' % q_val
769- ' 0.66'
770-
771-
772- .. note::
773- You do not need to use `' %.2f ' % ` when you use this function.
774- We use this to format our output such that `doctest` compares the calculated output to the
775- expected output upto two decimal points only. The accuracy of the solvers can calculate the
776- `float ` output to a certain amount of precision such that the value deviates after a few digits
777- of accuracy.
709+ >> > np.around(q_val, decimals = 2 )
710+ 0.66
778711
779712 Note that as we are calculating a lower bound, it is possible that a value this
780713high will not be obtained, or in other words, the algorithm can get stuck in a
0 commit comments