(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* z a))) (t_2 (/ x t_1)) (t_3 (/ (- x (* y z)) t_1)))
(if (<= t_3 -1e-111)
(- t_2 (/ y (/ t_1 z)))
(if (<= t_3 -2e-310)
(log1p (expm1 t_3))
(if (<= t_3 0.0)
(/ (- y (/ x z)) a)
(if (<= t_3 5e+298)
(- t_2 (/ (* y z) t_1))
(- (/ y a) (/ x (* z a)))))))))double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (z * a);
double t_2 = x / t_1;
double t_3 = (x - (y * z)) / t_1;
double tmp;
if (t_3 <= -1e-111) {
tmp = t_2 - (y / (t_1 / z));
} else if (t_3 <= -2e-310) {
tmp = log1p(expm1(t_3));
} else if (t_3 <= 0.0) {
tmp = (y - (x / z)) / a;
} else if (t_3 <= 5e+298) {
tmp = t_2 - ((y * z) / t_1);
} else {
tmp = (y / a) - (x / (z * a));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t - (z * a);
double t_2 = x / t_1;
double t_3 = (x - (y * z)) / t_1;
double tmp;
if (t_3 <= -1e-111) {
tmp = t_2 - (y / (t_1 / z));
} else if (t_3 <= -2e-310) {
tmp = Math.log1p(Math.expm1(t_3));
} else if (t_3 <= 0.0) {
tmp = (y - (x / z)) / a;
} else if (t_3 <= 5e+298) {
tmp = t_2 - ((y * z) / t_1);
} else {
tmp = (y / a) - (x / (z * a));
}
return tmp;
}
def code(x, y, z, t, a): return (x - (y * z)) / (t - (a * z))
def code(x, y, z, t, a): t_1 = t - (z * a) t_2 = x / t_1 t_3 = (x - (y * z)) / t_1 tmp = 0 if t_3 <= -1e-111: tmp = t_2 - (y / (t_1 / z)) elif t_3 <= -2e-310: tmp = math.log1p(math.expm1(t_3)) elif t_3 <= 0.0: tmp = (y - (x / z)) / a elif t_3 <= 5e+298: tmp = t_2 - ((y * z) / t_1) else: tmp = (y / a) - (x / (z * a)) return tmp
function code(x, y, z, t, a) return Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z))) end
function code(x, y, z, t, a) t_1 = Float64(t - Float64(z * a)) t_2 = Float64(x / t_1) t_3 = Float64(Float64(x - Float64(y * z)) / t_1) tmp = 0.0 if (t_3 <= -1e-111) tmp = Float64(t_2 - Float64(y / Float64(t_1 / z))); elseif (t_3 <= -2e-310) tmp = log1p(expm1(t_3)); elseif (t_3 <= 0.0) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (t_3 <= 5e+298) tmp = Float64(t_2 - Float64(Float64(y * z) / t_1)); else tmp = Float64(Float64(y / a) - Float64(x / Float64(z * a))); end return tmp end
code[x_, y_, z_, t_, a_] := N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -1e-111], N[(t$95$2 - N[(y / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -2e-310], N[Log[1 + N[(Exp[t$95$3] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$3, 5e+298], N[(t$95$2 - N[(N[(y * z), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(y / a), $MachinePrecision] - N[(x / N[(z * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := t - z \cdot a\\
t_2 := \frac{x}{t_1}\\
t_3 := \frac{x - y \cdot z}{t_1}\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{-111}:\\
\;\;\;\;t_2 - \frac{y}{\frac{t_1}{z}}\\
\mathbf{elif}\;t_3 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(t_3\right)\right)\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+298}:\\
\;\;\;\;t_2 - \frac{y \cdot z}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} - \frac{x}{z \cdot a}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
Results
| Original | 10.2 |
|---|---|
| Target | 1.6 |
| Herbie | 3.8 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.00000000000000009e-111Initial program 5.7
Taylor expanded in x around 0 5.7
Simplified0.8
if -1.00000000000000009e-111 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.999999999999994e-310Initial program 0.2
Applied egg-rr0.2
Taylor expanded in x around 0 0.2
Simplified7.7
Applied egg-rr0.2
if -1.999999999999994e-310 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -0.0Initial program 24.4
Applied egg-rr24.4
Taylor expanded in x around 0 24.4
Simplified24.5
Taylor expanded in t around 0 27.2
Simplified17.7
if -0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 5.0000000000000003e298Initial program 0.2
Applied egg-rr0.2
Taylor expanded in x around 0 0.2
Simplified4.3
Applied egg-rr0.2
if 5.0000000000000003e298 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 61.8
Applied egg-rr61.8
Taylor expanded in x around 0 61.8
Simplified37.0
Taylor expanded in a around inf 12.1
Simplified11.9
Final simplification3.8
herbie shell --seed 2022159
(FPCore (x y z t a)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< z -32113435955957344.0) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))
(/ (- x (* y z)) (- t (* a z))))