
(FPCore (wj x) :precision binary64 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
return wj - ((t_0 - x) / (exp(wj) + t_0));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
t_0 = wj * exp(wj)
code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x): t_0 = wj * math.exp(wj) return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x) t_0 = Float64(wj * exp(wj)) return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) end
function tmp = code(wj, x) t_0 = wj * exp(wj); tmp = wj - ((t_0 - x) / (exp(wj) + t_0)); end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (wj x) :precision binary64 (let* ((t_0 (* wj (exp wj)))) (- wj (/ (- t_0 x) (+ (exp wj) t_0)))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
return wj - ((t_0 - x) / (exp(wj) + t_0));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
t_0 = wj * exp(wj)
code = wj - ((t_0 - x) / (exp(wj) + t_0))
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
return wj - ((t_0 - x) / (Math.exp(wj) + t_0));
}
def code(wj, x): t_0 = wj * math.exp(wj) return wj - ((t_0 - x) / (math.exp(wj) + t_0))
function code(wj, x) t_0 = Float64(wj * exp(wj)) return Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) end
function tmp = code(wj, x) t_0 = wj * exp(wj); tmp = wj - ((t_0 - x) / (exp(wj) + t_0)); end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
wj - \frac{t\_0 - x}{e^{wj} + t\_0}
\end{array}
\end{array}
(FPCore (wj x)
:precision binary64
(let* ((t_0 (* wj (exp wj))) (t_1 (+ (* x -4.0) (* x 1.5))))
(if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 1e-18)
(+
x
(+
(* -2.0 (* wj x))
(+
(*
(pow wj 3.0)
(- -1.0 (+ (* x -3.0) (+ (* -2.0 t_1) (* x 0.6666666666666666)))))
(* (pow wj 2.0) (- 1.0 t_1)))))
(+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0))))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = (x * -4.0) + (x * 1.5);
double tmp;
if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1e-18) {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (pow(wj, 2.0) * (1.0 - t_1))));
} else {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = wj * exp(wj)
t_1 = (x * (-4.0d0)) + (x * 1.5d0)
if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1d-18) then
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 3.0d0) * ((-1.0d0) - ((x * (-3.0d0)) + (((-2.0d0) * t_1) + (x * 0.6666666666666666d0))))) + ((wj ** 2.0d0) * (1.0d0 - t_1))))
else
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
double t_1 = (x * -4.0) + (x * 1.5);
double tmp;
if ((wj + ((x - t_0) / (Math.exp(wj) + t_0))) <= 1e-18) {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (Math.pow(wj, 2.0) * (1.0 - t_1))));
} else {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): t_0 = wj * math.exp(wj) t_1 = (x * -4.0) + (x * 1.5) tmp = 0 if (wj + ((x - t_0) / (math.exp(wj) + t_0))) <= 1e-18: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (math.pow(wj, 2.0) * (1.0 - t_1)))) else: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(Float64(x * -4.0) + Float64(x * 1.5)) tmp = 0.0 if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 1e-18) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64(Float64((wj ^ 3.0) * Float64(-1.0 - Float64(Float64(x * -3.0) + Float64(Float64(-2.0 * t_1) + Float64(x * 0.6666666666666666))))) + Float64((wj ^ 2.0) * Float64(1.0 - t_1))))); else tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) t_0 = wj * exp(wj); t_1 = (x * -4.0) + (x * 1.5); tmp = 0.0; if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 1e-18) tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + ((wj ^ 2.0) * (1.0 - t_1)))); else tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-18], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[wj, 3.0], $MachinePrecision] * N[(-1.0 - N[(N[(x * -3.0), $MachinePrecision] + N[(N[(-2.0 * t$95$1), $MachinePrecision] + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := x \cdot -4 + x \cdot 1.5\\
\mathbf{if}\;wj + \frac{x - t\_0}{e^{wj} + t\_0} \leq 10^{-18}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{3} \cdot \left(-1 - \left(x \cdot -3 + \left(-2 \cdot t\_1 + x \cdot 0.6666666666666666\right)\right)\right) + {wj}^{2} \cdot \left(1 - t\_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\end{array}
\end{array}
if (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) < 1.0000000000000001e-18Initial program 72.7%
distribute-rgt1-in72.7%
associate-/l/72.6%
div-sub72.6%
associate-/l*72.6%
*-inverses72.6%
/-rgt-identity72.6%
Simplified72.6%
Taylor expanded in wj around 0 99.3%
if 1.0000000000000001e-18 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 95.6%
distribute-rgt1-in95.7%
associate-/l/95.7%
div-sub95.6%
associate-/l*95.6%
*-inverses98.4%
/-rgt-identity98.4%
Simplified98.4%
Final simplification99.1%
(FPCore (wj x)
:precision binary64
(if (<= wj -0.00092)
(+ wj (/ (- (exp (- (log x) wj)) wj) (+ wj 1.0)))
(+
x
(+
(* -2.0 (* wj x))
(- (* (pow wj 2.0) (- 1.0 (+ (* x -4.0) (* x 1.5)))) (pow wj 3.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= -0.00092) {
tmp = wj + ((exp((log(x) - wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))) - pow(wj, 3.0)));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-0.00092d0)) then
tmp = wj + ((exp((log(x) - wj)) - wj) / (wj + 1.0d0))
else
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 2.0d0) * (1.0d0 - ((x * (-4.0d0)) + (x * 1.5d0)))) - (wj ** 3.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -0.00092) {
tmp = wj + ((Math.exp((Math.log(x) - wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))) - Math.pow(wj, 3.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -0.00092: tmp = wj + ((math.exp((math.log(x) - wj)) - wj) / (wj + 1.0)) else: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))) - math.pow(wj, 3.0))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -0.00092) tmp = Float64(wj + Float64(Float64(exp(Float64(log(x) - wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64(Float64((wj ^ 2.0) * Float64(1.0 - Float64(Float64(x * -4.0) + Float64(x * 1.5)))) - (wj ^ 3.0)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -0.00092) tmp = wj + ((exp((log(x) - wj)) - wj) / (wj + 1.0)); else tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))) - (wj ^ 3.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -0.00092], N[(wj + N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] - wj), $MachinePrecision]], $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -0.00092:\\
\;\;\;\;wj + \frac{e^{\log x - wj} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right) - {wj}^{3}\right)\right)\\
\end{array}
\end{array}
if wj < -9.2000000000000003e-4Initial program 82.3%
distribute-rgt1-in83.3%
associate-/l/83.9%
div-sub82.9%
associate-/l*82.9%
*-inverses83.9%
/-rgt-identity83.9%
Simplified83.9%
add-exp-log80.5%
div-exp92.6%
Applied egg-rr92.6%
if -9.2000000000000003e-4 < wj Initial program 79.2%
distribute-rgt1-in79.2%
associate-/l/79.2%
div-sub79.2%
associate-/l*79.2%
*-inverses80.0%
/-rgt-identity80.0%
Simplified80.0%
Taylor expanded in wj around 0 98.6%
Taylor expanded in x around 0 98.5%
Final simplification98.3%
(FPCore (wj x) :precision binary64 (if (<= x 2.3e-63) (+ x (+ (* -2.0 (* wj x)) (- (pow wj 2.0) (pow wj 3.0)))) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (x <= 2.3e-63) {
tmp = x + ((-2.0 * (wj * x)) + (pow(wj, 2.0) - pow(wj, 3.0)));
} else {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.3d-63) then
tmp = x + (((-2.0d0) * (wj * x)) + ((wj ** 2.0d0) - (wj ** 3.0d0)))
else
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= 2.3e-63) {
tmp = x + ((-2.0 * (wj * x)) + (Math.pow(wj, 2.0) - Math.pow(wj, 3.0)));
} else {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= 2.3e-63: tmp = x + ((-2.0 * (wj * x)) + (math.pow(wj, 2.0) - math.pow(wj, 3.0))) else: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (x <= 2.3e-63) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64((wj ^ 2.0) - (wj ^ 3.0)))); else tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= 2.3e-63) tmp = x + ((-2.0 * (wj * x)) + ((wj ^ 2.0) - (wj ^ 3.0))); else tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, 2.3e-63], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3 \cdot 10^{-63}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{2} - {wj}^{3}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\end{array}
\end{array}
if x < 2.3e-63Initial program 71.1%
distribute-rgt1-in71.2%
associate-/l/71.2%
div-sub71.1%
associate-/l*71.1%
*-inverses71.7%
/-rgt-identity71.7%
Simplified71.7%
Taylor expanded in wj around 0 97.7%
Taylor expanded in x around 0 97.5%
Taylor expanded in x around 0 97.4%
if 2.3e-63 < x Initial program 98.6%
distribute-rgt1-in98.6%
associate-/l/98.6%
div-sub98.6%
associate-/l*98.6%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Final simplification98.2%
(FPCore (wj x)
:precision binary64
(if (<= wj -0.00082)
(+ wj (/ (- (exp (- (log x) wj)) wj) (+ wj 1.0)))
(+
x
(+ (* -2.0 (* wj x)) (* (pow wj 2.0) (- 1.0 (+ (* x -4.0) (* x 1.5))))))))
double code(double wj, double x) {
double tmp;
if (wj <= -0.00082) {
tmp = wj + ((exp((log(x) - wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + (pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-0.00082d0)) then
tmp = wj + ((exp((log(x) - wj)) - wj) / (wj + 1.0d0))
else
tmp = x + (((-2.0d0) * (wj * x)) + ((wj ** 2.0d0) * (1.0d0 - ((x * (-4.0d0)) + (x * 1.5d0)))))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -0.00082) {
tmp = wj + ((Math.exp((Math.log(x) - wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + (Math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -0.00082: tmp = wj + ((math.exp((math.log(x) - wj)) - wj) / (wj + 1.0)) else: tmp = x + ((-2.0 * (wj * x)) + (math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -0.00082) tmp = Float64(wj + Float64(Float64(exp(Float64(log(x) - wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64((wj ^ 2.0) * Float64(1.0 - Float64(Float64(x * -4.0) + Float64(x * 1.5)))))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -0.00082) tmp = wj + ((exp((log(x) - wj)) - wj) / (wj + 1.0)); else tmp = x + ((-2.0 * (wj * x)) + ((wj ^ 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -0.00082], N[(wj + N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] - wj), $MachinePrecision]], $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -0.00082:\\
\;\;\;\;wj + \frac{e^{\log x - wj} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right)\right)\\
\end{array}
\end{array}
if wj < -8.1999999999999998e-4Initial program 82.3%
distribute-rgt1-in83.3%
associate-/l/83.9%
div-sub82.9%
associate-/l*82.9%
*-inverses83.9%
/-rgt-identity83.9%
Simplified83.9%
add-exp-log80.5%
div-exp92.6%
Applied egg-rr92.6%
if -8.1999999999999998e-4 < wj Initial program 79.2%
distribute-rgt1-in79.2%
associate-/l/79.2%
div-sub79.2%
associate-/l*79.2%
*-inverses80.0%
/-rgt-identity80.0%
Simplified80.0%
Taylor expanded in wj around 0 98.1%
Final simplification97.9%
(FPCore (wj x)
:precision binary64
(if (<= wj -3e-9)
(+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))
(+
x
(+ (* -2.0 (* wj x)) (* (pow wj 2.0) (- 1.0 (+ (* x -4.0) (* x 1.5))))))))
double code(double wj, double x) {
double tmp;
if (wj <= -3e-9) {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + (pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-3d-9)) then
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
else
tmp = x + (((-2.0d0) * (wj * x)) + ((wj ** 2.0d0) * (1.0d0 - ((x * (-4.0d0)) + (x * 1.5d0)))))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -3e-9) {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + (Math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -3e-9: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) else: tmp = x + ((-2.0 * (wj * x)) + (math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -3e-9) tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64((wj ^ 2.0) * Float64(1.0 - Float64(Float64(x * -4.0) + Float64(x * 1.5)))))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -3e-9) tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); else tmp = x + ((-2.0 * (wj * x)) + ((wj ^ 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -3e-9], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -3 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right)\right)\\
\end{array}
\end{array}
if wj < -2.99999999999999998e-9Initial program 84.5%
distribute-rgt1-in85.4%
associate-/l/85.9%
div-sub85.0%
associate-/l*85.0%
*-inverses85.9%
/-rgt-identity85.9%
Simplified85.9%
if -2.99999999999999998e-9 < wj Initial program 79.1%
distribute-rgt1-in79.1%
associate-/l/79.1%
div-sub79.1%
associate-/l*79.1%
*-inverses79.9%
/-rgt-identity79.9%
Simplified79.9%
Taylor expanded in wj around 0 98.2%
Final simplification97.8%
(FPCore (wj x) :precision binary64 (if (<= wj -2.95e-9) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0))) (+ x (+ (* -2.0 (* wj x)) (pow wj 2.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= -2.95e-9) {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + pow(wj, 2.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-2.95d-9)) then
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
else
tmp = x + (((-2.0d0) * (wj * x)) + (wj ** 2.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -2.95e-9) {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + Math.pow(wj, 2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -2.95e-9: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) else: tmp = x + ((-2.0 * (wj * x)) + math.pow(wj, 2.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -2.95e-9) tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + (wj ^ 2.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -2.95e-9) tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); else tmp = x + ((-2.0 * (wj * x)) + (wj ^ 2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -2.95e-9], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -2.95 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2}\right)\\
\end{array}
\end{array}
if wj < -2.9499999999999999e-9Initial program 84.5%
distribute-rgt1-in85.4%
associate-/l/85.9%
div-sub85.0%
associate-/l*85.0%
*-inverses85.9%
/-rgt-identity85.9%
Simplified85.9%
if -2.9499999999999999e-9 < wj Initial program 79.1%
distribute-rgt1-in79.1%
associate-/l/79.1%
div-sub79.1%
associate-/l*79.1%
*-inverses79.9%
/-rgt-identity79.9%
Simplified79.9%
Taylor expanded in wj around 0 98.2%
Taylor expanded in x around 0 98.2%
Final simplification97.8%
(FPCore (wj x) :precision binary64 (+ x (+ (* -2.0 (* wj x)) (pow wj 2.0))))
double code(double wj, double x) {
return x + ((-2.0 * (wj * x)) + pow(wj, 2.0));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + (((-2.0d0) * (wj * x)) + (wj ** 2.0d0))
end function
public static double code(double wj, double x) {
return x + ((-2.0 * (wj * x)) + Math.pow(wj, 2.0));
}
def code(wj, x): return x + ((-2.0 * (wj * x)) + math.pow(wj, 2.0))
function code(wj, x) return Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + (wj ^ 2.0))) end
function tmp = code(wj, x) tmp = x + ((-2.0 * (wj * x)) + (wj ^ 2.0)); end
code[wj_, x_] := N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2}\right)
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around 0 96.0%
Taylor expanded in x around 0 95.8%
Final simplification95.8%
(FPCore (wj x) :precision binary64 (if (<= wj -1.02e-49) (+ wj (/ (- (* x (- 1.0 wj)) wj) (+ wj 1.0))) (* x (/ (- 1.0 wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= -1.02e-49) {
tmp = wj + (((x * (1.0 - wj)) - wj) / (wj + 1.0));
} else {
tmp = x * ((1.0 - wj) / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-1.02d-49)) then
tmp = wj + (((x * (1.0d0 - wj)) - wj) / (wj + 1.0d0))
else
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -1.02e-49) {
tmp = wj + (((x * (1.0 - wj)) - wj) / (wj + 1.0));
} else {
tmp = x * ((1.0 - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -1.02e-49: tmp = wj + (((x * (1.0 - wj)) - wj) / (wj + 1.0)) else: tmp = x * ((1.0 - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -1.02e-49) tmp = Float64(wj + Float64(Float64(Float64(x * Float64(1.0 - wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -1.02e-49) tmp = wj + (((x * (1.0 - wj)) - wj) / (wj + 1.0)); else tmp = x * ((1.0 - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -1.02e-49], N[(wj + N[(N[(N[(x * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -1.02 \cdot 10^{-49}:\\
\;\;\;\;wj + \frac{x \cdot \left(1 - wj\right) - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < -1.02000000000000009e-49Initial program 73.1%
distribute-rgt1-in73.4%
associate-/l/73.5%
div-sub73.2%
associate-/l*73.2%
*-inverses73.5%
/-rgt-identity73.5%
Simplified73.5%
Taylor expanded in wj around 0 65.5%
associate-*r*65.5%
neg-mul-165.5%
distribute-rgt1-in65.5%
+-commutative65.5%
sub-neg65.5%
Simplified65.5%
if -1.02000000000000009e-49 < wj Initial program 79.9%
distribute-rgt1-in79.9%
associate-/l/79.9%
div-sub79.9%
associate-/l*79.9%
*-inverses80.7%
/-rgt-identity80.7%
Simplified80.7%
Taylor expanded in wj around 0 79.4%
associate-*r*79.4%
neg-mul-179.4%
distribute-rgt1-in79.4%
+-commutative79.4%
sub-neg79.4%
Simplified79.4%
Taylor expanded in x around inf 88.5%
+-commutative88.5%
+-commutative88.5%
div-sub88.5%
Simplified88.5%
Final simplification86.5%
(FPCore (wj x) :precision binary64 (+ (- wj (/ wj (+ wj 1.0))) (/ (- 1.0 wj) (/ (+ wj 1.0) x))))
double code(double wj, double x) {
return (wj - (wj / (wj + 1.0))) + ((1.0 - wj) / ((wj + 1.0) / x));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = (wj - (wj / (wj + 1.0d0))) + ((1.0d0 - wj) / ((wj + 1.0d0) / x))
end function
public static double code(double wj, double x) {
return (wj - (wj / (wj + 1.0))) + ((1.0 - wj) / ((wj + 1.0) / x));
}
def code(wj, x): return (wj - (wj / (wj + 1.0))) + ((1.0 - wj) / ((wj + 1.0) / x))
function code(wj, x) return Float64(Float64(wj - Float64(wj / Float64(wj + 1.0))) + Float64(Float64(1.0 - wj) / Float64(Float64(wj + 1.0) / x))) end
function tmp = code(wj, x) tmp = (wj - (wj / (wj + 1.0))) + ((1.0 - wj) / ((wj + 1.0) / x)); end
code[wj_, x_] := N[(N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - wj), $MachinePrecision] / N[(N[(wj + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(wj - \frac{wj}{wj + 1}\right) + \frac{1 - wj}{\frac{wj + 1}{x}}
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around 0 78.2%
associate-*r*78.2%
neg-mul-178.2%
distribute-rgt1-in78.2%
+-commutative78.2%
sub-neg78.2%
Simplified78.2%
div-sub78.2%
associate--r-86.9%
associate-/l*86.6%
Applied egg-rr86.6%
Final simplification86.6%
(FPCore (wj x) :precision binary64 (* x (/ (- 1.0 wj) (+ wj 1.0))))
double code(double wj, double x) {
return x * ((1.0 - wj) / (wj + 1.0));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x * ((1.0d0 - wj) / (wj + 1.0d0))
end function
public static double code(double wj, double x) {
return x * ((1.0 - wj) / (wj + 1.0));
}
def code(wj, x): return x * ((1.0 - wj) / (wj + 1.0))
function code(wj, x) return Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))) end
function tmp = code(wj, x) tmp = x * ((1.0 - wj) / (wj + 1.0)); end
code[wj_, x_] := N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 - wj}{wj + 1}
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around 0 78.2%
associate-*r*78.2%
neg-mul-178.2%
distribute-rgt1-in78.2%
+-commutative78.2%
sub-neg78.2%
Simplified78.2%
Taylor expanded in x around inf 84.7%
+-commutative84.7%
+-commutative84.7%
div-sub84.7%
Simplified84.7%
Final simplification84.7%
(FPCore (wj x) :precision binary64 (* x (+ 1.0 (* wj -2.0))))
double code(double wj, double x) {
return x * (1.0 + (wj * -2.0));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x * (1.0d0 + (wj * (-2.0d0)))
end function
public static double code(double wj, double x) {
return x * (1.0 + (wj * -2.0));
}
def code(wj, x): return x * (1.0 + (wj * -2.0))
function code(wj, x) return Float64(x * Float64(1.0 + Float64(wj * -2.0))) end
function tmp = code(wj, x) tmp = x * (1.0 + (wj * -2.0)); end
code[wj_, x_] := N[(x * N[(1.0 + N[(wj * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + wj \cdot -2\right)
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around 0 96.7%
Taylor expanded in x around 0 96.5%
Taylor expanded in x around 0 96.3%
Taylor expanded in x around inf 84.7%
*-commutative84.7%
Simplified84.7%
Final simplification84.7%
(FPCore (wj x) :precision binary64 (+ x (* -2.0 (* wj x))))
double code(double wj, double x) {
return x + (-2.0 * (wj * x));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + ((-2.0d0) * (wj * x))
end function
public static double code(double wj, double x) {
return x + (-2.0 * (wj * x));
}
def code(wj, x): return x + (-2.0 * (wj * x))
function code(wj, x) return Float64(x + Float64(-2.0 * Float64(wj * x))) end
function tmp = code(wj, x) tmp = x + (-2.0 * (wj * x)); end
code[wj_, x_] := N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + -2 \cdot \left(wj \cdot x\right)
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around 0 84.7%
*-commutative84.7%
Simplified84.7%
Final simplification84.7%
(FPCore (wj x) :precision binary64 wj)
double code(double wj, double x) {
return wj;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = wj
end function
public static double code(double wj, double x) {
return wj;
}
def code(wj, x): return wj
function code(wj, x) return wj end
function tmp = code(wj, x) tmp = wj; end
code[wj_, x_] := wj
\begin{array}{l}
\\
wj
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around inf 4.3%
Final simplification4.3%
(FPCore (wj x) :precision binary64 x)
double code(double wj, double x) {
return x;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x
end function
public static double code(double wj, double x) {
return x;
}
def code(wj, x): return x
function code(wj, x) return x end
function tmp = code(wj, x) tmp = x; end
code[wj_, x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 79.3%
distribute-rgt1-in79.3%
associate-/l/79.3%
div-sub79.3%
associate-/l*79.3%
*-inverses80.1%
/-rgt-identity80.1%
Simplified80.1%
Taylor expanded in wj around 0 83.9%
Final simplification83.9%
(FPCore (wj x) :precision binary64 (- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj)))))))
double code(double wj, double x) {
return wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj)))));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = wj - ((wj / (wj + 1.0d0)) - (x / (exp(wj) + (wj * exp(wj)))))
end function
public static double code(double wj, double x) {
return wj - ((wj / (wj + 1.0)) - (x / (Math.exp(wj) + (wj * Math.exp(wj)))));
}
def code(wj, x): return wj - ((wj / (wj + 1.0)) - (x / (math.exp(wj) + (wj * math.exp(wj)))))
function code(wj, x) return Float64(wj - Float64(Float64(wj / Float64(wj + 1.0)) - Float64(x / Float64(exp(wj) + Float64(wj * exp(wj)))))) end
function tmp = code(wj, x) tmp = wj - ((wj / (wj + 1.0)) - (x / (exp(wj) + (wj * exp(wj))))); end
code[wj_, x_] := N[(wj - N[(N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[Exp[wj], $MachinePrecision] + N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right)
\end{array}
herbie shell --seed 2024039
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))