learn-physics-0.6.0.0: Haskell code for learning physics

Copyright(c) Scott N. Walck 2016
LicenseBSD3 (see LICENSE)
MaintainerScott N. Walck <walck@lvc.edu>
Stabilityexperimental
Safe HaskellTrustworthy
LanguageHaskell98

Physics.Learn.QuantumMat

Contents

Description

This module contains state vectors and matrices for quantum mechanics.

Synopsis

Complex numbers

State Vectors

xp :: Vector C Source

The state resulting from a measurement of spin angular momentum in the x direction on a spin-1/2 particle when the result of the measurement is hbar/2.

xm :: Vector C Source

The state resulting from a measurement of spin angular momentum in the x direction on a spin-1/2 particle when the result of the measurement is -hbar/2.

yp :: Vector C Source

The state resulting from a measurement of spin angular momentum in the y direction on a spin-1/2 particle when the result of the measurement is hbar/2.

ym :: Vector C Source

The state resulting from a measurement of spin angular momentum in the y direction on a spin-1/2 particle when the result of the measurement is -hbar/2.

zp :: Vector C Source

The state resulting from a measurement of spin angular momentum in the z direction on a spin-1/2 particle when the result of the measurement is hbar/2.

zm :: Vector C Source

The state resulting from a measurement of spin angular momentum in the z direction on a spin-1/2 particle when the result of the measurement is -hbar/2.

np :: Double -> Double -> Vector C Source

The state resulting from a measurement of spin angular momentum in the direction specified by spherical angles theta (polar angle) and phi (azimuthal angle) on a spin-1/2 particle when the result of the measurement is hbar/2.

nm :: Double -> Double -> Vector C Source

The state resulting from a measurement of spin angular momentum in the direction specified by spherical angles theta (polar angle) and phi (azimuthal angle) on a spin-1/2 particle when the result of the measurement is -hbar/2.

dim :: Vector C -> Int Source

Dimension of a vector.

scaleV :: C -> Vector C -> Vector C Source

Scale a complex vector by a complex number.

inner :: Vector C -> Vector C -> C Source

Complex inner product. First vector gets conjugated.

norm :: Vector C -> Double Source

Length of a complex vector.

normalize :: Vector C -> Vector C Source

Return a normalized version of a given state vector.

probVector Source

Arguments

:: Vector C

state vector

-> Vector Double

vector of probabilities

Return a vector of probabilities for a given state vector.

gramSchmidt :: [Vector C] -> [Vector C] Source

Form an orthonormal list of complex vectors from a linearly independent list of complex vectors.

conjV :: Vector C -> Vector C Source

Conjugate the entries of a vector.

fromList :: [C] -> Vector C Source

Construct a vector from a list of complex numbers.

toList :: Vector C -> [C] Source

Produce a list of complex numbers from a vector.

Matrices (operators)

sx :: Matrix C Source

The Pauli X matrix.

sy :: Matrix C Source

The Pauli Y matrix.

sz :: Matrix C Source

The Pauli Z matrix.

scaleM :: C -> Matrix C -> Matrix C Source

Scale a complex matrix by a complex number.

(<>) :: Matrix C -> Matrix C -> Matrix C Source

Matrix product.

(#>) :: Matrix C -> Vector C -> Vector C Source

Matrix-vector product.

(<#) :: Vector C -> Matrix C -> Vector C Source

Vector-matrix product

conjugateTranspose :: Matrix C -> Matrix C Source

Conjugate transpose of a matrix.

fromLists :: [[C]] -> Matrix C Source

Construct a matrix from a list of lists of complex numbers.

toLists :: Matrix C -> [[C]] Source

Produce a list of lists of complex numbers from a matrix.

size :: Matrix C -> (Int, Int) Source

Size of a matrix.

Density matrices

couter :: Vector C -> Vector C -> Matrix C Source

Complex outer product

dm :: Vector C -> Matrix C Source

Build a pure-state density matrix from a state vector.

trace :: Matrix C -> C Source

Trace of a matrix.

normalizeDM :: Matrix C -> Matrix C Source

Normalize a density matrix so that it has trace one.

oneQubitMixed :: Matrix C Source

The one-qubit totally mixed state.

Quantum Dynamics

timeEv :: Double -> Matrix C -> Vector C -> Vector C Source

Given a time step and a Hamiltonian matrix, advance the state vector using the Schrodinger equation. This method should be faster than using timeEvMat since it solves a linear system rather than calculating an inverse matrix. The function assumes hbar = 1.

timeEvMat :: Double -> Matrix C -> Matrix C Source

Given a time step and a Hamiltonian matrix, produce a unitary time evolution matrix. Unless you really need the time evolution matrix, it is better to use timeEv, which gives the same numerical results with doing an explicit matrix inversion. The function assumes hbar = 1.

Measurement

possibleOutcomes :: Matrix C -> [Double] Source

The possible outcomes of a measurement of an observable. These are the eigenvalues of the matrix of the observable.

Vector and Matrix

data Vector a :: * -> *

Storable-based vectors

Instances

LSDiv Vector 
Normed Vector Double 
Normed Vector Float 
Container Vector Double 
Container Vector Float 
Container Vector I 
Container Vector Z 
Container Vector t => Linear t Vector 
Storable a => Vector Vector a 
Mul Matrix Vector Vector 
Mul Vector Matrix Vector 
Container Vector e => Konst e Int Vector 
Normed Vector (Complex Double) 
Normed Vector (Complex Float) 
Container Vector (Complex Double) 
Container Vector (Complex Float) 
Representable Bra (Vector C) Source 
Representable Ket (Vector C) Source 
KnownNat m => Container Vector (Mod m I) 
KnownNat m => Container Vector (Mod m Z) 
Container Vector e => Build Int (e -> e) Vector e 
Storable a => IsList (Vector a) 
(Storable a, Eq a) => Eq (Vector a) 
(Data a, Storable a) => Data (Vector a) 
KnownNat m => Num (Vector (Mod m I)) 
KnownNat m => Num (Vector (Mod m Z)) 
(Storable a, Ord a) => Ord (Vector a) 
(Read a, Storable a) => Read (Vector a) 
(Show a, Storable a) => Show (Vector a) 
Storable a => Monoid (Vector a) 
NFData (Vector a) 
Normed (Vector Float) 
Normed (Vector (Complex Float)) 
KnownNat m => Normed (Vector (Mod m I)) 
KnownNat m => Normed (Vector (Mod m Z)) 
Normed (Vector I) 
Normed (Vector Z) 
Normed (Vector R) 
Normed (Vector C) 
Container Vector t => Additive (Vector t) 
Storable t => TransArray (Vector t) 
Storable a => Ixed (Vector a) 
Storable a => Wrapped (Vector a) 
Indexable (Vector Double) Double 
Indexable (Vector Float) Float 
Indexable (Vector I) I 
Indexable (Vector Z) Z 
(Storable a, (~) * t (Vector a')) => Rewrapped (Vector a) t 
Element t => Indexable (Matrix t) (Vector t) 
Indexable (Vector (Complex Double)) (Complex Double) 
Indexable (Vector (Complex Float)) (Complex Float) 
(Storable t, Indexable (Vector t) t) => Indexable (Vector (Mod m t)) (Mod m t) 
type IndexOf Vector = Int 
type Mutable Vector = MVector 
type ArgOf Vector a = a -> a 
type Item (Vector a) = a 
type ElementOf (Vector a) = a 
type Index (Vector a) = Int 
type IxValue (Vector a) = a 
type Unwrapped (Vector a) = [a] 
type TransRaw (Vector t) b = CInt -> Ptr t -> b 
type Trans (Vector t) b = CInt -> Ptr t -> b 

data Matrix t :: * -> *

Matrix representation suitable for BLAS/LAPACK computations.

Instances

LSDiv Matrix 
Normed Matrix Double 
Normed Matrix Float 
(Num a, Element a, Container Vector a) => Container Matrix a 
Container Matrix t => Linear t Matrix 
Mul Matrix Matrix Matrix 
Mul Matrix Vector Vector 
Mul Vector Matrix Vector 
Normed Matrix (Complex Double) 
Normed Matrix (Complex Float) 
Representable Operator (Matrix C) Source 
(Num e, Container Vector e) => Konst e (Int, Int) Matrix 
(Storable t, NFData t) => NFData (Matrix t) 
Normed (Matrix R) 
Normed (Matrix C) 
Container Matrix t => Additive (Matrix t) 
KnownNat m => Testable (Matrix (Mod m I)) 
Storable t => TransArray (Matrix t) 
Element t => Indexable (Matrix t) (Vector t) 
(CTrans t, Container Vector t) => Transposable (Matrix t) (Matrix t) 
Container Matrix e => Build (Int, Int) (e -> e -> e) Matrix e 
type IndexOf Matrix = (Int, Int) 
type ArgOf Matrix a = a -> a -> a 
type ElementOf (Matrix a) = a 
type TransRaw (Matrix t) b = CInt -> CInt -> Ptr t -> b 
type Trans (Matrix t) b = CInt -> CInt -> CInt -> CInt -> Ptr t -> b