(FPCore (x y z t a b) :precision binary64 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (+ a 1.0) (/ (* y b) t)))
(t_2 (/ (+ x (/ (* y z) t)) t_1))
(t_3 (/ y t_1)))
(if (<= t_2 (- INFINITY))
(* (/ z t) t_3)
(if (<= t_2 -4.472539530856903e-289)
t_2
(if (<= t_2 0.0)
(/ (+ z (/ x (/ y t))) b)
(if (<= t_2 1.7642758988097463e+126)
t_2
(if (<= t_2 INFINITY)
(fma t_3 (/ z t) (/ x t_1))
(/ (+ z (* x (/ t y))) b))))))))double code(double x, double y, double z, double t, double a, double b) {
return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a + 1.0) + ((y * b) / t);
double t_2 = (x + ((y * z) / t)) / t_1;
double t_3 = y / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (z / t) * t_3;
} else if (t_2 <= -4.472539530856903e-289) {
tmp = t_2;
} else if (t_2 <= 0.0) {
tmp = (z + (x / (y / t))) / b;
} else if (t_2 <= 1.7642758988097463e+126) {
tmp = t_2;
} else if (t_2 <= ((double) INFINITY)) {
tmp = fma(t_3, (z / t), (x / t_1));
} else {
tmp = (z + (x * (t / y))) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t)) t_2 = Float64(Float64(x + Float64(Float64(y * z) / t)) / t_1) t_3 = Float64(y / t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(z / t) * t_3); elseif (t_2 <= -4.472539530856903e-289) tmp = t_2; elseif (t_2 <= 0.0) tmp = Float64(Float64(z + Float64(x / Float64(y / t))) / b); elseif (t_2 <= 1.7642758988097463e+126) tmp = t_2; elseif (t_2 <= Inf) tmp = fma(t_3, Float64(z / t), Float64(x / t_1)); else tmp = Float64(Float64(z + Float64(x * Float64(t / y))) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(y / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(z / t), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$2, -4.472539530856903e-289], t$95$2, If[LessEqual[t$95$2, 0.0], N[(N[(z + N[(x / N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[t$95$2, 1.7642758988097463e+126], t$95$2, If[LessEqual[t$95$2, Infinity], N[(t$95$3 * N[(z / t), $MachinePrecision] + N[(x / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[(x * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]]]]]]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
t_1 := \left(a + 1\right) + \frac{y \cdot b}{t}\\
t_2 := \frac{x + \frac{y \cdot z}{t}}{t_1}\\
t_3 := \frac{y}{t_1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{z}{t} \cdot t_3\\
\mathbf{elif}\;t_2 \leq -4.472539530856903 \cdot 10^{-289}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{z + \frac{x}{\frac{y}{t}}}{b}\\
\mathbf{elif}\;t_2 \leq 1.7642758988097463 \cdot 10^{+126}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(t_3, \frac{z}{t}, \frac{x}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z + x \cdot \frac{t}{y}}{b}\\
\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 | 16.4 |
|---|---|
| Target | 13.2 |
| Herbie | 5.9 |
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -inf.0Initial program 64.0
Simplified40.7
Applied egg-rr40.7
Taylor expanded in z around inf 38.4
Simplified22.6
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -4.4725395308569033e-289 or -0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < 1.7642758988097463e126Initial program 0.5
if -4.4725395308569033e-289 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -0.0Initial program 27.2
Simplified19.4
Taylor expanded in z around 0 27.4
Simplified19.3
Taylor expanded in b around inf 21.9
Simplified20.0
if 1.7642758988097463e126 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 24.5
Simplified18.5
Applied egg-rr18.7
Taylor expanded in z around 0 14.6
Simplified10.5
if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) Initial program 64.0
Simplified56.3
Taylor expanded in z around 0 61.2
Simplified51.5
Applied egg-rr51.6
Taylor expanded in b around inf 4.6
Simplified2.3
Final simplification5.9
herbie shell --seed 2022151
(FPCore (x y z t a b)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(if (< t -1.3659085366310088e-271) (* 1.0 (* (+ x (* (/ y t) z)) (/ 1.0 (+ (+ a 1.0) (* (/ y t) b))))) (if (< t 3.036967103737246e-130) (/ z b) (* 1.0 (* (+ x (* (/ y t) z)) (/ 1.0 (+ (+ a 1.0) (* (/ y t) b)))))))
(/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))