Code Monkey home page Code Monkey logo

calcigral's Introduction

Calcigral

Simple integral calculator in Haskell

GitHub Workflow Status (with branch) GitHub top language license




What is Calcigral

Calcigral is a simple command-line utility for approximating the value of definite integrals with one variable over a real line.

Features

  • Three approximation strategies: Rectangle, Trapezoid, Paraboloid
  • Can approximate up to any absolute error
  • Supports $-\infty$, $+\infty$ approximation bounds
  • Function input: any haskell function using Prelude
  • Command-line interface

Examples

Simple

Evaluate $I = \int \limits_0^1 \sin(x) dx = 1 - \cos 1 \approx 0.45969...$

$ calcigral 0 1 sin
Strategy: Rectangle
IntegralResult {value = 0.459997112932708, steps = 15}
===
Strategy: Trapezoid
IntegralResult {value = 0.45954804321221476, steps = 62}
===
Strategy: Paraboloid
IntegralResult {value = 0.45970774492731087, steps = 18}
===

Note: Default max absolute error is 1e-3

Infinite bounds

Evaluate $I = \int \limits_{-\infty}^{\infty} e^{-x^2} dx = \sqrt \pi \approx 1.77245385...$

$ calcigral MinusInfinity PlusInfinity '\x -> exp (-x * x)' 0.001 1000 -s Paraboloid
Strategy: Paraboloid
IntegralResult {value = 1.7724624243349956, steps = 276}
===

Diverging

Evaluate $I = \int \limits_{0}^{1} \frac{1}{x} dx = \ln 1 - \ln 0 \rightarrow \infty$

$ calcigral 0 1 '\x -> 1 / x' -s Rectangle
Strategy: Rectangle
Diverging
===

Goals of this project

This utility is a educational project for the JetBrains Functional Programming course (Fall 2022) at Constructor University. Hence, the goals of this project are educational.

License

This project is BSD-3-Clause licensed


@waleko

calcigral's People

Contributors

waleko avatar

Watchers

 avatar

calcigral's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.