(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 (- x (/ y (* z 3.0)))) (t_2 (+ t_1 (/ t (* y (* z 3.0))))))
(if (<= t_2 -2e+303)
(+
(+ x (* y (/ -0.3333333333333333 z)))
(/ (* 0.3333333333333333 (/ t z)) y))
(if (<= t_2 2e+268)
(+ t_1 (/ t (* z (* y 3.0))))
(fma
1.0
(+ x (* (/ y z) -0.3333333333333333))
(/ (/ t z) (* y 3.0)))))))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 = x - (y / (z * 3.0));
double t_2 = t_1 + (t / (y * (z * 3.0)));
double tmp;
if (t_2 <= -2e+303) {
tmp = (x + (y * (-0.3333333333333333 / z))) + ((0.3333333333333333 * (t / z)) / y);
} else if (t_2 <= 2e+268) {
tmp = t_1 + (t / (z * (y * 3.0)));
} else {
tmp = fma(1.0, (x + ((y / z) * -0.3333333333333333)), ((t / z) / (y * 3.0)));
}
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(x - Float64(y / Float64(z * 3.0))) t_2 = Float64(t_1 + Float64(t / Float64(y * Float64(z * 3.0)))) tmp = 0.0 if (t_2 <= -2e+303) tmp = Float64(Float64(x + Float64(y * Float64(-0.3333333333333333 / z))) + Float64(Float64(0.3333333333333333 * Float64(t / z)) / y)); elseif (t_2 <= 2e+268) tmp = Float64(t_1 + Float64(t / Float64(z * Float64(y * 3.0)))); else tmp = fma(1.0, Float64(x + Float64(Float64(y / z) * -0.3333333333333333)), Float64(Float64(t / z) / Float64(y * 3.0))); 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[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+303], N[(N[(x + N[(y * N[(-0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(t / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+268], N[(t$95$1 + N[(t / N[(z * N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(x + N[(N[(y / z), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision] + N[(N[(t / z), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
t_2 := t_1 + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+303}:\\
\;\;\;\;\left(x + y \cdot \frac{-0.3333333333333333}{z}\right) + \frac{0.3333333333333333 \cdot \frac{t}{z}}{y}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+268}:\\
\;\;\;\;t_1 + \frac{t}{z \cdot \left(y \cdot 3\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, x + \frac{y}{z} \cdot -0.3333333333333333, \frac{\frac{t}{z}}{y \cdot 3}\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 3.7 |
|---|---|
| Target | 1.9 |
| Herbie | 0.9 |
if (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -2e303Initial program 49.8
Applied egg-rr1.5
Applied egg-rr1.5
Applied egg-rr1.5
Taylor expanded in t around 0 1.6
if -2e303 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < 1.9999999999999999e268Initial program 0.5
Applied egg-rr0.5
if 1.9999999999999999e268 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) Initial program 17.3
Applied egg-rr3.9
Final simplification0.9
herbie shell --seed 2022166
(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))))