
(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 12 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 (<= x -5e+60)
(/ (exp (- y)) x)
(if (<= x 7.6e-12)
(/ (pow (exp x) (log (/ x (+ x y)))) x)
(/ 1.0 (/ (exp y) (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if (x <= -5e+60) {
tmp = exp(-y) / x;
} else if (x <= 7.6e-12) {
tmp = pow(exp(x), log((x / (x + y)))) / x;
} else {
tmp = 1.0 / (exp(y) / (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 <= (-5d+60)) then
tmp = exp(-y) / x
else if (x <= 7.6d-12) then
tmp = (exp(x) ** log((x / (x + y)))) / x
else
tmp = 1.0d0 / (exp(y) / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5e+60) {
tmp = Math.exp(-y) / x;
} else if (x <= 7.6e-12) {
tmp = Math.pow(Math.exp(x), Math.log((x / (x + y)))) / x;
} else {
tmp = 1.0 / (Math.exp(y) / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5e+60: tmp = math.exp(-y) / x elif x <= 7.6e-12: tmp = math.pow(math.exp(x), math.log((x / (x + y)))) / x else: tmp = 1.0 / (math.exp(y) / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -5e+60) tmp = Float64(exp(Float64(-y)) / x); elseif (x <= 7.6e-12) tmp = Float64((exp(x) ^ log(Float64(x / Float64(x + y)))) / x); else tmp = Float64(1.0 / Float64(exp(y) / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5e+60) tmp = exp(-y) / x; elseif (x <= 7.6e-12) tmp = (exp(x) ^ log((x / (x + y)))) / x; else tmp = 1.0 / (exp(y) / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5e+60], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(N[Power[N[Exp[x], $MachinePrecision], N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(N[Exp[y], $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+60}:\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{{\left(e^{x}\right)}^{\log \left(\frac{x}{x + y}\right)}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{e^{y}}{\frac{1}{x}}}\\
\end{array}
\end{array}
if x < -4.99999999999999975e60Initial program 58.4%
*-commutative58.4%
exp-to-pow58.4%
Simplified58.4%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -4.99999999999999975e60 < x < 7.59999999999999993e-12Initial program 86.1%
exp-prod99.9%
Simplified99.9%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
/-rgt-identity100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= x -940000.0) (/ (exp (- y)) x) (if (<= x 7.6e-12) (/ 1.0 x) (/ 1.0 (/ (exp y) (/ 1.0 x))))))
double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = exp(-y) / x;
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (exp(y) / (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 <= (-940000.0d0)) then
tmp = exp(-y) / x
else if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (exp(y) / (1.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = Math.exp(-y) / x;
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (Math.exp(y) / (1.0 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -940000.0: tmp = math.exp(-y) / x elif x <= 7.6e-12: tmp = 1.0 / x else: tmp = 1.0 / (math.exp(y) / (1.0 / x)) return tmp
function code(x, y) tmp = 0.0 if (x <= -940000.0) tmp = Float64(exp(Float64(-y)) / x); elseif (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(exp(y) / Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -940000.0) tmp = exp(-y) / x; elseif (x <= 7.6e-12) tmp = 1.0 / x; else tmp = 1.0 / (exp(y) / (1.0 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -940000.0], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], N[(1.0 / N[(N[Exp[y], $MachinePrecision] / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -940000:\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{e^{y}}{\frac{1}{x}}}\\
\end{array}
\end{array}
if x < -9.4e5Initial program 67.5%
*-commutative67.5%
exp-to-pow67.5%
Simplified67.5%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -9.4e5 < x < 7.59999999999999993e-12Initial program 84.6%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 99.6%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
/-rgt-identity100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= x -940000.0) (/ (exp (- y)) x) (if (<= x 7.6e-12) (/ 1.0 x) (/ 1.0 (* x (exp y))))))
double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = exp(-y) / x;
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x * exp(y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-940000.0d0)) then
tmp = exp(-y) / x
else if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x * exp(y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = Math.exp(-y) / x;
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x * Math.exp(y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -940000.0: tmp = math.exp(-y) / x elif x <= 7.6e-12: tmp = 1.0 / x else: tmp = 1.0 / (x * math.exp(y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -940000.0) tmp = Float64(exp(Float64(-y)) / x); elseif (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x * exp(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -940000.0) tmp = exp(-y) / x; elseif (x <= 7.6e-12) tmp = 1.0 / x; else tmp = 1.0 / (x * exp(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -940000.0], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], N[(1.0 / N[(x * N[Exp[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -940000:\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot e^{y}}\\
\end{array}
\end{array}
if x < -9.4e5Initial program 67.5%
*-commutative67.5%
exp-to-pow67.5%
Simplified67.5%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -9.4e5 < x < 7.59999999999999993e-12Initial program 84.6%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 99.6%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= x -940000.0) (not (<= x 7.6e-12))) (/ (exp (- y)) x) (/ 1.0 x)))
double code(double x, double y) {
double tmp;
if ((x <= -940000.0) || !(x <= 7.6e-12)) {
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 <= (-940000.0d0)) .or. (.not. (x <= 7.6d-12))) 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 <= -940000.0) || !(x <= 7.6e-12)) {
tmp = Math.exp(-y) / x;
} else {
tmp = 1.0 / x;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -940000.0) or not (x <= 7.6e-12): tmp = math.exp(-y) / x else: tmp = 1.0 / x return tmp
function code(x, y) tmp = 0.0 if ((x <= -940000.0) || !(x <= 7.6e-12)) 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 <= -940000.0) || ~((x <= 7.6e-12))) tmp = exp(-y) / x; else tmp = 1.0 / x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -940000.0], N[Not[LessEqual[x, 7.6e-12]], $MachinePrecision]], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -940000 \lor \neg \left(x \leq 7.6 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\end{array}
if x < -9.4e5 or 7.59999999999999993e-12 < x Initial program 69.3%
*-commutative69.3%
exp-to-pow69.3%
Simplified69.3%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -9.4e5 < x < 7.59999999999999993e-12Initial program 84.6%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 99.6%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= x -940000.0)
(+ (/ (- 1.0 y) x) (/ (* y y) x))
(if (<= x 7.6e-12)
(/ 1.0 x)
(/ 1.0 (+ x (* x (+ y (* (* y y) (+ 0.5 (* y 0.16666666666666666))))))))))
double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = ((1.0 - y) / x) + ((y * y) / x);
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * (y + ((y * y) * (0.5 + (y * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-940000.0d0)) then
tmp = ((1.0d0 - y) / x) + ((y * y) / x)
else if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * (y + ((y * y) * (0.5d0 + (y * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = ((1.0 - y) / x) + ((y * y) / x);
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * (y + ((y * y) * (0.5 + (y * 0.16666666666666666))))));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -940000.0: tmp = ((1.0 - y) / x) + ((y * y) / x) elif x <= 7.6e-12: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * (y + ((y * y) * (0.5 + (y * 0.16666666666666666)))))) return tmp
function code(x, y) tmp = 0.0 if (x <= -940000.0) tmp = Float64(Float64(Float64(1.0 - y) / x) + Float64(Float64(y * y) / x)); elseif (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * Float64(y + Float64(Float64(y * y) * Float64(0.5 + Float64(y * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -940000.0) tmp = ((1.0 - y) / x) + ((y * y) / x); elseif (x <= 7.6e-12) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * (y + ((y * y) * (0.5 + (y * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -940000.0], N[(N[(N[(1.0 - y), $MachinePrecision] / x), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], N[(1.0 / N[(x + N[(x * N[(y + N[(N[(y * y), $MachinePrecision] * N[(0.5 + N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -940000:\\
\;\;\;\;\frac{1 - y}{x} + \frac{y \cdot y}{x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot \left(y + \left(y \cdot y\right) \cdot \left(0.5 + y \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if x < -9.4e5Initial program 67.5%
*-commutative67.5%
exp-to-pow67.5%
Simplified67.5%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in y around 0 49.1%
Taylor expanded in y around 0 70.9%
+-commutative70.9%
mul-1-neg70.9%
sub-neg70.9%
div-sub70.9%
unpow270.9%
Simplified70.9%
if -9.4e5 < x < 7.59999999999999993e-12Initial program 84.6%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 99.6%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
/-rgt-identity100.0%
*-commutative100.0%
associate-/l*100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 81.9%
associate-+r+81.9%
associate-+r+81.9%
*-commutative81.9%
unpow281.9%
associate-*r*81.9%
associate-*r*81.9%
distribute-rgt-out82.0%
distribute-lft-out82.0%
cube-mult82.0%
associate-*r*82.0%
distribute-rgt-out82.1%
Simplified82.1%
Final simplification87.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ 1.0 (+ x (* x y)))))
(if (<= x -2.4e+129)
t_0
(if (<= x -5.8e+28)
(/ (- x (* x y)) (* x x))
(if (<= x 7.6e-12) (/ 1.0 x) t_0)))))
double code(double x, double y) {
double t_0 = 1.0 / (x + (x * y));
double tmp;
if (x <= -2.4e+129) {
tmp = t_0;
} else if (x <= -5.8e+28) {
tmp = (x - (x * y)) / (x * x);
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} 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) :: tmp
t_0 = 1.0d0 / (x + (x * y))
if (x <= (-2.4d+129)) then
tmp = t_0
else if (x <= (-5.8d+28)) then
tmp = (x - (x * y)) / (x * x)
else if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 / (x + (x * y));
double tmp;
if (x <= -2.4e+129) {
tmp = t_0;
} else if (x <= -5.8e+28) {
tmp = (x - (x * y)) / (x * x);
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 / (x + (x * y)) tmp = 0 if x <= -2.4e+129: tmp = t_0 elif x <= -5.8e+28: tmp = (x - (x * y)) / (x * x) elif x <= 7.6e-12: tmp = 1.0 / x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 / Float64(x + Float64(x * y))) tmp = 0.0 if (x <= -2.4e+129) tmp = t_0; elseif (x <= -5.8e+28) tmp = Float64(Float64(x - Float64(x * y)) / Float64(x * x)); elseif (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 / (x + (x * y)); tmp = 0.0; if (x <= -2.4e+129) tmp = t_0; elseif (x <= -5.8e+28) tmp = (x - (x * y)) / (x * x); elseif (x <= 7.6e-12) tmp = 1.0 / x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e+129], t$95$0, If[LessEqual[x, -5.8e+28], N[(N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{x + x \cdot y}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{+129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -5.8 \cdot 10^{+28}:\\
\;\;\;\;\frac{x - x \cdot y}{x \cdot x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.3999999999999999e129 or 7.59999999999999993e-12 < x Initial program 65.4%
*-commutative65.4%
exp-to-pow65.4%
Simplified65.4%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in y around 0 64.0%
if -2.3999999999999999e129 < x < -5.8000000000000002e28Initial program 77.8%
exp-prod77.8%
Simplified77.8%
Taylor expanded in x around inf 44.7%
mul-1-neg44.7%
unsub-neg44.7%
Simplified44.7%
frac-sub59.2%
*-un-lft-identity59.2%
*-commutative59.2%
Applied egg-rr59.2%
if -5.8000000000000002e28 < x < 7.59999999999999993e-12Initial program 85.4%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 98.8%
Final simplification80.5%
(FPCore (x y) :precision binary64 (if (<= x -940000.0) (+ (/ (- 1.0 y) x) (/ (* y y) x)) (if (<= x 7.6e-12) (/ 1.0 x) (/ 1.0 (+ x (* x y))))))
double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = ((1.0 - y) / x) + ((y * y) / x);
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-940000.0d0)) then
tmp = ((1.0d0 - y) / x) + ((y * y) / x)
else if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = ((1.0 - y) / x) + ((y * y) / x);
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -940000.0: tmp = ((1.0 - y) / x) + ((y * y) / x) elif x <= 7.6e-12: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -940000.0) tmp = Float64(Float64(Float64(1.0 - y) / x) + Float64(Float64(y * y) / x)); elseif (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -940000.0) tmp = ((1.0 - y) / x) + ((y * y) / x); elseif (x <= 7.6e-12) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -940000.0], N[(N[(N[(1.0 - y), $MachinePrecision] / x), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], N[(1.0 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -940000:\\
\;\;\;\;\frac{1 - y}{x} + \frac{y \cdot y}{x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot y}\\
\end{array}
\end{array}
if x < -9.4e5Initial program 67.5%
*-commutative67.5%
exp-to-pow67.5%
Simplified67.5%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
clear-num100.0%
inv-pow100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in y around 0 49.1%
Taylor expanded in y around 0 70.9%
+-commutative70.9%
mul-1-neg70.9%
sub-neg70.9%
div-sub70.9%
unpow270.9%
Simplified70.9%
if -9.4e5 < x < 7.59999999999999993e-12Initial program 84.6%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 99.6%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in y around 0 70.0%
Final simplification84.0%
(FPCore (x y) :precision binary64 (if (<= x -940000.0) (/ (/ (- x (* x y)) x) x) (if (<= x 7.6e-12) (/ 1.0 x) (/ 1.0 (+ x (* x y))))))
double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = ((x - (x * y)) / x) / x;
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-940000.0d0)) then
tmp = ((x - (x * y)) / x) / x
else if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -940000.0) {
tmp = ((x - (x * y)) / x) / x;
} else if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -940000.0: tmp = ((x - (x * y)) / x) / x elif x <= 7.6e-12: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -940000.0) tmp = Float64(Float64(Float64(x - Float64(x * y)) / x) / x); elseif (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -940000.0) tmp = ((x - (x * y)) / x) / x; elseif (x <= 7.6e-12) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -940000.0], N[(N[(N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], N[(1.0 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -940000:\\
\;\;\;\;\frac{\frac{x - x \cdot y}{x}}{x}\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot y}\\
\end{array}
\end{array}
if x < -9.4e5Initial program 67.5%
exp-prod67.5%
Simplified67.5%
Taylor expanded in x around inf 44.9%
mul-1-neg44.9%
unsub-neg44.9%
Simplified44.9%
frac-sub40.6%
associate-/r*67.7%
*-un-lft-identity67.7%
*-commutative67.7%
Applied egg-rr67.7%
if -9.4e5 < x < 7.59999999999999993e-12Initial program 84.6%
exp-prod99.9%
Simplified99.9%
Taylor expanded in x around 0 99.6%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in y around 0 70.0%
Final simplification83.2%
(FPCore (x y) :precision binary64 (if (<= x 7.6e-12) (/ 1.0 x) (/ 1.0 (+ x (* x y)))))
double code(double x, double y) {
double tmp;
if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 7.6d-12) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 7.6e-12) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 7.6e-12: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= 7.6e-12) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 7.6e-12) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 7.6e-12], N[(1.0 / x), $MachinePrecision], N[(1.0 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.6 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot y}\\
\end{array}
\end{array}
if x < 7.59999999999999993e-12Initial program 79.0%
exp-prod89.2%
Simplified89.2%
Taylor expanded in x around 0 81.3%
if 7.59999999999999993e-12 < x Initial program 70.6%
*-commutative70.6%
exp-to-pow70.6%
Simplified70.6%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
Simplified99.9%
clear-num100.0%
inv-pow100.0%
exp-neg99.9%
associate-/r/100.0%
/-rgt-identity100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
Taylor expanded in y around 0 70.0%
Final simplification77.9%
(FPCore (x y) :precision binary64 (if (<= y -2.65e+157) (* y (- -1.0 y)) (/ 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -2.65e+157) {
tmp = y * (-1.0 - y);
} 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 (y <= (-2.65d+157)) then
tmp = y * ((-1.0d0) - y)
else
tmp = 1.0d0 / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.65e+157) {
tmp = y * (-1.0 - y);
} else {
tmp = 1.0 / x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.65e+157: tmp = y * (-1.0 - y) else: tmp = 1.0 / x return tmp
function code(x, y) tmp = 0.0 if (y <= -2.65e+157) tmp = Float64(y * Float64(-1.0 - y)); else tmp = Float64(1.0 / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.65e+157) tmp = y * (-1.0 - y); else tmp = 1.0 / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.65e+157], N[(y * N[(-1.0 - y), $MachinePrecision]), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{+157}:\\
\;\;\;\;y \cdot \left(-1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\end{array}
if y < -2.6499999999999999e157Initial program 59.4%
exp-prod80.7%
Simplified80.7%
Taylor expanded in x around inf 4.4%
mul-1-neg4.4%
unsub-neg4.4%
Simplified4.4%
clear-num4.4%
frac-sub4.2%
*-un-lft-identity4.2%
*-commutative4.2%
*-un-lft-identity4.2%
Applied egg-rr4.2%
associate-*r/3.7%
Applied egg-rr3.7%
Applied egg-rr63.0%
fma-def63.0%
+-commutative63.0%
distribute-lft-in63.0%
neg-mul-163.0%
distribute-lft-neg-in63.0%
distribute-rgt-out63.0%
sub-neg63.0%
Simplified63.0%
if -2.6499999999999999e157 < y Initial program 78.4%
exp-prod83.6%
Simplified83.6%
Taylor expanded in x around 0 78.8%
Final simplification77.2%
(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 76.4%
exp-prod83.3%
Simplified83.3%
Taylor expanded in x around 0 73.5%
Final simplification73.5%
(FPCore (x y) :precision binary64 y)
double code(double x, double y) {
return y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y
end function
public static double code(double x, double y) {
return y;
}
def code(x, y): return y
function code(x, y) return y end
function tmp = code(x, y) tmp = y; end
code[x_, y_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 76.4%
exp-prod83.3%
Simplified83.3%
Taylor expanded in x around inf 56.9%
mul-1-neg56.9%
unsub-neg56.9%
Simplified56.9%
frac-sub38.7%
*-un-lft-identity38.7%
*-commutative38.7%
Applied egg-rr38.7%
Taylor expanded in y around inf 6.4%
mul-1-neg6.4%
distribute-rgt-neg-in6.4%
Simplified6.4%
Applied egg-rr4.1%
+-rgt-identity4.1%
Simplified4.1%
Final simplification4.1%
(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 2023238
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"
:precision binary64
:herbie-target
(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))