Average Error: 25.5 → 8.2
Time: 8.5m
Precision: 64
Internal Precision: 1920
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \le -4.2533961552866985 \cdot 10^{-171}:\\
\;\;\;\;x + \frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{t - x}{\sqrt[3]{a - z}}\\
\mathbf{if}\;a \le 8.183905144226627 \cdot 10^{-137}:\\
\;\;\;\;t - \left(t - x\right) \cdot \frac{y}{z}\\
\mathbf{if}\;a \le 1.215880926283839 \cdot 10^{-41}:\\
\;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\
\mathbf{if}\;a \le 1820749428.2327986:\\
\;\;\;\;t - \left(t - x\right) \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{t - x}{\sqrt[3]{a - z}}\\
\end{array}\]
Target
| Original | 25.5 |
|---|
| Target | 13.6 |
|---|
| Herbie | 8.2 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt -1.2536131056095036 \cdot 10^{+188}:\\
\;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\
\mathbf{if}\;z \lt 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\
\mathbf{else}:\\
\;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\
\end{array}\]
Derivation
- Split input into 3 regimes
if a < -4.2533961552866985e-171 or 1820749428.2327986 < a
Initial program 21.9
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
- Using strategy
rm Applied add-cube-cbrt22.2
\[\leadsto x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}\]
Applied times-frac8.9
\[\leadsto x + \color{blue}{\frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{t - x}{\sqrt[3]{a - z}}}\]
if -4.2533961552866985e-171 < a < 8.183905144226627e-137 or 1.215880926283839e-41 < a < 1820749428.2327986
Initial program 35.7
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
Taylor expanded around inf 5.9
\[\leadsto \color{blue}{\left(\frac{y \cdot x}{z} + t\right) - \frac{y \cdot t}{z}}\]
Applied simplify1.5
\[\leadsto \color{blue}{t - \left(t - x\right) \cdot \frac{y}{z}}\]
if 8.183905144226627e-137 < a < 1.215880926283839e-41
Initial program 23.9
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
- Using strategy
rm Applied div-inv24.0
\[\leadsto x + \color{blue}{\left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}}\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:herbie-target
(if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))
(+ x (/ (* (- y z) (- t x)) (- a z))))