(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 (cos (- y (/ (* z t) 3.0)))))
(if (<= t_2 0.9999999999999992)
(- (* t_1 t_2) (* 0.3333333333333333 (/ a b)))
(- t_1 (/ a (* b 3.0))))))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 = cos((y - ((z * t) / 3.0)));
double tmp;
if (t_2 <= 0.9999999999999992) {
tmp = (t_1 * t_2) - (0.3333333333333333 * (a / b));
} else {
tmp = t_1 - (a / (b * 3.0));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((2.0d0 * sqrt(x)) * cos((y - ((z * t) / 3.0d0)))) - (a / (b * 3.0d0))
end function
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = 2.0d0 * sqrt(x)
t_2 = cos((y - ((z * t) / 3.0d0)))
if (t_2 <= 0.9999999999999992d0) then
tmp = (t_1 * t_2) - (0.3333333333333333d0 * (a / b))
else
tmp = t_1 - (a / (b * 3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 2.0 * Math.sqrt(x);
double t_2 = Math.cos((y - ((z * t) / 3.0)));
double tmp;
if (t_2 <= 0.9999999999999992) {
tmp = (t_1 * t_2) - (0.3333333333333333 * (a / b));
} else {
tmp = t_1 - (a / (b * 3.0));
}
return tmp;
}
def code(x, y, z, t, a, b): return ((2.0 * math.sqrt(x)) * math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0))
def code(x, y, z, t, a, b): t_1 = 2.0 * math.sqrt(x) t_2 = math.cos((y - ((z * t) / 3.0))) tmp = 0 if t_2 <= 0.9999999999999992: tmp = (t_1 * t_2) - (0.3333333333333333 * (a / b)) else: tmp = t_1 - (a / (b * 3.0)) 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 = cos(Float64(y - Float64(Float64(z * t) / 3.0))) tmp = 0.0 if (t_2 <= 0.9999999999999992) tmp = Float64(Float64(t_1 * t_2) - Float64(0.3333333333333333 * Float64(a / b))); else tmp = Float64(t_1 - Float64(a / Float64(b * 3.0))); end return tmp end
function tmp = code(x, y, z, t, a, b) tmp = ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0)); end
function tmp_2 = code(x, y, z, t, a, b) t_1 = 2.0 * sqrt(x); t_2 = cos((y - ((z * t) / 3.0))); tmp = 0.0; if (t_2 <= 0.9999999999999992) tmp = (t_1 * t_2) - (0.3333333333333333 * (a / b)); else tmp = t_1 - (a / (b * 3.0)); end tmp_2 = 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[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 0.9999999999999992], N[(N[(t$95$1 * t$95$2), $MachinePrecision] - N[(0.3333333333333333 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $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 := \cos \left(y - \frac{z \cdot t}{3}\right)\\
\mathbf{if}\;t_2 \leq 0.9999999999999992:\\
\;\;\;\;t_1 \cdot t_2 - 0.3333333333333333 \cdot \frac{a}{b}\\
\mathbf{else}:\\
\;\;\;\;t_1 - \frac{a}{b \cdot 3}\\
\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
Results
| Original | 21.3 |
|---|---|
| Target | 19.2 |
| Herbie | 17.2 |
if (cos.f64 (-.f64 y (/.f64 (*.f64 z t) 3))) < 0.999999999999999223Initial program 20.2
Taylor expanded in a around 0 20.3
if 0.999999999999999223 < (cos.f64 (-.f64 y (/.f64 (*.f64 z t) 3))) Initial program 23.1
Taylor expanded in z around 0 11.8
Taylor expanded in y around 0 11.8
Final simplification17.2
herbie shell --seed 2022152
(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))))