All Projects → mauriciopoppe → Interval Arithmetic

mauriciopoppe / Interval Arithmetic

Licence: bsl-1.0
An implementation of an algebraically closed interval system of the extended real number set

Programming Languages

typescript
32286 projects

Labels

Projects that are alternatives of or similar to Interval Arithmetic

fluent-plugin-http-pull
The input plugin of fluentd to pull log from rest api.
Stars: ✭ 19 (-68.33%)
Mutual labels:  interval
Portion
portion, a Python library providing data structure and operations for intervals.
Stars: ✭ 255 (+325%)
Mutual labels:  interval
Pg timetable
pg_timetable: Advanced scheduling for PostgreSQL
Stars: ✭ 382 (+536.67%)
Mutual labels:  interval
dlock
Interval Lock
Stars: ✭ 19 (-68.33%)
Mutual labels:  interval
IntervalSets.jl
Interval Sets for Julia
Stars: ✭ 62 (+3.33%)
Mutual labels:  interval
Time4j
Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
Stars: ✭ 328 (+446.67%)
Mutual labels:  interval
irsync
rsync on interval, via command line binary or docker container. Server and IOT builds for pull or push based device content management.
Stars: ✭ 19 (-68.33%)
Mutual labels:  interval
Nim Lapper
fast easy interval overlapping for nim-lang
Stars: ✭ 23 (-61.67%)
Mutual labels:  interval
cron-schedule
A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.
Stars: ✭ 28 (-53.33%)
Mutual labels:  interval
Tty Progressbar
Display a single or multiple progress bars in the terminal.
Stars: ✭ 377 (+528.33%)
Mutual labels:  interval
mahler.c
Western music theory library in C99
Stars: ✭ 13 (-78.33%)
Mutual labels:  interval
UniRate
Unity plugin to easily manage the application frame rate and rendering interval. Preventing battery power consumption and device heat, especially on mobile platforms.
Stars: ✭ 26 (-56.67%)
Mutual labels:  interval
Net
Android上强大的网络请求
Stars: ✭ 344 (+473.33%)
Mutual labels:  interval
candlestick-convert
[NPM] OHLCV Candlestick Batcher/Converter
Stars: ✭ 39 (-35%)
Mutual labels:  interval
React Native Gesture Password
A gesture password component for React Native. It supports both iOS and Android since it's written in pure JavaScript.
Stars: ✭ 530 (+783.33%)
Mutual labels:  interval
AdvancedTimer
AdvancedTimer implementation for Xamarin.Forms This repo is no longer maintained. New repo available.
Stars: ✭ 40 (-33.33%)
Mutual labels:  interval
Musictheory
Universal music theory library for iOS, iPadOS, macOS, tvOS and watchOS in Swift
Stars: ✭ 262 (+336.67%)
Mutual labels:  interval
Time
Type-safe time calculations in Kotlin, powered by generics.
Stars: ✭ 939 (+1465%)
Mutual labels:  interval
Period
PHP's time range API
Stars: ✭ 616 (+926.67%)
Mutual labels:  interval
Human Interval
Human readable time distances for javascript
Stars: ✭ 360 (+500%)
Mutual labels:  interval

interval-arithmetic

NPM Build Status codecov Dependency Status js-standard-style Stability FOSSA Status

An implementation of an algebraically closed interval system of the extended real number set

Description

An interval is a pair of numbers which represents all the numbers between them, closed means that the bounds are also included in the representation, extended real because the real number system is extended with two elements: -∞ and +∞ representing negative infinity and positive infinity respectively.

The implementation is a modified port of the Boost's interval arithmetic library, the modifications are based on some guidelines from the following papers/presentations:

floating point operations

Floating point is a way to represent a real number in an approximate way (due to the finite space existing on a computer), most calculations with real numbers will produce quantities that cannot be exactly represented with the space allocated and therefore this operation needs to be rounded in order to fit back into its finite representation, such errors are described in more detail here

Interval arithmetic

Instead of using a single floating point number as an approximation of a real number, interval arithmetic represents the approximated value as a set of possible values (considering the numbers that floating point cannot represent), let's say we want to represent the number 1 / 3, as a single floating point number it's approximated as 0.333333333333..., in the end there will be some 333... decimals that will be lost due to the nature of floating point, instead we can represent this number with the interval [0.2, 0.4], with this interval we're completely sure that 1 / 3 is within the interval (although the interval is also representing many more numbers), to improve the scope of the interval we have to understand that numbers in JavaScript are represented with 64 bits, therefore to get the next floating point number of a single precision number the last bit needs to be incremented to get the upper bound, and the last bit also needs to be decremented to get the lower point

Notable modifications

  • next/previous IEEE754 floating point number implementation based on Typed Arrays
  • division when both intervals contain zero creates a whole interval
  • cosine, tangent works with positive/negative values out of the box

Interval arithmetic evaluator

Due to the expressive nature of the way the methods interact with intervals it's sad that even the simplest operation needs a lot of characters to be typed, let's consider evaluating the result of 1 + 2 expressed with intervals

Interval.add(new Interval(1, 1), new Interval(2, 2))

This gets worse when the expression to be evaluated becomes complex like sin(exp(x)) + tan(x) - 1/cos(PI) * [1, 3]^2:

const x = Interval(0, 1);
Interval.add(
  Interval.sin(Interval.exp(x)),
  Interval.sub(
    Interval.tan(x),
    Interval.mul(
      Interval.div(Interval.ONE, Interval.cos(Interval.PI)),
      Interval.pow(Interval(1, 3), 2)
    )
  )
);

To avoid this 'expressiveness' mess there's an interval arithmetic evaluator module which I've created to deal with all the work of parsing/evaluating expressions like the one above

const compile = require('interval-arithmetic-eval');
compile('sin(exp(x)) + tan(x) - 1/cos(PI) * [1, 3]^2').eval({ x: [0, 1] })

Installation & Usage

$ npm install --save interval-arithmetic
import IOps, { Interval } from 'interval-arithmetic'
IOps.add(Interval(1), Interval(2))

API

See the homepage

Development

npm test

Deployment steps

// after the working directory is clean
npm test
npm run build
npm version (major|minor|patch)
git push origin master

// if everything went well
npm publish
npm run deploy

2015-2020 © Mauricio Poppe

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].