Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bernwo committed Apr 15, 2021
1 parent b31fe11 commit 501857e
Show file tree
Hide file tree
Showing 11 changed files with 1,513 additions and 19 deletions.
134 changes: 134 additions & 0 deletions Image/Bell_states/phi00_in.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions Image/Bell_states/phi00_out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions Image/Bell_states/phi01_in.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions Image/Bell_states/phi01_out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions Image/Bell_states/phi10_in.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions Image/Bell_states/phi10_out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 134 additions & 0 deletions Image/Bell_states/phi11_in.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions Image/Bell_states/phi11_out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
401 changes: 401 additions & 0 deletions Image/Example/eg_partialtr_bellstate_in.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions Image/Example/eg_partialtr_bellstate_out.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 36 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

![BernDiracLogo](Image/Logo/BernDirac_logo_v2.svg)

A [Wolfram Mathematica](https://www.wolfram.com/mathematica/) package for performing calculations involving matrices/vectors in the [Dirac notation](https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notation) which is usually used in [quantum mechanics](https://en.wikipedia.org/wiki/Quantum_mechanics)/[quantum computing](https://en.wikipedia.org/wiki/Quantum_computing). It utilises the *built-in functions without predefined meanings*, namely `Ket[]`, `Bra[]`, and `CircleTimes[]`, along with their respective alias, <code>"| ⟩" → <kbd>esc</kbd>ket<kbd>esc</kbd></code>, <code>"⟨ |" → <kbd>esc</kbd>bra<kbd>esc</kbd></code> and <code>"⊗" → <kbd>esc</kbd>c*<kbd>esc</kbd></code>.
A [Wolfram Mathematica](https://www.wolfram.com/mathematica/) package for performing calculations involving matrices/vectors in the [Dirac notation](https://en.wikipedia.org/wiki/Bra%E2%80%93ket_notation) which is usually used in [quantum mechanics](https://en.wikipedia.org/wiki/Quantum_mechanics)/[quantum computing](https://en.wikipedia.org/wiki/Quantum_computing). It utilises the *built-in functions without predefined meanings*, namely `Ket[]`, `Bra[]`, and `CircleTimes[]`, along with their respective alias, <code>| ⟩ <kbd>esc</kbd>ket<kbd>esc</kbd></code>, <code>⟨ | <kbd>esc</kbd>bra<kbd>esc</kbd></code> and <code>⊗ ↔ <kbd>esc</kbd>c*<kbd>esc</kbd></code>.

The basis which this package works in is {|0⟩,|1⟩}, which is also known as the *computational basis* or the *Z basis*.

Expand All @@ -19,16 +19,17 @@ Get[<path-to-BernDirac.wl>];

# Functions that this package provides
After loading [BernDirac.wl](https://github.com/bernie-wu/BernDirac/blob/main/BernDirac.wl) into your Mathematica notebook session, the following additional functions become available to use:
[`Ket[]`](#Ket "Go-to Ket[]")
[`Bra[]`](#Bra "Go-to Bra[]")
[`CircleTimes[]`](#CircleTimes "Go-to CircleTimes[]")
[`DiracForm[]`](#CircleTimes "Go-to DiracForm[]")
[`PartialTr[]`](#CircleTimes "Go-to PartialTr[]")
* [`Ket[]`](#Ket "Go-to Ket[]")
* [`Bra[]`](#Bra "Go-to Bra[]")
* [`CircleTimes[]`](#CircleTimes "Go-to CircleTimes[]")
* [`DiracForm[]`](#CircleTimes "Go-to DiracForm[]")
* [`PartialTr[]`](#CircleTimes "Go-to PartialTr[]")

The special quantities, namely the [**Bell states**](https://en.wikipedia.org/wiki/Bell_state) also become available to use via [`Ket[]`](#Ket "Go-to Ket[]") and [`Bra[]`](#Bra "Go-to Bra[]") (see section [Bell states](#Bell-states "Go-to Bell states")).

## Ket[]
`Ket[]` is used to denote a *column vector*. The alias `| ⟩` for `Ket[]` can be obtained with <code><kbd>esc</kbd>ket<kbd>esc</kbd></code>.
The allowed input for `Ket[]` is either `0` or `1` and the output for each case is as shown here:

The allowed input for `Ket[]` is either `0` or `1` and the output for each case is as shown here:
>> ![In:Ket[0]](Image/Ket/ket0_in.svg "Ket[0]")
>> ![Out:{{1},{0}}](Image/Ket/ket0_out.svg "{{1},{0}}")
>
Expand Down Expand Up @@ -61,7 +62,6 @@ Just like `Ket[]`, `Bra[]` also supports multiple inputs, as long as they are `0
Note that `Bra[1,1,0]` is equivalent to `Bra[1]⊗Bra[1]⊗Bra[0]` (see [`CircleTimes[]`](#CircleTimes "Go-to CircleTimes[]")).


## CircleTimes[]
The alias `` for `CircleTimes[]`, is used to denote the [*Kronecker product*](https://en.wikipedia.org/wiki/Kronecker_product) (sometimes also called [*Tensor product*](https://en.wikipedia.org/wiki/Tensor_product)). Use <code><kbd>esc</kbd>c*<kbd>esc</kbd></code> to obtain the alias.
Below, we show that `` works for multiple column vectors, row vectors, and square matrices.
Expand Down Expand Up @@ -97,9 +97,23 @@ Below, we show that `⊗` works for multiple column vectors, row vectors, and sq
>
>> ![Out:(αKet[0]⊗Ket[0]+βKet[1]⊗Ket[1]).(αBra[0]⊗Bra[0]+βBra[1]⊗Bra[1])](Image/BraKet/αket00_βket11_αbra00_βbra11_tensor_dirac_out.svg "α²|0,0⟩.⟨0,0|+αβ|0,0⟩.⟨1,1|+αβ|1,1⟩.⟨0,0|+β²|1,1⟩.⟨1,1|")
## PartialTr[]
`PartialTr[]` performs partial trace of a given system over the specified indices. This function takes 2 input arguments. The first input must be a *density matrix* (i.e. square matrix). The second input is a list of integer(s) indicating the indices where you would like to perform partial trace over.
## Bell states
By using the special letter capital dotted `Φ` and subscripts, we can access the four Bell states using [`Ket[]`](#Ket "Go-to Ket[]") and [`Bra[]`](#Ket "Go-to Ket[]"). Note that the special dotted `Φ` is known as [FormalCapitalPhi](https://reference.wolfram.com/language/ref/character/FormalCapitalPhi.html) in the documentation (for more information, see the formal letters section [here](https://reference.wolfram.com/language/tutorial/MathematicalAndOtherNotation.html)).
The dotted `Φ` alias can be accessed with <code><kbd>esc</kbd>.CapitalPhi<kbd>esc</kbd></code>, and inputting subscript(s) can be achieved with <code><kbd>ctrl</kbd>+<kbd>_</kbd></code>.
>> ![In:Ket[FormalCapitalPhi_00]](Image/Bell_states/phi00_in.svg "Ket[FormalCapitalPhi_00]")
>> ![Out:Ket[FormalCapitalPhi_00]](Image/Bell_states/phi00_out.svg "|0,0⟩/√2+|1,1⟩/√2")
>
>> ![In:Ket[FormalCapitalPhi_01]](Image/Bell_states/phi01_in.svg "Ket[FormalCapitalPhi_01]")
>> ![Out:Ket[FormalCapitalPhi_01]](Image/Bell_states/phi01_out.svg "|0,1⟩/√2+|1,0⟩/√2")
>
>> ![In:Ket[FormalCapitalPhi_10]](Image/Bell_states/phi10_in.svg "Ket[FormalCapitalPhi_10]")
>> ![Out:Ket[FormalCapitalPhi_10]](Image/Bell_states/phi10_out.svg "|0,0⟩/√2-|1,1⟩/√2")
>
>> ![In:Ket[FormalCapitalPhi_11]](Image/Bell_states/phi11_in.svg "Ket[FormalCapitalPhi_11]")
>> ![Out:Ket[FormalCapitalPhi_11]](Image/Bell_states/phi11_out.svg "|0,1⟩/√2-|1,0⟩/√2")
## PartialTr[]
`PartialTr[]` performs partial trace of a given system over the specified indices. This function takes 2 input arguments. The first input must be a *density matrix* (i.e. square matrix). The second input is a list of integer(s) indicating the indices where you would like to perform partial trace over.
>> ![In:PartialTr[αKet[0,1,1].Bra[0,1,1]+βKet[1,1,0].Bra[1,1,0],{1}]](Image/PartialTr/partialtr1_αketbra011_βketbra110_in.svg "PartialTr[αKet[0,1,1].Bra[0,1,1]+βKet[1,1,0].Bra[1,1,0],{1}]")
>> ![Out:PartialTr[αKet[0,1,1].Bra[0,1,1]+βKet[1,1,0].Bra[1,1,0],{1}]](Image/PartialTr/partialtr1_αketbra011_βketbra110_out.svg "β|1,0⟩.⟨1,0|+α|1,1⟩.⟨1,1|")
>
Expand All @@ -109,20 +123,23 @@ Below, we show that `⊗` works for multiple column vectors, row vectors, and sq
>> ![In:PartialTr[αKet[0,1,1].Bra[0,1,1]+βKet[1,1,0].Bra[1,1,0],{2,3}]](Image/PartialTr/partialtr23_αketbra011_βketbra110_in.svg "PartialTr[αKet[0,1,1].Bra[0,1,1]+βKet[1,1,0].Bra[1,1,0],{2,3}]")
>> ![Out:PartialTr[αKet[0,1,1].Bra[0,1,1]+βKet[1,1,0].Bra[1,1,0],{2,3}]](Image/PartialTr/partialtr23_αketbra011_βketbra110_out.svg "α|0⟩.⟨0|+β|1⟩.⟨1|")
# Example
The only file you need is [BernDirac.wl](https://github.com/bernie-wu/BernDirac/blob/main/BernDirac.wl). A Mathematica notebook .nb file showing examples of how to use this package can be found in the [Example](https://github.com/bernie-wu/BernDirac/tree/main/Example) folder.
# Example
**Applying bit-flip on one qubit in a system of 3 qubits**
>> ![In:Example1](Image/Example/eg_bitflip_in.svg "Example1")
>
>> ![Out:Example1](Image/Example/eg_bitflip_out.svg "Example1")
* Partial trace
* Some kind of Hamiltonian?
**Partial trace of a Bell state**
>> ![In:Example2](Image/Example/eg_partialtr_bellstate_in.svg "Example2")
>
>> ![Out:Example2](Image/Example/eg_partialtr_bellstate_out.svg "Example2")
**Examples in Mathematica notebook**
A Mathematica notebook .nb file showing some usage examples can be found in the [Example](https://github.com/bernie-wu/BernDirac/tree/main/Example) folder.

# Who am I and why did I create this package?
At the time of writing this I am a graduate student with homework assignments involved in heavy and tedious quantum mechanics calculations. I created this Mathematica package to ease my life and since it helped me a tonne, I figured I should share this with the public too in case someone is also in the same boat as me.
At the time of writing this I am a graduate student with homework assignments involved in heavy and tedious quantum mechanics calculations.
I created this Mathematica package to ease my life and since it helped me a tonne, I figured I should share this with the public too in case someone is also in the same boat as me.

# TO-DO
* Write a full fledged example usage within the [readme.md](https://github.com/bernie-wu/BernDirac/blob/main/README.md) itself.
* Write better *usage* descriptions in [BernDirac.wl](https://github.com/bernie-wu/BernDirac/blob/main/BernDirac.wl).
* Add more functions to [BernDirac.wl](https://github.com/bernie-wu/BernDirac/blob/main/BernDirac.wl).
* Write better *usage* descriptions in [BernDirac.wl](https://github.com/bernie-wu/BernDirac/blob/main/BernDirac.wl).

0 comments on commit 501857e

Please sign in to comment.