-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from EarlOld/bell-states
Added Bell States
- Loading branch information
Showing
9 changed files
with
226 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Bell States | ||
|
||
## Description | ||
|
||
The Bell states are four specific maximally entangled quantum states of two qubits. They are in a superposition of 0 and 1, and are the maximally entangled states. The Bell states form an orthonormal basis for the two qubits, and when one qubit is measured, the outcome of the other qubit is immediately known, no matter how far apart the qubits are. | ||
|
||
## Parameters | ||
|
||
- `first` (Type: `number`) - The first qubit index. | ||
- `second` (Type: `number`) - The second qubit index. | ||
|
||
## Example 1 - Prepare Bell Phi Plus State | ||
|
||
### Code | ||
|
||
```typescript | ||
import { Circuit } from '@earlold/quantum.js'; | ||
|
||
const circuit = new Circuit(2); | ||
circuit.prepareBellPhiPlus(0, 1); | ||
circuit.run(); | ||
console.log(circuit.stateToString); | ||
``` | ||
|
||
### Output | ||
|
||
```console | ||
0.00000000+0.00000000i|00> 0.00000% | ||
0.70710678+0.00000000i|01> 50.00000% | ||
0.70710678+0.00000000i|10> 50.00000% | ||
0.00000000+0.00000000i|11> 0.00000% | ||
``` | ||
|
||
## Example 2 - Prepare Bell Phi Minus State | ||
|
||
### Code | ||
|
||
```typescript | ||
import { Circuit } from '@earlold/quantum.js'; | ||
|
||
const circuit = new Circuit(2); | ||
circuit.prepareBellPhiMinus(0, 1); | ||
circuit.run(); | ||
console.log(circuit.stateToString); | ||
``` | ||
|
||
### Output | ||
|
||
```console | ||
0.70710678+0.00000000i|00> 50.00000% | ||
0.00000000+0.00000000i|01> 0.00000% | ||
0.00000000+0.00000000i|10> 0.00000% | ||
-0.70710678+0.00000000i|11> 50.00000% | ||
``` | ||
|
||
## Example 3 - Prepare Bell Psi Plus State | ||
|
||
### Code | ||
|
||
```typescript | ||
import { Circuit } from '@earlold/quantum.js'; | ||
|
||
const circuit = new Circuit(2); | ||
circuit.prepareBellPsiPlus(0, 1); | ||
circuit.run(); | ||
console.log(circuit.stateToString); | ||
``` | ||
|
||
### Output | ||
|
||
```console | ||
0.00000000+0.00000000i|00> 0.00000% | ||
0.70710678+0.00000000i|01> 50.00000% | ||
0.70710678+0.00000000i|10> 50.00000% | ||
0.00000000+0.00000000i|11> 0.00000% | ||
``` | ||
|
||
## Example 4 - Prepare Bell Psi Minus State | ||
|
||
### Code | ||
|
||
```typescript | ||
import { Circuit } from '@earlold/quantum.js'; | ||
|
||
const circuit = new Circuit(2); | ||
circuit.prepareBellPsiMinus(0, 1); | ||
circuit.run(); | ||
console.log(circuit.stateToString); | ||
``` | ||
|
||
### Output | ||
|
||
```console | ||
0.00000000+0.00000000i|00> 0.00000% | ||
-0.70710678+0.00000000i|01> 50.00000% | ||
0.70710678+0.00000000i|10> 50.00000% | ||
0.00000000+0.00000000i|11> 0.00000% | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ const config: DocsThemeConfig = { | |
}, | ||
docsRepositoryBase: 'https://github.com/EarlOld/quantum.js', | ||
footer: { | ||
text: 'MIT 2024 © EarlOld - [email protected].1', | ||
text: 'MIT 2024 © EarlOld - [email protected].2', | ||
}, | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export type ObjectQubitState = { | ||
index: number; | ||
indexBinStr: string; | ||
amplitude: { re: number; im: number }; | ||
amplitudeStr: string; | ||
magnitude: number; | ||
chance: number; | ||
chanceStr: string; | ||
phase: number; | ||
phaseStr: string; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,7 @@ | ||
import { optimizeQAOAWithCOBYLA } from 'library'; | ||
import { Circuit } from 'library'; | ||
|
||
const nodes = [0, 1, 2, 3, 4]; | ||
const edges: Array<[number, number]> = [ | ||
[0, 3], | ||
[0, 4], | ||
[1, 3], | ||
[1, 4], | ||
[2, 3], | ||
[2, 4], | ||
]; | ||
const steps = 1; | ||
const circuit = new Circuit(2); | ||
circuit.prepareBellPsiMinus(0, 1); | ||
circuit.run(); | ||
|
||
const { beta, gamma, score, maxCutScore } = optimizeQAOAWithCOBYLA(nodes, edges, steps); | ||
|
||
console.log('Optimized beta:', beta); | ||
console.log('Optimized gamma:', gamma); | ||
console.log('Best score:', score); | ||
console.log('maxCutScore:', maxCutScore); | ||
console.log(circuit.stateToString()); |