Average Error: 7.3 → 4.2
Time: 21.6s
Precision: 64
Internal precision: 128
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\left(x \cdot y - z \cdot y\right) \cdot t \le -1.9065966854774704 \cdot 10^{+60}:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{if}\;\left(x \cdot y - z \cdot y\right) \cdot t \le -8.963050224559816 \cdot 10^{-300}:\\
\;\;\;\;\left(\left(x - z\right) \cdot y\right) \cdot t\\
\mathbf{if}\;\left(x \cdot y - z \cdot y\right) \cdot t \le -0.0:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - z\right) \cdot y\right) \cdot t\\
\end{array}\]
Target
| Original | 7.3 |
| Comparison | 3.0 |
| Herbie | 4.2 |
\[ \begin{array}{l}
\mathbf{if}\;t \lt -9.231879582886777 \cdot 10^{-80}:\\
\;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\
\mathbf{if}\;t \lt 2.543067051564877 \cdot 10^{+83}:\\
\;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if (* (- (* x y) (* z y)) t) < -1.9065966854774704e+60 or -8.963050224559816e-300 < (* (- (* x y) (* z y)) t) < -0.0
Initial program 11.6
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
Applied simplify 2.5
\[\leadsto \color{blue}{\left(x - z\right) \cdot \left(y \cdot t\right)}\]
if -1.9065966854774704e+60 < (* (- (* x y) (* z y)) t) < -8.963050224559816e-300 or -0.0 < (* (- (* x y) (* z y)) t)
Initial program 5.1
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
Applied simplify 8.8
\[\leadsto \color{blue}{\left(x - z\right) \cdot \left(y \cdot t\right)}\]
- Using strategy
rm
Applied associate-*r* 5.1
\[\leadsto \color{blue}{\left(\left(x - z\right) \cdot y\right) \cdot t}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(308109862 3157295724 2075424664 3252260029 2236378824 3677209114)'
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:target
(if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))
(* (- (* x y) (* z y)) t))