(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1
(-
(+ (* 0.3333333333333333 (/ t (* y z))) x)
(* 0.3333333333333333 (/ y z)))))
(if (<= t -4.1631542270516714e-67)
t_1
(if (<= t 1.533233474346769e-23)
(fma (pow (/ z -0.3333333333333333) -1.0) (fma t (/ -1.0 y) y) x)
t_1))))double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
double t_1 = ((0.3333333333333333 * (t / (y * z))) + x) - (0.3333333333333333 * (y / z));
double tmp;
if (t <= -4.1631542270516714e-67) {
tmp = t_1;
} else if (t <= 1.533233474346769e-23) {
tmp = fma(pow((z / -0.3333333333333333), -1.0), fma(t, (-1.0 / y), y), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function code(x, y, z, t) t_1 = Float64(Float64(Float64(0.3333333333333333 * Float64(t / Float64(y * z))) + x) - Float64(0.3333333333333333 * Float64(y / z))) tmp = 0.0 if (t <= -4.1631542270516714e-67) tmp = t_1; elseif (t <= 1.533233474346769e-23) tmp = fma((Float64(z / -0.3333333333333333) ^ -1.0), fma(t, Float64(-1.0 / y), y), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(0.3333333333333333 * N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] - N[(0.3333333333333333 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.1631542270516714e-67], t$95$1, If[LessEqual[t, 1.533233474346769e-23], N[(N[Power[N[(z / -0.3333333333333333), $MachinePrecision], -1.0], $MachinePrecision] * N[(t * N[(-1.0 / y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := \left(0.3333333333333333 \cdot \frac{t}{y \cdot z} + x\right) - 0.3333333333333333 \cdot \frac{y}{z}\\
\mathbf{if}\;t \leq -4.1631542270516714 \cdot 10^{-67}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq 1.533233474346769 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left({\left(\frac{z}{-0.3333333333333333}\right)}^{-1}, \mathsf{fma}\left(t, \frac{-1}{y}, y\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 3.8 |
|---|---|
| Target | 1.7 |
| Herbie | 0.5 |
if t < -4.1631542270516714e-67 or 1.53323347434676888e-23 < t Initial program 0.7
Simplified7.6
Taylor expanded in z around 0 0.7
if -4.1631542270516714e-67 < t < 1.53323347434676888e-23Initial program 6.9
Simplified0.2
Applied egg-rr0.2
Applied egg-rr0.3
Final simplification0.5
herbie shell --seed 2022133
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))