
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
double code(double x, double y) {
return exp((x * log((x / (x + y))))) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp((x * log((x / (x + y))))) / x
end function
public static double code(double x, double y) {
return Math.exp((x * Math.log((x / (x + y))))) / x;
}
def code(x, y): return math.exp((x * math.log((x / (x + y))))) / x
function code(x, y) return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x) end
function tmp = code(x, y) tmp = exp((x * log((x / (x + y))))) / x; end
code[x_, y_] := N[(N[Exp[N[(x * N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
double code(double x, double y) {
return exp((x * log((x / (x + y))))) / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp((x * log((x / (x + y))))) / x
end function
public static double code(double x, double y) {
return Math.exp((x * Math.log((x / (x + y))))) / x;
}
def code(x, y): return math.exp((x * math.log((x / (x + y))))) / x
function code(x, y) return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x) end
function tmp = code(x, y) tmp = exp((x * log((x / (x + y))))) / x; end
code[x_, y_] := N[(N[Exp[N[(x * N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\end{array}
(FPCore (x y) :precision binary64 (if (or (<= x -1000000000.0) (not (<= x 3.6e-14))) (/ (exp (- y)) x) (/ (pow (exp x) (log (/ x (+ x y)))) x)))
double code(double x, double y) {
double tmp;
if ((x <= -1000000000.0) || !(x <= 3.6e-14)) {
tmp = exp(-y) / x;
} else {
tmp = pow(exp(x), log((x / (x + y)))) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-1000000000.0d0)) .or. (.not. (x <= 3.6d-14))) then
tmp = exp(-y) / x
else
tmp = (exp(x) ** log((x / (x + y)))) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -1000000000.0) || !(x <= 3.6e-14)) {
tmp = Math.exp(-y) / x;
} else {
tmp = Math.pow(Math.exp(x), Math.log((x / (x + y)))) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1000000000.0) or not (x <= 3.6e-14): tmp = math.exp(-y) / x else: tmp = math.pow(math.exp(x), math.log((x / (x + y)))) / x return tmp
function code(x, y) tmp = 0.0 if ((x <= -1000000000.0) || !(x <= 3.6e-14)) tmp = Float64(exp(Float64(-y)) / x); else tmp = Float64((exp(x) ^ log(Float64(x / Float64(x + y)))) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1000000000.0) || ~((x <= 3.6e-14))) tmp = exp(-y) / x; else tmp = (exp(x) ^ log((x / (x + y)))) / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1000000000.0], N[Not[LessEqual[x, 3.6e-14]], $MachinePrecision]], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], N[(N[Power[N[Exp[x], $MachinePrecision], N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1000000000 \lor \neg \left(x \leq 3.6 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\
\end{array}
\end{array}
if x < -1e9 or 3.5999999999999998e-14 < x Initial program 71.9%
*-commutative71.9%
exp-to-pow71.9%
Simplified71.9%
Taylor expanded in x around inf 99.8%
mul-1-neg99.8%
Simplified99.8%
if -1e9 < x < 3.5999999999999998e-14Initial program 77.4%
exp-prod100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (or (<= x -0.76) (not (<= x 3.6e-14))) (/ (exp (- y)) x) (/ 1.0 x)))
double code(double x, double y) {
double tmp;
if ((x <= -0.76) || !(x <= 3.6e-14)) {
tmp = exp(-y) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.76d0)) .or. (.not. (x <= 3.6d-14))) then
tmp = exp(-y) / x
else
tmp = 1.0d0 / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.76) || !(x <= 3.6e-14)) {
tmp = Math.exp(-y) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.76) or not (x <= 3.6e-14): tmp = math.exp(-y) / x else: tmp = 1.0 / x return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.76) || !(x <= 3.6e-14)) tmp = Float64(exp(Float64(-y)) / x); else tmp = Float64(1.0 / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.76) || ~((x <= 3.6e-14))) tmp = exp(-y) / x; else tmp = 1.0 / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.76], N[Not[LessEqual[x, 3.6e-14]], $MachinePrecision]], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.76 \lor \neg \left(x \leq 3.6 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\end{array}
if x < -0.76000000000000001 or 3.5999999999999998e-14 < x Initial program 72.3%
*-commutative72.3%
exp-to-pow72.3%
Simplified72.3%
Taylor expanded in x around inf 99.8%
mul-1-neg99.8%
Simplified99.8%
if -0.76000000000000001 < x < 3.5999999999999998e-14Initial program 77.0%
exp-prod100.0%
Simplified100.0%
Taylor expanded in x around 0 99.5%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= x -105000000.0)
(/
(/
(+
x
(*
y
(-
(* y (+ 0.5 (+ (* x 0.5) (* y (- (* x -0.16666666666666666) 0.5)))))
x)))
x)
x)
(if (<= x 4.2e+184)
(/ 1.0 x)
(/ (/ (+ x (* y (- (* y (+ 0.5 (* x 0.5))) x))) x) x))))
double code(double x, double y) {
double tmp;
if (x <= -105000000.0) {
tmp = ((x + (y * ((y * (0.5 + ((x * 0.5) + (y * ((x * -0.16666666666666666) - 0.5))))) - x))) / x) / x;
} else if (x <= 4.2e+184) {
tmp = 1.0 / x;
} else {
tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-105000000.0d0)) then
tmp = ((x + (y * ((y * (0.5d0 + ((x * 0.5d0) + (y * ((x * (-0.16666666666666666d0)) - 0.5d0))))) - x))) / x) / x
else if (x <= 4.2d+184) then
tmp = 1.0d0 / x
else
tmp = ((x + (y * ((y * (0.5d0 + (x * 0.5d0))) - x))) / x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -105000000.0) {
tmp = ((x + (y * ((y * (0.5 + ((x * 0.5) + (y * ((x * -0.16666666666666666) - 0.5))))) - x))) / x) / x;
} else if (x <= 4.2e+184) {
tmp = 1.0 / x;
} else {
tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -105000000.0: tmp = ((x + (y * ((y * (0.5 + ((x * 0.5) + (y * ((x * -0.16666666666666666) - 0.5))))) - x))) / x) / x elif x <= 4.2e+184: tmp = 1.0 / x else: tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -105000000.0) tmp = Float64(Float64(Float64(x + Float64(y * Float64(Float64(y * Float64(0.5 + Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(x * -0.16666666666666666) - 0.5))))) - x))) / x) / x); elseif (x <= 4.2e+184) tmp = Float64(1.0 / x); else tmp = Float64(Float64(Float64(x + Float64(y * Float64(Float64(y * Float64(0.5 + Float64(x * 0.5))) - x))) / x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -105000000.0) tmp = ((x + (y * ((y * (0.5 + ((x * 0.5) + (y * ((x * -0.16666666666666666) - 0.5))))) - x))) / x) / x; elseif (x <= 4.2e+184) tmp = 1.0 / x; else tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -105000000.0], N[(N[(N[(x + N[(y * N[(N[(y * N[(0.5 + N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(x * -0.16666666666666666), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 4.2e+184], N[(1.0 / x), $MachinePrecision], N[(N[(N[(x + N[(y * N[(N[(y * N[(0.5 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -105000000:\\
\;\;\;\;\frac{\frac{x + y \cdot \left(y \cdot \left(0.5 + \left(x \cdot 0.5 + y \cdot \left(x \cdot -0.16666666666666666 - 0.5\right)\right)\right) - x\right)}{x}}{x}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+184}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + y \cdot \left(y \cdot \left(0.5 + x \cdot 0.5\right) - x\right)}{x}}{x}\\
\end{array}
\end{array}
if x < -1.05e8Initial program 73.8%
*-commutative73.8%
exp-to-pow73.8%
Simplified73.8%
Taylor expanded in x around inf 63.1%
mul-1-neg63.1%
associate-/l*63.1%
mul-1-neg63.1%
distribute-rgt-out63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in x around 0 63.0%
associate-*r*63.0%
distribute-rgt-out70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in y around 0 77.2%
if -1.05e8 < x < 4.2e184Initial program 82.3%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.3%
if 4.2e184 < x Initial program 42.8%
*-commutative42.8%
exp-to-pow42.8%
Simplified42.8%
Taylor expanded in x around inf 78.9%
mul-1-neg78.9%
associate-/l*78.9%
mul-1-neg78.9%
distribute-rgt-out84.2%
metadata-eval84.2%
Simplified84.2%
Taylor expanded in x around 0 84.2%
associate-*r*84.2%
distribute-rgt-out84.2%
*-commutative84.2%
Simplified84.2%
Taylor expanded in y around 0 56.9%
Final simplification80.8%
(FPCore (x y) :precision binary64 (if (or (<= x -0.98) (not (<= x 2.2e+185))) (/ (/ (+ x (* y (- (* y (+ 0.5 (* x 0.5))) x))) x) x) (/ 1.0 x)))
double code(double x, double y) {
double tmp;
if ((x <= -0.98) || !(x <= 2.2e+185)) {
tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.98d0)) .or. (.not. (x <= 2.2d+185))) then
tmp = ((x + (y * ((y * (0.5d0 + (x * 0.5d0))) - x))) / x) / x
else
tmp = 1.0d0 / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.98) || !(x <= 2.2e+185)) {
tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.98) or not (x <= 2.2e+185): tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x else: tmp = 1.0 / x return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.98) || !(x <= 2.2e+185)) tmp = Float64(Float64(Float64(x + Float64(y * Float64(Float64(y * Float64(0.5 + Float64(x * 0.5))) - x))) / x) / x); else tmp = Float64(1.0 / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.98) || ~((x <= 2.2e+185))) tmp = ((x + (y * ((y * (0.5 + (x * 0.5))) - x))) / x) / x; else tmp = 1.0 / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.98], N[Not[LessEqual[x, 2.2e+185]], $MachinePrecision]], N[(N[(N[(x + N[(y * N[(N[(y * N[(0.5 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.98 \lor \neg \left(x \leq 2.2 \cdot 10^{+185}\right):\\
\;\;\;\;\frac{\frac{x + y \cdot \left(y \cdot \left(0.5 + x \cdot 0.5\right) - x\right)}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\end{array}
if x < -0.97999999999999998 or 2.2000000000000001e185 < x Initial program 63.1%
*-commutative63.1%
exp-to-pow63.1%
Simplified63.1%
Taylor expanded in x around inf 68.5%
mul-1-neg68.5%
associate-/l*68.5%
mul-1-neg68.5%
distribute-rgt-out70.4%
metadata-eval70.4%
Simplified70.4%
Taylor expanded in x around 0 70.4%
associate-*r*70.4%
distribute-rgt-out75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in y around 0 69.2%
if -0.97999999999999998 < x < 2.2000000000000001e185Initial program 82.1%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.8%
Final simplification80.8%
(FPCore (x y)
:precision binary64
(if (<= x -1.35)
(+ (* y (* (/ y x) (+ 0.5 (* y -0.16666666666666666)))) (/ (- 1.0 y) x))
(if (<= x 8.5e+185)
(/ 1.0 x)
(/ (+ 1.0 (* y (+ -1.0 (/ (* 0.5 (+ y (* x y))) x)))) x))))
double code(double x, double y) {
double tmp;
if (x <= -1.35) {
tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x);
} else if (x <= 8.5e+185) {
tmp = 1.0 / x;
} else {
tmp = (1.0 + (y * (-1.0 + ((0.5 * (y + (x * y))) / x)))) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.35d0)) then
tmp = (y * ((y / x) * (0.5d0 + (y * (-0.16666666666666666d0))))) + ((1.0d0 - y) / x)
else if (x <= 8.5d+185) then
tmp = 1.0d0 / x
else
tmp = (1.0d0 + (y * ((-1.0d0) + ((0.5d0 * (y + (x * y))) / x)))) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.35) {
tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x);
} else if (x <= 8.5e+185) {
tmp = 1.0 / x;
} else {
tmp = (1.0 + (y * (-1.0 + ((0.5 * (y + (x * y))) / x)))) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.35: tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x) elif x <= 8.5e+185: tmp = 1.0 / x else: tmp = (1.0 + (y * (-1.0 + ((0.5 * (y + (x * y))) / x)))) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -1.35) tmp = Float64(Float64(y * Float64(Float64(y / x) * Float64(0.5 + Float64(y * -0.16666666666666666)))) + Float64(Float64(1.0 - y) / x)); elseif (x <= 8.5e+185) tmp = Float64(1.0 / x); else tmp = Float64(Float64(1.0 + Float64(y * Float64(-1.0 + Float64(Float64(0.5 * Float64(y + Float64(x * y))) / x)))) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.35) tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x); elseif (x <= 8.5e+185) tmp = 1.0 / x; else tmp = (1.0 + (y * (-1.0 + ((0.5 * (y + (x * y))) / x)))) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.35], N[(N[(y * N[(N[(y / x), $MachinePrecision] * N[(0.5 + N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.5e+185], N[(1.0 / x), $MachinePrecision], N[(N[(1.0 + N[(y * N[(-1.0 + N[(N[(0.5 * N[(y + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35:\\
\;\;\;\;y \cdot \left(\frac{y}{x} \cdot \left(0.5 + y \cdot -0.16666666666666666\right)\right) + \frac{1 - y}{x}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+185}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + y \cdot \left(-1 + \frac{0.5 \cdot \left(y + x \cdot y\right)}{x}\right)}{x}\\
\end{array}
\end{array}
if x < -1.3500000000000001Initial program 74.6%
*-commutative74.6%
exp-to-pow74.6%
Simplified74.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
Simplified99.6%
Taylor expanded in y around 0 75.1%
Simplified75.1%
if -1.3500000000000001 < x < 8.50000000000000013e185Initial program 82.1%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.8%
if 8.50000000000000013e185 < x Initial program 42.8%
exp-prod42.8%
Simplified42.8%
Taylor expanded in y around 0 39.4%
Taylor expanded in x around 0 49.2%
distribute-lft-out49.2%
Simplified49.2%
Final simplification79.3%
(FPCore (x y) :precision binary64 (if (<= x -0.85) (+ (* y (* (/ y x) (+ 0.5 (* y -0.16666666666666666)))) (/ (- 1.0 y) x)) (if (<= x 1e+186) (/ 1.0 x) (/ (/ (* x (- 1.0 y)) x) x))))
double code(double x, double y) {
double tmp;
if (x <= -0.85) {
tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x);
} else if (x <= 1e+186) {
tmp = 1.0 / x;
} else {
tmp = ((x * (1.0 - y)) / x) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.85d0)) then
tmp = (y * ((y / x) * (0.5d0 + (y * (-0.16666666666666666d0))))) + ((1.0d0 - y) / x)
else if (x <= 1d+186) then
tmp = 1.0d0 / x
else
tmp = ((x * (1.0d0 - y)) / x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.85) {
tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x);
} else if (x <= 1e+186) {
tmp = 1.0 / x;
} else {
tmp = ((x * (1.0 - y)) / x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.85: tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x) elif x <= 1e+186: tmp = 1.0 / x else: tmp = ((x * (1.0 - y)) / x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.85) tmp = Float64(Float64(y * Float64(Float64(y / x) * Float64(0.5 + Float64(y * -0.16666666666666666)))) + Float64(Float64(1.0 - y) / x)); elseif (x <= 1e+186) tmp = Float64(1.0 / x); else tmp = Float64(Float64(Float64(x * Float64(1.0 - y)) / x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.85) tmp = (y * ((y / x) * (0.5 + (y * -0.16666666666666666)))) + ((1.0 - y) / x); elseif (x <= 1e+186) tmp = 1.0 / x; else tmp = ((x * (1.0 - y)) / x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.85], N[(N[(y * N[(N[(y / x), $MachinePrecision] * N[(0.5 + N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+186], N[(1.0 / x), $MachinePrecision], N[(N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.85:\\
\;\;\;\;y \cdot \left(\frac{y}{x} \cdot \left(0.5 + y \cdot -0.16666666666666666\right)\right) + \frac{1 - y}{x}\\
\mathbf{elif}\;x \leq 10^{+186}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot \left(1 - y\right)}{x}}{x}\\
\end{array}
\end{array}
if x < -0.849999999999999978Initial program 74.6%
*-commutative74.6%
exp-to-pow74.6%
Simplified74.6%
Taylor expanded in x around inf 99.6%
mul-1-neg99.6%
Simplified99.6%
Taylor expanded in y around 0 75.1%
Simplified75.1%
if -0.849999999999999978 < x < 9.9999999999999998e185Initial program 82.1%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.8%
if 9.9999999999999998e185 < x Initial program 42.8%
*-commutative42.8%
exp-to-pow42.8%
Simplified42.8%
Taylor expanded in x around inf 78.9%
mul-1-neg78.9%
associate-/l*78.9%
mul-1-neg78.9%
distribute-rgt-out84.2%
metadata-eval84.2%
Simplified84.2%
Taylor expanded in x around 0 84.2%
associate-*r*84.2%
distribute-rgt-out84.2%
*-commutative84.2%
Simplified84.2%
Taylor expanded in y around 0 49.2%
mul-1-neg49.2%
*-commutative49.2%
distribute-lft-neg-in49.2%
distribute-rgt1-in49.2%
+-commutative49.2%
sub-neg49.2%
Simplified49.2%
Final simplification79.3%
(FPCore (x y) :precision binary64 (if (or (<= x -0.44) (not (<= x 1.95e+185))) (/ (/ (* x (- 1.0 y)) x) x) (/ 1.0 x)))
double code(double x, double y) {
double tmp;
if ((x <= -0.44) || !(x <= 1.95e+185)) {
tmp = ((x * (1.0 - y)) / x) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-0.44d0)) .or. (.not. (x <= 1.95d+185))) then
tmp = ((x * (1.0d0 - y)) / x) / x
else
tmp = 1.0d0 / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -0.44) || !(x <= 1.95e+185)) {
tmp = ((x * (1.0 - y)) / x) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -0.44) or not (x <= 1.95e+185): tmp = ((x * (1.0 - y)) / x) / x else: tmp = 1.0 / x return tmp
function code(x, y) tmp = 0.0 if ((x <= -0.44) || !(x <= 1.95e+185)) tmp = Float64(Float64(Float64(x * Float64(1.0 - y)) / x) / x); else tmp = Float64(1.0 / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -0.44) || ~((x <= 1.95e+185))) tmp = ((x * (1.0 - y)) / x) / x; else tmp = 1.0 / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -0.44], N[Not[LessEqual[x, 1.95e+185]], $MachinePrecision]], N[(N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.44 \lor \neg \left(x \leq 1.95 \cdot 10^{+185}\right):\\
\;\;\;\;\frac{\frac{x \cdot \left(1 - y\right)}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\end{array}
if x < -0.440000000000000002 or 1.9499999999999999e185 < x Initial program 63.1%
*-commutative63.1%
exp-to-pow63.1%
Simplified63.1%
Taylor expanded in x around inf 68.5%
mul-1-neg68.5%
associate-/l*68.5%
mul-1-neg68.5%
distribute-rgt-out70.4%
metadata-eval70.4%
Simplified70.4%
Taylor expanded in x around 0 70.4%
associate-*r*70.4%
distribute-rgt-out75.2%
*-commutative75.2%
Simplified75.2%
Taylor expanded in y around 0 61.8%
mul-1-neg61.8%
*-commutative61.8%
distribute-lft-neg-in61.8%
distribute-rgt1-in61.8%
+-commutative61.8%
sub-neg61.8%
Simplified61.8%
if -0.440000000000000002 < x < 1.9499999999999999e185Initial program 82.1%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.8%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (<= x -0.44) (/ (/ (- x (* x y)) x) x) (if (<= x 1.05e+185) (/ 1.0 x) (/ (/ (* x (- 1.0 y)) x) x))))
double code(double x, double y) {
double tmp;
if (x <= -0.44) {
tmp = ((x - (x * y)) / x) / x;
} else if (x <= 1.05e+185) {
tmp = 1.0 / x;
} else {
tmp = ((x * (1.0 - y)) / x) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.44d0)) then
tmp = ((x - (x * y)) / x) / x
else if (x <= 1.05d+185) then
tmp = 1.0d0 / x
else
tmp = ((x * (1.0d0 - y)) / x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.44) {
tmp = ((x - (x * y)) / x) / x;
} else if (x <= 1.05e+185) {
tmp = 1.0 / x;
} else {
tmp = ((x * (1.0 - y)) / x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.44: tmp = ((x - (x * y)) / x) / x elif x <= 1.05e+185: tmp = 1.0 / x else: tmp = ((x * (1.0 - y)) / x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.44) tmp = Float64(Float64(Float64(x - Float64(x * y)) / x) / x); elseif (x <= 1.05e+185) tmp = Float64(1.0 / x); else tmp = Float64(Float64(Float64(x * Float64(1.0 - y)) / x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.44) tmp = ((x - (x * y)) / x) / x; elseif (x <= 1.05e+185) tmp = 1.0 / x; else tmp = ((x * (1.0 - y)) / x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.44], N[(N[(N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.05e+185], N[(1.0 / x), $MachinePrecision], N[(N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.44:\\
\;\;\;\;\frac{\frac{x - x \cdot y}{x}}{x}\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{+185}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot \left(1 - y\right)}{x}}{x}\\
\end{array}
\end{array}
if x < -0.440000000000000002Initial program 74.6%
*-commutative74.6%
exp-to-pow74.6%
Simplified74.6%
Taylor expanded in x around inf 62.7%
mul-1-neg62.7%
associate-/l*62.7%
mul-1-neg62.7%
distribute-rgt-out62.7%
metadata-eval62.7%
Simplified62.7%
Taylor expanded in x around 0 62.6%
associate-*r*62.6%
distribute-rgt-out70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in y around 0 69.0%
mul-1-neg69.0%
sub-neg69.0%
Simplified69.0%
if -0.440000000000000002 < x < 1.05e185Initial program 82.1%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.8%
if 1.05e185 < x Initial program 42.8%
*-commutative42.8%
exp-to-pow42.8%
Simplified42.8%
Taylor expanded in x around inf 78.9%
mul-1-neg78.9%
associate-/l*78.9%
mul-1-neg78.9%
distribute-rgt-out84.2%
metadata-eval84.2%
Simplified84.2%
Taylor expanded in x around 0 84.2%
associate-*r*84.2%
distribute-rgt-out84.2%
*-commutative84.2%
Simplified84.2%
Taylor expanded in y around 0 49.2%
mul-1-neg49.2%
*-commutative49.2%
distribute-lft-neg-in49.2%
distribute-rgt1-in49.2%
+-commutative49.2%
sub-neg49.2%
Simplified49.2%
Final simplification77.7%
(FPCore (x y) :precision binary64 (if (<= x -0.7) (/ (+ 1.0 (* y (+ -1.0 (* y 0.5)))) x) (if (<= x 1.2e+185) (/ 1.0 x) (/ (/ (* x (- 1.0 y)) x) x))))
double code(double x, double y) {
double tmp;
if (x <= -0.7) {
tmp = (1.0 + (y * (-1.0 + (y * 0.5)))) / x;
} else if (x <= 1.2e+185) {
tmp = 1.0 / x;
} else {
tmp = ((x * (1.0 - y)) / x) / x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.7d0)) then
tmp = (1.0d0 + (y * ((-1.0d0) + (y * 0.5d0)))) / x
else if (x <= 1.2d+185) then
tmp = 1.0d0 / x
else
tmp = ((x * (1.0d0 - y)) / x) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.7) {
tmp = (1.0 + (y * (-1.0 + (y * 0.5)))) / x;
} else if (x <= 1.2e+185) {
tmp = 1.0 / x;
} else {
tmp = ((x * (1.0 - y)) / x) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.7: tmp = (1.0 + (y * (-1.0 + (y * 0.5)))) / x elif x <= 1.2e+185: tmp = 1.0 / x else: tmp = ((x * (1.0 - y)) / x) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.7) tmp = Float64(Float64(1.0 + Float64(y * Float64(-1.0 + Float64(y * 0.5)))) / x); elseif (x <= 1.2e+185) tmp = Float64(1.0 / x); else tmp = Float64(Float64(Float64(x * Float64(1.0 - y)) / x) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.7) tmp = (1.0 + (y * (-1.0 + (y * 0.5)))) / x; elseif (x <= 1.2e+185) tmp = 1.0 / x; else tmp = ((x * (1.0 - y)) / x) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.7], N[(N[(1.0 + N[(y * N[(-1.0 + N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.2e+185], N[(1.0 / x), $MachinePrecision], N[(N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.7:\\
\;\;\;\;\frac{1 + y \cdot \left(-1 + y \cdot 0.5\right)}{x}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+185}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot \left(1 - y\right)}{x}}{x}\\
\end{array}
\end{array}
if x < -0.69999999999999996Initial program 74.6%
exp-prod73.8%
Simplified73.8%
Taylor expanded in y around 0 74.9%
Taylor expanded in x around inf 74.9%
*-commutative74.9%
Simplified74.9%
if -0.69999999999999996 < x < 1.19999999999999995e185Initial program 82.1%
exp-prod98.7%
Simplified98.7%
Taylor expanded in x around 0 88.8%
if 1.19999999999999995e185 < x Initial program 42.8%
*-commutative42.8%
exp-to-pow42.8%
Simplified42.8%
Taylor expanded in x around inf 78.9%
mul-1-neg78.9%
associate-/l*78.9%
mul-1-neg78.9%
distribute-rgt-out84.2%
metadata-eval84.2%
Simplified84.2%
Taylor expanded in x around 0 84.2%
associate-*r*84.2%
distribute-rgt-out84.2%
*-commutative84.2%
Simplified84.2%
Taylor expanded in y around 0 49.2%
mul-1-neg49.2%
*-commutative49.2%
distribute-lft-neg-in49.2%
distribute-rgt1-in49.2%
+-commutative49.2%
sub-neg49.2%
Simplified49.2%
Final simplification79.3%
(FPCore (x y) :precision binary64 (/ 1.0 x))
double code(double x, double y) {
return 1.0 / x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / x
end function
public static double code(double x, double y) {
return 1.0 / x;
}
def code(x, y): return 1.0 / x
function code(x, y) return Float64(1.0 / x) end
function tmp = code(x, y) tmp = 1.0 / x; end
code[x_, y_] := N[(1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x}
\end{array}
Initial program 74.3%
exp-prod83.9%
Simplified83.9%
Taylor expanded in x around 0 71.3%
Final simplification71.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (exp (/ -1.0 y)) x)) (t_1 (/ (pow (/ x (+ y x)) x) x)))
(if (< y -3.7311844206647956e+94)
t_0
(if (< y 2.817959242728288e+37)
t_1
(if (< y 2.347387415166998e+178) (log (exp t_1)) t_0)))))
double code(double x, double y) {
double t_0 = exp((-1.0 / y)) / x;
double t_1 = pow((x / (y + x)), x) / x;
double tmp;
if (y < -3.7311844206647956e+94) {
tmp = t_0;
} else if (y < 2.817959242728288e+37) {
tmp = t_1;
} else if (y < 2.347387415166998e+178) {
tmp = log(exp(t_1));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(((-1.0d0) / y)) / x
t_1 = ((x / (y + x)) ** x) / x
if (y < (-3.7311844206647956d+94)) then
tmp = t_0
else if (y < 2.817959242728288d+37) then
tmp = t_1
else if (y < 2.347387415166998d+178) then
tmp = log(exp(t_1))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.exp((-1.0 / y)) / x;
double t_1 = Math.pow((x / (y + x)), x) / x;
double tmp;
if (y < -3.7311844206647956e+94) {
tmp = t_0;
} else if (y < 2.817959242728288e+37) {
tmp = t_1;
} else if (y < 2.347387415166998e+178) {
tmp = Math.log(Math.exp(t_1));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = math.exp((-1.0 / y)) / x t_1 = math.pow((x / (y + x)), x) / x tmp = 0 if y < -3.7311844206647956e+94: tmp = t_0 elif y < 2.817959242728288e+37: tmp = t_1 elif y < 2.347387415166998e+178: tmp = math.log(math.exp(t_1)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(exp(Float64(-1.0 / y)) / x) t_1 = Float64((Float64(x / Float64(y + x)) ^ x) / x) tmp = 0.0 if (y < -3.7311844206647956e+94) tmp = t_0; elseif (y < 2.817959242728288e+37) tmp = t_1; elseif (y < 2.347387415166998e+178) tmp = log(exp(t_1)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = exp((-1.0 / y)) / x; t_1 = ((x / (y + x)) ^ x) / x; tmp = 0.0; if (y < -3.7311844206647956e+94) tmp = t_0; elseif (y < 2.817959242728288e+37) tmp = t_1; elseif (y < 2.347387415166998e+178) tmp = log(exp(t_1)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Exp[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision], x], $MachinePrecision] / x), $MachinePrecision]}, If[Less[y, -3.7311844206647956e+94], t$95$0, If[Less[y, 2.817959242728288e+37], t$95$1, If[Less[y, 2.347387415166998e+178], N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e^{\frac{-1}{y}}}{x}\\
t_1 := \frac{{\left(\frac{x}{y + x}\right)}^{x}}{x}\\
\mathbf{if}\;y < -3.7311844206647956 \cdot 10^{+94}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 2.817959242728288 \cdot 10^{+37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y < 2.347387415166998 \cdot 10^{+178}:\\
\;\;\;\;\log \left(e^{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024115
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"
:precision binary64
:alt
(if (< y -3.7311844206647956e+94) (/ (exp (/ -1.0 y)) x) (if (< y 2.817959242728288e+37) (/ (pow (/ x (+ y x)) x) x) (if (< y 2.347387415166998e+178) (log (exp (/ (pow (/ x (+ y x)) x) x))) (/ (exp (/ -1.0 y)) x))))
(/ (exp (* x (log (/ x (+ x y))))) x))