
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 99.6%
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp b) 1.0)))
double code(double a, double b) {
return exp(a) / (exp(b) + 1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(b) + 1.0d0)
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(b) + 1.0);
}
def code(a, b): return math.exp(a) / (math.exp(b) + 1.0)
function code(a, b) return Float64(exp(a) / Float64(exp(b) + 1.0)) end
function tmp = code(a, b) tmp = exp(a) / (exp(b) + 1.0); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{b} + 1}
\end{array}
Initial program 99.6%
Taylor expanded in a around 0
Simplified98.6%
Final simplification98.6%
(FPCore (a b) :precision binary64 (if (<= a -165000000.0) (/ (exp a) 2.0) (/ 1.0 (+ (exp b) 1.0))))
double code(double a, double b) {
double tmp;
if (a <= -165000000.0) {
tmp = exp(a) / 2.0;
} else {
tmp = 1.0 / (exp(b) + 1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-165000000.0d0)) then
tmp = exp(a) / 2.0d0
else
tmp = 1.0d0 / (exp(b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -165000000.0) {
tmp = Math.exp(a) / 2.0;
} else {
tmp = 1.0 / (Math.exp(b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -165000000.0: tmp = math.exp(a) / 2.0 else: tmp = 1.0 / (math.exp(b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -165000000.0) tmp = Float64(exp(a) / 2.0); else tmp = Float64(1.0 / Float64(exp(b) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -165000000.0) tmp = exp(a) / 2.0; else tmp = 1.0 / (exp(b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -165000000.0], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], N[(1.0 / N[(N[Exp[b], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -165000000:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{b} + 1}\\
\end{array}
\end{array}
if a < -1.65e8Initial program 100.0%
Taylor expanded in a around 0
Simplified100.0%
Taylor expanded in b around 0
Simplified100.0%
if -1.65e8 < a Initial program 99.4%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6498.4%
Simplified98.4%
Final simplification98.9%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* b (+ 0.5 (* b 0.16666666666666666)))) (t_1 (* b (- -1.0 t_0))))
(if (<= b 4.4e+51)
(/ (exp a) 2.0)
(if (<= b 5e+102)
(/ (+ 2.0 t_1) (+ 4.0 (* (* b (+ 1.0 t_0)) t_1)))
(/ 6.0 (* b (* b b)))))))
double code(double a, double b) {
double t_0 = b * (0.5 + (b * 0.16666666666666666));
double t_1 = b * (-1.0 - t_0);
double tmp;
if (b <= 4.4e+51) {
tmp = exp(a) / 2.0;
} else if (b <= 5e+102) {
tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = b * (0.5d0 + (b * 0.16666666666666666d0))
t_1 = b * ((-1.0d0) - t_0)
if (b <= 4.4d+51) then
tmp = exp(a) / 2.0d0
else if (b <= 5d+102) then
tmp = (2.0d0 + t_1) / (4.0d0 + ((b * (1.0d0 + t_0)) * t_1))
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = b * (0.5 + (b * 0.16666666666666666));
double t_1 = b * (-1.0 - t_0);
double tmp;
if (b <= 4.4e+51) {
tmp = Math.exp(a) / 2.0;
} else if (b <= 5e+102) {
tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): t_0 = b * (0.5 + (b * 0.16666666666666666)) t_1 = b * (-1.0 - t_0) tmp = 0 if b <= 4.4e+51: tmp = math.exp(a) / 2.0 elif b <= 5e+102: tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1)) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) t_0 = Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))) t_1 = Float64(b * Float64(-1.0 - t_0)) tmp = 0.0 if (b <= 4.4e+51) tmp = Float64(exp(a) / 2.0); elseif (b <= 5e+102) tmp = Float64(Float64(2.0 + t_1) / Float64(4.0 + Float64(Float64(b * Float64(1.0 + t_0)) * t_1))); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) t_0 = b * (0.5 + (b * 0.16666666666666666)); t_1 = b * (-1.0 - t_0); tmp = 0.0; if (b <= 4.4e+51) tmp = exp(a) / 2.0; elseif (b <= 5e+102) tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1)); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 4.4e+51], N[(N[Exp[a], $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[b, 5e+102], N[(N[(2.0 + t$95$1), $MachinePrecision] / N[(4.0 + N[(N[(b * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\\
t_1 := b \cdot \left(-1 - t\_0\right)\\
\mathbf{if}\;b \leq 4.4 \cdot 10^{+51}:\\
\;\;\;\;\frac{e^{a}}{2}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\frac{2 + t\_1}{4 + \left(b \cdot \left(1 + t\_0\right)\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 4.39999999999999984e51Initial program 99.5%
Taylor expanded in a around 0
Simplified98.2%
Taylor expanded in b around 0
Simplified76.9%
if 4.39999999999999984e51 < b < 5e102Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f647.2%
Simplified7.2%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
Applied egg-rr100.0%
if 5e102 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64100.0%
Simplified100.0%
Final simplification82.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* b (+ 0.5 (* b 0.16666666666666666)))) (t_1 (* b (- -1.0 t_0))))
(if (<= b -3.7e-216)
(+ 0.5 (* a (+ 0.25 (* -0.020833333333333332 (* a a)))))
(if (<= b 5e+102)
(/ (+ 2.0 t_1) (+ 4.0 (* (* b (+ 1.0 t_0)) t_1)))
(/ 6.0 (* b (* b b)))))))
double code(double a, double b) {
double t_0 = b * (0.5 + (b * 0.16666666666666666));
double t_1 = b * (-1.0 - t_0);
double tmp;
if (b <= -3.7e-216) {
tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a))));
} else if (b <= 5e+102) {
tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = b * (0.5d0 + (b * 0.16666666666666666d0))
t_1 = b * ((-1.0d0) - t_0)
if (b <= (-3.7d-216)) then
tmp = 0.5d0 + (a * (0.25d0 + ((-0.020833333333333332d0) * (a * a))))
else if (b <= 5d+102) then
tmp = (2.0d0 + t_1) / (4.0d0 + ((b * (1.0d0 + t_0)) * t_1))
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = b * (0.5 + (b * 0.16666666666666666));
double t_1 = b * (-1.0 - t_0);
double tmp;
if (b <= -3.7e-216) {
tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a))));
} else if (b <= 5e+102) {
tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): t_0 = b * (0.5 + (b * 0.16666666666666666)) t_1 = b * (-1.0 - t_0) tmp = 0 if b <= -3.7e-216: tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a)))) elif b <= 5e+102: tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1)) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) t_0 = Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))) t_1 = Float64(b * Float64(-1.0 - t_0)) tmp = 0.0 if (b <= -3.7e-216) tmp = Float64(0.5 + Float64(a * Float64(0.25 + Float64(-0.020833333333333332 * Float64(a * a))))); elseif (b <= 5e+102) tmp = Float64(Float64(2.0 + t_1) / Float64(4.0 + Float64(Float64(b * Float64(1.0 + t_0)) * t_1))); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) t_0 = b * (0.5 + (b * 0.16666666666666666)); t_1 = b * (-1.0 - t_0); tmp = 0.0; if (b <= -3.7e-216) tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a)))); elseif (b <= 5e+102) tmp = (2.0 + t_1) / (4.0 + ((b * (1.0 + t_0)) * t_1)); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.7e-216], N[(0.5 + N[(a * N[(0.25 + N[(-0.020833333333333332 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e+102], N[(N[(2.0 + t$95$1), $MachinePrecision] / N[(4.0 + N[(N[(b * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\\
t_1 := b \cdot \left(-1 - t\_0\right)\\
\mathbf{if}\;b \leq -3.7 \cdot 10^{-216}:\\
\;\;\;\;0.5 + a \cdot \left(0.25 + -0.020833333333333332 \cdot \left(a \cdot a\right)\right)\\
\mathbf{elif}\;b \leq 5 \cdot 10^{+102}:\\
\;\;\;\;\frac{2 + t\_1}{4 + \left(b \cdot \left(1 + t\_0\right)\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < -3.69999999999999996e-216Initial program 98.9%
Taylor expanded in b around 0
Simplified62.4%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6445.1%
Simplified45.1%
if -3.69999999999999996e-216 < b < 5e102Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6475.2%
Simplified75.2%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6450.8%
Simplified50.8%
flip-+N/A
clear-numN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
Applied egg-rr65.3%
if 5e102 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64100.0%
Simplified100.0%
Final simplification63.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* b (+ 0.5 (* b 0.16666666666666666)))))
(if (<= b -3.1e-216)
(+ 0.5 (* a (+ 0.25 (* -0.020833333333333332 (* a a)))))
(if (<= b 2e+154)
(/ 1.0 (+ 2.0 (/ (* b (- 1.0 (* t_0 t_0))) (- 1.0 t_0))))
(/ 2.0 (* b b))))))
double code(double a, double b) {
double t_0 = b * (0.5 + (b * 0.16666666666666666));
double tmp;
if (b <= -3.1e-216) {
tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a))));
} else if (b <= 2e+154) {
tmp = 1.0 / (2.0 + ((b * (1.0 - (t_0 * t_0))) / (1.0 - t_0)));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
real(8) :: tmp
t_0 = b * (0.5d0 + (b * 0.16666666666666666d0))
if (b <= (-3.1d-216)) then
tmp = 0.5d0 + (a * (0.25d0 + ((-0.020833333333333332d0) * (a * a))))
else if (b <= 2d+154) then
tmp = 1.0d0 / (2.0d0 + ((b * (1.0d0 - (t_0 * t_0))) / (1.0d0 - t_0)))
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = b * (0.5 + (b * 0.16666666666666666));
double tmp;
if (b <= -3.1e-216) {
tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a))));
} else if (b <= 2e+154) {
tmp = 1.0 / (2.0 + ((b * (1.0 - (t_0 * t_0))) / (1.0 - t_0)));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): t_0 = b * (0.5 + (b * 0.16666666666666666)) tmp = 0 if b <= -3.1e-216: tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a)))) elif b <= 2e+154: tmp = 1.0 / (2.0 + ((b * (1.0 - (t_0 * t_0))) / (1.0 - t_0))) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) t_0 = Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))) tmp = 0.0 if (b <= -3.1e-216) tmp = Float64(0.5 + Float64(a * Float64(0.25 + Float64(-0.020833333333333332 * Float64(a * a))))); elseif (b <= 2e+154) tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(b * Float64(1.0 - Float64(t_0 * t_0))) / Float64(1.0 - t_0)))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) t_0 = b * (0.5 + (b * 0.16666666666666666)); tmp = 0.0; if (b <= -3.1e-216) tmp = 0.5 + (a * (0.25 + (-0.020833333333333332 * (a * a)))); elseif (b <= 2e+154) tmp = 1.0 / (2.0 + ((b * (1.0 - (t_0 * t_0))) / (1.0 - t_0))); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.1e-216], N[(0.5 + N[(a * N[(0.25 + N[(-0.020833333333333332 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e+154], N[(1.0 / N[(2.0 + N[(N[(b * N[(1.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\\
\mathbf{if}\;b \leq -3.1 \cdot 10^{-216}:\\
\;\;\;\;0.5 + a \cdot \left(0.25 + -0.020833333333333332 \cdot \left(a \cdot a\right)\right)\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{2 + \frac{b \cdot \left(1 - t\_0 \cdot t\_0\right)}{1 - t\_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < -3.1000000000000002e-216Initial program 98.9%
Taylor expanded in b around 0
Simplified62.4%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6445.1%
Simplified45.1%
if -3.1000000000000002e-216 < b < 2.00000000000000007e154Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6476.7%
Simplified76.7%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6453.8%
Simplified53.8%
*-commutativeN/A
flip-+N/A
associate-*l/N/A
/-lowering-/.f64N/A
Applied egg-rr65.3%
if 2.00000000000000007e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0%
Simplified100.0%
Final simplification61.9%
(FPCore (a b)
:precision binary64
(if (<= b 310.0)
(+ 0.5 (* a 0.25))
(if (<= b 1.15e+77)
(* -0.020833333333333332 (* a (* a a)))
(if (<= b 1.35e+154)
(/
1.0
(+
2.0
(/ (- (* 0.25 (* (* b b) (* b b))) (* b b)) (- (* 0.5 (* b b)) b))))
(/ 2.0 (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= 310.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.15e+77) {
tmp = -0.020833333333333332 * (a * (a * a));
} else if (b <= 1.35e+154) {
tmp = 1.0 / (2.0 + (((0.25 * ((b * b) * (b * b))) - (b * b)) / ((0.5 * (b * b)) - b)));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 310.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 1.15d+77) then
tmp = (-0.020833333333333332d0) * (a * (a * a))
else if (b <= 1.35d+154) then
tmp = 1.0d0 / (2.0d0 + (((0.25d0 * ((b * b) * (b * b))) - (b * b)) / ((0.5d0 * (b * b)) - b)))
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 310.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.15e+77) {
tmp = -0.020833333333333332 * (a * (a * a));
} else if (b <= 1.35e+154) {
tmp = 1.0 / (2.0 + (((0.25 * ((b * b) * (b * b))) - (b * b)) / ((0.5 * (b * b)) - b)));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 310.0: tmp = 0.5 + (a * 0.25) elif b <= 1.15e+77: tmp = -0.020833333333333332 * (a * (a * a)) elif b <= 1.35e+154: tmp = 1.0 / (2.0 + (((0.25 * ((b * b) * (b * b))) - (b * b)) / ((0.5 * (b * b)) - b))) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 310.0) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 1.15e+77) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); elseif (b <= 1.35e+154) tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(0.25 * Float64(Float64(b * b) * Float64(b * b))) - Float64(b * b)) / Float64(Float64(0.5 * Float64(b * b)) - b)))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 310.0) tmp = 0.5 + (a * 0.25); elseif (b <= 1.15e+77) tmp = -0.020833333333333332 * (a * (a * a)); elseif (b <= 1.35e+154) tmp = 1.0 / (2.0 + (((0.25 * ((b * b) * (b * b))) - (b * b)) / ((0.5 * (b * b)) - b))); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 310.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e+77], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(1.0 / N[(2.0 + N[(N[(N[(0.25 * N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(0.5 * N[(b * b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 310:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{2 + \frac{0.25 \cdot \left(\left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) - b \cdot b}{0.5 \cdot \left(b \cdot b\right) - b}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 310Initial program 99.4%
Taylor expanded in b around 0
Simplified80.1%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6454.8%
Simplified54.8%
if 310 < b < 1.14999999999999997e77Initial program 100.0%
Taylor expanded in b around 0
Simplified44.6%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f642.5%
Simplified2.5%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6438.1%
Simplified38.1%
if 1.14999999999999997e77 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f645.9%
Simplified5.9%
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
flip-+N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
swap-sqrN/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
Applied egg-rr100.0%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0%
Simplified100.0%
(FPCore (a b)
:precision binary64
(if (<= b 320.0)
(+ 0.5 (* a 0.25))
(if (<= b 9.8e+100)
(* -0.020833333333333332 (* a (* a a)))
(/ 1.0 (+ 2.0 (* b (+ 1.0 (* b (+ 0.5 (* b 0.16666666666666666))))))))))
double code(double a, double b) {
double tmp;
if (b <= 320.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 9.8e+100) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 320.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 9.8d+100) then
tmp = (-0.020833333333333332d0) * (a * (a * a))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (b * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 320.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 9.8e+100) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 320.0: tmp = 0.5 + (a * 0.25) elif b <= 9.8e+100: tmp = -0.020833333333333332 * (a * (a * a)) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= 320.0) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 9.8e+100) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(b * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 320.0) tmp = 0.5 + (a * 0.25); elseif (b <= 9.8e+100) tmp = -0.020833333333333332 * (a * (a * a)); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (b * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 320.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.8e+100], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(2.0 + N[(b * N[(1.0 + N[(b * N[(0.5 + N[(b * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 320:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{+100}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(0.5 + b \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if b < 320Initial program 99.4%
Taylor expanded in b around 0
Simplified80.1%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6454.8%
Simplified54.8%
if 320 < b < 9.79999999999999934e100Initial program 100.0%
Taylor expanded in b around 0
Simplified35.4%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f642.7%
Simplified2.7%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6440.7%
Simplified40.7%
if 9.79999999999999934e100 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6497.8%
Simplified97.8%
(FPCore (a b)
:precision binary64
(if (<= b 310.0)
(+ 0.5 (* a 0.25))
(if (<= b 9.8e+100)
(* -0.020833333333333332 (* a (* a a)))
(/ 6.0 (* b (* b b))))))
double code(double a, double b) {
double tmp;
if (b <= 310.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 9.8e+100) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 310.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 9.8d+100) then
tmp = (-0.020833333333333332d0) * (a * (a * a))
else
tmp = 6.0d0 / (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 310.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 9.8e+100) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 6.0 / (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 310.0: tmp = 0.5 + (a * 0.25) elif b <= 9.8e+100: tmp = -0.020833333333333332 * (a * (a * a)) else: tmp = 6.0 / (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (b <= 310.0) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 9.8e+100) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(6.0 / Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 310.0) tmp = 0.5 + (a * 0.25); elseif (b <= 9.8e+100) tmp = -0.020833333333333332 * (a * (a * a)); else tmp = 6.0 / (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 310.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.8e+100], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 310:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 9.8 \cdot 10^{+100}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{6}{b \cdot \left(b \cdot b\right)}\\
\end{array}
\end{array}
if b < 310Initial program 99.4%
Taylor expanded in b around 0
Simplified80.1%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6454.8%
Simplified54.8%
if 310 < b < 9.79999999999999934e100Initial program 100.0%
Taylor expanded in b around 0
Simplified35.4%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f642.7%
Simplified2.7%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6440.7%
Simplified40.7%
if 9.79999999999999934e100 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6497.8%
Simplified97.8%
Taylor expanded in b around inf
/-lowering-/.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6497.8%
Simplified97.8%
(FPCore (a b)
:precision binary64
(if (<= b 280.0)
(+ 0.5 (* a 0.25))
(if (<= b 1.35e+154)
(* -0.020833333333333332 (* a (* a a)))
(/ 2.0 (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 280.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.35e+154) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 280.0d0) then
tmp = 0.5d0 + (a * 0.25d0)
else if (b <= 1.35d+154) then
tmp = (-0.020833333333333332d0) * (a * (a * a))
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 280.0) {
tmp = 0.5 + (a * 0.25);
} else if (b <= 1.35e+154) {
tmp = -0.020833333333333332 * (a * (a * a));
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 280.0: tmp = 0.5 + (a * 0.25) elif b <= 1.35e+154: tmp = -0.020833333333333332 * (a * (a * a)) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 280.0) tmp = Float64(0.5 + Float64(a * 0.25)); elseif (b <= 1.35e+154) tmp = Float64(-0.020833333333333332 * Float64(a * Float64(a * a))); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 280.0) tmp = 0.5 + (a * 0.25); elseif (b <= 1.35e+154) tmp = -0.020833333333333332 * (a * (a * a)); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 280.0], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e+154], N[(-0.020833333333333332 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 280:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;-0.020833333333333332 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 280Initial program 99.4%
Taylor expanded in b around 0
Simplified80.1%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6454.8%
Simplified54.8%
if 280 < b < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in b around 0
Simplified30.5%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f642.8%
Simplified2.8%
Taylor expanded in a around inf
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6442.1%
Simplified42.1%
if 1.35000000000000003e154 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64100.0%
Simplified100.0%
(FPCore (a b) :precision binary64 (if (<= b 1.7) (+ 0.5 (* a 0.25)) (/ 2.0 (* b b))))
double code(double a, double b) {
double tmp;
if (b <= 1.7) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.7d0) then
tmp = 0.5d0 + (a * 0.25d0)
else
tmp = 2.0d0 / (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.7) {
tmp = 0.5 + (a * 0.25);
} else {
tmp = 2.0 / (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.7: tmp = 0.5 + (a * 0.25) else: tmp = 2.0 / (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.7) tmp = Float64(0.5 + Float64(a * 0.25)); else tmp = Float64(2.0 / Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.7) tmp = 0.5 + (a * 0.25); else tmp = 2.0 / (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.7], N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7:\\
\;\;\;\;0.5 + a \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b \cdot b}\\
\end{array}
\end{array}
if b < 1.69999999999999996Initial program 99.4%
Taylor expanded in b around 0
Simplified80.1%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6454.8%
Simplified54.8%
if 1.69999999999999996 < b Initial program 100.0%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0%
Simplified100.0%
Taylor expanded in b around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6447.0%
Simplified47.0%
Taylor expanded in b around inf
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f6447.0%
Simplified47.0%
(FPCore (a b) :precision binary64 (+ 0.5 (* a 0.25)))
double code(double a, double b) {
return 0.5 + (a * 0.25);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0 + (a * 0.25d0)
end function
public static double code(double a, double b) {
return 0.5 + (a * 0.25);
}
def code(a, b): return 0.5 + (a * 0.25)
function code(a, b) return Float64(0.5 + Float64(a * 0.25)) end
function tmp = code(a, b) tmp = 0.5 + (a * 0.25); end
code[a_, b_] := N[(0.5 + N[(a * 0.25), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 + a \cdot 0.25
\end{array}
Initial program 99.6%
Taylor expanded in b around 0
Simplified67.7%
Taylor expanded in a around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6440.6%
Simplified40.6%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.6%
Taylor expanded in a around 0
/-lowering-/.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f6481.1%
Simplified81.1%
Taylor expanded in b around 0
Simplified40.2%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (exp (- b a)))))
double code(double a, double b) {
return 1.0 / (1.0 + exp((b - a)));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + exp((b - a)))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + Math.exp((b - a)));
}
def code(a, b): return 1.0 / (1.0 + math.exp((b - a)))
function code(a, b) return Float64(1.0 / Float64(1.0 + exp(Float64(b - a)))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + exp((b - a))); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[Exp[N[(b - a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + e^{b - a}}
\end{array}
herbie shell --seed 2024162
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(! :herbie-platform default (/ 1 (+ 1 (exp (- b a)))))
(/ (exp a) (+ (exp a) (exp b))))