Average Error: 7.2 → 6.5
Time: 1.5m
Precision: 64
Internal Precision: 384
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -6.7291158904237084 \cdot 10^{+66}:\\ \;\;\;\;\frac{y \cdot x}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.2
Target5.8
Herbie6.5
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{if}\;z \lt 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* x y) (* z t)) < -6.7291158904237084e+66

    1. Initial program 13.5

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Taylor expanded around 0 13.5

      \[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{z \cdot t}{a}}\]
    3. Using strategy rm
    4. Applied associate-/l*10.5

      \[\leadsto \frac{y \cdot x}{a} - \color{blue}{\frac{z}{\frac{a}{t}}}\]

    if -6.7291158904237084e+66 < (- (* x y) (* z t))

    1. Initial program 5.1

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-inv5.2

      \[\leadsto \color{blue}{\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.5m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))