| Alternative 1 | |
|---|---|
| Error | 20.2 |
| Cost | 649 |
\[\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+98} \lor \neg \left(z \leq 2.25 \cdot 10^{-70}\right):\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\]
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
(FPCore (x y z t) :precision binary64 (if (<= (* z t) 1e+289) (/ x (- y (* z t))) (/ (/ (- x) t) 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) <= 1e+289) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / t) / z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (y - (z * t))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z * t) <= 1d+289) then
tmp = x / (y - (z * t))
else
tmp = (-x / t) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 1e+289) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / t) / z;
}
return tmp;
}
def code(x, y, z, t): return x / (y - (z * t))
def code(x, y, z, t): tmp = 0 if (z * t) <= 1e+289: tmp = x / (y - (z * t)) else: tmp = (-x / t) / 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) <= 1e+289) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(Float64(-x) / t) / z); end return tmp end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * t) <= 1e+289) tmp = x / (y - (z * t)); else tmp = (-x / t) / z; end tmp_2 = 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], 1e+289], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / t), $MachinePrecision] / z), $MachinePrecision]]
\frac{x}{y - z \cdot t}
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 10^{+289}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{t}}{z}\\
\end{array}
Results
| Original | 2.7 |
|---|---|
| Target | 1.7 |
| Herbie | 1.4 |
if (*.f64 z t) < 1.0000000000000001e289Initial program 1.5
if 1.0000000000000001e289 < (*.f64 z t) Initial program 17.3
Applied egg-rr17.4
Taylor expanded in y around 0 17.4
Simplified0.1
Final simplification1.4
| Alternative 1 | |
|---|---|
| Error | 20.2 |
| Cost | 649 |
| Alternative 2 | |
|---|---|
| Error | 19.2 |
| Cost | 649 |
| Alternative 3 | |
|---|---|
| Error | 17.9 |
| Cost | 648 |
| Alternative 4 | |
|---|---|
| Error | 27.9 |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Error | 30.6 |
| Cost | 192 |
herbie shell --seed 2022343
(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))))