Average Error: 14.4 → 6.1
Time: 28.5s
Precision: 64
Internal Precision: 384
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -7.542630138100415 \cdot 10^{+19}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{if}\;y \le 1.5601337082604852 \cdot 10^{-118}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{if}\;y \le 3.281842225634271 \cdot 10^{+250}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot y\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original14.4
Target1.4
Herbie6.1
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.658954423153415 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt 2.0087180502407133 \cdot 10^{+217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if y < -7.542630138100415e+19

    1. Initial program 17.5

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Applied simplify7.3

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    3. Taylor expanded around 0 8.1

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

    if -7.542630138100415e+19 < y < 1.5601337082604852e-118

    1. Initial program 12.9

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Applied simplify6.0

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    3. Using strategy rm
    4. Applied div-inv6.1

      \[\leadsto \color{blue}{x \cdot \frac{1}{\frac{z}{y}}}\]
    5. Applied simplify5.5

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

    if 1.5601337082604852e-118 < y < 3.281842225634271e+250

    1. Initial program 14.2

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Applied simplify4.3

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    3. Taylor expanded around 0 5.0

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

    if 3.281842225634271e+250 < y

    1. Initial program 23.9

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Applied simplify12.8

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}}\]
    3. Using strategy rm
    4. Applied associate-/r/13.0

      \[\leadsto \color{blue}{\frac{x}{z} \cdot y}\]
  3. Recombined 4 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 28.5s)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))

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