-
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.
- Loading branch information
Showing
15 changed files
with
736 additions
and
20 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
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,53 @@ | ||
# Superdense Coding | ||
|
||
## Overview | ||
|
||
Superdense coding is a quantum communication protocol that enables the transmission of two classical bits of information using a single qubit. This protocol leverages the phenomenon of quantum entanglement, making it one of the most efficient quantum communication techniques. | ||
|
||
In this protocol, two parties, typically referred to as **Alice** and **Bob**, share an entangled qubit pair. By performing specific quantum operations on her qubit, Alice can encode two classical bits of information. She then sends her qubit to Bob, who can decode the information using his entangled qubit. This allows them to effectively communicate two classical bits using only one qubit. | ||
|
||
### How It Works | ||
|
||
1. **Entanglement Creation**: | ||
- Alice and Bob start with a shared entangled qubit pair. This pair is typically in the Bell state `|00 + |11`. | ||
|
||
2. **Encoding by Alice**: | ||
- Alice encodes her two classical bits (\(00\), \(01\), \(10\), or \(11\)) by applying a specific quantum gate to her qubit. The choice of gate (Identity, X, Z, or XZ) depends on the two bits she wants to send. | ||
|
||
3. **Transmission**: | ||
- After encoding, Alice sends her qubit to Bob. | ||
|
||
4. **Decoding by Bob**: | ||
- Bob, now in possession of both qubits, applies a series of quantum operations (specifically, a CNOT gate followed by a Hadamard gate) to decode the original two classical bits. | ||
|
||
### Quantum Circuit | ||
|
||
Below is the quantum circuit representation of the Superdense Coding protocol. This circuit shows how the two classical bits are encoded into a single qubit and how they can be decoded by the receiving party. | ||
|
||
import Image from 'next/image'; | ||
|
||
<div style={{background: '#fff'}}> | ||
<Image src="/circuit-1723265269895.webp" alt="Superdense Coding Circuit" width={500} height={300} /> | ||
</div> | ||
|
||
### Example Usage in TypeScript | ||
|
||
The following example demonstrates how to use the Superdense Coding protocol to send the classical bits "11": | ||
|
||
```typescript | ||
import { sendTwoBitsWithSDC } from '@earlold/quantum.js'; | ||
|
||
const { data } = sendTwoBitsWithSDC('11'); | ||
|
||
console.log(data); // Outputs: 11 | ||
``` | ||
|
||
In this example, `sendTwoBitsWithSDC` is a function that encapsulates the Superdense Coding protocol. It takes the two classical bits as input, encodes them into a qubit, and simulates the decoding process to return the original bits. | ||
|
||
### Conclusion | ||
|
||
Superdense Coding is a powerful example of quantum communication that highlights the potential of quantum protocols to enhance data transmission efficiency. By understanding and implementing this protocol, you can explore the fascinating interplay between classical and quantum information. | ||
|
||
--- | ||
|
||
This version adds more context and explanation to make the documentation clearer and more informative. |
Binary file not shown.
Binary file not shown.
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].2', | ||
text: 'MIT 2024 © EarlOld - [email protected].3', | ||
}, | ||
}; | ||
|
||
|
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,27 @@ | ||
import { sendTwoBitsWithSDC } from '../index'; | ||
|
||
describe('SDC', () => { | ||
it('send two qubits: 11 ', () => { | ||
const { data } = sendTwoBitsWithSDC('11'); | ||
|
||
expect(data).toEqual('11'); | ||
}); | ||
|
||
it('send two qubits: 10 ', () => { | ||
const { data } = sendTwoBitsWithSDC('10'); | ||
|
||
expect(data).toEqual('10'); | ||
}); | ||
|
||
it('send two qubits: 01 ', () => { | ||
const { data } = sendTwoBitsWithSDC('01'); | ||
|
||
expect(data).toEqual('01'); | ||
}); | ||
|
||
it('send two qubits: 00 ', () => { | ||
const { data } = sendTwoBitsWithSDC('00'); | ||
|
||
expect(data).toEqual('00'); | ||
}); | ||
}); |
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,4 +1,4 @@ | ||
import { Circuit } from './circuit'; | ||
import { optimizeQAOAWithCOBYLA } from './utils'; | ||
import { optimizeQAOAWithCOBYLA, sendTwoBitsWithSDC } from './utils'; | ||
|
||
export { Circuit, optimizeQAOAWithCOBYLA }; | ||
export { Circuit, optimizeQAOAWithCOBYLA, sendTwoBitsWithSDC }; |
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,50 @@ | ||
import { Circuit } from '../../circuit'; | ||
|
||
export type SuperDenseCoding = '00' | '01' | '10' | '11'; | ||
|
||
export type SuperDenseCodingResult = { | ||
data: SuperDenseCoding; | ||
circuit: Circuit; | ||
}; | ||
|
||
export const sendTwoBitsWithSDC = (data: SuperDenseCoding): SuperDenseCodingResult => { | ||
// Create a new circuit | ||
const circuit = new Circuit(2); | ||
|
||
// Encode the qubits | ||
circuit.h(0); | ||
circuit.cx(0, 1); | ||
|
||
// Apply the SuperDanceCoding | ||
|
||
switch (data) { | ||
case '00': | ||
break; | ||
case '01': | ||
circuit.x(0); | ||
break; | ||
case '10': | ||
circuit.z(0); | ||
break; | ||
case '11': | ||
circuit.x(0); | ||
circuit.z(0); | ||
break; | ||
} | ||
|
||
// Decode the qubits | ||
|
||
circuit.cx(0, 1); | ||
circuit.h(0); | ||
|
||
circuit.run(); | ||
|
||
// Measure the qubits | ||
|
||
const result = circuit.measure() as number[]; | ||
|
||
return { | ||
data: `${result[0]}${result[1]}` as SuperDenseCoding, | ||
circuit, | ||
}; | ||
}; |
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,3 +1,4 @@ | ||
import { optimizeQAOAWithCOBYLA } from './QAOA'; | ||
import { sendTwoBitsWithSDC } from './SuperDenseCoding'; | ||
|
||
export { optimizeQAOAWithCOBYLA }; | ||
export { optimizeQAOAWithCOBYLA, sendTwoBitsWithSDC }; |
Oops, something went wrong.