Average Error: 25.5 → 8.3
Time: 8.4m
Precision: 64
Internal Precision: 1664
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \le -5.431975634518425 \cdot 10^{-180}:\\
\;\;\;\;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 4.364749231637734 \cdot 10^{-136}:\\
\;\;\;\;t - \left(t - x\right) \cdot \frac{y}{z}\\
\mathbf{if}\;a \le 2.1615660863766092 \cdot 10^{-41}:\\
\;\;\;\;x + \left(\left(y - z\right) \cdot \left(t - x\right)\right) \cdot \frac{1}{a - z}\\
\mathbf{if}\;a \le 92563423223.6119:\\
\;\;\;\;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.3 |
|---|
\[\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 < -5.431975634518425e-180 or 92563423223.6119 < 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.3
\[\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-frac9.0
\[\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 -5.431975634518425e-180 < a < 4.364749231637734e-136 or 2.1615660863766092e-41 < a < 92563423223.6119
Initial program 35.7
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
Taylor expanded around inf 6.0
\[\leadsto \color{blue}{\left(\frac{y \cdot x}{z} + t\right) - \frac{y \cdot t}{z}}\]
Applied simplify1.4
\[\leadsto \color{blue}{t - \left(t - x\right) \cdot \frac{y}{z}}\]
if 4.364749231637734e-136 < a < 2.1615660863766092e-41
Initial program 24.1
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
- Using strategy
rm Applied div-inv24.2
\[\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
(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))))