Average Error: 3.0 → 1.8
Time: 36.2s
Precision: 64
Internal precision: 128
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -1.7570734968756763 \cdot 10^{+120}:\\
\;\;\;\;z \cdot y + \left(z \cdot \left(b \cdot a\right) + a \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot y + x\right) + \left(b \cdot z + t\right) \cdot a\\
\end{array}\]
Target
| Original | 3.0 |
| Comparison | 1.5 |
| Herbie | 1.8 |
\[ \begin{array}{l}
\mathbf{if}\;z \lt -1.1820553527347888 \cdot 10^{+19}:\\
\;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\
\mathbf{if}\;z \lt 4.7589743188364287 \cdot 10^{-122}:\\
\;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if z < -1.7570734968756763e+120
Initial program 19.5
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
Applied simplify 21.6
\[\leadsto \color{blue}{\left(z \cdot y + x\right) + \left(b \cdot z + t\right) \cdot a}\]
Applied taylor 0.1
\[\leadsto z \cdot y + \left(z \cdot \left(b \cdot a\right) + a \cdot t\right)\]
Taylor expanded around inf 0.1
\[\leadsto \color{blue}{z \cdot y + \left(z \cdot \left(b \cdot a\right) + a \cdot t\right)}\]
if -1.7570734968756763e+120 < z
Initial program 1.4
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
Applied simplify 2.0
\[\leadsto \color{blue}{\left(z \cdot y + x\right) + \left(b \cdot z + t\right) \cdot a}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1155861525 2976023767 2229427605 1257832866 1576552063 3568085888)'
(FPCore (x y z t a b)
:name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
:target
(if (< z -1.1820553527347888e+19) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))