(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 (* (* z t) -0.3333333333333333))
(t_2 (- y (/ (* z t) 3.0)))
(t_3 (* a (/ -0.3333333333333333 b))))
(if (<= t_2 -1e+210)
(fma 2.0 (* (sqrt x) (cos y)) (/ a (* b -3.0)))
(if (<= t_2 2e+305)
(fma
2.0
(* (sqrt x) (- (* (cos y) (cos t_1)) (* (sin t_1) (sin y))))
t_3)
(fma 2.0 (sqrt (* x (pow (cos y) 2.0))) t_3)))))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 = (z * t) * -0.3333333333333333;
double t_2 = y - ((z * t) / 3.0);
double t_3 = a * (-0.3333333333333333 / b);
double tmp;
if (t_2 <= -1e+210) {
tmp = fma(2.0, (sqrt(x) * cos(y)), (a / (b * -3.0)));
} else if (t_2 <= 2e+305) {
tmp = fma(2.0, (sqrt(x) * ((cos(y) * cos(t_1)) - (sin(t_1) * sin(y)))), t_3);
} else {
tmp = fma(2.0, sqrt((x * pow(cos(y), 2.0))), t_3);
}
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(Float64(z * t) * -0.3333333333333333) t_2 = Float64(y - Float64(Float64(z * t) / 3.0)) t_3 = Float64(a * Float64(-0.3333333333333333 / b)) tmp = 0.0 if (t_2 <= -1e+210) tmp = fma(2.0, Float64(sqrt(x) * cos(y)), Float64(a / Float64(b * -3.0))); elseif (t_2 <= 2e+305) tmp = fma(2.0, Float64(sqrt(x) * Float64(Float64(cos(y) * cos(t_1)) - Float64(sin(t_1) * sin(y)))), t_3); else tmp = fma(2.0, sqrt(Float64(x * (cos(y) ^ 2.0))), t_3); 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[(N[(z * t), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]}, Block[{t$95$2 = N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(a * N[(-0.3333333333333333 / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+210], N[(2.0 * N[(N[Sqrt[x], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] + N[(a / N[(b * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+305], N[(2.0 * N[(N[Sqrt[x], $MachinePrecision] * N[(N[(N[Cos[y], $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[t$95$1], $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], N[(2.0 * N[Sqrt[N[(x * N[Power[N[Cos[y], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + t$95$3), $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 := \left(z \cdot t\right) \cdot -0.3333333333333333\\
t_2 := y - \frac{z \cdot t}{3}\\
t_3 := a \cdot \frac{-0.3333333333333333}{b}\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{+210}:\\
\;\;\;\;\mathsf{fma}\left(2, \sqrt{x} \cdot \cos y, \frac{a}{b \cdot -3}\right)\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(2, \sqrt{x} \cdot \left(\cos y \cdot \cos t_1 - \sin t_1 \cdot \sin y\right), t_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \sqrt{x \cdot {\cos y}^{2}}, t_3\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a




Bits error versus b
| Original | 20.5 |
|---|---|
| Target | 18.4 |
| Herbie | 16.3 |
if (-.f64 y (/.f64 (*.f64 z t) 3)) < -9.99999999999999927e209Initial program 37.9
Simplified37.8
Taylor expanded in z around 0 26.1
Applied egg-rr26.1
if -9.99999999999999927e209 < (-.f64 y (/.f64 (*.f64 z t) 3)) < 1.9999999999999999e305Initial program 13.1
Simplified13.2
Applied egg-rr12.7
if 1.9999999999999999e305 < (-.f64 y (/.f64 (*.f64 z t) 3)) Initial program 62.0
Simplified62.1
Taylor expanded in z around 0 32.7
Applied egg-rr32.8
Final simplification16.3
herbie shell --seed 2022160
(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))))