Average Error: 5.9 → 1.3
Time: 1.1m
Precision: 64
Internal precision: 128
\[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
⬇
\[\begin{array}{l}
\mathbf{if}\;c \le -4.992810223583974 \cdot 10^{+25}:\\
\;\;\;\;2.0 \cdot \left(\left(y \cdot x + z \cdot t\right) - c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)\\
\mathbf{if}\;c \le 2.4074102642527796 \cdot 10^{+35}:\\
\;\;\;\;2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;2.0 \cdot \left(\left(y \cdot x + z \cdot t\right) - c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)\\
\end{array}\]
Target
| Original | 5.9 |
| Comparison | 1.6 |
| Herbie | 1.3 |
\[ 2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]
Derivation
- Split input into 2 regimes.
-
if c < -4.992810223583974e+25 or 2.4074102642527796e+35 < c
Initial program 21.4
\[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
Applied taylor 24.8
\[\leadsto 2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(b \cdot \left({c}^2 \cdot i\right) + a \cdot \left(c \cdot i\right)\right)\right)\]
Taylor expanded around inf 24.8
\[\leadsto 2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \color{blue}{\left(b \cdot \left({c}^2 \cdot i\right) + a \cdot \left(c \cdot i\right)\right)}\right)\]
Applied simplify 4.6
\[\leadsto \color{blue}{2.0 \cdot \left(\left(y \cdot x + z \cdot t\right) - \left(c \cdot i\right) \cdot \left(a + b \cdot c\right)\right)}\]
- Using strategy
rm
Applied associate-*l* 3.5
\[\leadsto 2.0 \cdot \left(\left(y \cdot x + z \cdot t\right) - \color{blue}{c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)}\right)\]
if -4.992810223583974e+25 < c < 2.4074102642527796e+35
Initial program 0.6
\[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(2247240326 1466415176 839190031 2083987511 2950843355 3951195608)'
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:target
(* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))