Average Error: 26.6 → 6.0
Time: 51.6s
Precision: 64
Internal precision: 128
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \le -1.0857363802206783 \cdot 10^{-54}:\\
\;\;\;\;x + {\left(\frac{\sqrt[3]{y - x} \cdot \sqrt[3]{z - t}}{\sqrt[3]{a - t}}\right)}^3\\
\mathbf{if}\;a \le 3.0098787995381245 \cdot 10^{-89}:\\
\;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\end{array}\]
Target
| Original | 26.6 |
| Comparison | 9.5 |
| Herbie | 6.0 |
\[ \begin{array}{l}
\mathbf{if}\;a \lt -1.6153062845442575 \cdot 10^{-142}:\\
\;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\mathbf{if}\;a \lt 3.774403170083174 \cdot 10^{-182}:\\
\;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\
\end{array} \]
Derivation
- Split input into 3 regimes.
-
if a < -1.0857363802206783e-54
Initial program 22.1
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
- Using strategy
rm
Applied add-cube-cbrt 22.5
\[\leadsto x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{\color{blue}{{\left(\sqrt[3]{a - t}\right)}^3}}\]
Applied add-cube-cbrt 22.5
\[\leadsto x + \frac{\left(y - x\right) \cdot \color{blue}{{\left(\sqrt[3]{z - t}\right)}^3}}{{\left(\sqrt[3]{a - t}\right)}^3}\]
Applied add-cube-cbrt 22.6
\[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^3} \cdot {\left(\sqrt[3]{z - t}\right)}^3}{{\left(\sqrt[3]{a - t}\right)}^3}\]
Applied cube-unprod 22.6
\[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{z - t}\right)}^3}}{{\left(\sqrt[3]{a - t}\right)}^3}\]
Applied cube-undiv 7.8
\[\leadsto x + \color{blue}{{\left(\frac{\sqrt[3]{y - x} \cdot \sqrt[3]{z - t}}{\sqrt[3]{a - t}}\right)}^3}\]
if -1.0857363802206783e-54 < a < 3.0098787995381245e-89
Initial program 35.6
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
Applied taylor 6.4
\[\leadsto \left(y + \frac{x \cdot z}{t}\right) - \frac{y \cdot z}{t}\]
Taylor expanded around inf 6.4
\[\leadsto \color{blue}{\left(y + \frac{x \cdot z}{t}\right) - \frac{y \cdot z}{t}}\]
Applied simplify 2.1
\[\leadsto \color{blue}{y - \frac{z}{t} \cdot \left(y - x\right)}\]
if 3.0098787995381245e-89 < a
Initial program 22.0
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
- Using strategy
rm
Applied *-un-lft-identity 22.0
\[\leadsto x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{\color{blue}{1 \cdot \left(a - t\right)}}\]
Applied times-frac 8.1
\[\leadsto x + \color{blue}{\frac{y - x}{1} \cdot \frac{z - t}{a - t}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(785850078 3242194136 497722281 2983700760 2327042056 1676814270)'
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:target
(if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))