Average Error: 19.8 → 9.3
Time: 2.0m
Precision: 64
Internal Precision: 384
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
↓
\[\begin{array}{l}
\mathbf{if}\;c \le -4.518506568601351 \cdot 10^{+81}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + 9.0 \cdot \frac{y \cdot \frac{x}{c}}{z}\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\\
\mathbf{if}\;c \le 2.7389558874700873 \cdot 10^{+193}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + 9.0 \cdot \left(\left(\frac{y}{z} \cdot x\right) \cdot \frac{1}{c}\right)\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{b}{z \cdot c} + 9.0 \cdot \frac{y \cdot \frac{x}{c}}{z}\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\\
\end{array}\]
Target
| Original | 19.8 |
|---|
| Target | 14.0 |
|---|
| Herbie | 9.3 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -1.100156740804105 \cdot 10^{-171}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt -0.0:\\
\;\;\;\;\frac{\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z}}{c}\\
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.1708877911747488 \cdot 10^{-53}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 2.876823679546137 \cdot 10^{+130}:\\
\;\;\;\;\left(\left(9.0 \cdot \frac{y}{c}\right) \cdot \frac{x}{z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\
\mathbf{if}\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \lt 1.3838515042456319 \cdot 10^{+158}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(z \cdot 4.0\right) \cdot \left(t \cdot a\right)\right) + b}{z \cdot c}\\
\mathbf{else}:\\
\;\;\;\;\left(9.0 \cdot \left(\frac{y}{c \cdot z} \cdot x\right) + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{a \cdot t}{c}\\
\end{array}\]
Derivation
- Split input into 2 regimes
if c < -4.518506568601351e+81 or 2.7389558874700873e+193 < c
Initial program 24.7
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
Taylor expanded around 0 16.4
\[\leadsto \color{blue}{\left(\frac{b}{z \cdot c} + 9.0 \cdot \frac{y \cdot x}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}}\]
- Using strategy
rm Applied associate-/l*13.2
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \frac{y \cdot x}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\frac{a}{\frac{c}{t}}}\]
- Using strategy
rm Applied times-frac12.4
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{x}{c}\right)}\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\]
- Using strategy
rm Applied associate-*l/8.9
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \color{blue}{\frac{y \cdot \frac{x}{c}}{z}}\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\]
if -4.518506568601351e+81 < c < 2.7389558874700873e+193
Initial program 16.4
\[\frac{\left(\left(x \cdot 9.0\right) \cdot y - \left(\left(z \cdot 4.0\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\]
Taylor expanded around 0 7.8
\[\leadsto \color{blue}{\left(\frac{b}{z \cdot c} + 9.0 \cdot \frac{y \cdot x}{z \cdot c}\right) - 4.0 \cdot \frac{a \cdot t}{c}}\]
- Using strategy
rm Applied associate-/l*9.3
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \frac{y \cdot x}{z \cdot c}\right) - 4.0 \cdot \color{blue}{\frac{a}{\frac{c}{t}}}\]
- Using strategy
rm Applied times-frac11.5
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{x}{c}\right)}\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\]
- Using strategy
rm Applied div-inv11.5
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \left(\frac{y}{z} \cdot \color{blue}{\left(x \cdot \frac{1}{c}\right)}\right)\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\]
Applied associate-*r*9.6
\[\leadsto \left(\frac{b}{z \cdot c} + 9.0 \cdot \color{blue}{\left(\left(\frac{y}{z} \cdot x\right) \cdot \frac{1}{c}\right)}\right) - 4.0 \cdot \frac{a}{\frac{c}{t}}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J"
:herbie-target
(if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -1.100156740804105e-171) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) -0.0) (/ (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.1708877911747488e-53) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 2.876823679546137e+130) (- (+ (* (* 9.0 (/ y c)) (/ x z)) (/ b (* c z))) (* 4.0 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 1.3838515042456319e+158) (/ (+ (- (* (* x 9.0) y) (* (* z 4.0) (* t a))) b) (* z c)) (- (+ (* 9.0 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4.0 (/ (* a t) c))))))))
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))