(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t) :precision binary64 (if (<= (* z t) 5e+227) (/ x (- y (* z t))) (* -1.0 (* (fma (/ (/ y t) t) (/ x z) (/ x t)) (/ 1.0 z)))))
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 tmp;
if ((z * t) <= 5e+227) {
tmp = x / (y - (z * t));
} else {
tmp = -1.0 * (fma(((y / t) / t), (x / z), (x / t)) * (1.0 / z));
}
return tmp;
}
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= 5e+227) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(-1.0 * Float64(fma(Float64(Float64(y / t) / t), Float64(x / z), Float64(x / t)) * Float64(1.0 / z))); end return tmp end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], 5e+227], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(N[(N[(y / t), $MachinePrecision] / t), $MachinePrecision] * N[(x / z), $MachinePrecision] + N[(x / t), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 5 \cdot 10^{+227}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\mathsf{fma}\left(\frac{\frac{y}{t}}{t}, \frac{x}{z}, \frac{x}{t}\right) \cdot \frac{1}{z}\right)\\
\end{array}
| Original | 2.6 |
|---|---|
| Target | 1.7 |
| Herbie | 1.6 |
if (*.f64 z t) < 4.9999999999999996e227Initial program 1.6
if 4.9999999999999996e227 < (*.f64 z t) Initial program 11.6
Taylor expanded in y around 0 15.0
Simplified1.8
Applied egg-rr1.6
Final simplification1.6
herbie shell --seed 2022203
(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))))