(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 (* 2.0 (sqrt x)))
(t_2 (/ a (* b 3.0)))
(t_3 (* (* z t) -0.3333333333333333)))
(if (<= (* z t) -3.5e+217)
(fma (/ a b) -0.3333333333333333 t_1)
(if (<= (* z t) 5e+168)
(- (* t_1 (- (* (cos y) (cos t_3)) (* (sin y) (sin t_3)))) t_2)
(- (sqrt (* (* x 4.0) (pow (cos y) 2.0))) t_2)))))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 = 2.0 * sqrt(x);
double t_2 = a / (b * 3.0);
double t_3 = (z * t) * -0.3333333333333333;
double tmp;
if ((z * t) <= -3.5e+217) {
tmp = fma((a / b), -0.3333333333333333, t_1);
} else if ((z * t) <= 5e+168) {
tmp = (t_1 * ((cos(y) * cos(t_3)) - (sin(y) * sin(t_3)))) - t_2;
} else {
tmp = sqrt(((x * 4.0) * pow(cos(y), 2.0))) - t_2;
}
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(2.0 * sqrt(x)) t_2 = Float64(a / Float64(b * 3.0)) t_3 = Float64(Float64(z * t) * -0.3333333333333333) tmp = 0.0 if (Float64(z * t) <= -3.5e+217) tmp = fma(Float64(a / b), -0.3333333333333333, t_1); elseif (Float64(z * t) <= 5e+168) tmp = Float64(Float64(t_1 * Float64(Float64(cos(y) * cos(t_3)) - Float64(sin(y) * sin(t_3)))) - t_2); else tmp = Float64(sqrt(Float64(Float64(x * 4.0) * (cos(y) ^ 2.0))) - t_2); 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[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(z * t), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -3.5e+217], N[(N[(a / b), $MachinePrecision] * -0.3333333333333333 + t$95$1), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+168], N[(N[(t$95$1 * N[(N[(N[Cos[y], $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision], N[(N[Sqrt[N[(N[(x * 4.0), $MachinePrecision] * N[Power[N[Cos[y], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t$95$2), $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 := 2 \cdot \sqrt{x}\\
t_2 := \frac{a}{b \cdot 3}\\
t_3 := \left(z \cdot t\right) \cdot -0.3333333333333333\\
\mathbf{if}\;z \cdot t \leq -3.5 \cdot 10^{+217}:\\
\;\;\;\;\mathsf{fma}\left(\frac{a}{b}, -0.3333333333333333, t_1\right)\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+168}:\\
\;\;\;\;t_1 \cdot \left(\cos y \cdot \cos t_3 - \sin y \cdot \sin t_3\right) - t_2\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(x \cdot 4\right) \cdot {\cos y}^{2}} - t_2\\
\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.6 |
| Herbie | 16.2 |
if (*.f64 z t) < -3.4999999999999998e217Initial program 50.9
Taylor expanded in z around 0 32.5
Applied egg-rr32.6
Taylor expanded in y around 0 32.3
Simplified32.3
if -3.4999999999999998e217 < (*.f64 z t) < 4.99999999999999967e168Initial program 11.4
Applied egg-rr10.8
if 4.99999999999999967e168 < (*.f64 z t) Initial program 46.4
Taylor expanded in z around 0 33.2
Applied egg-rr33.2
Final simplification16.2
herbie shell --seed 2022166
(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))))