ex_interval v0.1.3 ExInterval.Interval View Source

It implements the interval type and range operations on the type, using directed roundings intervals, recognize the input as strings and performs operations between intervals.

Link to this section Summary

Functions

Calculates the absolute value of the interval

Binary plus operator

Returns the distance between supremum and infimum of the interval

Division operator

Calculates the machine epsilon

Returns true if the value is an element or a subset of the interval

Returns the middle point of the interval

Multiplication operator

Returns a new Interval

Return the square root of the interval

Binary minus operator

Link to this section Types

Specs

interval() :: %ExInterval.Interval{inf: Float, sup: Float}

Link to this section Functions

Specs

absolute(interval() | list()) :: number()

Calculates the absolute value of the interval

Parameters

  • absolute/1

Examples

iex> ExInterval.Interval.absolute([-1, 1]) 1.0

Specs

add(
  number() | binary() | interval() | list(),
  number() | binary() | interval() | list()
) :: list()

Binary plus operator

Parameters

  • add/2

Examples

iex> ExInterval.Interval.add(%ExInterval.Interval{inf: 0.25, sup: 0.5}, 2) [2.25, 2.5]

iex> ExInterval.Interval.add("0.1", 0.1) [0.2, 0.2]

Specs

diameter(interval() | list()) :: number()

Returns the distance between supremum and infimum of the interval

Parameters

  • diameter/1

Examples

iex> ExInterval.Interval.diameter([-10, 1]) 11.0

Specs

division(
  number() | binary() | interval() | list(),
  number() | binary() | interval() | list()
) :: list()

Division operator

Parameters

  • division/2

Examples

iex> ExInterval.Interval.division(%ExInterval.Interval{inf: 0.25, sup: 0.5}, %ExInterval.Interval{inf: 2, sup: 4}) [0.0625, 0.25]

iex> ExInterval.Interval.division(%ExInterval.Interval{inf: -0.75, sup: 0.75}, 2) [-0.375, 0.375]

iex> ExInterval.Interval.division("0.1", 0.1) [1.0, 1.0]

Specs

eps() :: number()

Calculates the machine epsilon

Parameters

  • eps/0

Examples

iex> ExInterval.Interval.eps 2.220446049250313e-16

Link to this function

is_member?(value, second)

View Source

Specs

is_member?(
  number() | binary() | interval(),
  number() | binary() | list() | interval()
) :: boolean()

Returns true if the value is an element or a subset of the interval

Parameters

  • is_member?/2

Examples

iex> ExInterval.Interval.is_member?(0.0, %ExInterval.Interval{inf: -1, sup: -0.1}) false

iex> ExInterval.Interval.is_member?(0.0, %ExInterval.Interval{inf: -1, sup: 1}) true

iex> ExInterval.Interval.is_member?(0.0, %ExInterval.Interval{inf: 0.1, sup: 1}) false

Specs

middle(interval() | list()) :: float()

Returns the middle point of the interval

Parameters

  • middle/1

Examples

iex> ExInterval.Interval.middle(%ExInterval.Interval{inf: -10.0, sup: 5.0}) -2.5

Specs

mul(
  number() | binary() | interval() | list(),
  number() | binary() | interval() | list()
) :: list()

Multiplication operator

Parameters

  • mul/2

Examples

iex> ExInterval.Interval.mul(%ExInterval.Interval{inf: 0.25, sup: 0.5}, %ExInterval.Interval{inf: 2.0, sup: 3.0}) [0.5, 1.5]

iex> ExInterval.Interval.mul(%ExInterval.Interval{inf: -0.75, sup: 0.75}, "2") [-1.5, 1.5]

iex> ExInterval.Interval.mul(0.2, "0.1") [0.02, 0.020000000000000004]

Returns a new Interval

Parameters

  • new/1 or new/2

Examples

iex> ExInterval.Interval.new(1.1) [1.1, 1.1]

iex> ExInterval.Interval.new(1.1, 2.5) [1.1, 2.5]

Specs

new(number() | binary(), number() | binary()) :: list()

Specs

sqrt(interval() | list()) :: interval()

Return the square root of the interval

Parameters

  • sqrt/1

Examples

iex> ExInterval.Interval.sqrt([9, 25]) [3.0, 5.0]

Specs

sub(
  number() | binary() | interval() | list(),
  number() | binary() | interval() | list()
) :: list()

Binary minus operator

Parameters

  • sub/2

Examples

iex> ExInterval.Interval.sub(%ExInterval.Interval{inf: 0.25, sup: 0.5}, 2) [-1.75, -1.5]

iex> ExInterval.Interval.sub(%ExInterval.Interval{inf: -0.75, sup: 0.75}, "2") [-2.75, -1.25]

iex> ExInterval.Interval.sub("0.1", 0.1) [0.0, 0.0]