Average Error: 25.3 → 5.6
Time: 1.2m
Precision: 64
Internal Precision: 384
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \le -1.2709557362568119 \cdot 10^{+112}:\\
\;\;\;\;x \cdot \left(-y\right)\\
\mathbf{if}\;z \le 3.0149748654828578 \cdot 10^{+60}:\\
\;\;\;\;\frac{y \cdot x}{\left|\sqrt[3]{z \cdot z - a \cdot t}\right|} \cdot \frac{z}{\sqrt{\sqrt[3]{z \cdot z - t \cdot a}}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}\]
Target
| Original | 25.3 |
|---|
| Target | 6.8 |
|---|
| Herbie | 5.6 |
|---|
\[\begin{array}{l}
\mathbf{if}\;z \lt -3.1921305903852764 \cdot 10^{+46}:\\
\;\;\;\;-y \cdot x\\
\mathbf{if}\;z \lt 5.976268120920894 \cdot 10^{+90}:\\
\;\;\;\;\frac{x \cdot z}{\frac{\sqrt{z \cdot z - a \cdot t}}{y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}\]
Derivation
- Split input into 3 regimes
if z < -1.2709557362568119e+112
Initial program 45.9
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
Taylor expanded around -inf 0
\[\leadsto \color{blue}{-1 \cdot \left(y \cdot x\right)}\]
Applied simplify0
\[\leadsto \color{blue}{x \cdot \left(-y\right)}\]
if -1.2709557362568119e+112 < z < 3.0149748654828578e+60
Initial program 10.6
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
- Using strategy
rm Applied add-cube-cbrt11.0
\[\leadsto \frac{\left(x \cdot y\right) \cdot z}{\sqrt{\color{blue}{\left(\sqrt[3]{z \cdot z - t \cdot a} \cdot \sqrt[3]{z \cdot z - t \cdot a}\right) \cdot \sqrt[3]{z \cdot z - t \cdot a}}}}\]
Applied sqrt-prod11.0
\[\leadsto \frac{\left(x \cdot y\right) \cdot z}{\color{blue}{\sqrt{\sqrt[3]{z \cdot z - t \cdot a} \cdot \sqrt[3]{z \cdot z - t \cdot a}} \cdot \sqrt{\sqrt[3]{z \cdot z - t \cdot a}}}}\]
Applied times-frac10.4
\[\leadsto \color{blue}{\frac{x \cdot y}{\sqrt{\sqrt[3]{z \cdot z - t \cdot a} \cdot \sqrt[3]{z \cdot z - t \cdot a}}} \cdot \frac{z}{\sqrt{\sqrt[3]{z \cdot z - t \cdot a}}}}\]
Applied simplify10.4
\[\leadsto \color{blue}{\frac{y \cdot x}{\left|\sqrt[3]{z \cdot z - a \cdot t}\right|}} \cdot \frac{z}{\sqrt{\sqrt[3]{z \cdot z - t \cdot a}}}\]
if 3.0149748654828578e+60 < z
Initial program 39.8
\[\frac{\left(x \cdot y\right) \cdot z}{\sqrt{z \cdot z - t \cdot a}}\]
Taylor expanded around inf 0
\[\leadsto \color{blue}{y \cdot x}\]
- 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 "Statistics.Math.RootFinding:ridders from math-functions-0.1.5.2"
:herbie-target
(if (< z -3.1921305903852764e+46) (- (* y x)) (if (< z 5.976268120920894e+90) (/ (* x z) (/ (sqrt (- (* z z) (* a t))) y)) (* y x)))
(/ (* (* x y) z) (sqrt (- (* z z) (* t a)))))