
(FPCore (x y z) :precision binary64 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
double code(double x, double y, double z) {
return x + (exp((y * log((y / (z + y))))) / y);
}
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
public static double code(double x, double y, double z) {
return x + (Math.exp((y * Math.log((y / (z + y))))) / y);
}
def code(x, y, z): return x + (math.exp((y * math.log((y / (z + y))))) / y)
function code(x, y, z) return Float64(x + Float64(exp(Float64(y * log(Float64(y / Float64(z + y))))) / y)) end
function tmp = code(x, y, z) tmp = x + (exp((y * log((y / (z + y))))) / y); 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]
\begin{array}{l}
\\
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
double code(double x, double y, double z) {
return x + (exp((y * log((y / (z + y))))) / y);
}
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
public static double code(double x, double y, double z) {
return x + (Math.exp((y * Math.log((y / (z + y))))) / y);
}
def code(x, y, z): return x + (math.exp((y * math.log((y / (z + y))))) / y)
function code(x, y, z) return Float64(x + Float64(exp(Float64(y * log(Float64(y / Float64(z + y))))) / y)) end
function tmp = code(x, y, z) tmp = x + (exp((y * log((y / (z + y))))) / y); 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]
\begin{array}{l}
\\
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\end{array}
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (/ (exp (- 0.0 z)) y)))) (if (<= y -4500.0) t_0 (if (<= y 4.5e-7) (+ (/ 1.0 y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = x + (exp((0.0 - z)) / y);
double tmp;
if (y <= -4500.0) {
tmp = t_0;
} else if (y <= 4.5e-7) {
tmp = (1.0 / y) + 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
real(8) :: t_0
real(8) :: tmp
t_0 = x + (exp((0.0d0 - z)) / y)
if (y <= (-4500.0d0)) then
tmp = t_0
else if (y <= 4.5d-7) then
tmp = (1.0d0 / y) + x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + (Math.exp((0.0 - z)) / y);
double tmp;
if (y <= -4500.0) {
tmp = t_0;
} else if (y <= 4.5e-7) {
tmp = (1.0 / y) + x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + (math.exp((0.0 - z)) / y) tmp = 0 if y <= -4500.0: tmp = t_0 elif y <= 4.5e-7: tmp = (1.0 / y) + x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(exp(Float64(0.0 - z)) / y)) tmp = 0.0 if (y <= -4500.0) tmp = t_0; elseif (y <= 4.5e-7) tmp = Float64(Float64(1.0 / y) + x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (exp((0.0 - z)) / y); tmp = 0.0; if (y <= -4500.0) tmp = t_0; elseif (y <= 4.5e-7) tmp = (1.0 / y) + x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(N[Exp[N[(0.0 - z), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4500.0], t$95$0, If[LessEqual[y, 4.5e-7], N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \frac{e^{0 - z}}{y}\\
\mathbf{if}\;y \leq -4500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{y} + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4500 or 4.4999999999999998e-7 < y Initial program 90.0%
Simplified0
Taylor expanded in y around inf 0
Simplified0
if -4500 < y < 4.4999999999999998e-7Initial program 84.5%
Simplified0
Taylor expanded in z around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (if (<= z -1.92e+90) (/ (+ 1.0 (* y x)) y) (if (<= z -920.0) (/ (/ 1.0 y) (exp z)) (+ (/ 1.0 y) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.92e+90) {
tmp = (1.0 + (y * x)) / y;
} else if (z <= -920.0) {
tmp = (1.0 / y) / exp(z);
} else {
tmp = (1.0 / y) + x;
}
return tmp;
}
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 <= (-1.92d+90)) then
tmp = (1.0d0 + (y * x)) / y
else if (z <= (-920.0d0)) then
tmp = (1.0d0 / y) / exp(z)
else
tmp = (1.0d0 / y) + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.92e+90) {
tmp = (1.0 + (y * x)) / y;
} else if (z <= -920.0) {
tmp = (1.0 / y) / Math.exp(z);
} else {
tmp = (1.0 / y) + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.92e+90: tmp = (1.0 + (y * x)) / y elif z <= -920.0: tmp = (1.0 / y) / math.exp(z) else: tmp = (1.0 / y) + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.92e+90) tmp = Float64(Float64(1.0 + Float64(y * x)) / y); elseif (z <= -920.0) tmp = Float64(Float64(1.0 / y) / exp(z)); else tmp = Float64(Float64(1.0 / y) + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.92e+90) tmp = (1.0 + (y * x)) / y; elseif (z <= -920.0) tmp = (1.0 / y) / exp(z); else tmp = (1.0 / y) + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.92e+90], N[(N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[z, -920.0], N[(N[(1.0 / y), $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.92 \cdot 10^{+90}:\\
\;\;\;\;\frac{1 + y \cdot x}{y}\\
\mathbf{elif}\;z \leq -920:\\
\;\;\;\;\frac{\frac{1}{y}}{e^{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} + x\\
\end{array}
\end{array}
if z < -1.92000000000000004e90Initial program 54.2%
Simplified0
Taylor expanded in z around 0 0
Simplified0
Taylor expanded in y around 0 0
Simplified0
if -1.92000000000000004e90 < z < -920Initial program 45.7%
Simplified0
Taylor expanded in y around inf 0
Simplified0
Taylor expanded in x around 0 0
Simplified0
if -920 < z Initial program 96.0%
Simplified0
Taylor expanded in z around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (if (<= y -2.3e-72) x (if (<= y 1.35e-6) (/ 1.0 y) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e-72) {
tmp = x;
} else if (y <= 1.35e-6) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
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 (y <= (-2.3d-72)) then
tmp = x
else if (y <= 1.35d-6) then
tmp = 1.0d0 / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e-72) {
tmp = x;
} else if (y <= 1.35e-6) {
tmp = 1.0 / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.3e-72: tmp = x elif y <= 1.35e-6: tmp = 1.0 / y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.3e-72) tmp = x; elseif (y <= 1.35e-6) tmp = Float64(1.0 / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.3e-72) tmp = x; elseif (y <= 1.35e-6) tmp = 1.0 / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.3e-72], x, If[LessEqual[y, 1.35e-6], N[(1.0 / y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-72}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -2.29999999999999995e-72 or 1.34999999999999999e-6 < y Initial program 90.9%
Simplified0
Taylor expanded in x around inf 0
Simplified0
if -2.29999999999999995e-72 < y < 1.34999999999999999e-6Initial program 82.1%
Simplified0
Taylor expanded in y around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (if (<= z -370000000.0) (/ (+ 1.0 (* y x)) y) (+ (/ 1.0 y) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -370000000.0) {
tmp = (1.0 + (y * x)) / y;
} else {
tmp = (1.0 / y) + x;
}
return tmp;
}
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 <= (-370000000.0d0)) then
tmp = (1.0d0 + (y * x)) / y
else
tmp = (1.0d0 / y) + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -370000000.0) {
tmp = (1.0 + (y * x)) / y;
} else {
tmp = (1.0 / y) + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -370000000.0: tmp = (1.0 + (y * x)) / y else: tmp = (1.0 / y) + x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -370000000.0) tmp = Float64(Float64(1.0 + Float64(y * x)) / y); else tmp = Float64(Float64(1.0 / y) + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -370000000.0) tmp = (1.0 + (y * x)) / y; else tmp = (1.0 / y) + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -370000000.0], N[(N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -370000000:\\
\;\;\;\;\frac{1 + y \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y} + x\\
\end{array}
\end{array}
if z < -3.7e8Initial program 53.5%
Simplified0
Taylor expanded in z around 0 0
Simplified0
Taylor expanded in y around 0 0
Simplified0
if -3.7e8 < z Initial program 95.1%
Simplified0
Taylor expanded in z around 0 0
Simplified0
(FPCore (x y z) :precision binary64 (+ (/ 1.0 y) x))
double code(double x, double y, double z) {
return (1.0 / y) + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / y) + x
end function
public static double code(double x, double y, double z) {
return (1.0 / y) + x;
}
def code(x, y, z): return (1.0 / y) + x
function code(x, y, z) return Float64(Float64(1.0 / y) + x) end
function tmp = code(x, y, z) tmp = (1.0 / y) + x; end
code[x_, y_, z_] := N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{y} + x
\end{array}
Initial program 87.8%
Simplified0
Taylor expanded in z around 0 0
Simplified0
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.8%
Simplified0
Taylor expanded in x around inf 0
Simplified0
(FPCore (x y z) :precision binary64 (if (< (/ y (+ z y)) 7.11541576e-315) (+ x (/ (exp (/ -1.0 z)) y)) (+ x (/ (exp (log (pow (/ y (+ y z)) y))) y))))
double code(double x, double y, double z) {
double tmp;
if ((y / (z + y)) < 7.11541576e-315) {
tmp = x + (exp((-1.0 / z)) / y);
} else {
tmp = x + (exp(log(pow((y / (y + z)), y))) / y);
}
return tmp;
}
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 ((y / (z + y)) < 7.11541576d-315) then
tmp = x + (exp(((-1.0d0) / z)) / y)
else
tmp = x + (exp(log(((y / (y + z)) ** y))) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y / (z + y)) < 7.11541576e-315) {
tmp = x + (Math.exp((-1.0 / z)) / y);
} else {
tmp = x + (Math.exp(Math.log(Math.pow((y / (y + z)), y))) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y / (z + y)) < 7.11541576e-315: tmp = x + (math.exp((-1.0 / z)) / y) else: tmp = x + (math.exp(math.log(math.pow((y / (y + z)), y))) / y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y / Float64(z + y)) < 7.11541576e-315) tmp = Float64(x + Float64(exp(Float64(-1.0 / z)) / y)); else tmp = Float64(x + Float64(exp(log((Float64(y / Float64(y + z)) ^ y))) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y / (z + y)) < 7.11541576e-315) tmp = x + (exp((-1.0 / z)) / y); else tmp = x + (exp(log(((y / (y + z)) ^ y))) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[N[(y / N[(z + y), $MachinePrecision]), $MachinePrecision], 7.11541576e-315], N[(x + N[(N[Exp[N[(-1.0 / z), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Exp[N[Log[N[Power[N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision], y], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z + y} < 7.11541576 \cdot 10^{-315}:\\
\;\;\;\;x + \frac{e^{\frac{-1}{z}}}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{e^{\log \left({\left(\frac{y}{y + z}\right)}^{y}\right)}}{y}\\
\end{array}
\end{array}
herbie shell --seed 2024110
(FPCore (x y z)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, G"
:precision binary64
:alt
(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)))