MyNixOS website logo
Description

Library for symbolic integration of mathematical expressions.

Symtegration is a library providing symbolic integration of mathematical expressions.

For example,

>>> import Symtegration
>>> toHaskell <$> integrate "x" (4 * "x" ** 3 + 1)
Just "x + x ** 4"

See the Symtegration module for the main interface.

Symtegration

This is a Haskell library intended to support symbolic integration of mathematical expressions.

It offers the following:

  • Symbolic integration of mathematical expressions.

    • Integration of polynomials.

    • Integration of trigonometric functions.

    • Integration of exponential and logarithmic functions.

    • Integration of ratios of two polynomials.

    • Integration by substitution.

    • Integration by parts.

  • Symbolic representation of mathematical expressions.

  • Utility functions to make it easier to read the mathematical expressions. For example, deriving equivalent Haskell code for a mathematical expression, and some support for simplifying symbolic representations.

Build OpenSSF Best Practices OpenSSF Scorecard codecov

Integration

Mathematical expressions with either numeric coefficients or symbolic coefficients can be integrated. For example:

>>> import Symtegration
>>> toHaskell <$> integrate "x" (4 * "x" ** 3 + 1)
Just "x + x ** 4"
>>> toHaskell <$> integrate "z" ("x" * "z" + "y")
Just "y * z + 1 / 2 * x * z ** 2"

Concrete numbers can also be computed from these integrals. For example:

>>> import Symtegration
>>> let (Just p) = integrate "x" (4 * "x" ** 3 + 1)
>>> fractionalEvaluate p (\case "x" -> Just (3 / 7 :: Rational))
Just (1110 % 2401)

Symbolic integration in GHCi

With Symtegration, symbolic integration can be done within GHCi. When executing GHCi within the Symtegration project, it is best to load only the Symtegration module to avoid name collisions, so start GHCi without loading any modules.

$ stack ghci --no-load

Within GHCi, explicitly load the Symtegration module. You can then proceed to symbolically integrate mathematical expressions and compute approximate or exact values from these integrals.

>>> :load Symtegration
>>> toHaskell <$> integrate "x" ("a" * "x" ** 4 + "x" + "b")
Just "b * x + 1 / 2 * x ** 2 + a * (x ** 5) / 5"
>>>
>>> let (Just p) = integrate "x" ("x" ** 2)
>>> evaluate p (\case "x" -> Just 1)
Just 0.3333333333333333
>>>
>>> fractionalEvaluate p (\case "x" -> Just (1 :: Rational))
Just (1 % 3)

Symbolic integration in IHaskell

Symtegration can also be used in IHaskell to do symbolic integration. Its use can be seen in an example IHaskell notebook, which you can try out by running on mybinder.org.

Changes

See CHANGELOG.md for what has changed.

Code of conduct

Be nice; see CODE_OF_CONDUCT.md for details.

Security policy

See SECURITY.md for details.

Contributing

See CONTRIBUTING.md for details.

License

Apache 2.0; see LICENSE for details.

Metadata

Version

0.6.1

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows