| Alternative 1 | |
|---|---|
| Error | 0.9 |
| Cost | 14276 |
\[\begin{array}{l}
t_0 := x + \frac{y}{e^{z} \cdot 1.1283791670955126 - x \cdot y}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+261}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{x}\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
(FPCore (x y z)
:precision binary64
(if (<= z -240.0)
(+ x (/ -1.0 x))
(if (<= z 7.1e-47)
(+ x (/ -1.0 (+ x (/ -1.1283791670955126 y))))
(+ x (/ (* y 0.8862269254527579) (exp z))))))double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
double code(double x, double y, double z) {
double tmp;
if (z <= -240.0) {
tmp = x + (-1.0 / x);
} else if (z <= 7.1e-47) {
tmp = x + (-1.0 / (x + (-1.1283791670955126 / y)));
} else {
tmp = x + ((y * 0.8862269254527579) / exp(z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-240.0d0)) then
tmp = x + ((-1.0d0) / x)
else if (z <= 7.1d-47) then
tmp = x + ((-1.0d0) / (x + ((-1.1283791670955126d0) / y)))
else
tmp = x + ((y * 0.8862269254527579d0) / exp(z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
}
public static double code(double x, double y, double z) {
double tmp;
if (z <= -240.0) {
tmp = x + (-1.0 / x);
} else if (z <= 7.1e-47) {
tmp = x + (-1.0 / (x + (-1.1283791670955126 / y)));
} else {
tmp = x + ((y * 0.8862269254527579) / Math.exp(z));
}
return tmp;
}
def code(x, y, z): return x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
def code(x, y, z): tmp = 0 if z <= -240.0: tmp = x + (-1.0 / x) elif z <= 7.1e-47: tmp = x + (-1.0 / (x + (-1.1283791670955126 / y))) else: tmp = x + ((y * 0.8862269254527579) / math.exp(z)) return tmp
function code(x, y, z) return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))) end
function code(x, y, z) tmp = 0.0 if (z <= -240.0) tmp = Float64(x + Float64(-1.0 / x)); elseif (z <= 7.1e-47) tmp = Float64(x + Float64(-1.0 / Float64(x + Float64(-1.1283791670955126 / y)))); else tmp = Float64(x + Float64(Float64(y * 0.8862269254527579) / exp(z))); end return tmp end
function tmp = code(x, y, z) tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y))); end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -240.0) tmp = x + (-1.0 / x); elseif (z <= 7.1e-47) tmp = x + (-1.0 / (x + (-1.1283791670955126 / y))); else tmp = x + ((y * 0.8862269254527579) / exp(z)); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, -240.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.1e-47], N[(x + N[(-1.0 / N[(x + N[(-1.1283791670955126 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * 0.8862269254527579), $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\begin{array}{l}
\mathbf{if}\;z \leq -240:\\
\;\;\;\;x + \frac{-1}{x}\\
\mathbf{elif}\;z \leq 7.1 \cdot 10^{-47}:\\
\;\;\;\;x + \frac{-1}{x + \frac{-1.1283791670955126}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot 0.8862269254527579}{e^{z}}\\
\end{array}
Results
| Original | 2.7 |
|---|---|
| Target | 0.0 |
| Herbie | 0.7 |
if z < -240Initial program 6.9
Simplified0.0
Taylor expanded in y around inf 0.0
if -240 < z < 7.1000000000000002e-47Initial program 0.1
Simplified0.1
Taylor expanded in z around 0 0.4
Simplified0.4
if 7.1000000000000002e-47 < z Initial program 3.2
Simplified0.0
Taylor expanded in y around 0 2.0
Simplified2.0
Final simplification0.7
| Alternative 1 | |
|---|---|
| Error | 0.9 |
| Cost | 14276 |
| Alternative 2 | |
|---|---|
| Error | 0.0 |
| Cost | 13376 |
| Alternative 3 | |
|---|---|
| Error | 9.0 |
| Cost | 848 |
| Alternative 4 | |
|---|---|
| Error | 0.3 |
| Cost | 840 |
| Alternative 5 | |
|---|---|
| Error | 19.2 |
| Cost | 456 |
| Alternative 6 | |
|---|---|
| Error | 19.2 |
| Cost | 456 |
| Alternative 7 | |
|---|---|
| Error | 11.8 |
| Cost | 452 |
| Alternative 8 | |
|---|---|
| Error | 20.0 |
| Cost | 64 |
herbie shell --seed 2022330
(FPCore (x y z)
:name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(+ x (/ 1.0 (- (* (/ 1.1283791670955126 y) (exp z)) x)))
(+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))