Average Error: 7.1 → 4.4
Time: 20.7s
Precision: 64
Internal precision: 128
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \le -0.0:\\
\;\;\;\;\frac{1}{\frac{y - t}{\frac{x}{z}}} \cdot 2.0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\
\end{array}\]
Target
| Original | 7.1 |
| Comparison | 2.4 |
| Herbie | 4.4 |
\[ \begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\
\mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt 1.045027827330126 \cdot 10^{-269}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot 2.0}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if (/ (* x 2.0) (- (* y z) (* t z))) < -0.0
Initial program 7.6
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
Applied simplify 4.4
\[\leadsto \color{blue}{\frac{\frac{x}{z}}{y - t} \cdot 2.0}\]
- Using strategy
rm
Applied clear-num 4.9
\[\leadsto \color{blue}{\frac{1}{\frac{y - t}{\frac{x}{z}}}} \cdot 2.0\]
if -0.0 < (/ (* x 2.0) (- (* y z) (* t z)))
Initial program 6.0
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
Applied simplify 8.2
\[\leadsto \color{blue}{\frac{\frac{x}{z}}{y - t} \cdot 2.0}\]
- Using strategy
rm
Applied associate-/l/ 3.4
\[\leadsto \color{blue}{\frac{x}{\left(y - t\right) \cdot z}} \cdot 2.0\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1445915184 1441980852 4276603271 1303467849 3945581563 4230502465)'
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:target
(if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))
(/ (* x 2.0) (- (* y z) (* t z))))