learn-physics-0.6.5: Haskell code for learning physics

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

Physics.Learn.Ket

Contents

Description

This module contains ket vectors, bra vectors, and operators for quantum mechanics.

Synopsis

Basic data types

type C = Complex Double #

i :: C Source #

data Ket Source #

A ket vector describes the state of a quantum system.

Instances
Num Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(+) :: Ket -> Ket -> Ket #

(-) :: Ket -> Ket -> Ket #

(*) :: Ket -> Ket -> Ket #

negate :: Ket -> Ket #

abs :: Ket -> Ket #

signum :: Ket -> Ket #

fromInteger :: Integer -> Ket #

Show Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

showsPrec :: Int -> Ket -> ShowS #

show :: Ket -> String #

showList :: [Ket] -> ShowS #

Kron Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

kron :: Ket -> Ket -> Ket Source #

HasNorm Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Dagger Bra Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: Bra -> Ket Source #

Dagger Ket Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: Ket -> Bra Source #

Mult C Ket Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: C -> Ket -> Ket Source #

Mult Bra Ket C Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> Ket -> C Source #

Mult Operator Ket Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Operator -> Ket -> Ket Source #

Mult Ket C Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Ket -> C -> Ket Source #

Mult Ket Bra Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Ket -> Bra -> Operator Source #

Representable Ket (Vector C) Source # 
Instance details

Defined in Physics.Learn.Ket

data Bra Source #

A bra vector describes the state of a quantum system.

Instances
Num Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(+) :: Bra -> Bra -> Bra #

(-) :: Bra -> Bra -> Bra #

(*) :: Bra -> Bra -> Bra #

negate :: Bra -> Bra #

abs :: Bra -> Bra #

signum :: Bra -> Bra #

fromInteger :: Integer -> Bra #

Show Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

showsPrec :: Int -> Bra -> ShowS #

show :: Bra -> String #

showList :: [Bra] -> ShowS #

Kron Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

kron :: Bra -> Bra -> Bra Source #

HasNorm Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Dagger Bra Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: Bra -> Ket Source #

Dagger Ket Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: Ket -> Bra Source #

Mult C Bra Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: C -> Bra -> Bra Source #

Mult Bra C Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> C -> Bra Source #

Mult Bra Operator Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> Operator -> Bra Source #

Mult Bra Ket C Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> Ket -> C Source #

Mult Ket Bra Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Ket -> Bra -> Operator Source #

Representable Bra (Vector C) Source # 
Instance details

Defined in Physics.Learn.Ket

data Operator Source #

An operator describes an observable (a Hermitian operator) or an action (a unitary operator).

Instances
Num Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Show Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Kron Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Dagger Operator Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Mult C Operator Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: C -> Operator -> Operator Source #

Mult Bra Operator Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> Operator -> Bra Source #

Mult Operator C Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Operator -> C -> Operator Source #

Mult Operator Operator Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Mult Operator Ket Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Operator -> Ket -> Ket Source #

Mult Ket Bra Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Ket -> Bra -> Operator Source #

Representable Operator (Matrix C) Source # 
Instance details

Defined in Physics.Learn.Ket

Kets for spin-1/2 particles

xp :: Ket Source #

State of a spin-1/2 particle if measurement in the x-direction would give angular momentum +hbar/2.

xm :: Ket Source #

State of a spin-1/2 particle if measurement in the x-direction would give angular momentum -hbar/2.

yp :: Ket Source #

State of a spin-1/2 particle if measurement in the y-direction would give angular momentum +hbar/2.

ym :: Ket Source #

State of a spin-1/2 particle if measurement in the y-direction would give angular momentum -hbar/2.

zp :: Ket Source #

State of a spin-1/2 particle if measurement in the z-direction would give angular momentum +hbar/2.

zm :: Ket Source #

State of a spin-1/2 particle if measurement in the z-direction would give angular momentum -hbar/2.

np :: Double -> Double -> Ket Source #

State of a spin-1/2 particle if measurement in the n-direction, described by spherical polar angle theta and azimuthal angle phi, would give angular momentum +hbar/2.

nm :: Double -> Double -> Ket Source #

State of a spin-1/2 particle if measurement in the n-direction, described by spherical polar angle theta and azimuthal angle phi, would give angular momentum -hbar/2.

Operators for spin-1/2 particles

sx :: Operator Source #

The Pauli X operator.

sy :: Operator Source #

The Pauli Y operator.

sz :: Operator Source #

The Pauli Z operator.

sn :: Double -> Double -> Operator Source #

Pauli operator for an arbitrary direction given by spherical coordinates theta and phi.

sn' :: Double -> Double -> Operator Source #

Alternative definition of Pauli operator for an arbitrary direction.

Quantum Dynamics

timeEvOp :: Double -> Operator -> Operator Source #

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

timeEv :: Double -> Operator -> Ket -> Ket Source #

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

Composition

class Kron a where Source #

Methods

kron :: a -> a -> a Source #

Instances
Kron Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

kron :: Bra -> Bra -> Bra Source #

Kron Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Kron Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

kron :: Ket -> Ket -> Ket Source #

Measurement

possibleOutcomes :: Operator -> [Double] Source #

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

outcomesProjectors :: Operator -> [(Double, Operator)] Source #

Given an obervable, return a list of pairs of possible outcomes and projectors for each outcome.

outcomesProbabilities :: Operator -> Ket -> [(Double, Double)] Source #

Given an observable and a state ket, return a list of pairs of possible outcomes and probabilites for each outcome.

Generic multiplication

class Mult a b c | a b -> c where Source #

Generic multiplication including inner product, outer product, operator product, and whatever else makes sense. No conjugation takes place in this operation.

Methods

(<>) :: a -> b -> c infixl 7 Source #

Instances
Mult C C C Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

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

Mult C Bra Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: C -> Bra -> Bra Source #

Mult C Operator Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: C -> Operator -> Operator Source #

Mult C Ket Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: C -> Ket -> Ket Source #

Mult Bra C Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> C -> Bra Source #

Mult Bra Operator Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> Operator -> Bra Source #

Mult Bra Ket C Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Bra -> Ket -> C Source #

Mult Operator C Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Operator -> C -> Operator Source #

Mult Operator Operator Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Mult Operator Ket Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Operator -> Ket -> Ket Source #

Mult Ket C Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Ket -> C -> Ket Source #

Mult Ket Bra Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

(<>) :: Ket -> Bra -> Operator Source #

Adjoint operation

class Dagger a b | a -> b where Source #

The adjoint operation on complex numbers, kets, bras, and operators.

Methods

dagger :: a -> b Source #

Instances
Dagger C C Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: C -> C Source #

Dagger Bra Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: Bra -> Ket Source #

Dagger Operator Operator Source # 
Instance details

Defined in Physics.Learn.Ket

Dagger Ket Bra Source # 
Instance details

Defined in Physics.Learn.Ket

Methods

dagger :: Ket -> Bra Source #

Normalization

class HasNorm a where Source #

Methods

norm :: a -> Double Source #

normalize :: a -> a Source #

Instances
HasNorm Bra Source # 
Instance details

Defined in Physics.Learn.Ket

HasNorm Ket Source # 
Instance details

Defined in Physics.Learn.Ket

Representation

class Representable a b | a -> b where Source #

Methods

rep :: OrthonormalBasis -> a -> b Source #

dim :: a -> Int Source #

Instances
Representable Bra (Vector C) Source # 
Instance details

Defined in Physics.Learn.Ket

Representable Operator (Matrix C) Source # 
Instance details

Defined in Physics.Learn.Ket

Representable Ket (Vector C) Source # 
Instance details

Defined in Physics.Learn.Ket

Orthonormal bases

data OrthonormalBasis Source #

An orthonormal basis of kets.

makeOB :: [Ket] -> OrthonormalBasis Source #

Make an orthonormal basis from a list of linearly independent kets.

Orthonormal bases for spin-1/2 particles

xBasis :: OrthonormalBasis Source #

The orthonormal basis composed of xp and xm.

yBasis :: OrthonormalBasis Source #

The orthonormal basis composed of yp and ym.

zBasis :: OrthonormalBasis Source #

The orthonormal basis composed of zp and zm.

nBasis :: Double -> Double -> OrthonormalBasis Source #

Given spherical polar angle theta and azimuthal angle phi, the orthonormal basis composed of np theta phi and nm theta phi.