| Alternative 1 | |
|---|---|
| Error | 14.8 |
| Cost | 456 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+69}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-24}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (/ 1.0 y) x))) (if (<= z 0.23) t_0 (if (<= z 3.2e+71) x t_0))))
double code(double x, double y, double z) {
return x + (exp((y * log((y / (z + y))))) / y);
}
double code(double x, double y, double z) {
double t_0 = (1.0 / y) + x;
double tmp;
if (z <= 0.23) {
tmp = t_0;
} else if (z <= 3.2e+71) {
tmp = x;
} else {
tmp = t_0;
}
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 + (exp((y * log((y / (z + y))))) / 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) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / y) + x
if (z <= 0.23d0) then
tmp = t_0
else if (z <= 3.2d+71) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x + (Math.exp((y * Math.log((y / (z + y))))) / y);
}
public static double code(double x, double y, double z) {
double t_0 = (1.0 / y) + x;
double tmp;
if (z <= 0.23) {
tmp = t_0;
} else if (z <= 3.2e+71) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return x + (math.exp((y * math.log((y / (z + y))))) / y)
def code(x, y, z): t_0 = (1.0 / y) + x tmp = 0 if z <= 0.23: tmp = t_0 elif z <= 3.2e+71: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) return Float64(x + Float64(exp(Float64(y * log(Float64(y / Float64(z + y))))) / y)) end
function code(x, y, z) t_0 = Float64(Float64(1.0 / y) + x) tmp = 0.0 if (z <= 0.23) tmp = t_0; elseif (z <= 3.2e+71) tmp = x; else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = x + (exp((y * log((y / (z + y))))) / y); end
function tmp_2 = code(x, y, z) t_0 = (1.0 / y) + x; tmp = 0.0; if (z <= 0.23) tmp = t_0; elseif (z <= 3.2e+71) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x + N[(N[Exp[N[(y * N[Log[N[(y / N[(z + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, 0.23], t$95$0, If[LessEqual[z, 3.2e+71], x, t$95$0]]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := \frac{1}{y} + x\\
\mathbf{if}\;z \leq 0.23:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+71}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 6.2 |
|---|---|
| Target | 1.1 |
| Herbie | 2.9 |
if z < 0.23000000000000001 or 3.20000000000000023e71 < z Initial program 6.0
Simplified6.0
Taylor expanded in z around 0 1.9
if 0.23000000000000001 < z < 3.20000000000000023e71Initial program 10.1
Simplified10.1
Taylor expanded in x around inf 17.2
Final simplification2.9
| Alternative 1 | |
|---|---|
| Error | 14.8 |
| Cost | 456 |
| Alternative 2 | |
|---|---|
| Error | 28.3 |
| Cost | 64 |

herbie shell --seed 2022308
(FPCore (x y z)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, G"
:precision binary64
:herbie-target
(if (< (/ y (+ z y)) 7.11541576e-315) (+ x (/ (exp (/ -1.0 z)) y)) (+ x (/ (exp (log (pow (/ y (+ y z)) y))) y)))
(+ x (/ (exp (* y (log (/ y (+ z y))))) y)))