| Alternative 1 | |
|---|---|
| Error | 16.8 |
| Cost | 13504 |
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y + a \cdot \frac{-0.3333333333333333}{b}
\]
(FPCore (x y z t a b) :precision binary64 (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ a (* b 3.0)))
(t_2 (fma (* z -0.3333333333333333) t (* z (* t 0.3333333333333333))))
(t_3 (* 2.0 (sqrt x)))
(t_4 (fma t (* z -0.3333333333333333) y)))
(if (<= t 2.5078771355750503e-196)
(- (* t_3 (cos y)) t_1)
(if (<= t 2.0893490202273234e+165)
(- (* t_3 (- (* (cos t_4) (cos t_2)) (* (sin t_4) (sin t_2)))) t_1)
(- (sqrt (* (pow (cos y) 2.0) (* x 4.0))) t_1)))))double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = a / (b * 3.0);
double t_2 = fma((z * -0.3333333333333333), t, (z * (t * 0.3333333333333333)));
double t_3 = 2.0 * sqrt(x);
double t_4 = fma(t, (z * -0.3333333333333333), y);
double tmp;
if (t <= 2.5078771355750503e-196) {
tmp = (t_3 * cos(y)) - t_1;
} else if (t <= 2.0893490202273234e+165) {
tmp = (t_3 * ((cos(t_4) * cos(t_2)) - (sin(t_4) * sin(t_2)))) - t_1;
} else {
tmp = sqrt((pow(cos(y), 2.0) * (x * 4.0))) - t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - Float64(a / Float64(b * 3.0))) end
function code(x, y, z, t, a, b) t_1 = Float64(a / Float64(b * 3.0)) t_2 = fma(Float64(z * -0.3333333333333333), t, Float64(z * Float64(t * 0.3333333333333333))) t_3 = Float64(2.0 * sqrt(x)) t_4 = fma(t, Float64(z * -0.3333333333333333), y) tmp = 0.0 if (t <= 2.5078771355750503e-196) tmp = Float64(Float64(t_3 * cos(y)) - t_1); elseif (t <= 2.0893490202273234e+165) tmp = Float64(Float64(t_3 * Float64(Float64(cos(t_4) * cos(t_2)) - Float64(sin(t_4) * sin(t_2)))) - t_1); else tmp = Float64(sqrt(Float64((cos(y) ^ 2.0) * Float64(x * 4.0))) - t_1); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z * -0.3333333333333333), $MachinePrecision] * t + N[(z * N[(t * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t * N[(z * -0.3333333333333333), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t, 2.5078771355750503e-196], N[(N[(t$95$3 * N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[t, 2.0893490202273234e+165], N[(N[(t$95$3 * N[(N[(N[Cos[t$95$4], $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[t$95$4], $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[Cos[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(x * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]]]]]]]
\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := \mathsf{fma}\left(z \cdot -0.3333333333333333, t, z \cdot \left(t \cdot 0.3333333333333333\right)\right)\\
t_3 := 2 \cdot \sqrt{x}\\
t_4 := \mathsf{fma}\left(t, z \cdot -0.3333333333333333, y\right)\\
\mathbf{if}\;t \leq 2.5078771355750503 \cdot 10^{-196}:\\
\;\;\;\;t_3 \cdot \cos y - t_1\\
\mathbf{elif}\;t \leq 2.0893490202273234 \cdot 10^{+165}:\\
\;\;\;\;t_3 \cdot \left(\cos t_4 \cdot \cos t_2 - \sin t_4 \cdot \sin t_2\right) - t_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\cos y}^{2} \cdot \left(x \cdot 4\right)} - t_1\\
\end{array}
| Original | 20.5 |
|---|---|
| Target | 18.3 |
| Herbie | 17.0 |
if t < 2.5078771355750503e-196Initial program 15.6
Taylor expanded in z around 0 13.2
if 2.5078771355750503e-196 < t < 2.08934902022732337e165Initial program 14.6
Applied egg-rr14.5
Applied egg-rr13.4
if 2.08934902022732337e165 < t Initial program 39.6
Applied egg-rr39.7
Taylor expanded in z around 0 28.8
Applied egg-rr30.2
Final simplification17.0
| Alternative 1 | |
|---|---|
| Error | 16.8 |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Error | 16.7 |
| Cost | 13504 |
| Alternative 3 | |
|---|---|
| Error | 25.1 |
| Cost | 6976 |
| Alternative 4 | |
|---|---|
| Error | 36.1 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 36.0 |
| Cost | 320 |

herbie shell --seed 2022297
(FPCore (x y z t a b)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, K"
:precision binary64
:herbie-target
(if (< z -1.3793337487235141e+129) (- (* (* 2.0 (sqrt x)) (cos (- (/ 1.0 y) (/ (/ 0.3333333333333333 z) t)))) (/ (/ a 3.0) b)) (if (< z 3.516290613555987e+106) (- (* (* (sqrt x) 2.0) (cos (- y (* (/ t 3.0) z)))) (/ (/ a 3.0) b)) (- (* (cos (- y (/ (/ 0.3333333333333333 z) t))) (* 2.0 (sqrt x))) (/ (/ a b) 3.0))))
(- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))