-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Code for the book Learn Physics with Functional Programming -- -- Haskell code to help the user learn mechanics of one particle, -- mechanics of multiple interacting particles, and electromagnetic -- theory. LPFP-core elides all of the graphics dependencies of LPFP, so -- it has a much better chance of building without problems. @package LPFP-core @version 1.1.1 -- | Code from chapter 14 of the book Learn Physics with Functional -- Programming module LPFPCore.Newton2 velocityCF :: Mass -> Velocity -> [Force] -> Time -> Velocity type R = Double type Mass = R type Time = R type Position = R type Velocity = R type Force = R positionCF :: Mass -> Position -> Velocity -> [Force] -> Time -> Position velocityFt :: R -> Mass -> Velocity -> [Time -> Force] -> Time -> Velocity -- | Given a step size, a y-intercept, and a function, return a function -- with the given y-intercept whose derivative is the given function. antiDerivative :: R -> R -> (R -> R) -> R -> R -- | Given a step size, a function, a lower limit, and an upper limit, -- return the definite integral of the function. integral :: R -> (R -> R) -> R -> R -> R positionFt :: R -> Mass -> Position -> Velocity -> [Time -> Force] -> Time -> Position pedalCoast :: Time -> Force fAir :: R -> R -> R -> Velocity -> Force newtonSecondV :: Mass -> [Velocity -> Force] -> Velocity -> R updateVelocity :: R -> Mass -> [Velocity -> Force] -> Velocity -> Velocity velocityFv :: R -> Mass -> Velocity -> [Velocity -> Force] -> Time -> Velocity bikeVelocity :: Time -> Velocity newtonSecondTV :: Mass -> [(Time, Velocity) -> Force] -> (Time, Velocity) -> (R, R) updateTV :: R -> Mass -> [(Time, Velocity) -> Force] -> (Time, Velocity) -> (Time, Velocity) statesTV :: R -> Mass -> (Time, Velocity) -> [(Time, Velocity) -> Force] -> [(Time, Velocity)] velocityFtv :: R -> Mass -> (Time, Velocity) -> [(Time, Velocity) -> Force] -> Time -> Velocity pedalCoastAir :: [(Time, Velocity)] pedalCoastAir2 :: Time -> Velocity velocityCF' :: Mass -> Velocity -> [Force] -> Time -> Velocity sumF :: [R -> R] -> R -> R positionFv :: R -> Mass -> Position -> Velocity -> [Velocity -> Force] -> Time -> Position positionFtv :: R -> Mass -> Position -> Velocity -> [(Time, Velocity) -> Force] -> Time -> Position updateExample :: (Time, Velocity) -> (Time, Velocity) -- | Code from chapter 10 of the book Learn Physics with Functional -- Programming module LPFPCore.SimpleVec -- | A vector derivative takes a vector-valued function of a real variable -- (usually time) as input, and produces a vector-valued function of a -- real variable as output. type VecDerivative = (R -> Vec) -> R -> Vec -- | Given a step size, calculate the vector derivative of a vector-valued -- function of a real variable (usually time). vecDerivative :: R -> VecDerivative v1 :: R -> Vec xCompFunc :: (R -> Vec) -> R -> R -- | A derivative takes a real-valued function of a real variable (often -- time) as input, and produces a real-valued function of a real variable -- as output. type Derivative = (R -> R) -> R -> R -- | Given a step size, calculate the derivative of a real-valued function -- of a real variable (often time). derivative :: R -> Derivative -- | Time is a real number. type Time = R -- | The position of a particle can be represented as a vector. type PosVec = Vec -- | Velocity is a vector. type Velocity = Vec -- | Acceleration is a vector. type Acceleration = Vec -- | Given a time step and a position function, return a velocity function. velFromPos :: R -> (Time -> PosVec) -> Time -> Velocity -- | Given a time step and a velocity function, return an acceleration -- function. accFromVel :: R -> (Time -> Velocity) -> Time -> Acceleration -- | Given initial position and a constant velocity, return a position -- function. positionCV :: PosVec -> Velocity -> Time -> PosVec -- | Given initial velocity and a constant acceleration, return a velocity -- function. velocityCA :: Velocity -> Acceleration -> Time -> Velocity -- | Given initial position, initial velocity, and a constant acceleration, -- return a position function. positionCA :: PosVec -> Velocity -> Acceleration -> Time -> PosVec -- | Given a nonzero velocity and an acceleration, return the component of -- acceleration parallel to the velocity. aParallel :: Vec -> Vec -> Vec -- | Given a nonzero velocity and an acceleration, return the component of -- acceleration perpendicular to the velocity. aPerp :: Vec -> Vec -> Vec -- | Given velocity and acceleration, return the rate at which speed is -- changing. speedRateChange :: Vec -> Vec -> R radiusOfCurvature :: Vec -> Vec -> R projectilePos :: PosVec -> Velocity -> Time -> PosVec -- | An approximation to a real number. type R = Double data Mass Mass :: R -> Mass data Grade Grade :: String -> Int -> Grade grades :: [Grade] data GradeRecord GradeRecord :: String -> Int -> GradeRecord [name] :: GradeRecord -> String [grade] :: GradeRecord -> Int gradeRecords1 :: [GradeRecord] gradeRecords2 :: [GradeRecord] data MyBool MyFalse :: MyBool MyTrue :: MyBool data MyMaybe a MyNothing :: MyMaybe a MyJust :: a -> MyMaybe a -- | A type for three-dimensional vectors. data Vec Vec :: R -> R -> R -> Vec -- | x component of a vector [xComp] :: Vec -> R -- | y component of a vector [yComp] :: Vec -> R -- | z component of a vector [zComp] :: Vec -> R showDouble :: R -> String -- | Form a vector by giving its x, y, and z components. vec :: R -> R -> R -> Vec -- | A unit vector in the x direction. iHat :: Vec -- | A unit vector in the y direction. jHat :: Vec -- | A unit vector in the z direction. kHat :: Vec -- | The zero vector. zeroV :: Vec -- | Negate a vector. negateV :: Vec -> Vec -- | Vector addition. (^+^) :: Vec -> Vec -> Vec infixl 6 ^+^ -- | Vector subtraction. (^-^) :: Vec -> Vec -> Vec infixl 6 ^-^ -- | Add a list of vectors. sumV :: [Vec] -> Vec -- | Scalar multiplication of a number and a vector. (*^) :: R -> Vec -> Vec infixr 7 *^ -- | Scalar multiplication of a vector and a number. (^*) :: Vec -> R -> Vec infixl 7 ^* -- | Dot product of two vectors. (<.>) :: Vec -> Vec -> R infixr 7 <.> -- | Cross product of two vectors. (><) :: Vec -> Vec -> Vec infixl 7 >< -- | Division of a vector by a number. (^/) :: Vec -> R -> Vec infixr 7 ^/ -- | Magnitude of a vector. magnitude :: Vec -> R -- | Definite integral of a vector-valued function of a real number. vecIntegral :: R -> (R -> Vec) -> R -> R -> Vec maxHeight :: PosVec -> Velocity -> R speedCA :: Velocity -> Acceleration -> Time -> R xyProj :: Vec -> Vec magAngles :: Vec -> (R, R, R) gEarth :: Vec vBall :: R -> Vec speedRateChangeBall :: R -> R rNCM :: (R, R -> R) -> R -> Vec aPerpFromPosition :: R -> (R -> Vec) -> R -> Vec instance GHC.Show.Show LPFPCore.SimpleVec.Mass instance GHC.Classes.Eq LPFPCore.SimpleVec.Mass instance GHC.Show.Show LPFPCore.SimpleVec.Grade instance GHC.Classes.Eq LPFPCore.SimpleVec.Grade instance GHC.Show.Show LPFPCore.SimpleVec.GradeRecord instance GHC.Classes.Eq LPFPCore.SimpleVec.GradeRecord instance GHC.Show.Show LPFPCore.SimpleVec.MyBool instance GHC.Classes.Eq LPFPCore.SimpleVec.MyBool instance GHC.Show.Show a => GHC.Show.Show (LPFPCore.SimpleVec.MyMaybe a) instance GHC.Classes.Eq a => GHC.Classes.Eq (LPFPCore.SimpleVec.MyMaybe a) instance GHC.Classes.Eq LPFPCore.SimpleVec.Vec instance GHC.Show.Show LPFPCore.SimpleVec.Vec -- | Code from chapter 15 of the book Learn Physics with Functional -- Programming module LPFPCore.Mechanics1D type Time = R type TimeStep = R type Mass = R type Position = R type Velocity = R type Force = R type State1D = (Time, Position, Velocity) newtonSecond1D :: Mass -> [State1D -> Force] -> State1D -> (R, R, R) euler1D :: R -> (State1D -> (R, R, R)) -> State1D -> State1D updateTXV :: R -> Mass -> [State1D -> Force] -> State1D -> State1D statesTXV :: R -> Mass -> State1D -> [State1D -> Force] -> [State1D] velocity1D :: [State1D] -> Time -> Velocity velocityFtxv :: R -> Mass -> State1D -> [State1D -> Force] -> Time -> Velocity position1D :: [State1D] -> Time -> Position positionFtxv :: R -> Mass -> State1D -> [State1D -> Force] -> Time -> Position springForce :: R -> State1D -> Force dampedHOForces :: [State1D -> Force] dampedHOStates :: [State1D] pingpongPosition :: Time -> Velocity pingpongVelocity :: Time -> Velocity eulerCromer1D :: R -> (State1D -> (R, R, R)) -> State1D -> State1D updateTXVEC :: R -> Mass -> [State1D -> Force] -> State1D -> State1D -- | An update function takes a state as input and returns an updated state -- as output. type UpdateFunction s = s -> s -- | A differential equation takes a state as input and returns as output -- the rate at which the state is changing. type DifferentialEquation s ds = s -> ds -- | A numerical method turns a differential equation into a state-update -- function. type NumericalMethod s ds = DifferentialEquation s ds -> UpdateFunction s -- | Given a numerical method, a differential equation, and an initial -- state, return a list of states. solver :: NumericalMethod s ds -> DifferentialEquation s ds -> s -> [s] -- | A real vector space allows vector addition and scalar multiplication -- by reals. class RealVectorSpace ds (+++) :: RealVectorSpace ds => ds -> ds -> ds scale :: RealVectorSpace ds => R -> ds -> ds -- | A type class that expresses a relationship between a state space and a -- time-derivative-state space. class RealVectorSpace ds => Diff s ds shift :: Diff s ds => R -> ds -> s -> s -- | Given a step size, return the numerical method that uses the Euler -- method with that step size. euler :: Diff s ds => R -> (s -> ds) -> s -> s -- | Given a step size, return the numerical method that uses the 4th order -- Runge Kutta method with that step size. rungeKutta4 :: Diff s ds => R -> (s -> ds) -> s -> s exponential :: DifferentialEquation (R, R, R) (R, R, R) update2 :: (R, R, R) -> (R, R, R) earthGravity :: Mass -> State1D -> Force type MState = (Time, Mass, Position, Velocity) earthGravity2 :: MState -> Force positionFtxv2 :: R -> MState -> [MState -> Force] -> Time -> Position statesTXV2 :: R -> MState -> [MState -> Force] -> [MState] updateTXV2 :: R -> [MState -> Force] -> MState -> MState updateTV' :: R -> Mass -> [(Time, Velocity) -> Force] -> (Time, Velocity) -> (Time, Velocity) forces :: R -> [State1D -> R] vdp :: R -> [(R, R)] instance LPFPCore.Mechanics1D.Diff LPFPCore.Mechanics1D.State1D (LPFPCore.SimpleVec.R, LPFPCore.SimpleVec.R, LPFPCore.SimpleVec.R) instance LPFPCore.Mechanics1D.Diff (LPFPCore.Mechanics1D.Time, LPFPCore.Mechanics1D.Velocity) (LPFPCore.SimpleVec.R, LPFPCore.SimpleVec.R) instance LPFPCore.Mechanics1D.RealVectorSpace (LPFPCore.SimpleVec.R, LPFPCore.SimpleVec.R, LPFPCore.SimpleVec.R) instance LPFPCore.Mechanics1D.RealVectorSpace (LPFPCore.SimpleVec.R, LPFPCore.SimpleVec.R) -- | Code from chapters 16, 17, and 18 of the book Learn Physics with -- Functional Programming module LPFPCore.Mechanics3D -- | Data type for the state of a single particle in three-dimensional -- space. data ParticleState ParticleState :: R -> R -> R -> Vec -> Vec -> ParticleState [mass] :: ParticleState -> R [charge] :: ParticleState -> R [time] :: ParticleState -> R [posVec] :: ParticleState -> Vec [velocity] :: ParticleState -> Vec -- | A default particle state. defaultParticleState :: ParticleState rockState :: ParticleState -- | Data type for a one-body force. type OneBodyForce = ParticleState -> Vec -- | Data type for the time-derivative of a particle state. data DParticleState DParticleState :: R -> R -> R -> Vec -> Vec -> DParticleState [dmdt] :: DParticleState -> R [dqdt] :: DParticleState -> R [dtdt] :: DParticleState -> R [drdt] :: DParticleState -> Vec [dvdt] :: DParticleState -> Vec -- | Given a list of forces, return a differential equation based on -- Newton's second law. newtonSecondPS :: [OneBodyForce] -> ParticleState -> DParticleState -- | The force of gravity near Earth's surface. The z direction is toward -- the sky. Assumes SI units. earthSurfaceGravity :: OneBodyForce -- | The force of the Sun's gravity on an object. The origin is at center -- of the Sun. Assumes SI units. sunGravity :: OneBodyForce -- | The force of air resistance on an object. airResistance :: R -> R -> R -> OneBodyForce -- | The force of wind on an object. windForce :: Vec -> R -> R -> R -> OneBodyForce -- | The force of uniform electric and magnetic fields on an object. uniformLorentzForce :: Vec -> Vec -> OneBodyForce -- | Euler-Cromer method for the ParticleState data type. eulerCromerPS :: TimeStep -> NumericalMethod ParticleState DParticleState -- | Given a numerical method, a list of one-body forces, and an initial -- state, return a list of states describing how the particle evolves in -- time. statesPS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> [ParticleState] -- | Given a numerical method and a list of one-body forces, return a -- state-update function. updatePS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> ParticleState -- | Given a numerical method, a list of one-body forces, and an initial -- state, return a position function describing how the particle evolves -- in time. positionPS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> Time -> PosVec class HasTime s timeOf :: HasTime s => s -> Time constantForce :: Vec -> OneBodyForce moonSurfaceGravity :: OneBodyForce earthGravity :: OneBodyForce tvyPair :: ParticleState -> (R, R) tvyPairs :: [ParticleState] -> [(R, R)] tle1yr :: ParticleState -> Bool stateFunc :: [ParticleState] -> Time -> ParticleState airResAtAltitude :: R -> R -> R -> OneBodyForce projectileRangeComparison :: R -> R -> (R, R, R) halleyUpdate :: TimeStep -> ParticleState -> ParticleState halleyInitial :: ParticleState baseballForces :: [OneBodyForce] baseballTrajectory :: R -> R -> R -> [(R, R)] zGE0 :: [ParticleState] -> [ParticleState] trajectory :: [ParticleState] -> [(R, R)] baseballRange :: R -> R -> R -> R bestAngle :: (R, R) projectileUpdate :: TimeStep -> ParticleState -> ParticleState projectileInitial :: [String] -> ParticleState protonUpdate :: TimeStep -> ParticleState -> ParticleState protonInitial :: ParticleState apR :: R wallForce :: OneBodyForce energy :: ParticleState -> R firstOrbit :: ParticleState -> Bool -- | Given a list of forces, return a differential equation based on the -- theory of special relativity. relativityPS :: [OneBodyForce] -> ParticleState -> DParticleState twoProtUpdate :: TimeStep -> (ParticleState, ParticleState) -> (ParticleState, ParticleState) twoProtInitial :: (ParticleState, ParticleState) relativityPS' :: R -> [OneBodyForce] -> ParticleState -> DParticleState instance GHC.Show.Show LPFPCore.Mechanics3D.ParticleState instance GHC.Show.Show LPFPCore.Mechanics3D.DParticleState instance LPFPCore.Mechanics3D.HasTime LPFPCore.Mechanics3D.ParticleState instance LPFPCore.Mechanics1D.RealVectorSpace LPFPCore.Mechanics3D.DParticleState instance LPFPCore.Mechanics1D.Diff LPFPCore.Mechanics3D.ParticleState LPFPCore.Mechanics3D.DParticleState -- | Code from chapter 19 of the book Learn Physics with Functional -- Programming module LPFPCore.MultipleObjects type TwoBodyForce = ParticleState -> ParticleState -> ForceVector type ForceVector = Vec oneFromTwo :: ParticleState -> TwoBodyForce -> OneBodyForce gravityMagnitude :: Mass -> Mass -> R -> R universalGravity :: TwoBodyForce constantRepulsiveForceWrong :: ForceVector -> TwoBodyForce constantRepulsiveForce :: R -> TwoBodyForce linearSpring :: R -> R -> TwoBodyForce -- | Force provided by a spring that is fixed at one end. fixedLinearSpring :: R -> R -> Vec -> OneBodyForce centralForce :: (R -> R) -> TwoBodyForce linearSpringCentral :: R -> R -> TwoBodyForce billiardForce :: R -> R -> TwoBodyForce data Force ExternalForce :: Int -> OneBodyForce -> Force InternalForce :: Int -> Int -> TwoBodyForce -> Force data MultiParticleState MPS :: [ParticleState] -> MultiParticleState [particleStates] :: MultiParticleState -> [ParticleState] data DMultiParticleState DMPS :: [DParticleState] -> DMultiParticleState newtonSecondMPS :: [Force] -> MultiParticleState -> DMultiParticleState forcesOn :: Int -> MultiParticleState -> [Force] -> [OneBodyForce] forceOn :: Int -> MultiParticleState -> Force -> OneBodyForce eulerCromerMPS :: TimeStep -> NumericalMethod MultiParticleState DMultiParticleState updateMPS :: NumericalMethod MultiParticleState DMultiParticleState -> [Force] -> MultiParticleState -> MultiParticleState statesMPS :: NumericalMethod MultiParticleState DMultiParticleState -> [Force] -> MultiParticleState -> [MultiParticleState] speed :: ParticleState -> R universalGravity' :: TwoBodyForce universalGravityCentral :: TwoBodyForce lennardJones :: R -> R -> TwoBodyForce systemKE :: MultiParticleState -> R forcesOn' :: Int -> MultiParticleState -> [Force] -> [OneBodyForce] externalForcesOn :: Int -> [Force] -> [OneBodyForce] internalForcesOn :: Int -> MultiParticleState -> [Force] -> [OneBodyForce] instance GHC.Show.Show LPFPCore.MultipleObjects.MultiParticleState instance GHC.Show.Show LPFPCore.MultipleObjects.DMultiParticleState instance LPFPCore.Mechanics1D.RealVectorSpace LPFPCore.MultipleObjects.DMultiParticleState instance LPFPCore.Mechanics1D.Diff LPFPCore.MultipleObjects.MultiParticleState LPFPCore.MultipleObjects.DMultiParticleState instance LPFPCore.Mechanics3D.HasTime LPFPCore.MultipleObjects.MultiParticleState -- | Code from chapter 20 of the book Learn Physics with Functional -- Programming module LPFPCore.MOExamples twoSpringsForces :: [Force] twoSpringsInitial :: MultiParticleState twoSpringsUpdate :: TimeStep -> MultiParticleState -> MultiParticleState kineticEnergy :: ParticleState -> R systemKE :: MultiParticleState -> R linearSpringPE :: R -> R -> ParticleState -> ParticleState -> R earthSurfaceGravityPE :: ParticleState -> R twoSpringsPE :: MultiParticleState -> R twoSpringsME :: MultiParticleState -> R billiardForces :: R -> [Force] ballRadius :: R billiardDiffEq :: R -> MultiParticleState -> DMultiParticleState billiardUpdate :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> R -> TimeStep -> MultiParticleState -> MultiParticleState billiardEvolver :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> R -> TimeStep -> MultiParticleState -> [MultiParticleState] billiardInitial :: MultiParticleState billiardStates :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> R -> TimeStep -> [MultiParticleState] billiardStatesFinite :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> R -> TimeStep -> [MultiParticleState] momentum :: ParticleState -> Vec systemP :: MultiParticleState -> Vec percentChangePMag :: [MultiParticleState] -> R sigFigs :: Int -> R -> Float data Justification LJ :: Justification RJ :: Justification data Table a Table :: Justification -> [[a]] -> Table a pTable :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> [R] -> [TimeStep] -> Table Float pTableEu :: [R] -> [TimeStep] -> Table Float percentChangeKE :: [MultiParticleState] -> R tenths :: R -> Float keTable :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> [R] -> [TimeStep] -> Table Float contactSteps :: [MultiParticleState] -> Int inContact :: MultiParticleState -> Bool contactTable :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> [R] -> [TimeStep] -> Table Int closest :: [MultiParticleState] -> R separation :: MultiParticleState -> R closestTable :: (TimeStep -> NumericalMethod MultiParticleState DMultiParticleState) -> [R] -> [TimeStep] -> Table Float forcesString :: [Force] stringUpdate :: TimeStep -> MultiParticleState -> MultiParticleState stringInitialOvertone :: Int -> MultiParticleState stringInitialPluck :: MultiParticleState mpsPos :: MultiParticleState -> IO () mpsVel :: MultiParticleState -> IO () dissipation :: R -> R -> TwoBodyForce instance GHC.Show.Show LPFPCore.MOExamples.Justification instance GHC.Show.Show a => GHC.Show.Show (LPFPCore.MOExamples.Table a) -- | Code from chapter 21 of the book Learn Physics with Functional -- Programming module LPFPCore.Electricity type Charge = R elementaryCharge :: Charge coulombMagnitude :: Charge -> Charge -> R -> R coulombForce :: TwoBodyForce twoProtonStates :: R -> MultiParticleState -> [MultiParticleState] initialTwoProtonState :: R -> MultiParticleState oneProtonVelocity :: R -> R -> [(R, R)] tvPairs :: [(R, R)] oneProtonPosition :: R -> R -> [(R, R)] -- | Code from chapter 22 of the book Learn Physics with Functional -- Programming module LPFPCore.CoordinateSystems data Position Cart :: R -> R -> R -> Position type CoordinateSystem = (R, R, R) -> Position cartesian :: CoordinateSystem cylindrical :: CoordinateSystem spherical :: CoordinateSystem cart :: R -> R -> R -> Position cyl :: R -> R -> R -> Position sph :: R -> R -> R -> Position origin :: Position cartesianCoordinates :: Position -> (R, R, R) cylindricalCoordinates :: Position -> (R, R, R) sphericalCoordinates :: Position -> (R, R, R) type Displacement = Vec displacement :: Position -> Position -> Displacement shiftPosition :: Displacement -> Position -> Position type ScalarField = Position -> R xSF :: ScalarField rSF :: ScalarField fst3 :: (a, b, c) -> a snd3 :: (a, b, c) -> b thd3 :: (a, b, c) -> c ySF :: ScalarField type VectorField = Position -> Vec sHat :: VectorField phiHat :: VectorField rHat :: VectorField thetaHat :: VectorField xHat :: VectorField yHat :: VectorField zHat :: VectorField rVF :: VectorField addScalarFields :: [ScalarField] -> ScalarField addVectorFields :: [VectorField] -> VectorField sfTable :: ((R, R) -> Position) -> [R] -> [R] -> ScalarField -> Table Int magRad :: (R, R) -> (R, R) thetaSF :: ScalarField thetaHat3D :: IO () phiHatGrad :: IO () instance GHC.Show.Show LPFPCore.CoordinateSystems.Position -- | Code from chapter 28 of the book Learn Physics with Functional -- Programming module LPFPCore.Lorentz data ParticleFieldState ParticleFieldState :: R -> R -> R -> Position -> Vec -> VectorField -> VectorField -> ParticleFieldState [mass] :: ParticleFieldState -> R [charge] :: ParticleFieldState -> R [time] :: ParticleFieldState -> R [position] :: ParticleFieldState -> Position [velocity] :: ParticleFieldState -> Vec [electricField] :: ParticleFieldState -> VectorField [magneticField] :: ParticleFieldState -> VectorField data DParticleFieldState DParticleFieldState :: R -> R -> R -> Vec -> Vec -> VectorField -> VectorField -> DParticleFieldState [dmdt] :: DParticleFieldState -> R [dqdt] :: DParticleFieldState -> R [dtdt] :: DParticleFieldState -> R [drdt] :: DParticleFieldState -> Vec [dvdt] :: DParticleFieldState -> Vec [dEdt] :: DParticleFieldState -> VectorField [dBdt] :: DParticleFieldState -> VectorField lorentzForce :: ParticleFieldState -> Vec newtonSecondPFS :: ParticleFieldState -> DParticleFieldState pfsUpdate :: R -> ParticleFieldState -> ParticleFieldState defaultPFS :: ParticleFieldState scalePos :: R -> Position -> Position newtonSecondPFS' :: [ParticleFieldState -> Vec] -> ParticleFieldState -> DParticleFieldState instance LPFPCore.Mechanics1D.RealVectorSpace LPFPCore.Lorentz.DParticleFieldState instance LPFPCore.Mechanics1D.Diff LPFPCore.Lorentz.ParticleFieldState LPFPCore.Lorentz.DParticleFieldState instance LPFPCore.Mechanics3D.HasTime LPFPCore.Lorentz.ParticleFieldState -- | Code from chapter 23 of the book Learn Physics with Functional -- Programming module LPFPCore.Geometry data Curve Curve :: (R -> Position) -> R -> R -> Curve [curveFunc] :: Curve -> R -> Position [startingCurveParam] :: Curve -> R [endingCurveParam] :: Curve -> R circle2 :: Curve circle2' :: Curve unitCircle :: Curve straightLine :: Position -> Position -> Curve data Surface Surface :: ((R, R) -> Position) -> R -> R -> (R -> R) -> (R -> R) -> Surface [surfaceFunc] :: Surface -> (R, R) -> Position [lowerLimit] :: Surface -> R [upperLimit] :: Surface -> R [lowerCurve] :: Surface -> R -> R [upperCurve] :: Surface -> R -> R unitSphere :: Surface unitSphere' :: Surface parabolaSurface :: Surface shiftSurface :: Vec -> Surface -> Surface centeredSphere :: R -> Surface sphere :: R -> Position -> Surface northernHemisphere :: Surface disk :: R -> Surface unitCone :: R -> Surface data Volume Volume :: ((R, R, R) -> Position) -> R -> R -> (R -> R) -> (R -> R) -> (R -> R -> R) -> (R -> R -> R) -> Volume [volumeFunc] :: Volume -> (R, R, R) -> Position [loLimit] :: Volume -> R [upLimit] :: Volume -> R [loCurve] :: Volume -> R -> R [upCurve] :: Volume -> R -> R [loSurf] :: Volume -> R -> R -> R [upSurf] :: Volume -> R -> R -> R unitBall :: Volume centeredCylinder :: R -> R -> Volume circle :: Position -> R -> Curve square :: Curve squareFunc :: R -> Position northernHalfBall :: Volume centeredBall :: R -> Volume shiftVolume :: Vec -> Volume -> Volume quarterDiskBoundary :: R -> Curve quarterCylinder :: R -> R -> Volume -- | Code needed in chapter 24 of the book Learn Physics with Functional -- Programming module LPFPCore.Integrals type CurveApprox = Curve -> [(Position, Vec)] type SurfaceApprox = Surface -> [(Position, Vec)] type VolumeApprox = Volume -> [(Position, R)] scalarLineIntegral :: CurveApprox -> ScalarField -> Curve -> R scalarSurfaceIntegral :: SurfaceApprox -> ScalarField -> Surface -> R scalarVolumeIntegral :: VolumeApprox -> ScalarField -> Volume -> R vectorLineIntegral :: CurveApprox -> VectorField -> Curve -> Vec vectorSurfaceIntegral :: SurfaceApprox -> VectorField -> Surface -> Vec vectorVolumeIntegral :: VolumeApprox -> VectorField -> Volume -> Vec curveSample :: Int -> Curve -> [(Position, Vec)] type Segment = (Position, Position) segments :: Int -> Curve -> [Segment] linSpaced :: Int -> R -> R -> [R] surfaceSample :: Int -> Surface -> [(Position, Vec)] data Triangle Tri :: Position -> Position -> Position -> Triangle triCenter :: Triangle -> Position triArea :: Triangle -> Vec triangles :: Int -> Surface -> [Triangle] volumeSample :: Int -> Volume -> [(Position, R)] data Tet Tet :: Position -> Position -> Position -> Position -> Tet tetCenter :: Tet -> Position tetVolume :: Tet -> R data ParamCube PC :: (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> ParamCube [v000] :: ParamCube -> (R, R, R) [v001] :: ParamCube -> (R, R, R) [v010] :: ParamCube -> (R, R, R) [v011] :: ParamCube -> (R, R, R) [v100] :: ParamCube -> (R, R, R) [v101] :: ParamCube -> (R, R, R) [v110] :: ParamCube -> (R, R, R) [v111] :: ParamCube -> (R, R, R) tetrahedrons :: Int -> Volume -> [Tet] -- | Code from chapter 24 of the book Learn Physics with Functional -- Programming module LPFPCore.Charge type Charge = R data ChargeDistribution PointCharge :: Charge -> Position -> ChargeDistribution LineCharge :: ScalarField -> Curve -> ChargeDistribution SurfaceCharge :: ScalarField -> Surface -> ChargeDistribution VolumeCharge :: ScalarField -> Volume -> ChargeDistribution MultipleCharges :: [ChargeDistribution] -> ChargeDistribution protonOrigin :: ChargeDistribution chargedLine :: Charge -> R -> ChargeDistribution chargedBall :: Charge -> R -> ChargeDistribution diskCap :: R -> R -> R -> ChargeDistribution totalCharge :: ChargeDistribution -> Charge simpleDipole :: Vec -> R -> ChargeDistribution electricDipoleMoment :: ChargeDistribution -> Vec lineDipole :: Vec -> R -> ChargeDistribution chargedDisk :: Charge -> R -> ChargeDistribution circularLineCharge :: Charge -> R -> ChargeDistribution chargedSquarePlate :: Charge -> R -> ChargeDistribution chargedSphericalShell :: Charge -> R -> ChargeDistribution chargedCube :: Charge -> R -> ChargeDistribution squareCap :: R -> R -> R -> ChargeDistribution hydrogen :: ChargeDistribution -- | Code from chapter 25 of the book Learn Physics with Functional -- Programming module LPFPCore.ElectricField epsilon0 :: R cSI :: R mu0 :: R eFieldFromPointCharge :: Charge -> Position -> VectorField eField :: ChargeDistribution -> VectorField simpleDipoleSodiumChloride :: ChargeDistribution eFieldSodiumChloride :: VectorField eFieldIdealDipole :: Vec -> VectorField type VectorLineIntegral = VectorField -> Curve -> Vec type CurveApprox = Curve -> [(Position, Vec)] vectorLineIntegral :: CurveApprox -> VectorField -> Curve -> Vec eFieldFromLineCharge :: ScalarField -> Curve -> VectorField lineDipoleSodiumChloride :: ChargeDistribution eFieldLineDipole :: VectorField type VectorSurfaceIntegral = VectorField -> Surface -> Vec type SurfaceApprox = Surface -> [(Position, Vec)] vectorSurfaceIntegral :: SurfaceApprox -> VectorField -> Surface -> Vec eFieldFromSurfaceCharge :: ScalarField -> Surface -> VectorField eFieldDiskCap :: VectorField type VectorVolumeIntegral = VectorField -> Volume -> Vec type VolumeApprox = Volume -> [(Position, R)] vectorVolumeIntegral :: VolumeApprox -> VectorField -> Volume -> Vec eFieldFromVolumeCharge :: ScalarField -> Volume -> VectorField type ScalarLineIntegral = ScalarField -> Curve -> R scalarLineIntegral :: CurveApprox -> ScalarField -> Curve -> R type ScalarSurfaceIntegral = ScalarField -> Surface -> R scalarSurfaceIntegral :: SurfaceApprox -> ScalarField -> Surface -> R type ScalarVolumeIntegral = ScalarField -> Volume -> R scalarVolumeIntegral :: VolumeApprox -> ScalarField -> Volume -> R curveSample :: Int -> Curve -> [(Position, Vec)] type Segment = (Position, Position) segments :: Int -> Curve -> [Segment] linSpaced :: Int -> R -> R -> [R] surfaceSample :: Int -> Surface -> [(Position, Vec)] data Triangle Tri :: Position -> Position -> Position -> Triangle triCenter :: Triangle -> Position triArea :: Triangle -> Vec triangles :: Int -> Surface -> [Triangle] volumeSample :: Int -> Volume -> [(Position, R)] data Tet Tet :: Position -> Position -> Position -> Position -> Tet tetCenter :: Tet -> Position tetVolume :: Tet -> R data ParamCube PC :: (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> (R, R, R) -> ParamCube [v000] :: ParamCube -> (R, R, R) [v001] :: ParamCube -> (R, R, R) [v010] :: ParamCube -> (R, R, R) [v011] :: ParamCube -> (R, R, R) [v100] :: ParamCube -> (R, R, R) [v101] :: ParamCube -> (R, R, R) [v110] :: ParamCube -> (R, R, R) [v111] :: ParamCube -> (R, R, R) tetrahedrons :: Int -> Volume -> [Tet] type Field a = Position -> a class AbstractVector a zeroVector :: AbstractVector a => a add :: AbstractVector a => a -> a -> a scale :: AbstractVector a => R -> a -> a sumG :: AbstractVector a => [a] -> a generalLineIntegral :: AbstractVector a => CurveApprox -> Field a -> Curve -> a dottedSurfaceIntegral :: SurfaceApprox -> VectorField -> Surface -> R electricFluxFromField :: VectorField -> Surface -> R electricFluxFromCharge :: ChargeDistribution -> Surface -> R eFieldFromSurfaceChargeP :: SurfaceApprox -> ScalarField -> Surface -> VectorField surfaceArea :: Surface -> R dottedLineIntegral :: CurveApprox -> VectorField -> Curve -> R electricPotentialFromField :: VectorField -> ScalarField -- | Code from chapter 29 of the book Learn Physics with Functional -- Programming module LPFPCore.Maxwell directionalDerivative :: Vec -> ScalarField -> ScalarField curl :: R -> VectorField -> VectorField type FieldState = (R, VectorField, VectorField) maxwellUpdate :: R -> R -> (R -> VectorField) -> FieldState -> FieldState maxwellEvolve :: R -> R -> (R -> VectorField) -> FieldState -> [FieldState] exLocs :: [(Int, Int, Int)] eyLocs :: [(Int, Int, Int)] ezLocs :: [(Int, Int, Int)] bxLocs :: [(Int, Int, Int)] byLocs :: [(Int, Int, Int)] bzLocs :: [(Int, Int, Int)] spaceStepsCE :: Int hiEven :: Int evens :: [Int] odds :: [Int] data StateFDTD StateFDTD :: R -> R -> R -> R -> Map (Int, Int, Int) R -> Map (Int, Int, Int) R -> StateFDTD [timeFDTD] :: StateFDTD -> R [stepX] :: StateFDTD -> R [stepY] :: StateFDTD -> R [stepZ] :: StateFDTD -> R [eField] :: StateFDTD -> Map (Int, Int, Int) R [bField] :: StateFDTD -> Map (Int, Int, Int) R initialStateFDTD :: R -> StateFDTD lookupAZ :: Ord k => k -> Map k R -> R partialX :: R -> Map (Int, Int, Int) R -> (Int, Int, Int) -> R partialY :: R -> Map (Int, Int, Int) R -> (Int, Int, Int) -> R partialZ :: R -> Map (Int, Int, Int) R -> (Int, Int, Int) -> R curlEx :: StateFDTD -> (Int, Int, Int) -> R curlEy :: StateFDTD -> (Int, Int, Int) -> R curlEz :: StateFDTD -> (Int, Int, Int) -> R curlBx :: StateFDTD -> (Int, Int, Int) -> R curlBy :: StateFDTD -> (Int, Int, Int) -> R curlBz :: StateFDTD -> (Int, Int, Int) -> R stateUpdate :: R -> (R -> VectorField) -> StateFDTD -> StateFDTD updateE :: R -> VectorField -> StateFDTD -> StateFDTD updateB :: R -> StateFDTD -> StateFDTD updateEOneLoc :: R -> VectorField -> StateFDTD -> (Int, Int, Int) -> R -> R updateBOneLoc :: R -> StateFDTD -> (Int, Int, Int) -> R -> R jGaussian :: R -> VectorField getAverage :: (Int, Int, Int) -> Map (Int, Int, Int) R -> Vec instance GHC.Show.Show LPFPCore.Maxwell.StateFDTD -- | Code from chapter 26 of the book Learn Physics with Functional -- Programming module LPFPCore.Current type Current = R data CurrentDistribution LineCurrent :: Current -> Curve -> CurrentDistribution SurfaceCurrent :: VectorField -> Surface -> CurrentDistribution VolumeCurrent :: VectorField -> Volume -> CurrentDistribution MultipleCurrents :: [CurrentDistribution] -> CurrentDistribution circularCurrentLoop :: R -> R -> CurrentDistribution wireSolenoid :: R -> R -> R -> R -> CurrentDistribution sheetSolenoid :: R -> R -> R -> R -> CurrentDistribution wireToroid :: R -> R -> R -> R -> CurrentDistribution crossedLineIntegral :: CurveApprox -> VectorField -> Curve -> Vec magneticDipoleMoment :: CurrentDistribution -> Vec helmholtzCoil :: R -> R -> CurrentDistribution longStraightWire :: R -> R -> CurrentDistribution torus :: R -> R -> Surface totalCurrent :: VectorField -> Surface -> Current -- | Code from chapter 27 of the book Learn Physics with Functional -- Programming module LPFPCore.MagneticField bFieldFromLineCurrent :: Current -> Curve -> VectorField bField :: CurrentDistribution -> VectorField circleB :: VectorField bFieldIdealDipole :: Vec -> VectorField bFieldWireToroid :: VectorField bFieldFromSurfaceCurrent :: VectorField -> Surface -> VectorField bFieldFromVolumeCurrent :: VectorField -> Volume -> VectorField magneticFluxFromField :: VectorField -> Surface -> R magneticFluxFromCurrent :: CurrentDistribution -> Surface -> R visLoop :: IO () -- | Code from the book Learn Physics with Functional Programming module LPFPCore -- | An approximation to a real number. type R = Double -- | Time is a real number. type Time = R -- | A type for three-dimensional vectors. data Vec -- | The position of a particle can be represented as a vector. type PosVec = Vec -- | Velocity is a vector. type Velocity = Vec -- | Acceleration is a vector. type Acceleration = Vec -- | Form a vector by giving its x, y, and z components. vec :: R -> R -> R -> Vec -- | Vector addition. (^+^) :: Vec -> Vec -> Vec infixl 6 ^+^ -- | Vector subtraction. (^-^) :: Vec -> Vec -> Vec infixl 6 ^-^ -- | Scalar multiplication of a number and a vector. (*^) :: R -> Vec -> Vec infixr 7 *^ -- | Scalar multiplication of a vector and a number. (^*) :: Vec -> R -> Vec infixl 7 ^* -- | Division of a vector by a number. (^/) :: Vec -> R -> Vec infixr 7 ^/ -- | Dot product of two vectors. (<.>) :: Vec -> Vec -> R infixr 7 <.> -- | Cross product of two vectors. (><) :: Vec -> Vec -> Vec infixl 7 >< -- | Magnitude of a vector. magnitude :: Vec -> R -- | The zero vector. zeroV :: Vec -- | Negate a vector. negateV :: Vec -> Vec -- | Add a list of vectors. sumV :: [Vec] -> Vec -- | x component of a vector xComp :: Vec -> R -- | y component of a vector yComp :: Vec -> R -- | z component of a vector zComp :: Vec -> R -- | A unit vector in the x direction. iHat :: Vec -- | A unit vector in the y direction. jHat :: Vec -- | A unit vector in the z direction. kHat :: Vec -- | Given initial position and a constant velocity, return a position -- function. positionCV :: PosVec -> Velocity -> Time -> PosVec -- | Given initial velocity and a constant acceleration, return a velocity -- function. velocityCA :: Velocity -> Acceleration -> Time -> Velocity -- | Given initial position, initial velocity, and a constant acceleration, -- return a position function. positionCA :: PosVec -> Velocity -> Acceleration -> Time -> PosVec -- | Given a nonzero velocity and an acceleration, return the component of -- acceleration parallel to the velocity. aParallel :: Vec -> Vec -> Vec -- | Given a nonzero velocity and an acceleration, return the component of -- acceleration perpendicular to the velocity. aPerp :: Vec -> Vec -> Vec -- | Given velocity and acceleration, return the rate at which speed is -- changing. speedRateChange :: Vec -> Vec -> R -- | A derivative takes a real-valued function of a real variable (often -- time) as input, and produces a real-valued function of a real variable -- as output. type Derivative = (R -> R) -> R -> R -- | A vector derivative takes a vector-valued function of a real variable -- (usually time) as input, and produces a vector-valued function of a -- real variable as output. type VecDerivative = (R -> Vec) -> R -> Vec -- | Given a step size, calculate the derivative of a real-valued function -- of a real variable (often time). derivative :: R -> Derivative -- | Given a step size, calculate the vector derivative of a vector-valued -- function of a real variable (usually time). vecDerivative :: R -> VecDerivative -- | Given a step size, a function, a lower limit, and an upper limit, -- return the definite integral of the function. integral :: R -> (R -> R) -> R -> R -> R -- | Given a step size, a y-intercept, and a function, return a function -- with the given y-intercept whose derivative is the given function. antiDerivative :: R -> R -> (R -> R) -> R -> R -- | Given a time step and a position function, return a velocity function. velFromPos :: R -> (Time -> PosVec) -> Time -> Velocity -- | Given a time step and a velocity function, return an acceleration -- function. accFromVel :: R -> (Time -> Velocity) -> Time -> Acceleration -- | An update function takes a state as input and returns an updated state -- as output. type UpdateFunction s = s -> s -- | A differential equation takes a state as input and returns as output -- the rate at which the state is changing. type DifferentialEquation s ds = s -> ds -- | A numerical method turns a differential equation into a state-update -- function. type NumericalMethod s ds = DifferentialEquation s ds -> UpdateFunction s -- | A real vector space allows vector addition and scalar multiplication -- by reals. class RealVectorSpace ds (+++) :: RealVectorSpace ds => ds -> ds -> ds scale :: RealVectorSpace ds => R -> ds -> ds -- | A type class that expresses a relationship between a state space and a -- time-derivative-state space. class RealVectorSpace ds => Diff s ds shift :: Diff s ds => R -> ds -> s -> s -- | Given a numerical method, a differential equation, and an initial -- state, return a list of states. solver :: NumericalMethod s ds -> DifferentialEquation s ds -> s -> [s] -- | Given a step size, return the numerical method that uses the Euler -- method with that step size. euler :: Diff s ds => R -> (s -> ds) -> s -> s -- | Given a step size, return the numerical method that uses the 4th order -- Runge Kutta method with that step size. rungeKutta4 :: Diff s ds => R -> (s -> ds) -> s -> s -- | Data type for the state of a single particle in three-dimensional -- space. data ParticleState ParticleState :: R -> R -> R -> Vec -> Vec -> ParticleState [mass] :: ParticleState -> R [charge] :: ParticleState -> R [time] :: ParticleState -> R [posVec] :: ParticleState -> Vec [velocity] :: ParticleState -> Vec -- | Data type for the time-derivative of a particle state. data DParticleState DParticleState :: R -> R -> R -> Vec -> Vec -> DParticleState [dmdt] :: DParticleState -> R [dqdt] :: DParticleState -> R [dtdt] :: DParticleState -> R [drdt] :: DParticleState -> Vec [dvdt] :: DParticleState -> Vec class HasTime s timeOf :: HasTime s => s -> Time -- | A default particle state. defaultParticleState :: ParticleState -- | Given a list of forces, return a differential equation based on -- Newton's second law. newtonSecondPS :: [OneBodyForce] -> ParticleState -> DParticleState -- | Given a list of forces, return a differential equation based on the -- theory of special relativity. relativityPS :: [OneBodyForce] -> ParticleState -> DParticleState -- | Euler-Cromer method for the ParticleState data type. eulerCromerPS :: TimeStep -> NumericalMethod ParticleState DParticleState -- | Given a numerical method, a list of one-body forces, and an initial -- state, return a list of states describing how the particle evolves in -- time. statesPS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> [ParticleState] -- | Given a numerical method and a list of one-body forces, return a -- state-update function. updatePS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> ParticleState -- | Data type for a one-body force. type OneBodyForce = ParticleState -> Vec -- | The force of gravity near Earth's surface. The z direction is toward -- the sky. Assumes SI units. earthSurfaceGravity :: OneBodyForce -- | The force of the Sun's gravity on an object. The origin is at center -- of the Sun. Assumes SI units. sunGravity :: OneBodyForce -- | The force of air resistance on an object. airResistance :: R -> R -> R -> OneBodyForce -- | The force of wind on an object. windForce :: Vec -> R -> R -> R -> OneBodyForce -- | The force of uniform electric and magnetic fields on an object. uniformLorentzForce :: Vec -> Vec -> OneBodyForce -- | Force provided by a spring that is fixed at one end. fixedLinearSpring :: R -> R -> Vec -> OneBodyForce data Force ExternalForce :: Int -> OneBodyForce -> Force InternalForce :: Int -> Int -> TwoBodyForce -> Force data MultiParticleState MPS :: [ParticleState] -> MultiParticleState [particleStates] :: MultiParticleState -> [ParticleState] data DMultiParticleState DMPS :: [DParticleState] -> DMultiParticleState type TwoBodyForce = ParticleState -> ParticleState -> ForceVector universalGravity :: TwoBodyForce linearSpring :: R -> R -> TwoBodyForce centralForce :: (R -> R) -> TwoBodyForce billiardForce :: R -> R -> TwoBodyForce newtonSecondMPS :: [Force] -> MultiParticleState -> DMultiParticleState eulerCromerMPS :: TimeStep -> NumericalMethod MultiParticleState DMultiParticleState updateMPS :: NumericalMethod MultiParticleState DMultiParticleState -> [Force] -> MultiParticleState -> MultiParticleState statesMPS :: NumericalMethod MultiParticleState DMultiParticleState -> [Force] -> MultiParticleState -> [MultiParticleState] data Justification LJ :: Justification RJ :: Justification data Table a Table :: Justification -> [[a]] -> Table a kineticEnergy :: ParticleState -> R systemKE :: MultiParticleState -> R momentum :: ParticleState -> Vec systemP :: MultiParticleState -> Vec linearSpringPE :: R -> R -> ParticleState -> ParticleState -> R earthSurfaceGravityPE :: ParticleState -> R tenths :: R -> Float sigFigs :: Int -> R -> Float elementaryCharge :: Charge coulombForce :: TwoBodyForce data Position type Displacement = Vec type ScalarField = Position -> R type VectorField = Position -> Vec type CoordinateSystem = (R, R, R) -> Position cartesian :: CoordinateSystem cylindrical :: CoordinateSystem spherical :: CoordinateSystem cart :: R -> R -> R -> Position cyl :: R -> R -> R -> Position sph :: R -> R -> R -> Position cartesianCoordinates :: Position -> (R, R, R) cylindricalCoordinates :: Position -> (R, R, R) sphericalCoordinates :: Position -> (R, R, R) displacement :: Position -> Position -> Displacement shiftPosition :: Displacement -> Position -> Position rHat :: VectorField thetaHat :: VectorField phiHat :: VectorField sHat :: VectorField xHat :: VectorField yHat :: VectorField zHat :: VectorField origin :: Position xSF :: ScalarField ySF :: ScalarField rSF :: ScalarField rVF :: VectorField fst3 :: (a, b, c) -> a snd3 :: (a, b, c) -> b thd3 :: (a, b, c) -> c addScalarFields :: [ScalarField] -> ScalarField addVectorFields :: [VectorField] -> VectorField sfTable :: ((R, R) -> Position) -> [R] -> [R] -> ScalarField -> Table Int data Curve Curve :: (R -> Position) -> R -> R -> Curve [curveFunc] :: Curve -> R -> Position [startingCurveParam] :: Curve -> R [endingCurveParam] :: Curve -> R unitCircle :: Curve straightLine :: Position -> Position -> Curve data Surface Surface :: ((R, R) -> Position) -> R -> R -> (R -> R) -> (R -> R) -> Surface [surfaceFunc] :: Surface -> (R, R) -> Position [lowerLimit] :: Surface -> R [upperLimit] :: Surface -> R [lowerCurve] :: Surface -> R -> R [upperCurve] :: Surface -> R -> R unitSphere :: Surface centeredSphere :: R -> Surface sphere :: R -> Position -> Surface northernHemisphere :: Surface disk :: R -> Surface shiftSurface :: Vec -> Surface -> Surface data Volume Volume :: ((R, R, R) -> Position) -> R -> R -> (R -> R) -> (R -> R) -> (R -> R -> R) -> (R -> R -> R) -> Volume [volumeFunc] :: Volume -> (R, R, R) -> Position [loLimit] :: Volume -> R [upLimit] :: Volume -> R [loCurve] :: Volume -> R -> R [upCurve] :: Volume -> R -> R [loSurf] :: Volume -> R -> R -> R [upSurf] :: Volume -> R -> R -> R unitBall :: Volume centeredBall :: R -> Volume northernHalfBall :: Volume centeredCylinder :: R -> R -> Volume type Charge = R data ChargeDistribution PointCharge :: Charge -> Position -> ChargeDistribution LineCharge :: ScalarField -> Curve -> ChargeDistribution SurfaceCharge :: ScalarField -> Surface -> ChargeDistribution VolumeCharge :: ScalarField -> Volume -> ChargeDistribution MultipleCharges :: [ChargeDistribution] -> ChargeDistribution totalCharge :: ChargeDistribution -> Charge electricDipoleMoment :: ChargeDistribution -> Vec epsilon0 :: R cSI :: R mu0 :: R eField :: ChargeDistribution -> VectorField type ScalarLineIntegral = ScalarField -> Curve -> R type ScalarSurfaceIntegral = ScalarField -> Surface -> R type ScalarVolumeIntegral = ScalarField -> Volume -> R type VectorLineIntegral = VectorField -> Curve -> Vec type VectorSurfaceIntegral = VectorField -> Surface -> Vec type VectorVolumeIntegral = VectorField -> Volume -> Vec type CurveApprox = Curve -> [(Position, Vec)] type SurfaceApprox = Surface -> [(Position, Vec)] type VolumeApprox = Volume -> [(Position, R)] scalarLineIntegral :: CurveApprox -> ScalarField -> Curve -> R scalarSurfaceIntegral :: SurfaceApprox -> ScalarField -> Surface -> R scalarVolumeIntegral :: VolumeApprox -> ScalarField -> Volume -> R vectorLineIntegral :: CurveApprox -> VectorField -> Curve -> Vec vectorSurfaceIntegral :: SurfaceApprox -> VectorField -> Surface -> Vec vectorVolumeIntegral :: VolumeApprox -> VectorField -> Volume -> Vec dottedLineIntegral :: CurveApprox -> VectorField -> Curve -> R dottedSurfaceIntegral :: SurfaceApprox -> VectorField -> Surface -> R curveSample :: Int -> Curve -> [(Position, Vec)] surfaceSample :: Int -> Surface -> [(Position, Vec)] volumeSample :: Int -> Volume -> [(Position, R)] type Field a = Position -> a type Current = R data CurrentDistribution LineCurrent :: Current -> Curve -> CurrentDistribution SurfaceCurrent :: VectorField -> Surface -> CurrentDistribution VolumeCurrent :: VectorField -> Volume -> CurrentDistribution MultipleCurrents :: [CurrentDistribution] -> CurrentDistribution crossedLineIntegral :: CurveApprox -> VectorField -> Curve -> Vec totalCurrent :: VectorField -> Surface -> Current magneticDipoleMoment :: CurrentDistribution -> Vec bField :: CurrentDistribution -> VectorField lorentzForce :: ParticleFieldState -> Vec newtonSecondPFS :: ParticleFieldState -> DParticleFieldState defaultPFS :: ParticleFieldState directionalDerivative :: Vec -> ScalarField -> ScalarField curl :: R -> VectorField -> VectorField type FieldState = (R, VectorField, VectorField)