# `Feel.Analysis.Images.Number.Real`
[🔗](https://github.com/FeeJai/BDM/blob/feel-v0.1.0/apps/feel/lib/feel/analysis/images/number/real.ex#L1)

The numbers `sqrt`, `log` and `exp` can give, and when they give `null` (`Feel.Analysis.Images.Number`, D-161).

The three are increasing where they are defined and correctly rounded to 34 digits (`Feel.Runtime.Number.Power`, D-62),
so the numbers the run gives for the numbers of an interval are between the run's own results for its ends, and the ends
are computed by the run: the rounding is its own, and rounding keeps the order (as in `Feel.Analysis.Intervals`). The ends
of a result are included, which makes a set larger and never smaller. An open end is the number nearest to it only at
zero, where the domain ends: `sqrt` of `(0..4)` is from `1E-3088`, the root of the smallest number, and not from `0`.

| Function | Defined for | `null` for |
| -------- | ----------- | ---------- |
| `sqrt(x)` | `x >= 0` | a negative `x` |
| `log(x)` | `x > 0` | `x <= 0` |
| `exp(x)` | every `x` | an `x` whose result is past the range, or is too small to write |

**The exponential.** `exp(x)` is a number for every `x` up to `exp_range/0`'s `high`, the largest `x` for which the run
gives one (found with the run, at the precision of a number of that size: 34 digits). For a larger `x` the result is past
the largest number. At the other end the result is written with its 34 digits from the first, which reach down to -6176
from a result of 1E-6143 up, so every `x` from `low` up gives a number (D-161). Below it a result needs a digit below
-6176 unless its last digits happen to be zeros, which they do for about one `x` in 10 just below `low` and for fewer
further down, so the numbers between `low` and `cut` may or may not be written, and an interval of them gives `Null` and
every number from the smallest there is to the result at `low`. Below `cut` the result is below the smallest number
(1E-6176) and none is written.

# `result`

```elixir
@type result() :: {Feel.Type.NumberSet.t(), boolean()} | :error
```

The numbers of the result, and whether a number of the argument gives `null`.

# `exp`

```elixir
@spec exp(Feel.Type.NumberSet.t()) :: result()
```

The numbers `exp(x)` can be for the numbers of the set, and whether it can be `null`.

    iex> alias Feel.Type.NumberSet
    iex> set = NumberSet.interval(Decimal.new(0), Decimal.new(1))
    iex> {values, null?} = Feel.Analysis.Images.Number.Real.exp(set)
    iex> {NumberSet.format(values), null?}
    {"[1..2.718281828459045235360287471352662]", false}

# `exp_range`

```elixir
@spec exp_range() :: {Decimal.t(), Decimal.t(), Decimal.t()}
```

The numbers of the exponential `exp_range/0` speaks of: `{low, high, cut}`.

    iex> {low, high, cut} = Feel.Analysis.Images.Number.Real.exp_range()
    iex> {Decimal.to_string(low, :normal), Decimal.to_string(high, :normal), Decimal.to_string(cut, :normal)}
    {"-14144.78022626242263692252150612604", "14149.38539644841072829055748903541", "-14221"}

# `log`

```elixir
@spec log(Feel.Type.NumberSet.t()) :: result()
```

The numbers `log(x)` can be for the numbers of the set, and whether it can be `null`.

    iex> alias Feel.Type.NumberSet
    iex> set = NumberSet.interval(Decimal.new(1), Decimal.new(1))
    iex> {logs, null?} = Feel.Analysis.Images.Number.Real.log(set)
    iex> {NumberSet.format(logs), null?}
    {"0", false}

# `run`

```elixir
@spec run(String.t(), Decimal.t()) :: Feel.Runtime.Number.result()
```

The run's result of `sqrt`, `log` or `exp` for a number: `{:ok, number}`, or an error where the run gives `null`.

    iex> {:ok, root} = Feel.Analysis.Images.Number.Real.run("sqrt", Decimal.new(4))
    iex> Decimal.to_string(root, :normal)
    "2"
    iex> Feel.Analysis.Images.Number.Real.run("log", Decimal.new(0))
    {:error, :out_of_domain}

# `sqrt`

```elixir
@spec sqrt(Feel.Type.NumberSet.t()) :: result()
```

The numbers `sqrt(x)` can be for the numbers of the set, and whether it can be `null`.

    iex> alias Feel.Type.NumberSet
    iex> set = NumberSet.interval(Decimal.new(0), Decimal.new(100))
    iex> {roots, null?} = Feel.Analysis.Images.Number.Real.sqrt(set)
    iex> {NumberSet.format(roots), null?}
    {"[0..10]", false}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
