-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Haskell code for learning physics
--
-- A library of functions for vector calculus, calculation of electric
-- field, electric flux, magnetic field, and other quantities in
-- classical mechanics, electromagnetic theory, and quantum mechanics.
@package learn-physics
@version 0.6.4
-- | This module defines some common vector operations. It is intended that
-- this module not be imported directly, but that its functionality be
-- gained by importing either SimpleVec or CarrotVec,
-- but not both. Choose SimpleVec for vector operations (such as
-- vector addition) with simple concrete types, which work only with the
-- type Vec of three-dimensional vectors. Choose
-- CarrotVec for vector operations that work with any type in
-- the appropriate type class.
module Physics.Learn.CommonVec
-- | A type for vectors.
data Vec
Vec :: Double -> Double -> Double -> Vec
-- | x component
[xComp] :: Vec -> Double
-- | y component
[yComp] :: Vec -> Double
-- | z component
[zComp] :: Vec -> Double
-- | Form a vector by giving its x, y, and z components.
vec :: Double -> Double -> Double -> Vec
-- | Cross product.
(><) :: Vec -> Vec -> Vec
infixl 7 ><
-- | Unit vector in the x direction.
iHat :: Vec
-- | Unit vector in the y direction.
jHat :: Vec
-- | Unit vector in the z direction.
kHat :: Vec
instance GHC.Classes.Eq Physics.Learn.CommonVec.Vec
instance GHC.Show.Show Physics.Learn.CommonVec.Vec
-- | This module defines some basic vector functionality. It uses the same
-- internal data representation as SimpleVec, but declares
-- Vec to be an instance of VectorSpace. We import
-- zeroV, negateV, sumV, ^+^, ^-^ from
-- AdditiveGroup, and *^, ^*, ^/,
-- <.>, magnitude from VectorSpace.
--
-- CarrotVec exports exactly the same symbols as
-- SimpleVec; they are just defined differently.
module Physics.Learn.CarrotVec
-- | A type for vectors.
data Vec
-- | x component
xComp :: Vec -> Double
-- | y component
yComp :: Vec -> Double
-- | z component
zComp :: Vec -> Double
-- | Form a vector by giving its x, y, and z components.
vec :: Double -> Double -> Double -> Vec
-- | Add vectors
(^+^) :: AdditiveGroup v => v -> v -> v
infixl 6 ^+^
-- | Group subtraction
(^-^) :: AdditiveGroup v => v -> v -> v
infixl 6 ^-^
-- | Scale a vector
(*^) :: VectorSpace v => Scalar v -> v -> v
infixr 7 *^
-- | Vector multiplied by scalar
(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v
infixl 7 ^*
-- | Vector divided by scalar
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v
infixr 7 ^/
-- | Inner/dot product
(<.>) :: InnerSpace v => v -> v -> Scalar v
infixr 7 <.>
-- | Cross product.
(><) :: Vec -> Vec -> Vec
infixl 7 ><
-- | Length of a vector. See also magnitudeSq.
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s
-- | The zero element: identity for '(^+^)'
zeroV :: AdditiveGroup v => v
-- | Additive inverse
negateV :: AdditiveGroup v => v -> v
-- | Sum over several vectors
sumV :: (Foldable f, AdditiveGroup v) => f v -> v
-- | Unit vector in the x direction.
iHat :: Vec
-- | Unit vector in the y direction.
jHat :: Vec
-- | Unit vector in the z direction.
kHat :: Vec
instance Data.AdditiveGroup.AdditiveGroup Physics.Learn.CommonVec.Vec
instance Data.VectorSpace.VectorSpace Physics.Learn.CommonVec.Vec
instance Data.VectorSpace.InnerSpace Physics.Learn.CommonVec.Vec
-- | Composite Trapezoid Rule and Composite Simpson's Rule
module Physics.Learn.CompositeQuadrature
-- | Composite Trapezoid Rule
compositeTrapezoid :: (VectorSpace v, Fractional (Scalar v)) => Int -> Scalar v -> Scalar v -> (Scalar v -> v) -> v
-- | Composite Simpson's Rule
compositeSimpson :: (VectorSpace v, Fractional (Scalar v)) => Int -> Scalar v -> Scalar v -> (Scalar v -> v) -> v
-- | A module for working with the idea of position and coordinate systems.
module Physics.Learn.Position
-- | A type for position. Position is not a vector because it makes no
-- sense to add positions.
data Position
-- | A displacement is a vector.
type Displacement = Vec
-- | A scalar field associates a number with each position in space.
type ScalarField = Position -> Double
-- | A vector field associates a vector with each position in space.
type VectorField = Position -> Vec
-- | Sometimes we want to be able to talk about a field without saying
-- whether it is a scalar field or a vector field.
type Field v = Position -> v
-- | A coordinate system is a function from three parameters to space.
type CoordinateSystem = (Double, Double, Double) -> Position
-- | The Cartesian coordinate system. Coordinates are (x,y,z).
cartesian :: CoordinateSystem
-- | The cylindrical coordinate system. Coordinates are (s,phi,z), where s
-- is the distance from the z axis and phi is the angle with the x axis.
cylindrical :: CoordinateSystem
-- | The spherical coordinate system. Coordinates are (r,theta,phi), where
-- r is the distance from the origin, theta is the angle with the z axis,
-- and phi is the azimuthal angle.
spherical :: CoordinateSystem
-- | A helping function to take three numbers x, y, and z and form the
-- appropriate position using Cartesian coordinates.
cart :: Double -> Double -> Double -> Position
-- | A helping function to take three numbers s, phi, and z and form the
-- appropriate position using cylindrical coordinates.
cyl :: Double -> Double -> Double -> Position
-- | A helping function to take three numbers r, theta, and phi and form
-- the appropriate position using spherical coordinates.
sph :: Double -> Double -> Double -> Position
-- | Returns the three Cartesian coordinates as a triple from a position.
cartesianCoordinates :: Position -> (Double, Double, Double)
-- | Returns the three cylindrical coordinates as a triple from a position.
cylindricalCoordinates :: Position -> (Double, Double, Double)
-- | Returns the three spherical coordinates as a triple from a position.
sphericalCoordinates :: Position -> (Double, Double, Double)
-- | Displacement from source position to target position.
displacement :: Position -> Position -> Displacement
-- | Shift a position by a displacement.
shiftPosition :: Displacement -> Position -> Position
-- | An object is a map into Position.
shiftObject :: Displacement -> (a -> Position) -> a -> Position
-- | A field is a map from Position.
shiftField :: Displacement -> (Position -> v) -> Position -> v
-- | Add two scalar fields or two vector fields.
addFields :: AdditiveGroup v => [Field v] -> Field v
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing spherical coordinate r,
-- while spherical coordinates theta and phi are held constant. Defined
-- everywhere except at the origin. The unit vector rHat points in
-- different directions at different points in space. It is therefore
-- better interpreted as a vector field, rather than a vector.
rHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing spherical coordinate theta,
-- while spherical coordinates r and phi are held constant. Defined
-- everywhere except on the z axis.
thetaHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing (cylindrical or spherical)
-- coordinate phi, while cylindrical coordinates s and z (or spherical
-- coordinates r and theta) are held constant. Defined everywhere except
-- on the z axis.
phiHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing cylindrical coordinate s,
-- while cylindrical coordinates phi and z are held constant. Defined
-- everywhere except on the z axis.
sHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing Cartesian coordinate x,
-- while Cartesian coordinates y and z are held constant. Defined
-- everywhere.
xHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing Cartesian coordinate y,
-- while Cartesian coordinates x and z are held constant. Defined
-- everywhere.
yHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing Cartesian coordinate z,
-- while Cartesian coordinates x and y are held constant. Defined
-- everywhere.
zHat :: VectorField
instance GHC.Show.Show Physics.Learn.Position.Position
-- | This module contains functions for working with Curves and line
-- integrals along Curves.
module Physics.Learn.Curve
-- | Curve is a parametrized function into three-space, an initial
-- limit, and a final limit.
data Curve
Curve :: (Double -> Position) -> Double -> Double -> Curve
-- | function from one parameter into space
[curveFunc] :: Curve -> Double -> Position
-- | starting value of the parameter
[startingCurveParam] :: Curve -> Double
-- | ending value of the parameter
[endingCurveParam] :: Curve -> Double
-- | Reparametrize a curve from 0 to 1.
normalizeCurve :: Curve -> Curve
-- | Concatenate two curves.
concatCurves :: Curve -> Curve -> Curve
-- | Concatenate a list of curves. Parametrizes curves equally.
concatenateCurves :: [Curve] -> Curve
-- | Reverse a curve.
reverseCurve :: Curve -> Curve
-- | Evaluate the position of a curve at a parameter.
evalCurve :: Curve -> Double -> Position
-- | Shift a curve by a displacement.
shiftCurve :: Displacement -> Curve -> Curve
-- | The straight-line curve from one position to another.
straightLine :: Position -> Position -> Curve
-- | Calculates integral f dl over curve, where dl is a scalar line
-- element.
simpleLineIntegral :: (InnerSpace v, Scalar v ~ Double) => Int -> Field v -> Curve -> v
-- | A dotted line integral. Convenience function for
-- compositeSimpsonDottedLineIntegral.
dottedLineIntegral :: Int -> VectorField -> Curve -> Double
-- | Calculates integral vf x dl over curve. Convenience function for
-- compositeSimpsonCrossedLineIntegral.
crossedLineIntegral :: Int -> VectorField -> Curve -> Vec
-- | A dotted line integral, performed in an unsophisticated way.
compositeTrapezoidDottedLineIntegral :: Int -> VectorField -> Curve -> Double
-- | Calculates integral vf x dl over curve in an unsophisticated way.
compositeTrapezoidCrossedLineIntegral :: Int -> VectorField -> Curve -> Vec
-- | Quadratic approximation to vector field. Quadratic approximation to
-- curve. Composite strategy. Dotted line integral.
compositeSimpsonDottedLineIntegral :: Int -> VectorField -> Curve -> Double
-- | Quadratic approximation to vector field. Quadratic approximation to
-- curve. Composite strategy. Crossed line integral.
compositeSimpsonCrossedLineIntegral :: Int -> VectorField -> Curve -> Vec
-- | A module for working with coordinate systems.
module Physics.Learn.CoordinateSystem
-- | Specification of a coordinate system requires a map from coordinates
-- into space, and a map from space into coordinates.
data CoordinateSystem
CoordinateSystem :: ((Double, Double, Double) -> Position) -> (Position -> (Double, Double, Double)) -> CoordinateSystem
-- | a map from coordinates into space
[toPosition] :: CoordinateSystem -> (Double, Double, Double) -> Position
-- | a map from space into coordinates
[fromPosition] :: CoordinateSystem -> Position -> (Double, Double, Double)
-- | The standard Cartesian coordinate system
standardCartesian :: CoordinateSystem
-- | The standard cylindrical coordinate system
standardCylindrical :: CoordinateSystem
-- | The standard spherical coordinate system
standardSpherical :: CoordinateSystem
-- | Define a new coordinate system in terms of an existing one. First
-- parameter is a map from old coordinates to new coordinates. Second
-- parameter is the inverse map from new coordinates to old coordinates.
newCoordinateSystem :: ((Double, Double, Double) -> (Double, Double, Double)) -> ((Double, Double, Double) -> (Double, Double, Double)) -> CoordinateSystem -> CoordinateSystem
-- | Coordinate fields for Cartesian, cylindrical, and spherical
-- coordinates.
module Physics.Learn.CoordinateFields
-- | The x Cartesian coordinate of a position.
x :: ScalarField
-- | The y Cartesian coordinate of a position.
y :: ScalarField
-- | The z Cartesian (or cylindrical) coordinate of a position.
z :: ScalarField
-- | The s cylindrical coordinate of a position. This is the distance of
-- the position from the z axis.
s :: ScalarField
-- | The phi cylindrical (or spherical) coordinate of a position. This is
-- the angle from the positive x axis to the projection of the position
-- onto the xy plane.
phi :: ScalarField
-- | The r spherical coordinate of a position. This is the distance of the
-- position from the origin.
r :: ScalarField
-- | The theta spherical coordinate of a position. This is the angle from
-- the positive z axis to the position.
theta :: ScalarField
-- | This module contains state vectors and matrices for quantum mechanics.
module Physics.Learn.QuantumMat
type C = Complex Double
-- | 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.
xp :: Vector C
-- | 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
-- | 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.
yp :: Vector C
-- | 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
-- | 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.
zp :: Vector C
-- | 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
-- | 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.
np :: Double -> Double -> Vector C
-- | 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
-- | Dimension of a vector.
dim :: Vector C -> Int
-- | Scale a complex vector by a complex number.
scaleV :: C -> Vector C -> Vector C
-- | Complex inner product. First vector gets conjugated.
inner :: Vector C -> Vector C -> C
-- | Length of a complex vector.
norm :: Vector C -> Double
-- | Return a normalized version of a given state vector.
normalize :: Vector C -> Vector C
-- | Return a vector of probabilities for a given state vector.
probVector :: Vector C -> Vector Double
-- | Form an orthonormal list of complex vectors from a linearly
-- independent list of complex vectors.
gramSchmidt :: [Vector C] -> [Vector C]
-- | Conjugate the entries of a vector.
conjV :: Vector C -> Vector C
-- | Construct a vector from a list of complex numbers.
fromList :: [C] -> Vector C
-- | Produce a list of complex numbers from a vector.
toList :: Vector C -> [C]
-- | The Pauli X matrix.
sx :: Matrix C
-- | The Pauli Y matrix.
sy :: Matrix C
-- | The Pauli Z matrix.
sz :: Matrix C
-- | Scale a complex matrix by a complex number.
scaleM :: C -> Matrix C -> Matrix C
-- | Matrix product.
(<>) :: Matrix C -> Matrix C -> Matrix C
-- | Matrix-vector product.
(#>) :: Matrix C -> Vector C -> Vector C
-- | Vector-matrix product
(<#) :: Vector C -> Matrix C -> Vector C
-- | Conjugate transpose of a matrix.
conjugateTranspose :: Matrix C -> Matrix C
-- | Construct a matrix from a list of lists of complex numbers.
fromLists :: [[C]] -> Matrix C
-- | Produce a list of lists of complex numbers from a matrix.
toLists :: Matrix C -> [[C]]
-- | Size of a matrix.
size :: Matrix C -> (Int, Int)
-- | Apply a function to a matrix. Assumes the matrix is a normal matrix (a
-- matrix with an orthonormal basis of eigenvectors).
matrixFunction :: (C -> C) -> Matrix C -> Matrix C
-- | Complex outer product
couter :: Vector C -> Vector C -> Matrix C
-- | Build a pure-state density matrix from a state vector.
dm :: Vector C -> Matrix C
-- | Trace of a matrix.
trace :: Matrix C -> C
-- | Normalize a density matrix so that it has trace one.
normalizeDM :: Matrix C -> Matrix C
-- | The one-qubit totally mixed state.
oneQubitMixed :: Matrix C
-- | 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
-- without doing an explicit matrix inversion. The function assumes hbar
-- = 1.
timeEvMat :: Double -> Matrix C -> Matrix C
-- | 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.
timeEv :: Double -> Matrix C -> Vector C -> Vector C
-- | Given a Hamiltonian matrix, return a function from time to evolution
-- matrix. Uses spectral decomposition. Assumes hbar = 1.
timeEvMatSpec :: Matrix C -> Double -> Matrix C
class Kronecker a
kron :: Kronecker a => a -> a -> a
-- | The possible outcomes of a measurement of an observable. These are the
-- eigenvalues of the matrix of the observable.
possibleOutcomes :: Matrix C -> [Double]
-- | Given an obervable, return a list of pairs of possible outcomes and
-- projectors for each outcome.
outcomesProjectors :: Matrix C -> [(Double, Matrix C)]
-- | Given an observable and a state vector, return a list of pairs of
-- possible outcomes and probabilites for each outcome.
outcomesProbabilities :: Matrix C -> Vector C -> [(Double, Double)]
-- | Storable-based vectors
data Vector a
-- | Matrix representation suitable for BLAS/LAPACK computations.
data Matrix t
instance Internal.Numeric.Product t => Physics.Learn.QuantumMat.Kronecker (Data.Vector.Storable.Vector t)
instance Internal.Numeric.Product t => Physics.Learn.QuantumMat.Kronecker (Internal.Matrix.Matrix t)
-- | This module contains ket vectors, bra vectors, and operators for
-- quantum mechanics.
module Physics.Learn.Ket
type C = Complex Double
i :: C
magnitude :: C -> Double
-- | A ket vector describes the state of a quantum system.
data Ket
-- | A bra vector describes the state of a quantum system.
data Bra
-- | An operator describes an observable (a Hermitian operator) or an
-- action (a unitary operator).
data Operator
-- | State of a spin-1/2 particle if measurement in the x-direction would
-- give angular momentum +hbar/2.
xp :: Ket
-- | State of a spin-1/2 particle if measurement in the x-direction would
-- give angular momentum -hbar/2.
xm :: Ket
-- | State of a spin-1/2 particle if measurement in the y-direction would
-- give angular momentum +hbar/2.
yp :: Ket
-- | State of a spin-1/2 particle if measurement in the y-direction would
-- give angular momentum -hbar/2.
ym :: Ket
-- | State of a spin-1/2 particle if measurement in the z-direction would
-- give angular momentum +hbar/2.
zp :: Ket
-- | State of a spin-1/2 particle if measurement in the z-direction would
-- give angular momentum -hbar/2.
zm :: Ket
-- | 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.
np :: Double -> Double -> Ket
-- | 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
-- | The Pauli X operator.
sx :: Operator
-- | The Pauli Y operator.
sy :: Operator
-- | The Pauli Z operator.
sz :: Operator
-- | Pauli operator for an arbitrary direction given by spherical
-- coordinates theta and phi.
sn :: Double -> Double -> Operator
-- | Alternative definition of Pauli operator for an arbitrary direction.
sn' :: Double -> Double -> Operator
-- | 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.
timeEvOp :: Double -> Operator -> Operator
-- | 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.
timeEv :: Double -> Operator -> Ket -> Ket
class Kron a
kron :: Kron a => a -> a -> a
-- | The possible outcomes of a measurement of an observable. These are the
-- eigenvalues of the operator of the observable.
possibleOutcomes :: Operator -> [Double]
-- | Given an obervable, return a list of pairs of possible outcomes and
-- projectors for each outcome.
outcomesProjectors :: Operator -> [(Double, Operator)]
-- | Given an observable and a state ket, return a list of pairs of
-- possible outcomes and probabilites for each outcome.
outcomesProbabilities :: Operator -> Ket -> [(Double, Double)]
-- | Generic multiplication including inner product, outer product,
-- operator product, and whatever else makes sense. No conjugation takes
-- place in this operation.
class Mult a b c | a b -> c
(<>) :: Mult a b c => a -> b -> c
infixl 7 <>
-- | The adjoint operation on complex numbers, kets, bras, and operators.
class Dagger a b | a -> b
dagger :: Dagger a b => a -> b
class HasNorm a
norm :: HasNorm a => a -> Double
normalize :: HasNorm a => a -> a
class Representable a b | a -> b
rep :: Representable a b => OrthonormalBasis -> a -> b
dim :: Representable a b => a -> Int
-- | An orthonormal basis of kets.
data OrthonormalBasis
-- | Make an orthonormal basis from a list of linearly independent kets.
makeOB :: [Ket] -> OrthonormalBasis
listBasis :: OrthonormalBasis -> [Ket]
size :: OrthonormalBasis -> Int
-- | The orthonormal basis composed of xp and xm.
xBasis :: OrthonormalBasis
-- | The orthonormal basis composed of yp and ym.
yBasis :: OrthonormalBasis
-- | The orthonormal basis composed of zp and zm.
zBasis :: OrthonormalBasis
-- | Given spherical polar angle theta and azimuthal angle phi, the
-- orthonormal basis composed of np theta phi and nm theta
-- phi.
nBasis :: Double -> Double -> OrthonormalBasis
instance GHC.Show.Show Physics.Learn.Ket.OrthonormalBasis
instance Physics.Learn.Ket.Kron Physics.Learn.Ket.Ket
instance Physics.Learn.Ket.Kron Physics.Learn.Ket.Bra
instance Physics.Learn.Ket.Kron Physics.Learn.Ket.Operator
instance GHC.Show.Show Physics.Learn.Ket.Ket
instance GHC.Show.Show Physics.Learn.Ket.Operator
instance Physics.Learn.Ket.Representable Physics.Learn.Ket.Ket (Data.Vector.Storable.Vector Internal.Vector.C)
instance Physics.Learn.Ket.Representable Physics.Learn.Ket.Bra (Data.Vector.Storable.Vector Internal.Vector.C)
instance Physics.Learn.Ket.Representable Physics.Learn.Ket.Operator (Internal.Matrix.Matrix Internal.Vector.C)
instance Physics.Learn.Ket.HasNorm Physics.Learn.Ket.Ket
instance Physics.Learn.Ket.HasNorm Physics.Learn.Ket.Bra
instance Physics.Learn.Ket.Dagger Physics.Learn.Ket.Ket Physics.Learn.Ket.Bra
instance Physics.Learn.Ket.Dagger Physics.Learn.Ket.Bra Physics.Learn.Ket.Ket
instance Physics.Learn.Ket.Dagger Physics.Learn.Ket.Operator Physics.Learn.Ket.Operator
instance Physics.Learn.Ket.Dagger Internal.Vector.C Internal.Vector.C
instance Physics.Learn.Ket.Mult Internal.Vector.C Internal.Vector.C Internal.Vector.C
instance Physics.Learn.Ket.Mult Internal.Vector.C Physics.Learn.Ket.Ket Physics.Learn.Ket.Ket
instance Physics.Learn.Ket.Mult Internal.Vector.C Physics.Learn.Ket.Bra Physics.Learn.Ket.Bra
instance Physics.Learn.Ket.Mult Internal.Vector.C Physics.Learn.Ket.Operator Physics.Learn.Ket.Operator
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Ket Internal.Vector.C Physics.Learn.Ket.Ket
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Bra Internal.Vector.C Physics.Learn.Ket.Bra
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Operator Internal.Vector.C Physics.Learn.Ket.Operator
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Bra Physics.Learn.Ket.Ket Internal.Vector.C
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Bra Physics.Learn.Ket.Operator Physics.Learn.Ket.Bra
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Operator Physics.Learn.Ket.Ket Physics.Learn.Ket.Ket
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Ket Physics.Learn.Ket.Bra Physics.Learn.Ket.Operator
instance Physics.Learn.Ket.Mult Physics.Learn.Ket.Operator Physics.Learn.Ket.Operator Physics.Learn.Ket.Operator
instance GHC.Show.Show Physics.Learn.Ket.Bra
instance GHC.Num.Num Physics.Learn.Ket.Bra
instance GHC.Num.Num Physics.Learn.Ket.Operator
instance GHC.Num.Num Physics.Learn.Ket.Ket
-- | Splitters, recombiners, and detectors for Stern-Gerlach experiments.
module Physics.Learn.BeamStack
data BeamStack
-- | A beam of randomly oriented spin-1/2 particles.
randomBeam :: BeamStack
-- | Given angles describing the orientation of the splitter, removes an
-- incoming beam from the stack and replaces it with two beams, a spin-up
-- and a spin-down beam. The spin-down beam is the most recent beam on
-- the stack.
split :: Double -> Double -> BeamStack -> BeamStack
-- | Given angles describing the orientation of the recombiner, returns a
-- single beam from an incoming pair of beams.
recombine :: Double -> Double -> BeamStack -> BeamStack
-- | Given angles describing the direction of a uniform magnetic field, and
-- given an angle describing the product of the Larmor frequency and the
-- time, return an output beam from an input beam.
applyBField :: Double -> Double -> Double -> BeamStack -> BeamStack
-- | Remove the most recent beam from the stack.
dropBeam :: BeamStack -> BeamStack
-- | Interchange the two most recent beams on the stack.
flipBeams :: BeamStack -> BeamStack
-- | Return the number of beams in a BeamStack.
numBeams :: BeamStack -> Int
-- | Return the intensities of a stack of beams.
detect :: BeamStack -> [Double]
-- | A Stern-Gerlach splitter in the x direction.
splitX :: BeamStack -> BeamStack
-- | A Stern-Gerlach splitter in the y direction.
splitY :: BeamStack -> BeamStack
-- | A Stern-Gerlach splitter in the z direction.
splitZ :: BeamStack -> BeamStack
-- | Given an angle in radians describing the product of the Larmor
-- frequency and the time, apply a magnetic in the x direction to the
-- most recent beam on the stack.
applyBFieldX :: Double -> BeamStack -> BeamStack
-- | Given an angle in radians describing the product of the Larmor
-- frequency and the time, apply a magnetic in the y direction to the
-- most recent beam on the stack.
applyBFieldY :: Double -> BeamStack -> BeamStack
-- | Given an angle in radians describing the product of the Larmor
-- frequency and the time, apply a magnetic in the z direction to the
-- most recent beam on the stack.
applyBFieldZ :: Double -> BeamStack -> BeamStack
-- | A Stern-Gerlach recombiner in the x direction.
recombineX :: BeamStack -> BeamStack
-- | A Stern-Gerlach recombiner in the y direction.
recombineY :: BeamStack -> BeamStack
-- | A Stern-Gerlach recombiner in the z direction.
recombineZ :: BeamStack -> BeamStack
-- | Filter for spin-up particles in the x direction.
xpFilter :: BeamStack -> BeamStack
-- | Filter for spin-down particles in the x direction.
xmFilter :: BeamStack -> BeamStack
-- | Filter for spin-up particles in the z direction.
zpFilter :: BeamStack -> BeamStack
-- | Filter for spin-down particles in the z direction.
zmFilter :: BeamStack -> BeamStack
instance GHC.Show.Show Physics.Learn.BeamStack.BeamStack
-- | Functions for approximately solving equations like f(x) = 0. These
-- functions proceed by assuming that f is continuous, and that a root is
-- bracketed. A bracket around a root consists of numbers a, b such that
-- f(a) f(b) <= 0. Since the product changes sign, there must be an x
-- with a < x < b such that f(x) = 0.
module Physics.Learn.RootFinding
-- | Find a list of roots for a function over a given range. There are no
-- guarantees that all roots will be found. Uses findRootsN with
-- 1000 intervals.
findRoots :: (Double -> Double) -> (Double, Double) -> [Double]
-- | Find a list of roots for a function over a given range. First
-- parameter is the initial number of intervals to use to find the roots.
-- If roots are closely spaced, this number of intervals may need to be
-- large.
findRootsN :: Int -> (Double -> Double) -> (Double, Double) -> [Double]
-- | Find a single root in a bracketed region. The algorithm continues
-- until it exhausts the precision of a Double. This could cause
-- the function to hang.
findRoot :: (Double -> Double) -> (Double, Double) -> Double
-- | Given an initial bracketing of a root (an interval (a,b) for which
-- f(a) f(b) <= 0), produce a bracket (c,d) for which |c-d| <
-- desired accuracy.
bracketRoot :: (Ord a, Fractional a) => a -> (a -> a) -> (a, a) -> (a, a)
-- | Given a bracketed root, return a half-width bracket.
bracketRootStep :: (Ord a, Fractional a) => (a -> a) -> ((a, a), (a, a)) -> ((a, a), (a, a))
-- | This module contains functions to solve the (time dependent)
-- Schrodinger equation in one spatial dimension for a given potential
-- function.
module Physics.Learn.Schrodinger1D
-- | Free potential. The potential energy is zero everywhere.
freeV :: Double -> Double
-- | Harmonic potential. This is the potential energy of a linear spring.
harmonicV :: Double -> Double -> Double
-- | Finite square well potential. Potential is zero inside the well, and
-- constant outside the well. Well is centered at the origin.
squareWell :: Double -> Double -> Double -> Double
-- | A double well potential. Potential energy is a quartic function of
-- position that gives two wells, each approximately harmonic at the
-- bottom of the well.
doubleWell :: Double -> Double -> Double -> Double
-- | A step barrier potential. Potential is zero to left of origin.
stepV :: Double -> Double -> Double
-- | A potential barrier with thickness and height.
wall :: Double -> Double -> Double -> Double -> Double
coherent :: R -> C -> R -> C
gaussian :: R -> R -> R -> C
movingGaussian :: R -> R -> R -> R -> C
-- | Transform a wavefunction into a state vector.
stateVectorFromWavefunction :: R -> R -> Int -> (R -> C) -> Vector C
hamiltonianMatrix :: R -> R -> Int -> R -> R -> (R -> R) -> Matrix C
expectX :: Vector C -> Vector R -> R
-- | Produce a gloss Picture of state vector for 1D wavefunction.
picture :: (Double, Double) -> [Double] -> Vector C -> Picture
xRange :: R -> R -> Int -> [R]
listForm :: (R, R, Vector C) -> ([R], Vector C)
-- | Basic operations on the vector type Vec, such as vector
-- addition and scalar multiplication. This module is simple in the sense
-- that the operations on vectors all have simple, concrete types,
-- without the need for type classes. This makes using and reasoning
-- about vector operations easier for a person just learning Haskell.
module Physics.Learn.SimpleVec
-- | A type for vectors.
data Vec
type R = Double
-- | x component
xComp :: Vec -> Double
-- | y component
yComp :: Vec -> Double
-- | z component
zComp :: Vec -> Double
-- | Form a vector by giving its x, y, and z components.
vec :: Double -> Double -> Double -> Vec
-- | Vector addition.
(^+^) :: Vec -> Vec -> Vec
infixl 6 ^+^
-- | Vector subtraction.
(^-^) :: Vec -> Vec -> Vec
infixl 6 ^-^
-- | Scalar multiplication, where the scalar is on the left and the vector
-- is on the right.
(*^) :: R -> Vec -> Vec
infixl 7 *^
-- | Scalar multiplication, where the scalar is on the right and the vector
-- is on the left.
(^*) :: Vec -> R -> Vec
infixl 7 ^*
-- | Division of a vector by a scalar.
(^/) :: Vec -> R -> Vec
infixl 7 ^/
-- | Dot product of two vectors.
(<.>) :: Vec -> Vec -> R
infixl 7 <.>
-- | Cross product.
(><) :: Vec -> Vec -> Vec
infixl 7 ><
-- | Magnitude of a vector.
magnitude :: Vec -> R
-- | The zero vector.
zeroV :: Vec
-- | The additive inverse of a vector.
negateV :: Vec -> Vec
-- | Sum of a list of vectors.
sumV :: [Vec] -> Vec
-- | Unit vector in the x direction.
iHat :: Vec
-- | Unit vector in the y direction.
jHat :: Vec
-- | Unit vector in the z direction.
kHat :: Vec
-- | A StateSpace is an affine space where the associated vector
-- space has scalars that are instances of Fractional. If p is an
-- instance of StateSpace, then the associated vectorspace
-- Diff p is intended to represent the space of (time) derivatives
-- of paths in p.
--
-- StateSpace is very similar to Conal Elliott's
-- AffineSpace.
module Physics.Learn.StateSpace
-- | An instance of StateSpace is a data type that can serve as the
-- state of some system. Alternatively, a StateSpace is a
-- collection of dependent variables for a differential equation. A
-- StateSpace has an associated vector space for the (time)
-- derivatives of the state. The associated vector space is a linearized
-- version of the StateSpace.
class (VectorSpace (Diff p), Fractional (Scalar (Diff p))) => StateSpace p where {
-- | Associated vector space
type family Diff p;
}
-- | Subtract points
(.-.) :: StateSpace p => p -> p -> Diff p
-- | Point plus vector
(.+^) :: StateSpace p => p -> Diff p -> p
infix 6 .-.
infixl 6 .+^
-- | Point minus vector
(.-^) :: StateSpace p => p -> Diff p -> p
infixl 6 .-^
-- | The scalars of the associated vector space can be thought of as time
-- intervals.
type Time p = Scalar (Diff p)
-- | A differential equation expresses how the dependent variables (state)
-- change with the independent variable (time). A differential equation
-- is specified by giving the (time) derivative of the state as a
-- function of the state. The (time) derivative of a state is an element
-- of the associated vector space.
type DifferentialEquation state = state -> Diff state
-- | An initial value problem is a differential equation along with an
-- initial state.
type InitialValueProblem state = (DifferentialEquation state, state)
-- | An evolution method is a way of approximating the state after
-- advancing a finite interval in the independent variable (time) from a
-- given state.
type EvolutionMethod state = DifferentialEquation state " differential equation" -> Time state " time interval" -> state " initial state" -> state " evolved state"
-- | A (numerical) solution method is a way of converting an initial value
-- problem into a list of states (a solution). The list of states need
-- not be equally spaced in time.
type SolutionMethod state = InitialValueProblem state -> [state]
-- | Given an evolution method and a time step, return the solution method
-- which applies the evolution method repeatedly with with given time
-- step. The solution method returned will produce an infinite list of
-- states.
stepSolution :: EvolutionMethod state -> Time state -> SolutionMethod state
-- | The Euler method is the simplest evolution method. It increments the
-- state by the derivative times the time step.
eulerMethod :: StateSpace state => EvolutionMethod state
instance (Physics.Learn.StateSpace.StateSpace p, Physics.Learn.StateSpace.StateSpace q, Physics.Learn.StateSpace.Time p Data.Type.Equality.~ Physics.Learn.StateSpace.Time q) => Physics.Learn.StateSpace.StateSpace (p, q)
instance (Physics.Learn.StateSpace.StateSpace p, Physics.Learn.StateSpace.StateSpace q, Physics.Learn.StateSpace.StateSpace r, Physics.Learn.StateSpace.Time p Data.Type.Equality.~ Physics.Learn.StateSpace.Time q, Physics.Learn.StateSpace.Time q Data.Type.Equality.~ Physics.Learn.StateSpace.Time r) => Physics.Learn.StateSpace.StateSpace (p, q, r)
instance Physics.Learn.StateSpace.StateSpace GHC.Types.Double
instance Physics.Learn.StateSpace.StateSpace Physics.Learn.CommonVec.Vec
instance Physics.Learn.StateSpace.StateSpace Physics.Learn.Position.Position
instance Physics.Learn.StateSpace.StateSpace p => Physics.Learn.StateSpace.StateSpace [p]
instance Data.AdditiveGroup.AdditiveGroup v => Data.AdditiveGroup.AdditiveGroup [v]
instance Data.VectorSpace.VectorSpace v => Data.VectorSpace.VectorSpace [v]
-- | Differential equation solving using 4th-order Runge-Kutta
module Physics.Learn.RungeKutta
-- | Take a single 4th-order Runge-Kutta step
rungeKutta4 :: StateSpace p => (p -> Diff p) -> Time p -> p -> p
-- | Solve a first-order system of differential equations with 4th-order
-- Runge-Kutta
integrateSystem :: StateSpace p => (p -> Diff p) -> Time p -> p -> [p]
-- | Newton's second law and all that
module Physics.Learn.Mechanics
-- | Time (in s).
type TheTime = Double
-- | A time step (in s).
type TimeStep = Double
-- | Velocity of a particle (in m/s).
type Velocity = Vec
-- | A simple one-particle state, to get started quickly with mechanics of
-- one particle.
type SimpleState = (TheTime, Position, Velocity)
-- | An acceleration function gives the particle's acceleration as a
-- function of the particle's state. The specification of this function
-- is what makes one single-particle mechanics problem different from
-- another. In order to write this function, add all of the forces that
-- act on the particle, and divide this net force by the particle's mass.
-- (Newton's second law).
type SimpleAccelerationFunction = SimpleState -> Vec
-- | Time derivative of state for a single particle with a constant mass.
simpleStateDeriv :: SimpleAccelerationFunction -> DifferentialEquation SimpleState
-- | Single Runge-Kutta step
simpleRungeKuttaStep :: SimpleAccelerationFunction -> TimeStep -> SimpleState -> SimpleState
-- | The state of a single particle is given by the position of the
-- particle and the velocity of the particle.
data St
St :: Position -> Velocity -> St
[position] :: St -> Position
[velocity] :: St -> Velocity
-- | The associated vector space for the state of a single particle.
data DSt
DSt :: Vec -> Vec -> DSt
-- | The state of a system of one particle is given by the current time,
-- the position of the particle, and the velocity of the particle.
-- Including time in the state like this allows us to have time-dependent
-- forces.
type OneParticleSystemState = (TheTime, St)
-- | An acceleration function gives the particle's acceleration as a
-- function of the particle's state.
type OneParticleAccelerationFunction = OneParticleSystemState -> Vec
-- | Time derivative of state for a single particle with a constant mass.
oneParticleStateDeriv :: OneParticleAccelerationFunction -> DifferentialEquation OneParticleSystemState
-- | Single Runge-Kutta step
oneParticleRungeKuttaStep :: OneParticleAccelerationFunction -> TimeStep -> OneParticleSystemState -> OneParticleSystemState
-- | List of system states
oneParticleRungeKuttaSolution :: OneParticleAccelerationFunction -> TimeStep -> OneParticleSystemState -> [OneParticleSystemState]
-- | The state of a system of two particles is given by the current time,
-- the position and velocity of particle 1, and the position and velocity
-- of particle 2.
type TwoParticleSystemState = (TheTime, St, St)
-- | An acceleration function gives a pair of accelerations (one for
-- particle 1, one for particle 2) as a function of the system's state.
type TwoParticleAccelerationFunction = TwoParticleSystemState -> (Vec, Vec)
-- | Time derivative of state for two particles with constant mass.
twoParticleStateDeriv :: TwoParticleAccelerationFunction -> DifferentialEquation TwoParticleSystemState
-- | Single Runge-Kutta step for two-particle system
twoParticleRungeKuttaStep :: TwoParticleAccelerationFunction -> TimeStep -> TwoParticleSystemState -> TwoParticleSystemState
-- | The state of a system of many particles is given by the current time
-- and a list of one-particle states.
type ManyParticleSystemState = (TheTime, [St])
-- | An acceleration function gives a list of accelerations (one for each
-- particle) as a function of the system's state.
type ManyParticleAccelerationFunction = ManyParticleSystemState -> [Vec]
-- | Time derivative of state for many particles with constant mass.
manyParticleStateDeriv :: ManyParticleAccelerationFunction -> DifferentialEquation ManyParticleSystemState
-- | Single Runge-Kutta step for many-particle system
manyParticleRungeKuttaStep :: ManyParticleAccelerationFunction -> TimeStep -> ManyParticleSystemState -> ManyParticleSystemState
instance GHC.Show.Show Physics.Learn.Mechanics.DSt
instance GHC.Show.Show Physics.Learn.Mechanics.St
instance Data.AdditiveGroup.AdditiveGroup Physics.Learn.Mechanics.DSt
instance Data.VectorSpace.VectorSpace Physics.Learn.Mechanics.DSt
instance Physics.Learn.StateSpace.StateSpace Physics.Learn.Mechanics.St
-- | This module contains functions for working with Surfaces and
-- surface integrals over Surfaces.
module Physics.Learn.Surface
-- | Surface is a parametrized function from two parameters to space, lower
-- and upper limits on the first parameter, and lower and upper limits
-- for the second parameter (expressed as functions of the first
-- parameter).
data Surface
Surface :: ((Double, Double) -> Position) -> Double -> Double -> (Double -> Double) -> (Double -> Double) -> Surface
-- | function from two parameters (s,t) into space
[surfaceFunc] :: Surface -> (Double, Double) -> Position
-- | s_l
[lowerLimit] :: Surface -> Double
-- | s_u
[upperLimit] :: Surface -> Double
-- | t_l(s)
[lowerCurve] :: Surface -> Double -> Double
-- | t_u(s)
[upperCurve] :: Surface -> Double -> Double
-- | A unit sphere, centered at the origin.
unitSphere :: Surface
-- | A sphere with given radius centered at the origin.
centeredSphere :: Double -> Surface
-- | Sphere with given radius and center.
sphere :: Double -> Position -> Surface
-- | The upper half of a unit sphere, centered at the origin.
northernHemisphere :: Surface
-- | A disk with given radius, centered at the origin.
disk :: Double -> Surface
-- | Shift a surface by a displacement.
shiftSurface :: Displacement -> Surface -> Surface
-- | A plane surface integral, in which area element is a scalar.
surfaceIntegral :: (VectorSpace v, Scalar v ~ Double) => Int -> Int -> Field v -> Surface -> v
-- | A dotted surface integral, in which area element is a vector.
dottedSurfaceIntegral :: Int -> Int -> VectorField -> Surface -> Double
-- | Some tools related to the gloss 2D graphics and animation library.
module Physics.Learn.Visual.GlossTools
-- | assumes radians coming in
polarToCart :: (Float, Float) -> (Float, Float)
-- | theta=0 is positive x axis, output angle in radians
cartToPolar :: (Float, Float) -> (Float, Float)
-- | An arrow
arrow :: Point -> Point -> Picture
-- | A think arrow
thickArrow :: Float -> Point -> Point -> Picture
-- | This module contains helping functions for using Gnuplot.
module Physics.Learn.Visual.PlotTools
-- | An Attribute with a given label at a given position.
label :: String -> (Double, Double) -> Attribute
-- | An Attribute that requests postscript output.
postscript :: Attribute
-- | An Attribute giving the postscript file name.
psFile :: FilePath -> Attribute
-- | An example of the use of label. See the source code.
examplePlot1 :: IO ()
-- | An example of the use of postscript and psFile. See the
-- source code.
examplePlot2 :: IO ()
-- | Plot a Curve in the xy plane using Gnuplot
plotXYCurve :: Curve -> IO ()
-- | Some tools related to the not-gloss 3D graphics and animation library.
module Physics.Learn.Visual.VisTools
-- | Make a V3 object from a Vec.
v3FromVec :: Vec -> V3 Double
-- | Make a V3 object from a Position.
v3FromPos :: Position -> V3 Double
-- | A VisObject arrow from a vector
visVec :: Color -> Vec -> VisObject Double
-- | Place a vector at a particular position.
oneVector :: Color -> Position -> Vec -> VisObject Double
-- | Display a vector field.
displayVectorField :: Color -> Double -> [Position] -> VectorField -> VisObject Double
-- | A displayable VisObject for a curve.
curveObject :: Color -> Curve -> VisObject Double
instance GHC.Show.Show Physics.Learn.Visual.VisTools.Sph
instance GHC.Show.Show Physics.Learn.Visual.VisTools.Cart
-- | This module contains functions for working with Volumes and
-- volume integrals over Volumes.
module Physics.Learn.Volume
-- | Volume is a parametrized function from three parameters to space,
-- lower and upper limits on the first parameter, lower and upper limits
-- for the second parameter (expressed as functions of the first
-- parameter), and lower and upper limits for the third parameter
-- (expressed as functions of the first and second parameters).
data Volume
Volume :: ((Double, Double, Double) -> Position) -> Double -> Double -> (Double -> Double) -> (Double -> Double) -> (Double -> Double -> Double) -> (Double -> Double -> Double) -> Volume
-- | function from 3 parameters to space
[volumeFunc] :: Volume -> (Double, Double, Double) -> Position
-- | s_a
[loLimit] :: Volume -> Double
-- | s_b
[upLimit] :: Volume -> Double
-- | t_a(s)
[loCurve] :: Volume -> Double -> Double
-- | t_b(s)
[upCurve] :: Volume -> Double -> Double
-- | u_a(s,t)
[loSurf] :: Volume -> Double -> Double -> Double
-- | u_b(s,t)
[upSurf] :: Volume -> Double -> Double -> Double
-- | A unit ball, centered at the origin.
unitBall :: Volume
-- | A unit ball, centered at the origin. Specified in Cartesian
-- coordinates.
unitBallCartesian :: Volume
-- | A ball with given radius, centered at the origin.
centeredBall :: Double -> Volume
-- | Ball with given radius and center.
ball :: Double -> Position -> Volume
-- | Upper half ball, unit radius, centered at origin.
northernHalfBall :: Volume
-- | Cylinder with given radius and height. Circular base of the cylinder
-- is centered at the origin. Circular top of the cylinder lies in plane
-- z = h.
centeredCylinder :: Double -> Double -> Volume
-- | Shift a volume by a displacement.
shiftVolume :: Displacement -> Volume -> Volume
-- | A volume integral
volumeIntegral :: (VectorSpace v, Scalar v ~ Double) => Int -> Int -> Int -> Field v -> Volume -> v
-- | This module contains functions for working with current, magnetic
-- field, and magnetic flux.
module Physics.Learn.Current
-- | Electric current, in units of Amperes (A)
type Current = Double
-- | A current distribution is a line current (current through a wire), a
-- surface current, a volume current, or a combination of these. The
-- VectorField describes a surface current density or a volume
-- current density.
data CurrentDistribution
-- | current through a wire
LineCurrent :: Current -> Curve -> CurrentDistribution
-- | VectorField is surface current density (A/m)
SurfaceCurrent :: VectorField -> Surface -> CurrentDistribution
-- | VectorField is volume current density (A/m^2)
VolumeCurrent :: VectorField -> Volume -> CurrentDistribution
-- | combination of current distributions
MultipleCurrents :: [CurrentDistribution] -> CurrentDistribution
-- | The magnetic field produced by a current distribution. This is the
-- simplest way to find the magnetic field, because it works for any
-- current distribution (line, surface, volume, or combination).
bField :: CurrentDistribution -> VectorField
-- | Magnetic field produced by a line current (current through a wire).
-- The function bField calls this function to evaluate the
-- magnetic field produced by a line current.
bFieldFromLineCurrent :: Current -> Curve -> VectorField
-- | Magnetic field produced by a surface current. The function
-- bField calls this function to evaluate the magnetic field
-- produced by a surface current. This function assumes that surface
-- current density will be specified parallel to the surface, and does
-- not check if that is true.
bFieldFromSurfaceCurrent :: VectorField -> Surface -> VectorField
-- | Magnetic field produced by a volume current. The function
-- bField calls this function to evaluate the magnetic field
-- produced by a volume current.
bFieldFromVolumeCurrent :: VectorField -> Volume -> VectorField
-- | The magnetic flux through a surface produced by a current
-- distribution.
magneticFlux :: Surface -> CurrentDistribution -> Double
-- | This module contains functions for working with charge, electric
-- field, electric flux, and electric potential.
module Physics.Learn.Charge
-- | Electric charge, in units of Coulombs (C)
type Charge = Double
-- | A charge distribution is a point charge, a line charge, a surface
-- charge, a volume charge, or a combination of these. The
-- ScalarField describes a linear charge density, a surface charge
-- density, or a volume charge density.
data ChargeDistribution
-- | point charge
PointCharge :: Charge -> Position -> ChargeDistribution
-- | ScalarField is linear charge density (C/m)
LineCharge :: ScalarField -> Curve -> ChargeDistribution
-- | ScalarField is surface charge density (C/m^2)
SurfaceCharge :: ScalarField -> Surface -> ChargeDistribution
-- | ScalarField is volume charge density (C/m^3)
VolumeCharge :: ScalarField -> Volume -> ChargeDistribution
-- | combination of charge distributions
MultipleCharges :: [ChargeDistribution] -> ChargeDistribution
-- | Total charge (in C) of a charge distribution.
totalCharge :: ChargeDistribution -> Charge
-- | The electric field produced by a charge distribution. This is the
-- simplest way to find the electric field, because it works for any
-- charge distribution (point, line, surface, volume, or combination).
eField :: ChargeDistribution -> VectorField
-- | Electric field produced by a point charge. The function eField
-- calls this function to evaluate the electric field produced by a point
-- charge.
eFieldFromPointCharge :: Charge -> Position -> VectorField
-- | Electric field produced by a line charge. The function eField
-- calls this function to evaluate the electric field produced by a line
-- charge.
eFieldFromLineCharge :: ScalarField -> Curve -> VectorField
-- | Electric field produced by a surface charge. The function
-- eField calls this function to evaluate the electric field
-- produced by a surface charge.
eFieldFromSurfaceCharge :: ScalarField -> Surface -> VectorField
-- | Electric field produced by a volume charge. The function eField
-- calls this function to evaluate the electric field produced by a
-- volume charge.
eFieldFromVolumeCharge :: ScalarField -> Volume -> VectorField
-- | The electric flux through a surface produced by a charge distribution.
electricFlux :: Surface -> ChargeDistribution -> Double
-- | Electric potential from electric field, given a position to be the
-- zero of electric potential.
electricPotentialFromField :: Position -> VectorField -> ScalarField
-- | Electric potential produced by a charge distribution. The position
-- where the electric potential is zero is taken to be infinity.
electricPotentialFromCharge :: ChargeDistribution -> ScalarField
-- | Functions for learning physics.
module Physics.Learn
-- | Time (in s).
type TheTime = Double
-- | A time step (in s).
type TimeStep = Double
-- | Velocity of a particle (in m/s).
type Velocity = Vec
-- | A simple one-particle state, to get started quickly with mechanics of
-- one particle.
type SimpleState = (TheTime, Position, Velocity)
-- | An acceleration function gives the particle's acceleration as a
-- function of the particle's state. The specification of this function
-- is what makes one single-particle mechanics problem different from
-- another. In order to write this function, add all of the forces that
-- act on the particle, and divide this net force by the particle's mass.
-- (Newton's second law).
type SimpleAccelerationFunction = SimpleState -> Vec
-- | Time derivative of state for a single particle with a constant mass.
simpleStateDeriv :: SimpleAccelerationFunction -> DifferentialEquation SimpleState
-- | Single Runge-Kutta step
simpleRungeKuttaStep :: SimpleAccelerationFunction -> TimeStep -> SimpleState -> SimpleState
-- | The state of a single particle is given by the position of the
-- particle and the velocity of the particle.
data St
St :: Position -> Velocity -> St
[position] :: St -> Position
[velocity] :: St -> Velocity
-- | The associated vector space for the state of a single particle.
data DSt
DSt :: Vec -> Vec -> DSt
-- | The state of a system of one particle is given by the current time,
-- the position of the particle, and the velocity of the particle.
-- Including time in the state like this allows us to have time-dependent
-- forces.
type OneParticleSystemState = (TheTime, St)
-- | An acceleration function gives the particle's acceleration as a
-- function of the particle's state.
type OneParticleAccelerationFunction = OneParticleSystemState -> Vec
-- | Time derivative of state for a single particle with a constant mass.
oneParticleStateDeriv :: OneParticleAccelerationFunction -> DifferentialEquation OneParticleSystemState
-- | Single Runge-Kutta step
oneParticleRungeKuttaStep :: OneParticleAccelerationFunction -> TimeStep -> OneParticleSystemState -> OneParticleSystemState
-- | List of system states
oneParticleRungeKuttaSolution :: OneParticleAccelerationFunction -> TimeStep -> OneParticleSystemState -> [OneParticleSystemState]
-- | The state of a system of two particles is given by the current time,
-- the position and velocity of particle 1, and the position and velocity
-- of particle 2.
type TwoParticleSystemState = (TheTime, St, St)
-- | An acceleration function gives a pair of accelerations (one for
-- particle 1, one for particle 2) as a function of the system's state.
type TwoParticleAccelerationFunction = TwoParticleSystemState -> (Vec, Vec)
-- | Time derivative of state for two particles with constant mass.
twoParticleStateDeriv :: TwoParticleAccelerationFunction -> DifferentialEquation TwoParticleSystemState
-- | Single Runge-Kutta step for two-particle system
twoParticleRungeKuttaStep :: TwoParticleAccelerationFunction -> TimeStep -> TwoParticleSystemState -> TwoParticleSystemState
-- | The state of a system of many particles is given by the current time
-- and a list of one-particle states.
type ManyParticleSystemState = (TheTime, [St])
-- | An acceleration function gives a list of accelerations (one for each
-- particle) as a function of the system's state.
type ManyParticleAccelerationFunction = ManyParticleSystemState -> [Vec]
-- | Time derivative of state for many particles with constant mass.
manyParticleStateDeriv :: ManyParticleAccelerationFunction -> DifferentialEquation ManyParticleSystemState
-- | Single Runge-Kutta step for many-particle system
manyParticleRungeKuttaStep :: ManyParticleAccelerationFunction -> TimeStep -> ManyParticleSystemState -> ManyParticleSystemState
-- | Electric charge, in units of Coulombs (C)
type Charge = Double
-- | A charge distribution is a point charge, a line charge, a surface
-- charge, a volume charge, or a combination of these. The
-- ScalarField describes a linear charge density, a surface charge
-- density, or a volume charge density.
data ChargeDistribution
-- | point charge
PointCharge :: Charge -> Position -> ChargeDistribution
-- | ScalarField is linear charge density (C/m)
LineCharge :: ScalarField -> Curve -> ChargeDistribution
-- | ScalarField is surface charge density (C/m^2)
SurfaceCharge :: ScalarField -> Surface -> ChargeDistribution
-- | ScalarField is volume charge density (C/m^3)
VolumeCharge :: ScalarField -> Volume -> ChargeDistribution
-- | combination of charge distributions
MultipleCharges :: [ChargeDistribution] -> ChargeDistribution
-- | Total charge (in C) of a charge distribution.
totalCharge :: ChargeDistribution -> Charge
-- | Electric current, in units of Amperes (A)
type Current = Double
-- | A current distribution is a line current (current through a wire), a
-- surface current, a volume current, or a combination of these. The
-- VectorField describes a surface current density or a volume
-- current density.
data CurrentDistribution
-- | current through a wire
LineCurrent :: Current -> Curve -> CurrentDistribution
-- | VectorField is surface current density (A/m)
SurfaceCurrent :: VectorField -> Surface -> CurrentDistribution
-- | VectorField is volume current density (A/m^2)
VolumeCurrent :: VectorField -> Volume -> CurrentDistribution
-- | combination of current distributions
MultipleCurrents :: [CurrentDistribution] -> CurrentDistribution
-- | The electric field produced by a charge distribution. This is the
-- simplest way to find the electric field, because it works for any
-- charge distribution (point, line, surface, volume, or combination).
eField :: ChargeDistribution -> VectorField
-- | The electric flux through a surface produced by a charge distribution.
electricFlux :: Surface -> ChargeDistribution -> Double
-- | Electric potential from electric field, given a position to be the
-- zero of electric potential.
electricPotentialFromField :: Position -> VectorField -> ScalarField
-- | Electric potential produced by a charge distribution. The position
-- where the electric potential is zero is taken to be infinity.
electricPotentialFromCharge :: ChargeDistribution -> ScalarField
-- | The magnetic field produced by a current distribution. This is the
-- simplest way to find the magnetic field, because it works for any
-- current distribution (line, surface, volume, or combination).
bField :: CurrentDistribution -> VectorField
-- | The magnetic flux through a surface produced by a current
-- distribution.
magneticFlux :: Surface -> CurrentDistribution -> Double
-- | A type for vectors.
data Vec
-- | x component
xComp :: Vec -> Double
-- | y component
yComp :: Vec -> Double
-- | z component
zComp :: Vec -> Double
-- | Form a vector by giving its x, y, and z components.
vec :: Double -> Double -> Double -> Vec
-- | Add vectors
(^+^) :: AdditiveGroup v => v -> v -> v
infixl 6 ^+^
-- | Group subtraction
(^-^) :: AdditiveGroup v => v -> v -> v
infixl 6 ^-^
-- | Scale a vector
(*^) :: VectorSpace v => Scalar v -> v -> v
infixr 7 *^
-- | Vector multiplied by scalar
(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v
infixl 7 ^*
-- | Vector divided by scalar
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v
infixr 7 ^/
-- | Inner/dot product
(<.>) :: InnerSpace v => v -> v -> Scalar v
infixr 7 <.>
-- | Cross product.
(><) :: Vec -> Vec -> Vec
infixl 7 ><
-- | Length of a vector. See also magnitudeSq.
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s
-- | The zero element: identity for '(^+^)'
zeroV :: AdditiveGroup v => v
-- | Additive inverse
negateV :: AdditiveGroup v => v -> v
-- | Sum over several vectors
sumV :: (Foldable f, AdditiveGroup v) => f v -> v
-- | Unit vector in the x direction.
iHat :: Vec
-- | Unit vector in the y direction.
jHat :: Vec
-- | Unit vector in the z direction.
kHat :: Vec
-- | A type for position. Position is not a vector because it makes no
-- sense to add positions.
data Position
-- | A displacement is a vector.
type Displacement = Vec
-- | A scalar field associates a number with each position in space.
type ScalarField = Position -> Double
-- | A vector field associates a vector with each position in space.
type VectorField = Position -> Vec
-- | Sometimes we want to be able to talk about a field without saying
-- whether it is a scalar field or a vector field.
type Field v = Position -> v
-- | A coordinate system is a function from three parameters to space.
type CoordinateSystem = (Double, Double, Double) -> Position
-- | The Cartesian coordinate system. Coordinates are (x,y,z).
cartesian :: CoordinateSystem
-- | The cylindrical coordinate system. Coordinates are (s,phi,z), where s
-- is the distance from the z axis and phi is the angle with the x axis.
cylindrical :: CoordinateSystem
-- | The spherical coordinate system. Coordinates are (r,theta,phi), where
-- r is the distance from the origin, theta is the angle with the z axis,
-- and phi is the azimuthal angle.
spherical :: CoordinateSystem
-- | A helping function to take three numbers x, y, and z and form the
-- appropriate position using Cartesian coordinates.
cart :: Double -> Double -> Double -> Position
-- | A helping function to take three numbers s, phi, and z and form the
-- appropriate position using cylindrical coordinates.
cyl :: Double -> Double -> Double -> Position
-- | A helping function to take three numbers r, theta, and phi and form
-- the appropriate position using spherical coordinates.
sph :: Double -> Double -> Double -> Position
-- | Returns the three Cartesian coordinates as a triple from a position.
cartesianCoordinates :: Position -> (Double, Double, Double)
-- | Returns the three cylindrical coordinates as a triple from a position.
cylindricalCoordinates :: Position -> (Double, Double, Double)
-- | Returns the three spherical coordinates as a triple from a position.
sphericalCoordinates :: Position -> (Double, Double, Double)
-- | Displacement from source position to target position.
displacement :: Position -> Position -> Displacement
-- | Shift a position by a displacement.
shiftPosition :: Displacement -> Position -> Position
-- | An object is a map into Position.
shiftObject :: Displacement -> (a -> Position) -> a -> Position
-- | A field is a map from Position.
shiftField :: Displacement -> (Position -> v) -> Position -> v
-- | Add two scalar fields or two vector fields.
addFields :: AdditiveGroup v => [Field v] -> Field v
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing spherical coordinate r,
-- while spherical coordinates theta and phi are held constant. Defined
-- everywhere except at the origin. The unit vector rHat points in
-- different directions at different points in space. It is therefore
-- better interpreted as a vector field, rather than a vector.
rHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing spherical coordinate theta,
-- while spherical coordinates r and phi are held constant. Defined
-- everywhere except on the z axis.
thetaHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing (cylindrical or spherical)
-- coordinate phi, while cylindrical coordinates s and z (or spherical
-- coordinates r and theta) are held constant. Defined everywhere except
-- on the z axis.
phiHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing cylindrical coordinate s,
-- while cylindrical coordinates phi and z are held constant. Defined
-- everywhere except on the z axis.
sHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing Cartesian coordinate x,
-- while Cartesian coordinates y and z are held constant. Defined
-- everywhere.
xHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing Cartesian coordinate y,
-- while Cartesian coordinates x and z are held constant. Defined
-- everywhere.
yHat :: VectorField
-- | The vector field in which each point in space is associated with a
-- unit vector in the direction of increasing Cartesian coordinate z,
-- while Cartesian coordinates x and y are held constant. Defined
-- everywhere.
zHat :: VectorField
-- | Curve is a parametrized function into three-space, an initial
-- limit, and a final limit.
data Curve
Curve :: (Double -> Position) -> Double -> Double -> Curve
-- | function from one parameter into space
[curveFunc] :: Curve -> Double -> Position
-- | starting value of the parameter
[startingCurveParam] :: Curve -> Double
-- | ending value of the parameter
[endingCurveParam] :: Curve -> Double
-- | Reparametrize a curve from 0 to 1.
normalizeCurve :: Curve -> Curve
-- | Concatenate two curves.
concatCurves :: Curve -> Curve -> Curve
-- | Concatenate a list of curves. Parametrizes curves equally.
concatenateCurves :: [Curve] -> Curve
-- | Reverse a curve.
reverseCurve :: Curve -> Curve
-- | Evaluate the position of a curve at a parameter.
evalCurve :: Curve -> Double -> Position
-- | Shift a curve by a displacement.
shiftCurve :: Displacement -> Curve -> Curve
-- | The straight-line curve from one position to another.
straightLine :: Position -> Position -> Curve
-- | Calculates integral f dl over curve, where dl is a scalar line
-- element.
simpleLineIntegral :: (InnerSpace v, Scalar v ~ Double) => Int -> Field v -> Curve -> v
-- | A dotted line integral. Convenience function for
-- compositeSimpsonDottedLineIntegral.
dottedLineIntegral :: Int -> VectorField -> Curve -> Double
-- | Calculates integral vf x dl over curve. Convenience function for
-- compositeSimpsonCrossedLineIntegral.
crossedLineIntegral :: Int -> VectorField -> Curve -> Vec
-- | Surface is a parametrized function from two parameters to space, lower
-- and upper limits on the first parameter, and lower and upper limits
-- for the second parameter (expressed as functions of the first
-- parameter).
data Surface
Surface :: ((Double, Double) -> Position) -> Double -> Double -> (Double -> Double) -> (Double -> Double) -> Surface
-- | function from two parameters (s,t) into space
[surfaceFunc] :: Surface -> (Double, Double) -> Position
-- | s_l
[lowerLimit] :: Surface -> Double
-- | s_u
[upperLimit] :: Surface -> Double
-- | t_l(s)
[lowerCurve] :: Surface -> Double -> Double
-- | t_u(s)
[upperCurve] :: Surface -> Double -> Double
-- | A unit sphere, centered at the origin.
unitSphere :: Surface
-- | A sphere with given radius centered at the origin.
centeredSphere :: Double -> Surface
-- | Sphere with given radius and center.
sphere :: Double -> Position -> Surface
-- | The upper half of a unit sphere, centered at the origin.
northernHemisphere :: Surface
-- | A disk with given radius, centered at the origin.
disk :: Double -> Surface
-- | Shift a surface by a displacement.
shiftSurface :: Displacement -> Surface -> Surface
-- | A plane surface integral, in which area element is a scalar.
surfaceIntegral :: (VectorSpace v, Scalar v ~ Double) => Int -> Int -> Field v -> Surface -> v
-- | A dotted surface integral, in which area element is a vector.
dottedSurfaceIntegral :: Int -> Int -> VectorField -> Surface -> Double
-- | Volume is a parametrized function from three parameters to space,
-- lower and upper limits on the first parameter, lower and upper limits
-- for the second parameter (expressed as functions of the first
-- parameter), and lower and upper limits for the third parameter
-- (expressed as functions of the first and second parameters).
data Volume
Volume :: ((Double, Double, Double) -> Position) -> Double -> Double -> (Double -> Double) -> (Double -> Double) -> (Double -> Double -> Double) -> (Double -> Double -> Double) -> Volume
-- | function from 3 parameters to space
[volumeFunc] :: Volume -> (Double, Double, Double) -> Position
-- | s_a
[loLimit] :: Volume -> Double
-- | s_b
[upLimit] :: Volume -> Double
-- | t_a(s)
[loCurve] :: Volume -> Double -> Double
-- | t_b(s)
[upCurve] :: Volume -> Double -> Double
-- | u_a(s,t)
[loSurf] :: Volume -> Double -> Double -> Double
-- | u_b(s,t)
[upSurf] :: Volume -> Double -> Double -> Double
-- | A unit ball, centered at the origin.
unitBall :: Volume
-- | A unit ball, centered at the origin. Specified in Cartesian
-- coordinates.
unitBallCartesian :: Volume
-- | A ball with given radius, centered at the origin.
centeredBall :: Double -> Volume
-- | Ball with given radius and center.
ball :: Double -> Position -> Volume
-- | Upper half ball, unit radius, centered at origin.
northernHalfBall :: Volume
-- | Cylinder with given radius and height. Circular base of the cylinder
-- is centered at the origin. Circular top of the cylinder lies in plane
-- z = h.
centeredCylinder :: Double -> Double -> Volume
-- | Shift a volume by a displacement.
shiftVolume :: Displacement -> Volume -> Volume
-- | A volume integral
volumeIntegral :: (VectorSpace v, Scalar v ~ Double) => Int -> Int -> Int -> Field v -> Volume -> v
-- | An instance of StateSpace is a data type that can serve as the
-- state of some system. Alternatively, a StateSpace is a
-- collection of dependent variables for a differential equation. A
-- StateSpace has an associated vector space for the (time)
-- derivatives of the state. The associated vector space is a linearized
-- version of the StateSpace.
class (VectorSpace (Diff p), Fractional (Scalar (Diff p))) => StateSpace p where {
-- | Associated vector space
type family Diff p;
}
-- | Subtract points
(.-.) :: StateSpace p => p -> p -> Diff p
-- | Point plus vector
(.+^) :: StateSpace p => p -> Diff p -> p
infix 6 .-.
infixl 6 .+^
-- | Point minus vector
(.-^) :: StateSpace p => p -> Diff p -> p
infixl 6 .-^
-- | The scalars of the associated vector space can be thought of as time
-- intervals.
type Time p = Scalar (Diff p)
-- | A differential equation expresses how the dependent variables (state)
-- change with the independent variable (time). A differential equation
-- is specified by giving the (time) derivative of the state as a
-- function of the state. The (time) derivative of a state is an element
-- of the associated vector space.
type DifferentialEquation state = state -> Diff state
-- | An initial value problem is a differential equation along with an
-- initial state.
type InitialValueProblem state = (DifferentialEquation state, state)
-- | An evolution method is a way of approximating the state after
-- advancing a finite interval in the independent variable (time) from a
-- given state.
type EvolutionMethod state = DifferentialEquation state " differential equation" -> Time state " time interval" -> state " initial state" -> state " evolved state"
-- | A (numerical) solution method is a way of converting an initial value
-- problem into a list of states (a solution). The list of states need
-- not be equally spaced in time.
type SolutionMethod state = InitialValueProblem state -> [state]
-- | Given an evolution method and a time step, return the solution method
-- which applies the evolution method repeatedly with with given time
-- step. The solution method returned will produce an infinite list of
-- states.
stepSolution :: EvolutionMethod state -> Time state -> SolutionMethod state
-- | The Euler method is the simplest evolution method. It increments the
-- state by the derivative times the time step.
eulerMethod :: StateSpace state => EvolutionMethod state
-- | Take a single 4th-order Runge-Kutta step
rungeKutta4 :: StateSpace p => (p -> Diff p) -> Time p -> p -> p
-- | Solve a first-order system of differential equations with 4th-order
-- Runge-Kutta
integrateSystem :: StateSpace p => (p -> Diff p) -> Time p -> p -> [p]
-- | An Attribute with a given label at a given position.
label :: String -> (Double, Double) -> Attribute
-- | An Attribute that requests postscript output.
postscript :: Attribute
-- | An Attribute giving the postscript file name.
psFile :: FilePath -> Attribute
-- | assumes radians coming in
polarToCart :: (Float, Float) -> (Float, Float)
-- | theta=0 is positive x axis, output angle in radians
cartToPolar :: (Float, Float) -> (Float, Float)
-- | An arrow
arrow :: Point -> Point -> Picture
-- | A think arrow
thickArrow :: Float -> Point -> Point -> Picture
-- | Make a V3 object from a Vec.
v3FromVec :: Vec -> V3 Double
-- | Make a V3 object from a Position.
v3FromPos :: Position -> V3 Double
-- | A VisObject arrow from a vector
visVec :: Color -> Vec -> VisObject Double
-- | Place a vector at a particular position.
oneVector :: Color -> Position -> Vec -> VisObject Double
-- | Display a vector field.
displayVectorField :: Color -> Double -> [Position] -> VectorField -> VisObject Double
-- | A displayable VisObject for a curve.
curveObject :: Color -> Curve -> VisObject Double
-- | This module contains functions for displaying the state of a spin-1/2
-- particle or other quantum two-level system as a point on the Bloch
-- Sphere.
module Physics.Learn.BlochSphere
-- | A Vis object.
type VisObj = VisObject Double
-- | Convert a 2x1 complex state vector for a qubit into Bloch (x,y,z)
-- coordinates.
toPos :: Vector C -> Position
-- | Convert a qubit ket into Bloch (x,y,z) coordinates.
ketToPos :: Ket -> Position
-- | A static VisObj for the state of a qubit.
staticBlochSphere :: Position -> VisObj
-- | Display a qubit state vector as a point on the Bloch Sphere.
displayStaticState :: Vector C -> IO ()
-- | Given a Bloch vector as a function of time, return a VisObj as
-- a function of time.
animatedBlochSphere :: (Double -> Position) -> Float -> VisObj
-- | Given a sample rate, initial qubit state vector, and state propagation
-- function, produce a simulation. The Float in the state
-- propagation function is the time since the beginning of the
-- simulation.
simulateBlochSphere :: Double -> Vector C -> (Float -> (Float, Vector C) -> (Float, Vector C)) -> IO ()
-- | Given a sample rate, initial qubit state ket, and state propagation
-- function, produce a simulation. The Float in the state
-- propagation function is the time since the beginning of the
-- simulation.
simulateBlochSphereK :: Double -> Ket -> (Float -> (Float, Ket) -> (Float, Ket)) -> IO ()
-- | Produce a state propagation function from a time-dependent
-- Hamiltonian.
stateProp :: (Double -> Matrix C) -> Float -> (Float, Vector C) -> (Float, Vector C)
-- | Produce a state propagation function from a time-dependent
-- Hamiltonian.
statePropK :: (Double -> Operator) -> Float -> (Float, Ket) -> (Float, Ket)
-- | Given an initial qubit state and a time-dependent Hamiltonian, produce
-- a visualization.
evolutionBlochSphere :: Vector C -> (Double -> Matrix C) -> IO ()
-- | Given an initial qubit ket and a time-dependent Hamiltonian, produce a
-- visualization.
evolutionBlochSphereK :: Ket -> (Double -> Operator) -> IO ()
-- | Hamiltonian for nuclear magnetic resonance. Explain omega0, omegaR,
-- omega.
hamRabi :: Double -> Double -> Double -> Double -> Matrix C