(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (/ (- x) t) z)))
(if (<= (* z t) -4e+250)
t_1
(if (<= (* z t) 5e+252) (/ x (fma t (- z) y)) t_1))))double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
double code(double x, double y, double z, double t) {
double t_1 = (-x / t) / z;
double tmp;
if ((z * t) <= -4e+250) {
tmp = t_1;
} else if ((z * t) <= 5e+252) {
tmp = x / fma(t, -z, y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function code(x, y, z, t) t_1 = Float64(Float64(Float64(-x) / t) / z) tmp = 0.0 if (Float64(z * t) <= -4e+250) tmp = t_1; elseif (Float64(z * t) <= 5e+252) tmp = Float64(x / fma(t, Float64(-z), y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -4e+250], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e+252], N[(x / N[(t * (-z) + y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
t_1 := \frac{\frac{-x}{t}}{z}\\
\mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+250}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+252}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(t, -z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
| Original | 2.8 |
|---|---|
| Target | 1.9 |
| Herbie | 0.2 |
if (*.f64 z t) < -3.9999999999999997e250 or 4.9999999999999997e252 < (*.f64 z t) Initial program 15.1
Applied egg-rr15.1
Taylor expanded in y around 0 15.6
Simplified0.6
if -3.9999999999999997e250 < (*.f64 z t) < 4.9999999999999997e252Initial program 0.1
Taylor expanded in x around 0 0.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2022190
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))
(/ x (- y (* z t))))