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




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 3.6 |
|---|---|
| Target | 1.8 |
| Herbie | 1.0 |
if (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -4.67909907399541e292Initial program 32.8
Applied egg-rr2.5
Taylor expanded in t around 0 2.5
if -4.67909907399541e292 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < 1.15884642285841031e288Initial program 0.6
Applied egg-rr1.7
Applied egg-rr1.7
Applied egg-rr0.6
if 1.15884642285841031e288 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) Initial program 25.8
Applied egg-rr3.3
Applied egg-rr3.3
Applied egg-rr3.3
Taylor expanded in x around 0 27.0
Simplified5.8
Final simplification1.0
herbie shell --seed 2022150
(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))))