-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiagonalizer.nb
5512 lines (5372 loc) · 246 KB
/
Diagonalizer.nb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 10.4' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 251986, 5504]
NotebookOptionsPosition[ 246518, 5331]
NotebookOutlinePosition[ 246887, 5347]
CellTagsIndexPosition[ 246844, 5344]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell["This notebook diagonalize a given rate matrix.", "Text",
CellChangeTimes->{{3.672713741567542*^9, 3.672713777013112*^9}}],
Cell["\<\
Calculates the rate matrix for any input and any output configuration of \
photons in a interferometer.\
\>", "Text",
CellChangeTimes->{{3.643610913425571*^9, 3.643610939541642*^9}}],
Cell["Inputs: the input and output photon configurations.", "Text",
CellChangeTimes->{{3.6436089545677147`*^9, 3.643608979910529*^9}}],
Cell[BoxData[{
RowBox[{
RowBox[{"inputdist", " ", "=", " ",
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"outputdist", " ", "=", " ",
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"inputpermutation", "=",
RowBox[{"Cycles", "[",
RowBox[{"{",
RowBox[{"{", "}"}], "}"}], "]"}]}], ";"}]}], "Input",
CellChangeTimes->{{3.6436004058020353`*^9, 3.643600409468233*^9}, {
3.6436009704049587`*^9, 3.6436009717383833`*^9}, {3.643602399992597*^9,
3.643602406605891*^9}, {3.6436072966466627`*^9, 3.643607298370922*^9}, {
3.643607362781349*^9, 3.643607364282209*^9}, {3.6436074267145977`*^9,
3.643607428185925*^9}, {3.6436074612051773`*^9, 3.643607464361793*^9}, {
3.6436083405631104`*^9, 3.64360834179792*^9}, {3.643610005275527*^9,
3.643610017448551*^9}, {3.643610081352216*^9, 3.6436100831652803`*^9}, {
3.6436108733560677`*^9, 3.643610874673819*^9}, {3.643611123222293*^9,
3.64361116391925*^9}, {3.6436113867749767`*^9, 3.6436113886416693`*^9}, {
3.643611440901795*^9, 3.643611442846052*^9}, {3.643611495594458*^9,
3.643611498256769*^9}, {3.643611538411118*^9, 3.643611603890555*^9}, {
3.6436127258819036`*^9, 3.6436127268667*^9}, {3.643645392872064*^9,
3.643645394638459*^9}, {3.6436454437735567`*^9, 3.64364544966813*^9}, {
3.643645490482872*^9, 3.643645541616087*^9}, {3.6436470643497972`*^9,
3.643647065892641*^9}, {3.643647769036433*^9, 3.643647773892983*^9}, {
3.6436479123234177`*^9, 3.643647913768911*^9}, {3.643648201179006*^9,
3.643648206052462*^9}, {3.643648549278146*^9, 3.643648551949889*^9}, {
3.643650827779578*^9, 3.643650829668572*^9}, {3.643651122683813*^9,
3.643651127277918*^9}, {3.64365683855057*^9, 3.643656844647785*^9}, {
3.647120379200632*^9, 3.647120384777946*^9}, {3.647122186254682*^9,
3.647122191563105*^9}, {3.6471933725262747`*^9, 3.647193390883336*^9}, {
3.6471938170986843`*^9, 3.647193823515936*^9}, {3.647213365806601*^9,
3.64721336747812*^9}, {3.6472134397263308`*^9, 3.647213442585253*^9}, {
3.647213803593987*^9, 3.6472138078043337`*^9}, {3.647311763570917*^9,
3.6473117646794786`*^9}, {3.652220064485099*^9, 3.652220065756666*^9}, {
3.652420517800768*^9, 3.6524205568518553`*^9}, {3.652420707787077*^9,
3.652420710754376*^9}, {3.672330282847165*^9, 3.672330285630321*^9}, {
3.673046229993739*^9, 3.6730462331102533`*^9}, {3.673046607090119*^9,
3.6730466080443563`*^9}, {3.673046794379424*^9, 3.673046795038377*^9}, {
3.6730468512180433`*^9, 3.673046873898426*^9}, {3.6730544884926777`*^9,
3.673054489712656*^9}, {3.673055389697695*^9, 3.6730553904999933`*^9}, {
3.673056628285479*^9, 3.673056631189335*^9}, {3.673057081548152*^9,
3.673057083414384*^9}, {3.6730678183743143`*^9, 3.673067820175185*^9}, {
3.673068007469626*^9, 3.673068042799155*^9}, {3.673130631196372*^9,
3.6731306324287643`*^9}, {3.6731307465297127`*^9, 3.673130749017703*^9}, {
3.6731314396251593`*^9, 3.673131440531262*^9}, {3.673138727363439*^9,
3.673138730337132*^9}, {3.673138891805002*^9, 3.6731388926344767`*^9}, {
3.673141118204981*^9, 3.673141119043228*^9}, {3.673143153744055*^9,
3.673143156445366*^9}, {3.673144733824004*^9, 3.673144739718957*^9}, {
3.6731515843968563`*^9, 3.67315159675119*^9}, {3.673152133141114*^9,
3.673152143766457*^9}, {3.673323981897853*^9, 3.6733239932992563`*^9}, {
3.67332614524061*^9, 3.6733261491302767`*^9}, {3.673329410363263*^9,
3.673329412041313*^9}, {3.6733301025501137`*^9, 3.673330103552463*^9}, {
3.673330391141528*^9, 3.673330392015518*^9}, {3.673330972142354*^9,
3.6733309733155527`*^9}, {3.67333259812778*^9, 3.673332611715108*^9}, {
3.673332846404707*^9, 3.673332849186913*^9}, {3.6733344693482027`*^9,
3.673334470674493*^9}, {3.673334917144683*^9, 3.673334919551613*^9}, {
3.673452231948052*^9, 3.673452233172964*^9}, {3.67376144771124*^9,
3.673761449765923*^9}, {3.673762565227644*^9, 3.673762566142223*^9}, {
3.6738414016763077`*^9, 3.673841403264984*^9}, {3.673841913722795*^9,
3.673841914603649*^9}, {3.673844388368328*^9, 3.673844389210224*^9}, {
3.673844650020645*^9, 3.673844650703499*^9}, {3.677369982731784*^9,
3.677369986454764*^9}, {3.677370447622026*^9, 3.677370449260198*^9}, {
3.6776082761661987`*^9, 3.677608278982682*^9}, {3.677608525475278*^9,
3.677608526412114*^9}, {3.677615739041712*^9, 3.677615743674333*^9}, {
3.677615822204801*^9, 3.677615824267688*^9}, {3.677616099203451*^9,
3.677616135474544*^9}, {3.677616233817958*^9, 3.677616234827898*^9}, {
3.677616306589551*^9, 3.677616307768577*^9}, {3.6776163427049026`*^9,
3.677616382013188*^9}, {3.677628795401904*^9, 3.677628805478928*^9}, {
3.6822685945847187`*^9, 3.682268595694191*^9}, {3.6822800929212427`*^9,
3.6822800950692387`*^9}, {3.6822812535435553`*^9, 3.68228125580882*^9}, {
3.682281374399225*^9, 3.682281375482122*^9}, {3.6826965663328333`*^9,
3.682696568632247*^9}, {3.6925123100179567`*^9, 3.69251234031686*^9}, {
3.692512522981163*^9, 3.692512526276197*^9}, {3.6925140654732857`*^9,
3.6925140669975557`*^9}, {3.6925142678661737`*^9, 3.69251426938305*^9}, {
3.692514513908565*^9, 3.6925145152183104`*^9}, {3.692546787570361*^9,
3.692546788387909*^9}, {3.692547123868018*^9, 3.692547129108329*^9}, {
3.692595522797427*^9, 3.692595526983211*^9}, {3.693716713489725*^9,
3.693716717494331*^9}, {3.6937168479140263`*^9, 3.693716855527012*^9}, {
3.6960975807648983`*^9, 3.6960975835847816`*^9}, {3.696563253558247*^9,
3.696563278526478*^9}, 3.696563317147834*^9, {3.69656445278008*^9,
3.696564456397275*^9}, {3.69656618986312*^9, 3.6965661900415077`*^9}, {
3.696569260513928*^9, 3.69656926384342*^9}, {3.696569837118264*^9,
3.696569839963835*^9}, {3.702095957472187*^9, 3.7020959626975327`*^9}, {
3.702096529996467*^9, 3.70209653304147*^9}, {3.702101883401783*^9,
3.7021018880934258`*^9}, {3.702102288128048*^9, 3.702102289287963*^9}, {
3.702102418935258*^9, 3.702102426487275*^9}, {3.702469593732791*^9,
3.7024695952071323`*^9}, {3.702469686794738*^9, 3.702469688060645*^9}, {
3.702470195886283*^9, 3.702470195987872*^9}, {3.70247025531733*^9,
3.702470255458856*^9}, {3.702471393228657*^9, 3.702471401388249*^9}, {
3.702472491943955*^9, 3.702472520118208*^9}, {3.702481034533146*^9,
3.7024810475610523`*^9}, 3.702482356457306*^9, {3.702482435649699*^9,
3.702482455179685*^9}, {3.702482799087942*^9, 3.702482808637529*^9},
3.702507447753146*^9, {3.702509406455062*^9, 3.702509419814437*^9}, {
3.702509561290934*^9, 3.7025095825524683`*^9}, {3.702509620242532*^9,
3.702509621098278*^9}, 3.702509720597459*^9, {3.702509800662324*^9,
3.7025098638433113`*^9}, {3.7025099005890913`*^9, 3.7025099452307*^9}, {
3.7025113874934263`*^9, 3.702511396931369*^9}, {3.702511437634686*^9,
3.702511461389318*^9}, {3.702512185094224*^9, 3.702512189176845*^9}, {
3.702512466506857*^9, 3.7025124714694138`*^9}, {3.702513006926819*^9,
3.7025130110007753`*^9}, {3.702513163418192*^9, 3.702513164594586*^9}, {
3.70251648161614*^9, 3.7025164827694607`*^9}, {3.702516633903874*^9,
3.7025166340834303`*^9}, {3.702516673896756*^9, 3.702516681412279*^9}, {
3.702516932317202*^9, 3.702516933054793*^9}, {3.702562529315987*^9,
3.7025625558151217`*^9}, {3.702564597263501*^9, 3.702564602645142*^9}, {
3.702571603429942*^9, 3.702571603839892*^9}, {3.702571752818224*^9,
3.7025717561039953`*^9}, {3.702573053157105*^9, 3.70257305642293*^9}, {
3.7025732895696783`*^9, 3.702573294080175*^9}, {3.702576546350718*^9,
3.7025765477349052`*^9}, {3.702576677954946*^9, 3.7025766788982058`*^9}, {
3.702576944702092*^9, 3.7025769512839518`*^9}, {3.702596027058977*^9,
3.7025960308351593`*^9}, {3.7025974839032793`*^9, 3.702597503965905*^9}, {
3.702598072730838*^9, 3.7025980753685007`*^9}, {3.7025984244897013`*^9,
3.702598430211032*^9}, {3.7025986001777554`*^9, 3.702598601721396*^9}, {
3.702598635277529*^9, 3.702598638338502*^9}, {3.702598885363525*^9,
3.702598888538286*^9}, {3.702599808770001*^9, 3.7025998093325644`*^9}, {
3.702600103144238*^9, 3.702600104149873*^9}, {3.7026008477149277`*^9,
3.7026008498628263`*^9}, {3.702600965010933*^9, 3.702600986858077*^9}, {
3.702601032379504*^9, 3.702601034845749*^9}, {3.702601092131206*^9,
3.702601107628088*^9}, {3.702602445057652*^9, 3.702602449783873*^9}, {
3.70260253470936*^9, 3.702602538425085*^9}, {3.702602597242291*^9,
3.702602605106901*^9}, {3.702602904393817*^9, 3.702602906481667*^9}, {
3.702604638063805*^9, 3.702604674822218*^9}, {3.702604913242951*^9,
3.7026049148257713`*^9}, {3.702637148832757*^9, 3.702637170795683*^9}, {
3.702637258196789*^9, 3.7026372898581448`*^9}, {3.702637431853889*^9,
3.702637435176393*^9}, {3.702637570367167*^9, 3.7026375764956017`*^9}, {
3.702637780069415*^9, 3.702637782307193*^9}, {3.7026597660400257`*^9,
3.702659769257114*^9}, {3.702659864995763*^9, 3.702659866351164*^9}, {
3.702683222148241*^9, 3.702683222488493*^9}, 3.7026845884801483`*^9, {
3.702684746141087*^9, 3.702684746552732*^9}, {3.702695675069509*^9,
3.7026956777881327`*^9}, {3.7026957305607452`*^9, 3.702695737926909*^9}, {
3.70269630613282*^9, 3.702696306472793*^9}, {3.702696503510229*^9,
3.702696509254643*^9}, {3.702696853059559*^9, 3.702696884318495*^9}, {
3.702697269891591*^9, 3.7026972747437353`*^9}, {3.702697808974243*^9,
3.7026978114274607`*^9}, {3.70269792777709*^9, 3.702697959489936*^9}, {
3.702698271721086*^9, 3.702698274524032*^9}, {3.7027005883546124`*^9,
3.7027005923621073`*^9}, {3.702701558548768*^9, 3.702701560858753*^9}, {
3.7027024842457952`*^9, 3.702702485531762*^9}, 3.702702986018485*^9, {
3.702703835144135*^9, 3.7027038353561*^9}, 3.7027054349525957`*^9, {
3.702706615399864*^9, 3.7027066182501583`*^9}, {3.702708884496859*^9,
3.702708886181444*^9}, {3.702721985030258*^9, 3.7027219882000113`*^9}, {
3.702724928039158*^9, 3.702724931186866*^9}, {3.702725426719936*^9,
3.702725429764462*^9}, {3.702727712878235*^9, 3.702727714645068*^9}, {
3.702727767988468*^9, 3.702727768256044*^9}, 3.70272862903754*^9, {
3.7027286944015217`*^9, 3.7027286948116713`*^9}, {3.702728875460835*^9,
3.702728887642188*^9}, 3.70272911319226*^9, {3.702733188066002*^9,
3.7027331883564777`*^9}, 3.702733537389166*^9, {3.702733665199657*^9,
3.702733665523652*^9}, 3.702734146836747*^9, {3.7027342523217583`*^9,
3.702734252534932*^9}, 3.702734323376067*^9, {3.702746111283703*^9,
3.702746113633271*^9}, {3.702746272304015*^9, 3.702746274952227*^9}, {
3.702751694606956*^9, 3.7027517275665913`*^9}, {3.702776334481266*^9,
3.702776337445428*^9}, {3.702777248860635*^9, 3.702777251757118*^9}, {
3.702785611257811*^9, 3.7027856211330748`*^9}, {3.702806839138578*^9,
3.702806840374284*^9}, {3.7028202730177917`*^9, 3.702820274908327*^9}, {
3.7028209224764338`*^9, 3.702820922710919*^9}, {3.702820954192719*^9,
3.702820954437063*^9}, {3.702821061781996*^9, 3.702821065132842*^9}, {
3.702821123772341*^9, 3.702821126613688*^9}, {3.70282116735529*^9,
3.702821171254588*^9}, {3.7028240001025543`*^9, 3.702824003528173*^9}, {
3.702824162431761*^9, 3.702824164552782*^9}, {3.702899100652224*^9,
3.702899101591248*^9}, {3.702908099848566*^9, 3.702908152415694*^9},
3.702909138728657*^9, {3.702913100017565*^9, 3.702913100253669*^9},
3.7029131374067163`*^9, 3.702919973233938*^9, {3.7029865677644033`*^9,
3.70298658694488*^9}, {3.704735718442852*^9, 3.7047357186717157`*^9},
3.704735784986566*^9, {3.704735990517077*^9, 3.7047359908165607`*^9},
3.704736026691176*^9, {3.704736729946877*^9, 3.704736730509121*^9}, {
3.704761703375286*^9, 3.704761704725349*^9}, 3.704764361253539*^9, {
3.7050897510491247`*^9, 3.7050897535655413`*^9}, {3.705089807644816*^9,
3.705089818711872*^9}, {3.7060552929173326`*^9, 3.70605529390913*^9}, {
3.710159421452835*^9, 3.710159425493452*^9}, {3.710163709013483*^9,
3.7101637122976427`*^9}, {3.710163955046075*^9, 3.7101639572810917`*^9}, {
3.710179219500955*^9, 3.710179220720817*^9}, {3.710774278310836*^9,
3.7107742795395308`*^9}, {3.710774366686047*^9, 3.710774367596382*^9}, {
3.710774426754599*^9, 3.7107744276890383`*^9}, {3.7107769403969593`*^9,
3.710776941829914*^9}, {3.710864956011348*^9, 3.7108649587311163`*^9}, {
3.710865114609601*^9, 3.710865149512567*^9}, {3.71086532484015*^9,
3.710865325831327*^9}, {3.711312254826334*^9, 3.711312256007635*^9}, {
3.711313473578124*^9, 3.7113134746325493`*^9}, {3.711313538362739*^9,
3.711313539370935*^9}, {3.712086459949098*^9, 3.712086464261816*^9}, {
3.7120865169720087`*^9, 3.712086518479251*^9}},
Background->RGBColor[1, 0.925, 0.925],
ExpressionUUID -> "fe05df54-b7e8-4a03-a21d-82333737c476"],
Cell["\<\
Calculate
- the total number of photons
- the number of channels
- the number of words corresponding to the output distribution
- the factor due to the normalization of the wavefunction and POVM
- input word
- output word\
\>", "Text",
CellChangeTimes->{{3.6436089861925793`*^9, 3.643609058415332*^9}, {
3.647133663193893*^9, 3.647133667730901*^9}}],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{"nphotons", " ", "=", " ",
RowBox[{"Total", "[", "inputdist", "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"nchannels", " ", "=", " ",
RowBox[{"Length", "[", "inputdist", "]"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"uniquewords", " ", "=", " ",
RowBox[{
RowBox[{"nphotons", "!"}], "/",
RowBox[{"Apply", "[",
RowBox[{"Times", ",",
RowBox[{"Map", "[",
RowBox[{"Factorial", ",", "outputdist"}], "]"}]}], "]"}]}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"normalization", " ", "=", " ",
RowBox[{
RowBox[{"Apply", "[",
RowBox[{"Times", ",",
RowBox[{"Map", "[",
RowBox[{"Factorial", ",", "inputdist"}], "]"}]}], "]"}], "*",
RowBox[{"Apply", "[",
RowBox[{"Times", ",",
RowBox[{"Map", "[",
RowBox[{"Factorial", ",", "outputdist"}], "]"}]}], "]"}]}]}],
";"}], "\[IndentingNewLine]",
RowBox[{"inputword", " ", "=", " ",
RowBox[{"Flatten", "[",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"ConstantArray", "[",
RowBox[{"i", ",",
RowBox[{"inputdist", "[",
RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",",
RowBox[{"Length", "[", "inputdist", "]"}]}], "}"}]}], "]"}],
"]"}]}], "\[IndentingNewLine]",
RowBox[{"inputword", " ", "=", " ",
RowBox[{"Permute", "[",
RowBox[{"inputword", ",", "inputpermutation"}],
"]"}]}], "\[IndentingNewLine]",
RowBox[{"outputword", " ", "=", " ",
RowBox[{"Flatten", "[",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"ConstantArray", "[",
RowBox[{"i", ",",
RowBox[{"outputdist", "[",
RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",",
RowBox[{"Length", "[", "outputdist", "]"}]}], "}"}]}], "]"}],
"]"}]}]}], "Input",
CellChangeTimes->{{3.6436007033739243`*^9, 3.6436007073488817`*^9}, {
3.6436008799881687`*^9, 3.643600886061687*^9}, {3.64360246023202*^9,
3.643602462759058*^9}, {3.64360361735153*^9, 3.6436036423127403`*^9}, {
3.643607106690818*^9, 3.6436071186030416`*^9}, {3.643612387199192*^9,
3.6436123979765787`*^9}, {3.6436127046115303`*^9, 3.643612709647593*^9}, {
3.643645419416998*^9, 3.643645431513942*^9}, {3.647128571916294*^9,
3.6471285757914553`*^9}, {3.64713234987523*^9, 3.647132352985072*^9}, {
3.6472137032742233`*^9, 3.647213705770382*^9}, {3.6738450608830967`*^9,
3.6738450626169*^9}, 3.692512066344832*^9, {3.6960992605084887`*^9,
3.696099271682272*^9}, {3.696099369837681*^9, 3.6960993727602997`*^9}, {
3.696191836353341*^9, 3.696191839683031*^9}, {3.696191966108968*^9,
3.6961919670729103`*^9}, {3.6961925062785177`*^9, 3.696192507506144*^9}, {
3.6961925378733883`*^9, 3.696192538782093*^9}, {3.6961926616007423`*^9,
3.696192664959443*^9}, {3.6961926995026903`*^9, 3.6961927007503653`*^9}, {
3.696193020385069*^9, 3.696193023590469*^9}, {3.696193152156657*^9,
3.696193153216682*^9}, {3.6962671731039*^9, 3.696267173227747*^9}, {
3.6962684520717707`*^9, 3.696268452176271*^9}, {3.696269065949791*^9,
3.696269066954226*^9}, {3.69627085015924*^9, 3.696270851784555*^9}, {
3.6962708989467278`*^9, 3.696270900115822*^9}, {3.696271005762088*^9,
3.6962710066238127`*^9}, {3.696271061233728*^9, 3.696271062389233*^9}, {
3.6962715077861233`*^9, 3.696271508913896*^9}, {3.6962715441969233`*^9,
3.696271545040305*^9}, {3.696271682936751*^9, 3.696271683789673*^9}, {
3.696271825376959*^9, 3.6962718262698793`*^9}, {3.696272016787965*^9,
3.6962720181423264`*^9}, {3.6962720495960407`*^9, 3.696272050631528*^9}, {
3.6962721259712133`*^9, 3.696272127032815*^9}, {3.69627957864473*^9,
3.696279579573985*^9}, {3.696279946225854*^9, 3.696279946494183*^9}, {
3.696282416660492*^9, 3.696282416878262*^9}, {3.696563291172612*^9,
3.6965632932423553`*^9}},
ExpressionUUID -> "969c8a4f-b00d-4d7c-a07a-738fa79e0813"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"1", ",", "2", ",", "3"}], "}"}]], "Output",
CellChangeTimes->{{3.702469571032873*^9, 3.702469597296749*^9},
3.702469688989553*^9, 3.70247019810108*^9, 3.702470261841568*^9, {
3.702471397616684*^9, 3.702471403880574*^9}, {3.702472501547501*^9,
3.7024725213700542`*^9}, {3.70248103592286*^9, 3.702481053481544*^9},
3.702482359086129*^9, {3.7024824429833717`*^9, 3.702482456521924*^9}, {
3.7024828005790653`*^9, 3.7024828108098183`*^9}, 3.702507449190795*^9, {
3.7025094086655416`*^9, 3.702509421213887*^9}, 3.70250958332957*^9,
3.702509622305529*^9, {3.7025097210941277`*^9, 3.702509748318342*^9}, {
3.702509786378057*^9, 3.7025098025726957`*^9}, 3.702509832829151*^9,
3.702509865385399*^9, {3.702509904005179*^9, 3.702509946090067*^9},
3.7025113988765707`*^9, {3.7025114392442207`*^9, 3.7025114632800617`*^9}, {
3.7025130486447678`*^9, 3.7025130740150337`*^9}, 3.702513320753933*^9,
3.7025168190355663`*^9, {3.7025169353278913`*^9, 3.702516960448949*^9}, {
3.702562518957118*^9, 3.7025625325190763`*^9}, {3.7025645902791157`*^9,
3.7025646033306513`*^9}, 3.702571412346579*^9, 3.702571605263884*^9,
3.702598716286675*^9, 3.702598889831387*^9, 3.7025989293215*^9,
3.702599810655203*^9, {3.702600972115129*^9, 3.7026009889695807`*^9}, {
3.702601021591724*^9, 3.702601036717586*^9}, 3.70260260621784*^9, {
3.7026371535098553`*^9, 3.702637172514566*^9}, 3.7026374811081743`*^9,
3.702659771935375*^9, 3.702659869752652*^9, 3.7026832777046747`*^9,
3.702684589107842*^9, 3.702684747936557*^9, 3.702695684343931*^9,
3.702695738381248*^9, 3.7026963075062857`*^9, 3.7026965104243813`*^9, {
3.702696872709827*^9, 3.702696885838612*^9}, 3.70269727581358*^9,
3.702697814055936*^9, {3.702697932998901*^9, 3.702697960250832*^9},
3.70270059337376*^9, 3.702702487406662*^9, 3.702702987336054*^9,
3.702703836135223*^9, 3.702705435829104*^9, 3.7027088873222923`*^9,
3.702722029525415*^9, 3.702727715823975*^9, 3.702727768780787*^9,
3.7027286298492393`*^9, {3.7027288557506657`*^9, 3.702728888859825*^9},
3.70272911371634*^9, 3.70273319402*^9, 3.702733538859668*^9,
3.7027336676555767`*^9, 3.702734147650754*^9, 3.70273425319405*^9,
3.702735892668199*^9, 3.702743440513303*^9, 3.702746276043922*^9,
3.70275172865172*^9, 3.702753892510138*^9, 3.702785614112587*^9,
3.702820277726775*^9, 3.702820923516975*^9, 3.702820956268908*^9,
3.7028210666927557`*^9, 3.70282112846847*^9, 3.702821172206377*^9,
3.702824004926608*^9, 3.702824165639739*^9, 3.7028991040739613`*^9, {
3.702908116688802*^9, 3.702908153379405*^9}, 3.702909139299223*^9,
3.702913102165073*^9, 3.702913139472206*^9, 3.702919974218903*^9,
3.702982160231192*^9, {3.7029865703275146`*^9, 3.702986588326756*^9},
3.704734384145322*^9, 3.70473572717207*^9, 3.704735792995459*^9, {
3.704736002637966*^9, 3.70473603076194*^9}, 3.704736731991805*^9,
3.7047369231382103`*^9, 3.704737109974566*^9, 3.704761706698764*^9,
3.704764363978464*^9, {3.705089797222213*^9, 3.705089813331683*^9},
3.706055295993286*^9, 3.708804140126786*^9, 3.710027179720771*^9,
3.7101594293941813`*^9, 3.710163713897545*^9, 3.710163959308848*^9,
3.710179230147686*^9, 3.710774282732366*^9, 3.710774371254599*^9,
3.710774429372019*^9, 3.710776944097926*^9, 3.710864979147684*^9,
3.710865120925139*^9, 3.710865151132959*^9, 3.71086532723147*^9,
3.7108654771628933`*^9, 3.711312259454773*^9, 3.711313476810034*^9,
3.711313540674445*^9, 3.71208646930584*^9, 3.712086520912491*^9},
ExpressionUUID -> "626dc0bc-7948-45de-b7ff-7ceaa8132ecd"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"1", ",", "2", ",", "3"}], "}"}]], "Output",
CellChangeTimes->{{3.702469571032873*^9, 3.702469597296749*^9},
3.702469688989553*^9, 3.70247019810108*^9, 3.702470261841568*^9, {
3.702471397616684*^9, 3.702471403880574*^9}, {3.702472501547501*^9,
3.7024725213700542`*^9}, {3.70248103592286*^9, 3.702481053481544*^9},
3.702482359086129*^9, {3.7024824429833717`*^9, 3.702482456521924*^9}, {
3.7024828005790653`*^9, 3.7024828108098183`*^9}, 3.702507449190795*^9, {
3.7025094086655416`*^9, 3.702509421213887*^9}, 3.70250958332957*^9,
3.702509622305529*^9, {3.7025097210941277`*^9, 3.702509748318342*^9}, {
3.702509786378057*^9, 3.7025098025726957`*^9}, 3.702509832829151*^9,
3.702509865385399*^9, {3.702509904005179*^9, 3.702509946090067*^9},
3.7025113988765707`*^9, {3.7025114392442207`*^9, 3.7025114632800617`*^9}, {
3.7025130486447678`*^9, 3.7025130740150337`*^9}, 3.702513320753933*^9,
3.7025168190355663`*^9, {3.7025169353278913`*^9, 3.702516960448949*^9}, {
3.702562518957118*^9, 3.7025625325190763`*^9}, {3.7025645902791157`*^9,
3.7025646033306513`*^9}, 3.702571412346579*^9, 3.702571605263884*^9,
3.702598716286675*^9, 3.702598889831387*^9, 3.7025989293215*^9,
3.702599810655203*^9, {3.702600972115129*^9, 3.7026009889695807`*^9}, {
3.702601021591724*^9, 3.702601036717586*^9}, 3.70260260621784*^9, {
3.7026371535098553`*^9, 3.702637172514566*^9}, 3.7026374811081743`*^9,
3.702659771935375*^9, 3.702659869752652*^9, 3.7026832777046747`*^9,
3.702684589107842*^9, 3.702684747936557*^9, 3.702695684343931*^9,
3.702695738381248*^9, 3.7026963075062857`*^9, 3.7026965104243813`*^9, {
3.702696872709827*^9, 3.702696885838612*^9}, 3.70269727581358*^9,
3.702697814055936*^9, {3.702697932998901*^9, 3.702697960250832*^9},
3.70270059337376*^9, 3.702702487406662*^9, 3.702702987336054*^9,
3.702703836135223*^9, 3.702705435829104*^9, 3.7027088873222923`*^9,
3.702722029525415*^9, 3.702727715823975*^9, 3.702727768780787*^9,
3.7027286298492393`*^9, {3.7027288557506657`*^9, 3.702728888859825*^9},
3.70272911371634*^9, 3.70273319402*^9, 3.702733538859668*^9,
3.7027336676555767`*^9, 3.702734147650754*^9, 3.70273425319405*^9,
3.702735892668199*^9, 3.702743440513303*^9, 3.702746276043922*^9,
3.70275172865172*^9, 3.702753892510138*^9, 3.702785614112587*^9,
3.702820277726775*^9, 3.702820923516975*^9, 3.702820956268908*^9,
3.7028210666927557`*^9, 3.70282112846847*^9, 3.702821172206377*^9,
3.702824004926608*^9, 3.702824165639739*^9, 3.7028991040739613`*^9, {
3.702908116688802*^9, 3.702908153379405*^9}, 3.702909139299223*^9,
3.702913102165073*^9, 3.702913139472206*^9, 3.702919974218903*^9,
3.702982160231192*^9, {3.7029865703275146`*^9, 3.702986588326756*^9},
3.704734384145322*^9, 3.70473572717207*^9, 3.704735792995459*^9, {
3.704736002637966*^9, 3.70473603076194*^9}, 3.704736731991805*^9,
3.7047369231382103`*^9, 3.704737109974566*^9, 3.704761706698764*^9,
3.704764363978464*^9, {3.705089797222213*^9, 3.705089813331683*^9},
3.706055295993286*^9, 3.708804140126786*^9, 3.710027179720771*^9,
3.7101594293941813`*^9, 3.710163713897545*^9, 3.710163959308848*^9,
3.710179230147686*^9, 3.710774282732366*^9, 3.710774371254599*^9,
3.710774429372019*^9, 3.710776944097926*^9, 3.710864979147684*^9,
3.710865120925139*^9, 3.710865151132959*^9, 3.71086532723147*^9,
3.7108654771628933`*^9, 3.711312259454773*^9, 3.711313476810034*^9,
3.711313540674445*^9, 3.71208646930584*^9, 3.712086520914122*^9},
ExpressionUUID -> "626dc0bc-7948-45de-b7ff-7ceaa8132ecd"],
Cell[BoxData[
RowBox[{"{",
RowBox[{"1", ",", "2", ",", "3"}], "}"}]], "Output",
CellChangeTimes->{{3.702469571032873*^9, 3.702469597296749*^9},
3.702469688989553*^9, 3.70247019810108*^9, 3.702470261841568*^9, {
3.702471397616684*^9, 3.702471403880574*^9}, {3.702472501547501*^9,
3.7024725213700542`*^9}, {3.70248103592286*^9, 3.702481053481544*^9},
3.702482359086129*^9, {3.7024824429833717`*^9, 3.702482456521924*^9}, {
3.7024828005790653`*^9, 3.7024828108098183`*^9}, 3.702507449190795*^9, {
3.7025094086655416`*^9, 3.702509421213887*^9}, 3.70250958332957*^9,
3.702509622305529*^9, {3.7025097210941277`*^9, 3.702509748318342*^9}, {
3.702509786378057*^9, 3.7025098025726957`*^9}, 3.702509832829151*^9,
3.702509865385399*^9, {3.702509904005179*^9, 3.702509946090067*^9},
3.7025113988765707`*^9, {3.7025114392442207`*^9, 3.7025114632800617`*^9}, {
3.7025130486447678`*^9, 3.7025130740150337`*^9}, 3.702513320753933*^9,
3.7025168190355663`*^9, {3.7025169353278913`*^9, 3.702516960448949*^9}, {
3.702562518957118*^9, 3.7025625325190763`*^9}, {3.7025645902791157`*^9,
3.7025646033306513`*^9}, 3.702571412346579*^9, 3.702571605263884*^9,
3.702598716286675*^9, 3.702598889831387*^9, 3.7025989293215*^9,
3.702599810655203*^9, {3.702600972115129*^9, 3.7026009889695807`*^9}, {
3.702601021591724*^9, 3.702601036717586*^9}, 3.70260260621784*^9, {
3.7026371535098553`*^9, 3.702637172514566*^9}, 3.7026374811081743`*^9,
3.702659771935375*^9, 3.702659869752652*^9, 3.7026832777046747`*^9,
3.702684589107842*^9, 3.702684747936557*^9, 3.702695684343931*^9,
3.702695738381248*^9, 3.7026963075062857`*^9, 3.7026965104243813`*^9, {
3.702696872709827*^9, 3.702696885838612*^9}, 3.70269727581358*^9,
3.702697814055936*^9, {3.702697932998901*^9, 3.702697960250832*^9},
3.70270059337376*^9, 3.702702487406662*^9, 3.702702987336054*^9,
3.702703836135223*^9, 3.702705435829104*^9, 3.7027088873222923`*^9,
3.702722029525415*^9, 3.702727715823975*^9, 3.702727768780787*^9,
3.7027286298492393`*^9, {3.7027288557506657`*^9, 3.702728888859825*^9},
3.70272911371634*^9, 3.70273319402*^9, 3.702733538859668*^9,
3.7027336676555767`*^9, 3.702734147650754*^9, 3.70273425319405*^9,
3.702735892668199*^9, 3.702743440513303*^9, 3.702746276043922*^9,
3.70275172865172*^9, 3.702753892510138*^9, 3.702785614112587*^9,
3.702820277726775*^9, 3.702820923516975*^9, 3.702820956268908*^9,
3.7028210666927557`*^9, 3.70282112846847*^9, 3.702821172206377*^9,
3.702824004926608*^9, 3.702824165639739*^9, 3.7028991040739613`*^9, {
3.702908116688802*^9, 3.702908153379405*^9}, 3.702909139299223*^9,
3.702913102165073*^9, 3.702913139472206*^9, 3.702919974218903*^9,
3.702982160231192*^9, {3.7029865703275146`*^9, 3.702986588326756*^9},
3.704734384145322*^9, 3.70473572717207*^9, 3.704735792995459*^9, {
3.704736002637966*^9, 3.70473603076194*^9}, 3.704736731991805*^9,
3.7047369231382103`*^9, 3.704737109974566*^9, 3.704761706698764*^9,
3.704764363978464*^9, {3.705089797222213*^9, 3.705089813331683*^9},
3.706055295993286*^9, 3.708804140126786*^9, 3.710027179720771*^9,
3.7101594293941813`*^9, 3.710163713897545*^9, 3.710163959308848*^9,
3.710179230147686*^9, 3.710774282732366*^9, 3.710774371254599*^9,
3.710774429372019*^9, 3.710776944097926*^9, 3.710864979147684*^9,
3.710865120925139*^9, 3.710865151132959*^9, 3.71086532723147*^9,
3.7108654771628933`*^9, 3.711312259454773*^9, 3.711313476810034*^9,
3.711313540674445*^9, 3.71208646930584*^9, 3.712086520915518*^9},
ExpressionUUID -> "626dc0bc-7948-45de-b7ff-7ceaa8132ecd"]
}, Open ]],
Cell["\<\
The list is a vector with each index corresponding to each frequency \
variable. The entries are the channels (expressed as delay variables) in \
which the inputs photons were. We call these the phases.\
\>", "Text",
CellChangeTimes->{{3.643609067721588*^9, 3.6436091384181833`*^9}, {
3.643609902873415*^9, 3.643609907960125*^9}, {3.683505581831818*^9,
3.683505582507188*^9}}],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{"inputtaus", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Subscript", "[",
RowBox[{"\[Tau]", ",", "i"}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "nphotons"}], "}"}]}], "]"}]}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"(*",
RowBox[{"inputtaus", "=",
RowBox[{"Permute", "[",
RowBox[{"inputtaus", ",", "inputpermutation"}], "]"}]}],
"*)"}]}]}], "Input",
CellChangeTimes->{{3.643600629434431*^9, 3.64360064343703*^9}, {
3.643602416465149*^9, 3.643602421079155*^9}, 3.6436029013083973`*^9, {
3.67304497311657*^9, 3.673044975790825*^9}, {3.673046052325045*^9,
3.673046079166574*^9}, {3.673329626775543*^9, 3.673329627218115*^9},
3.673330118841947*^9, {3.673330425986174*^9, 3.67333047108928*^9}, {
3.673330904707602*^9, 3.6733309158774157`*^9}, {3.673330997968594*^9,
3.6733310226852694`*^9}, {3.6733313686677923`*^9,
3.6733313768104486`*^9}, {3.673332432680971*^9, 3.6733324377449837`*^9}, {
3.673332853071681*^9, 3.67333286448102*^9}, {3.6835087978469543`*^9,
3.683508804191559*^9}, {3.684274644980596*^9, 3.684274651772459*^9}, {
3.69619186438135*^9, 3.696191931024104*^9}, {3.696191970863138*^9,
3.6961919712915583`*^9}, 3.696192510409196*^9, {3.6961925422937737`*^9,
3.696192542571875*^9}, {3.696192668208301*^9, 3.696192668329112*^9}, {
3.696192703274898*^9, 3.696192703415341*^9}, {3.696193026878469*^9,
3.696193027189204*^9}, {3.6961931563069696`*^9, 3.696193156435804*^9}, {
3.696268428076783*^9, 3.696268428210168*^9}, {3.696269069265308*^9,
3.6962690695275583`*^9}, {3.696270748279986*^9, 3.696270749076486*^9}, {
3.6962708552879353`*^9, 3.696270855755619*^9}, {3.696270894855493*^9,
3.696270895569908*^9}, {3.696271002339291*^9, 3.696271002718774*^9}, {
3.696272011634452*^9, 3.6962720531016607`*^9}, {3.696272129323411*^9,
3.696272129726449*^9}, {3.696279582790657*^9, 3.6962795836646748`*^9},
3.696279949184925*^9, {3.6962824199754133`*^9, 3.696282420237813*^9},
3.696282459473501*^9, {3.696356417860567*^9, 3.696356420930139*^9},
3.696563286212397*^9, {3.702513015082049*^9, 3.70251301762225*^9}, {
3.702513316507017*^9, 3.702513318517189*^9}, {3.7026046867736473`*^9,
3.70260468937008*^9}, {3.7026048685962963`*^9, 3.702604869906116*^9}, {
3.702637141373564*^9, 3.702637143834428*^9}, {3.7026372101029387`*^9,
3.702637212949531*^9}, {3.702637263990807*^9, 3.7026372663005953`*^9}, {
3.702637339948943*^9, 3.702637342389942*^9}, {3.702637448359185*^9,
3.702637450723886*^9}, {3.702637638172937*^9, 3.702637640246686*^9}, {
3.702637772258209*^9, 3.702637776733778*^9}},
ExpressionUUID -> "79b01b21-3d02-4d96-85d1-4887f0201875"],
Cell[BoxData[
RowBox[{"{",
RowBox[{
SubscriptBox["\[Tau]", "1"], ",",
SubscriptBox["\[Tau]", "2"], ",",
SubscriptBox["\[Tau]", "3"]}], "}"}]], "Output",
CellChangeTimes->{{3.702469571066551*^9, 3.7024695973219*^9},
3.702469688997642*^9, 3.702470198109639*^9, 3.702470261852824*^9, {
3.702472501570518*^9, 3.7024725213781013`*^9}, {3.7024810359556007`*^9,
3.7024810534898443`*^9}, 3.702482359120418*^9, {3.702482442991192*^9,
3.7024824565412893`*^9}, {3.7024828005866537`*^9, 3.702482810831984*^9},
3.702507449209249*^9, {3.7025094086869087`*^9, 3.702509421237359*^9},
3.7025095833372097`*^9, 3.702509622313506*^9, {3.7025097211020203`*^9,
3.702509748360331*^9}, {3.702509786405898*^9, 3.702509802596884*^9},
3.7025098328494053`*^9, 3.702509865393355*^9, {3.702509904012313*^9,
3.7025099460987062`*^9}, 3.702511398884507*^9, {3.70251143925359*^9,
3.702511463288756*^9}, {3.7025130486786823`*^9, 3.702513074147172*^9},
3.702513320765224*^9, 3.702516819046139*^9, {3.702516935342767*^9,
3.702516960462463*^9}, {3.702562519035554*^9, 3.702562532591228*^9}, {
3.702564590325602*^9, 3.702564603338447*^9}, 3.702571412378295*^9,
3.702571605287694*^9, 3.7025987163023767`*^9, 3.702598889866816*^9,
3.702598929368586*^9, 3.702599810689785*^9, {3.702600972126295*^9,
3.702600988987357*^9}, {3.702601021627713*^9, 3.702601036748989*^9},
3.7026026062501907`*^9, 3.702604730820381*^9, {3.702637153536448*^9,
3.702637172540749*^9}, 3.702637481148099*^9, 3.7026597720261297`*^9,
3.702659869810087*^9, 3.70268327781706*^9, 3.702684589131488*^9,
3.702684747962545*^9, 3.7026956843724203`*^9, 3.702695738405423*^9,
3.7026963075256147`*^9, 3.7026965104313707`*^9, {3.702696872735921*^9,
3.702696885865271*^9}, 3.7026972758358393`*^9, 3.702697814081976*^9, {
3.7026979330071793`*^9, 3.7026979602697353`*^9}, 3.702700593386548*^9,
3.7027024874171677`*^9, 3.702702987360408*^9, 3.702703836146832*^9,
3.7027054358554*^9, 3.702708887335176*^9, 3.7027220295602703`*^9,
3.702727715831965*^9, 3.7027277688068523`*^9, 3.702728629875709*^9, {
3.702728855787526*^9, 3.702728888883897*^9}, 3.702729113725113*^9,
3.702733194032655*^9, 3.702733538883297*^9, 3.702733667678587*^9,
3.702734147661643*^9, 3.702734253204674*^9, 3.7027358927036743`*^9,
3.7027434405438633`*^9, 3.702746276119092*^9, 3.702751728659936*^9,
3.702753892517868*^9, 3.702785614119998*^9, 3.702820277813575*^9,
3.702820923538072*^9, 3.7028209562760963`*^9, 3.7028210667212133`*^9,
3.702821128491691*^9, 3.702821172219864*^9, 3.702824005015736*^9,
3.7028241656677856`*^9, 3.702899104158515*^9, {3.702908116765766*^9,
3.7029081533867617`*^9}, 3.702909139306452*^9, 3.702913102185976*^9,
3.702913139498784*^9, 3.7029199742945633`*^9, 3.7029821603189297`*^9, {
3.702986570402878*^9, 3.702986588407845*^9}, 3.704734384225649*^9,
3.7047357271837187`*^9, 3.7047357930151463`*^9, {3.7047360026734133`*^9,
3.704736030768834*^9}, 3.704736732016445*^9, 3.70473692318202*^9,
3.704737110024096*^9, 3.704761706775302*^9, 3.70476436406339*^9, {
3.705089797306612*^9, 3.70508981340371*^9}, 3.706055296078619*^9,
3.708804140209395*^9, 3.710027179733686*^9, 3.710159429401743*^9,
3.71016371396984*^9, 3.710163959330681*^9, 3.710179230155438*^9,
3.710774282806719*^9, 3.7107743713300333`*^9, 3.7107744294474363`*^9,
3.710776944176388*^9, 3.710864979155192*^9, 3.710865120950247*^9,
3.710865151140366*^9, 3.7108653272652683`*^9, 3.7108654772005444`*^9,
3.711312259530633*^9, 3.711313476821583*^9, 3.7113135406821632`*^9,
3.7120864693911877`*^9, 3.7120865209903183`*^9},
ExpressionUUID -> "59593d84-7ae3-4d8f-bcc0-2ad73b7e38de"]
}, Open ]],
Cell["The words corresponding to the output configuration", "Text",
CellChangeTimes->{{3.6436091974241457`*^9, 3.643609208614133*^9},
3.682697142287814*^9}],
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{"outputwords", " ", "=", " ",
RowBox[{"Permutations", "[", "outputword", "]"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"noutputwords", " ", "=", " ",
RowBox[{"Length", "[", "outputwords", "]"}]}],
";"}], "\[IndentingNewLine]",
RowBox[{"vvector", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Apply", "[",
RowBox[{"Times", ",",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Subscript", "[",
RowBox[{"U", ",",
RowBox[{"ToExpression", "[",
RowBox[{
RowBox[{"ToString", "[",
RowBox[{"inputword", "[",
RowBox[{"[", "j", "]"}], "]"}], "]"}], "<>",
RowBox[{"ToString", "[",
RowBox[{
RowBox[{"outputwords", "[",
RowBox[{"[", "i", "]"}], "]"}], "[",
RowBox[{"[", "j", "]"}], "]"}], "]"}]}], "]"}]}], "]"}], ",",
RowBox[{"{",
RowBox[{"j", ",", "nphotons"}], "}"}]}], "]"}]}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "uniquewords"}], "}"}]}], "]"}]}]}], "Input",
CellChangeTimes->{{3.643600779310021*^9, 3.6436007799852133`*^9}, {
3.643601688138*^9, 3.643601689761088*^9}, {3.643602410563664*^9,
3.643602413203109*^9}, {3.643645425458413*^9, 3.6436454258217983`*^9}, {
3.647122481388741*^9, 3.647122485322937*^9}, {3.647132347964672*^9,
3.647132356978148*^9}, {3.673055518403865*^9, 3.673055552661477*^9}, {
3.673055617051785*^9, 3.673055643487081*^9}, {3.6733292860282173`*^9,
3.673329288745943*^9}, {3.6733296158883867`*^9, 3.673329624361185*^9}, {
3.6738414139182262`*^9, 3.673841415691887*^9}, 3.692512564977085*^9,
3.696279478051526*^9, 3.696561180921638*^9, {3.7021029207247972`*^9,
3.70210292459621*^9}},
ExpressionUUID -> "3403f762-acdb-4c91-ac93-18fb2c92a9e6"],
Cell[BoxData[
RowBox[{"{",
RowBox[{
RowBox[{
SubscriptBox["U", "11"], " ",
SubscriptBox["U", "22"], " ",
SubscriptBox["U", "33"]}], ",",
RowBox[{
SubscriptBox["U", "11"], " ",
SubscriptBox["U", "23"], " ",
SubscriptBox["U", "32"]}], ",",
RowBox[{
SubscriptBox["U", "12"], " ",
SubscriptBox["U", "21"], " ",
SubscriptBox["U", "33"]}], ",",
RowBox[{
SubscriptBox["U", "12"], " ",
SubscriptBox["U", "23"], " ",
SubscriptBox["U", "31"]}], ",",
RowBox[{
SubscriptBox["U", "13"], " ",
SubscriptBox["U", "21"], " ",
SubscriptBox["U", "32"]}], ",",
RowBox[{
SubscriptBox["U", "13"], " ",
SubscriptBox["U", "22"], " ",
SubscriptBox["U", "31"]}]}], "}"}]], "Output",
CellChangeTimes->{{3.702102921284745*^9, 3.702102925194409*^9}, {
3.702469571097262*^9, 3.702469597344307*^9}, 3.7024696890228167`*^9,
3.70247019813354*^9, 3.702470261899097*^9, 3.702471411723023*^9, {
3.702472501595199*^9, 3.702472521403191*^9}, {3.702481035979806*^9,
3.702481053536524*^9}, 3.702482359142049*^9, {3.702482443014935*^9,
3.702482456561247*^9}, {3.7024828006096563`*^9, 3.702482810854204*^9},
3.7025074492319107`*^9, {3.702509408709651*^9, 3.70250942126073*^9},
3.7025095833627768`*^9, 3.702509622339176*^9, {3.702509721127123*^9,
3.702509748398759*^9}, {3.7025097864291887`*^9, 3.702509802650258*^9},
3.702509832868596*^9, 3.702509865418057*^9, {3.702509904033249*^9,
3.7025099461225357`*^9}, 3.702511398907666*^9, {3.7025114392756577`*^9,
3.702511463310958*^9}, {3.7025130487138853`*^9, 3.702513074326756*^9},
3.702513320898572*^9, 3.702516819073312*^9, {3.702516935368917*^9,
3.702516960487207*^9}, {3.702562519219626*^9, 3.702562532662828*^9}, {
3.702564590367076*^9, 3.7025646033643913`*^9}, 3.702571412400845*^9,
3.702571605309882*^9, 3.702598716348098*^9, 3.7025988898953257`*^9,
3.7025989294161386`*^9, 3.702599810714862*^9, {3.702600972154995*^9,
3.702600989018108*^9}, {3.7026010216619263`*^9, 3.702601036781596*^9},
3.702602606279875*^9, {3.702637153557206*^9, 3.702637172560337*^9},
3.702637481180889*^9, 3.7026597720756083`*^9, 3.702659869859982*^9,
3.702683277907979*^9, 3.702684589151823*^9, 3.702684747983704*^9,
3.7026956845150623`*^9, 3.7026957384276943`*^9, 3.7026963075462837`*^9,
3.702696510449204*^9, {3.7026968727558823`*^9, 3.702696885885605*^9},
3.7026972758411207`*^9, 3.7026978141000137`*^9, {3.702697933026799*^9,
3.7026979602865667`*^9}, 3.702700593407655*^9, 3.702702487465765*^9,
3.702702987380065*^9, 3.702703836170362*^9, 3.702705435876021*^9,
3.7027088873600197`*^9, 3.702722029583507*^9, 3.7027277158589487`*^9,
3.7027277688292017`*^9, 3.7027286298967733`*^9, {3.702728855823297*^9,
3.702728888904394*^9}, 3.702729113745615*^9, 3.7027331940603333`*^9,
3.702733538903901*^9, 3.70273366770054*^9, 3.7027341476828327`*^9,
3.7027342532828693`*^9, 3.702735892734174*^9, 3.702743440565647*^9,
3.702746276194077*^9, 3.702751728688878*^9, 3.702753892539318*^9,
3.7027856141411333`*^9, 3.702820277888503*^9, 3.702820923556645*^9,
3.7028209562996407`*^9, 3.702821066741699*^9, 3.702821128511713*^9,
3.702821172242818*^9, 3.702824005098921*^9, 3.702824165691134*^9,
3.702899104233726*^9, {3.702908116844606*^9, 3.702908153409834*^9},
3.7029091393300343`*^9, 3.702913102206628*^9, 3.702913139520639*^9,
3.702919974373934*^9, 3.702982160427745*^9, {3.702986570473403*^9,
3.7029865884804697`*^9}, 3.704734384300465*^9, 3.704735727204135*^9,
3.704735793034461*^9, {3.7047360027037477`*^9, 3.704736030804833*^9},
3.7047367320419397`*^9, 3.704736923215886*^9, 3.70473711006376*^9,
3.704761706850811*^9, 3.704764364136935*^9, {3.705089797492031*^9,
3.7050898134741163`*^9}, 3.706055296149864*^9, 3.7088041402822437`*^9,
3.71002717975893*^9, 3.710159429427257*^9, 3.710163714044733*^9,
3.7101639593512173`*^9, 3.710179230179173*^9, 3.710774282882193*^9,
3.710774371403153*^9, 3.710774429518581*^9, 3.710776944250049*^9,
3.710864979179668*^9, 3.710865120972909*^9, 3.710865151161578*^9,
3.710865327297039*^9, 3.710865477225857*^9, 3.711312259603551*^9,
3.7113134768426323`*^9, 3.711313540704885*^9, 3.712086469468367*^9,
3.712086521116015*^9},
ExpressionUUID -> "bea4d877-1f55-46a4-840a-f15a19b13e21"]
}, Open ]],
Cell["\<\
Detection results in various transformations from the input frequencies to \
the detected ones. Each entry in this list corresponds to one such \
transformation.\
\>", "Text",
CellChangeTimes->{{3.6436091716487513`*^9, 3.6436091788641663`*^9}, {
3.643609216350312*^9, 3.643609281187804*^9}, 3.682697147439858*^9}],
Cell[BoxData[
RowBox[{
RowBox[{"permutationcombs", " ", "=", " ",
RowBox[{"Flatten", "[",
RowBox[{
RowBox[{"Apply", "[",
RowBox[{"Outer", ",",
RowBox[{"Join", "[",
RowBox[{
RowBox[{"{", "List", "}"}], ",",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Range", "[",
RowBox[{"Factorial", "[",
RowBox[{"outputdist", "[",
RowBox[{"[", "i", "]"}], "]"}], "]"}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "nchannels"}], "}"}]}], "]"}]}], "]"}]}], "]"}],
",",
RowBox[{"Range", "[", "nchannels", "]"}]}], "]"}]}], ";"}]], "Input",
CellChangeTimes->{{3.643600890279058*^9, 3.6436008937062893`*^9}, {
3.643601636159626*^9, 3.643601638795483*^9}, {3.6436024365717173`*^9,
3.6436024368298407`*^9}, {3.643602826006589*^9, 3.643602829860251*^9}, {
3.643611352856986*^9, 3.643611381543642*^9}, {3.6436114189163303`*^9,
3.6436114190435658`*^9}, {3.6436114635900993`*^9,
3.6436115276708527`*^9}, {3.643650704879425*^9, 3.6436507081319933`*^9},
3.673841424599286*^9, 3.692512285022995*^9, 3.6965611754981403`*^9},
ExpressionUUID -> "eb6c40b8-4e08-43b7-a4f0-14b1927e50c3"],
Cell["\<\
Here are the actual possible transformations corresponding to each output \
port.\
\>", "Text",
CellChangeTimes->{{3.643609296504184*^9, 3.6436093214118023`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"outputwordperms", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Permutations", "[",
RowBox[{"Flatten", "[",
RowBox[{"Position", "[",
RowBox[{"outputword", ",", "i"}], "]"}], "]"}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "nchannels"}], "}"}]}], "]"}]}], ";"}]], "Input",
CellChangeTimes->{{3.643601876629016*^9, 3.64360190585225*^9}, {
3.6436024272602377`*^9, 3.643602429697255*^9}, 3.652220424342286*^9, {
3.673329352138795*^9, 3.673329381430142*^9}, 3.673841425586051*^9,
3.692512047865033*^9, 3.696561176315899*^9},
ExpressionUUID -> "6f6e70b8-8318-4517-b93c-c7d4db9fc2c5"],
Cell["\<\
Using the above, create a list of list of phases. Each element is a list of \
phases corresponding to one word.\
\>", "Text",
CellChangeTimes->{{3.643609871331644*^9, 3.643609919442646*^9},
3.6776082960586863`*^9}],
Cell[BoxData[
RowBox[{
RowBox[{"phases", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Table", "[",
RowBox[{
RowBox[{
RowBox[{"freqperm", " ", "=", " ",
RowBox[{"Flatten", "[",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Position", "[",
RowBox[{
RowBox[{"outputwords", "[",
RowBox[{"[", "m", "]"}], "]"}], ",", "k"}], "]"}], ",",
RowBox[{"{",
RowBox[{"k", ",", "nchannels"}], "}"}]}], "]"}], "]"}]}], ";",
RowBox[{"Permute", "[",
RowBox[{"inputtaus", ",",
RowBox[{
RowBox[{"Range", "[", "nphotons", "]"}], "/.",
RowBox[{"Thread", "[",
RowBox[{"Rule", "[",
RowBox[{"freqperm", ",",
RowBox[{"Flatten", "[",
RowBox[{"Table", "[",
RowBox[{
RowBox[{
RowBox[{"outputwordperms", "[",
RowBox[{"[", "j", "]"}], "]"}], "[",
RowBox[{"[",
RowBox[{
RowBox[{"permutationcombs", "[",
RowBox[{"[", "i", "]"}], "]"}], "[",
RowBox[{"[", "j", "]"}], "]"}], "]"}], "]"}], ",",
RowBox[{"{",
RowBox[{"j", ",", "nchannels"}], "}"}]}], "]"}], "]"}]}],
"]"}], "]"}]}]}], "]"}]}], ",",
RowBox[{"{",
RowBox[{"i", ",",
RowBox[{"Length", "[", "permutationcombs", "]"}]}], "}"}]}], "]"}],
",",
RowBox[{"{",
RowBox[{"m", ",", "uniquewords"}], "}"}]}], "]"}]}], " ",
";"}]], "Input",
CellChangeTimes->{{3.643604215051797*^9, 3.643604240261505*^9}, {
3.64360433268126*^9, 3.643604436016824*^9}, {3.6436045132224913`*^9,
3.643604536643573*^9}, {3.643604606011339*^9, 3.643604606811653*^9}, {
3.643604643907631*^9, 3.6436046448532248`*^9}, 3.6436117095389233`*^9,
3.643656834019087*^9, {3.6471221788441753`*^9, 3.647122199176426*^9}, {
3.6733292977231083`*^9, 3.67332931375158*^9}, 3.673329385749482*^9,
3.673841427297411*^9, 3.6925121018332033`*^9, 3.696561199627715*^9},
ExpressionUUID -> "18d426b3-a1b1-4df0-a16b-fe49368c243a"],
Cell["\<\
The rate matrix can be calculate simply by multiplying appropriate phases and \
integrating.\
\>", "Text",
CellChangeTimes->{{3.643609926112221*^9, 3.6436099667824373`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
RowBox[{"MrWizard1", " ", "from", " ",
RowBox[{"http", ":"}]}], "//",
RowBox[{
RowBox[{
RowBox[{
RowBox[{
RowBox[{"mathematica", ".", "stackexchange", ".", "com"}], "/",
"questions"}], "/", "7887"}], "/", "best"}], "-", "way", "-", "to",
"-", "create", "-", "symmetric", "-", "matrices"}]}], " ", "*)"}],
"\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"FastSymmetricMatrixCalculator", "[",
RowBox[{"n_", ",", "f_"}], "]"}], ":=",
RowBox[{
RowBox[{
RowBox[{"Join", "[",
RowBox[{"#", ",",
RowBox[{"Rest", "/@",
RowBox[{"#", "~", "Flatten", "~",
RowBox[{"{", "2", "}"}]}]}], ",", "2"}], "]"}], "&"}], "@",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"i", "~", "f", "~", "j"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "n"}], "}"}], ",",
RowBox[{"{",
RowBox[{"j", ",", "i"}], "}"}]}], "]"}]}]}], ";"}],
"\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"REntry", "[",
RowBox[{"n1_", ",", "n2_"}], "]"}], " ", ":=", " ",
RowBox[{"Sum", "[",
RowBox[{
RowBox[{
RowBox[{"Exp", "[",
RowBox[{"Simplify", "[",
RowBox[{"Sum", "[",
RowBox[{
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"d", "[",
RowBox[{"[", "k", "]"}], "]"}], "===", "0"}], ",", "0", ",",
RowBox[{
RowBox[{
RowBox[{"-",
RowBox[{"s", "^", "2"}]}],
RowBox[{
RowBox[{
RowBox[{"d", "[",
RowBox[{"[", "k", "]"}], "]"}], "^", "2"}], "/", "2"}]}],
" ", "+", " ",
RowBox[{"I", " ", "w0", " ",
RowBox[{"d", "[",
RowBox[{"[", "k", "]"}], "]"}]}]}]}], "]"}], ",",
RowBox[{"{",
RowBox[{"k", ",", "nphotons"}], "}"}]}], "]"}], "]"}], "]"}],
"/", "normalization"}], ",",
RowBox[{"{",
RowBox[{"d", ",",
RowBox[{"Flatten", "[",
RowBox[{
RowBox[{"Outer", "[",
RowBox[{
RowBox[{
RowBox[{"#1", "-", "#2"}], "&"}], ",",
RowBox[{"phases", "[",
RowBox[{"[", "n1", "]"}], "]"}], ",",
RowBox[{"phases", "[",
RowBox[{"[", "n2", "]"}], "]"}], ",", "1"}], "]"}], ",", "1"}],
"]"}]}], " ", "}"}]}], "]"}]}], ";"}], ";"}],
"\[IndentingNewLine]",
RowBox[{
RowBox[{"R", " ", "=", " ",
RowBox[{"FastSymmetricMatrixCalculator", "[",
RowBox[{"uniquewords", ",", "REntry"}], "]"}]}], ";"}]}]}]], "Input",
CellChangeTimes->{{3.6436034293631153`*^9, 3.643603430729287*^9}, {
3.6436036452948017`*^9, 3.643603646616407*^9}, {3.643606749900938*^9,
3.643606754291605*^9}, {3.643606853799705*^9, 3.643606870624839*^9}, {
3.6436070047673798`*^9, 3.643607020849152*^9}, {3.643607123244136*^9,
3.6436072505466433`*^9}, 3.643607431812676*^9, 3.6436083348400183`*^9, {
3.6436094051022587`*^9, 3.643609479465283*^9}, {3.643609685141212*^9,
3.643609706450014*^9}, {3.643609749758381*^9, 3.6436097963542147`*^9}, {
3.6436099946469603`*^9, 3.643610001864996*^9}, 3.643611361637236*^9, {
3.6436115478747587`*^9, 3.6436115699038963`*^9}, 3.643612863218288*^9,
3.643645436792832*^9, 3.643667989551588*^9, 3.6471204444742603`*^9, {
3.673329514837044*^9, 3.673329539917852*^9}, {3.673330205063508*^9,
3.673330283418886*^9}, {3.6734994688949623`*^9, 3.673499516133524*^9}, {
3.6734995528961363`*^9, 3.673499578823101*^9}, {3.673501461833869*^9,
3.673501469003357*^9}, {3.673501958239484*^9, 3.673501979263432*^9}},
ExpressionUUID -> "09b6abd8-3d0a-486c-a199-4a73887b95bb"],
Cell[CellGroupData[{
Cell[BoxData[
RowBox[{"R", " ", "//", "MatrixForm"}]], "Input",
CellChangeTimes->{{3.673329426795864*^9, 3.673329445491034*^9},
3.67350202341892*^9, 3.696270863246983*^9},
ExpressionUUID -> "d6aeaf1d-b9f7-436e-a9a6-0a9e28a04431"],
Cell[BoxData[
TagBox[
RowBox[{"(", "\[NoBreak]", GridBox[{
{"1",
SuperscriptBox["\[ExponentialE]",
RowBox[{
RowBox[{"-",
SuperscriptBox["s", "2"]}], " ",
SuperscriptBox[
RowBox[{"(",
RowBox[{
SubscriptBox["\[Tau]", "2"], "-",
SubscriptBox["\[Tau]", "3"]}], ")"}], "2"]}]],
SuperscriptBox["\[ExponentialE]",
RowBox[{
RowBox[{"-",
SuperscriptBox["s", "2"]}], " ",
SuperscriptBox[
RowBox[{"(",
RowBox[{
SubscriptBox["\[Tau]", "1"], "-",
SubscriptBox["\[Tau]", "2"]}], ")"}], "2"]}]],
SuperscriptBox["\[ExponentialE]",
RowBox[{
RowBox[{"-",
SuperscriptBox["s", "2"]}], " ",
RowBox[{"(",
RowBox[{
SubsuperscriptBox["\[Tau]", "1", "2"], "+",
SubsuperscriptBox["\[Tau]", "2", "2"], "-",
RowBox[{
SubscriptBox["\[Tau]", "2"], " ",
SubscriptBox["\[Tau]", "3"]}], "+",