Average Error: 19.8 → 8.0
Time: 1.2m
Precision: 64
Internal precision: 128
\[\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}\;\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} \le -2.1533033503554896 \cdot 10^{-227}:\\
\;\;\;\;\left(9.0 \cdot \frac{y}{\frac{c \cdot z}{x}} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{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} \le 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{else}:\\
\;\;\;\;\left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \left(\frac{t}{c} \cdot a\right)\\
\end{array}\]
Target
| Original | 19.8 |
| Comparison | 13.8 |
| Herbie | 8.0 |
\[ \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 3 regimes.
-
if (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < -2.1533033503554896e-227
Initial program 12.0
\[\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}\]
Applied taylor 7.3
\[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]
Taylor expanded around 0 7.3
\[\leadsto \color{blue}{\left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
- Using strategy
rm
Applied associate-/l* 7.4
\[\leadsto \left(9.0 \cdot \color{blue}{\frac{y}{\frac{c \cdot z}{x}}} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]
if -2.1533033503554896e-227 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) < 0.0
Initial program 35.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}\]
- Using strategy
rm
Applied associate-/r* 0.5
\[\leadsto \color{blue}{\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}}\]
if 0.0 < (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))
Initial program 22.3
\[\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}\]
Applied taylor 11.8
\[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}\]
Taylor expanded around 0 11.8
\[\leadsto \color{blue}{\left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \frac{t \cdot a}{c}}\]
- Using strategy
rm
Applied associate-/l* 10.8
\[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \color{blue}{\frac{t}{\frac{c}{a}}}\]
- Using strategy
rm
Applied associate-/r/ 10.1
\[\leadsto \left(9.0 \cdot \frac{y \cdot x}{c \cdot z} + \frac{b}{c \cdot z}\right) - 4.0 \cdot \color{blue}{\left(\frac{t}{c} \cdot a\right)}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(724045636 2503216985 2112021327 2271983714 3388563250 1713609638)'
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J"
: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)))