
(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 (+ (* x -4.0) (* x 1.5))))
(if (<= wj -3.7e-6)
(+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))
(+
x
(+
(* -2.0 (* wj x))
(+
(*
(pow wj 3.0)
(- -1.0 (+ (* x -3.0) (+ (* -2.0 t_0) (* x 0.6666666666666666)))))
(* (pow wj 2.0) (- 1.0 t_0))))))))
double code(double wj, double x) {
double t_0 = (x * -4.0) + (x * 1.5);
double tmp;
if (wj <= -3.7e-6) {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + (pow(wj, 2.0) * (1.0 - t_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) :: tmp
t_0 = (x * (-4.0d0)) + (x * 1.5d0)
if (wj <= (-3.7d-6)) then
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
else
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 3.0d0) * ((-1.0d0) - ((x * (-3.0d0)) + (((-2.0d0) * t_0) + (x * 0.6666666666666666d0))))) + ((wj ** 2.0d0) * (1.0d0 - t_0))))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = (x * -4.0) + (x * 1.5);
double tmp;
if (wj <= -3.7e-6) {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + (Math.pow(wj, 2.0) * (1.0 - t_0))));
}
return tmp;
}
def code(wj, x): t_0 = (x * -4.0) + (x * 1.5) tmp = 0 if wj <= -3.7e-6: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) else: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + (math.pow(wj, 2.0) * (1.0 - t_0)))) return tmp
function code(wj, x) t_0 = Float64(Float64(x * -4.0) + Float64(x * 1.5)) tmp = 0.0 if (wj <= -3.7e-6) 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(Float64((wj ^ 3.0) * Float64(-1.0 - Float64(Float64(x * -3.0) + Float64(Float64(-2.0 * t_0) + Float64(x * 0.6666666666666666))))) + Float64((wj ^ 2.0) * Float64(1.0 - t_0))))); end return tmp end
function tmp_2 = code(wj, x) t_0 = (x * -4.0) + (x * 1.5); tmp = 0.0; if (wj <= -3.7e-6) tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); else tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_0) + (x * 0.6666666666666666))))) + ((wj ^ 2.0) * (1.0 - t_0)))); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -3.7e-6], 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[(N[Power[wj, 3.0], $MachinePrecision] * N[(-1.0 - N[(N[(x * -3.0), $MachinePrecision] + N[(N[(-2.0 * t$95$0), $MachinePrecision] + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot -4 + x \cdot 1.5\\
\mathbf{if}\;wj \leq -3.7 \cdot 10^{-6}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{3} \cdot \left(-1 - \left(x \cdot -3 + \left(-2 \cdot t_0 + x \cdot 0.6666666666666666\right)\right)\right) + {wj}^{2} \cdot \left(1 - t_0\right)\right)\right)\\
\end{array}
\end{array}
if wj < -3.7000000000000002e-6Initial program 33.1%
distribute-rgt1-in99.7%
associate-/l/100.0%
div-sub33.3%
associate-/l*33.3%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
if -3.7000000000000002e-6 < wj Initial program 73.5%
distribute-rgt1-in73.5%
associate-/l/73.5%
div-sub73.5%
associate-/l*73.5%
*-inverses74.3%
/-rgt-identity74.3%
Simplified74.3%
Taylor expanded in wj around 0 98.9%
Final simplification98.9%
(FPCore (wj x)
:precision binary64
(if (<= wj -3.05e-6)
(+ 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)))) (pow wj 3.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= -3.05e-6) {
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)))) - 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 <= (-3.05d-6)) 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)))) - (wj ** 3.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -3.05e-6) {
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)))) - Math.pow(wj, 3.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -3.05e-6: 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)))) - math.pow(wj, 3.0))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -3.05e-6) 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(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 <= -3.05e-6) 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)))) - (wj ^ 3.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -3.05e-6], 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[(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 -3.05 \cdot 10^{-6}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{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 < -3.05000000000000002e-6Initial program 33.1%
distribute-rgt1-in99.7%
associate-/l/100.0%
div-sub33.3%
associate-/l*33.3%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
if -3.05000000000000002e-6 < wj Initial program 73.5%
distribute-rgt1-in73.5%
associate-/l/73.5%
div-sub73.5%
associate-/l*73.5%
*-inverses74.3%
/-rgt-identity74.3%
Simplified74.3%
Taylor expanded in wj around 0 98.9%
Taylor expanded in x around 0 98.9%
Final simplification98.9%
(FPCore (wj x) :precision binary64 (if (<= wj -5.2e-9) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0))) (+ x (- (pow wj 2.0) (pow wj 3.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= -5.2e-9) {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + (pow(wj, 2.0) - 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 <= (-5.2d-9)) then
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
else
tmp = x + ((wj ** 2.0d0) - (wj ** 3.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -5.2e-9) {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + (Math.pow(wj, 2.0) - Math.pow(wj, 3.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -5.2e-9: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) else: tmp = x + (math.pow(wj, 2.0) - math.pow(wj, 3.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -5.2e-9) tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x + Float64((wj ^ 2.0) - (wj ^ 3.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -5.2e-9) tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); else tmp = x + ((wj ^ 2.0) - (wj ^ 3.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -5.2e-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[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -5.2 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \left({wj}^{2} - {wj}^{3}\right)\\
\end{array}
\end{array}
if wj < -5.2000000000000002e-9Initial program 56.8%
distribute-rgt1-in96.8%
associate-/l/97.0%
div-sub57.0%
associate-/l*57.0%
*-inverses97.0%
/-rgt-identity97.0%
Simplified97.0%
if -5.2000000000000002e-9 < wj Initial program 73.2%
distribute-rgt1-in73.2%
associate-/l/73.2%
div-sub73.2%
associate-/l*73.2%
*-inverses74.0%
/-rgt-identity74.0%
Simplified74.0%
Taylor expanded in wj around 0 98.9%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 98.7%
+-commutative98.7%
mul-1-neg98.7%
unsub-neg98.7%
Simplified98.7%
Final simplification98.6%
(FPCore (wj x) :precision binary64 (if (or (<= x -2e-274) (not (<= x 2.5e-287))) (/ x (* (exp wj) (+ wj 1.0))) (* wj (+ wj (* x -2.0)))))
double code(double wj, double x) {
double tmp;
if ((x <= -2e-274) || !(x <= 2.5e-287)) {
tmp = x / (exp(wj) * (wj + 1.0));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-2d-274)) .or. (.not. (x <= 2.5d-287))) then
tmp = x / (exp(wj) * (wj + 1.0d0))
else
tmp = wj * (wj + (x * (-2.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if ((x <= -2e-274) || !(x <= 2.5e-287)) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -2e-274) or not (x <= 2.5e-287): tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = wj * (wj + (x * -2.0)) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -2e-274) || !(x <= 2.5e-287)) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); else tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if ((x <= -2e-274) || ~((x <= 2.5e-287))) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = wj * (wj + (x * -2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[Or[LessEqual[x, -2e-274], N[Not[LessEqual[x, 2.5e-287]], $MachinePrecision]], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-274} \lor \neg \left(x \leq 2.5 \cdot 10^{-287}\right):\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\end{array}
\end{array}
if x < -1.99999999999999993e-274 or 2.50000000000000013e-287 < x Initial program 75.2%
distribute-rgt1-in76.8%
associate-/l/76.8%
div-sub75.2%
associate-/l*75.2%
*-inverses77.7%
/-rgt-identity77.7%
Simplified77.7%
Taylor expanded in x around inf 88.9%
+-commutative88.9%
Simplified88.9%
if -1.99999999999999993e-274 < x < 2.50000000000000013e-287Initial program 8.0%
distribute-rgt1-in8.0%
associate-/l/8.0%
div-sub8.0%
associate-/l*8.0%
*-inverses8.0%
/-rgt-identity8.0%
Simplified8.0%
Taylor expanded in wj around 0 99.5%
Taylor expanded in x around 0 99.5%
Taylor expanded in wj around inf 90.7%
+-commutative90.7%
unpow290.7%
associate-*r*90.7%
*-commutative90.7%
associate-*r*90.7%
distribute-rgt-out90.7%
Simplified90.7%
Final simplification89.0%
(FPCore (wj x) :precision binary64 (if (<= wj -6.2e-9) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0))) (+ x (fma wj wj (* x (* wj -2.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= -6.2e-9) {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = x + fma(wj, wj, (x * (wj * -2.0)));
}
return tmp;
}
function code(wj, x) tmp = 0.0 if (wj <= -6.2e-9) tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64(x + fma(wj, wj, Float64(x * Float64(wj * -2.0)))); end return tmp end
code[wj_, x_] := If[LessEqual[wj, -6.2e-9], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(wj * wj + N[(x * N[(wj * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -6.2 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(wj, wj, x \cdot \left(wj \cdot -2\right)\right)\\
\end{array}
\end{array}
if wj < -6.2000000000000001e-9Initial program 52.0%
distribute-rgt1-in96.5%
associate-/l/96.6%
div-sub52.2%
associate-/l*52.2%
*-inverses96.6%
/-rgt-identity96.6%
Simplified96.6%
if -6.2000000000000001e-9 < wj Initial program 73.3%
distribute-rgt1-in73.3%
associate-/l/73.3%
div-sub73.3%
associate-/l*73.3%
*-inverses74.1%
/-rgt-identity74.1%
Simplified74.1%
Taylor expanded in wj around 0 98.7%
Taylor expanded in x around 0 98.7%
+-commutative98.7%
unpow298.7%
fma-def98.7%
associate-*r*98.7%
*-commutative98.7%
Applied egg-rr98.7%
Final simplification98.6%
(FPCore (wj x) :precision binary64 (if (<= wj -0.0001) (/ x (* (exp wj) (+ wj 1.0))) (+ x (fma wj wj (* x (* wj -2.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= -0.0001) {
tmp = x / (exp(wj) * (wj + 1.0));
} else {
tmp = x + fma(wj, wj, (x * (wj * -2.0)));
}
return tmp;
}
function code(wj, x) tmp = 0.0 if (wj <= -0.0001) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); else tmp = Float64(x + fma(wj, wj, Float64(x * Float64(wj * -2.0)))); end return tmp end
code[wj_, x_] := If[LessEqual[wj, -0.0001], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(wj * wj + N[(x * N[(wj * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -0.0001:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{fma}\left(wj, wj, x \cdot \left(wj \cdot -2\right)\right)\\
\end{array}
\end{array}
if wj < -1.00000000000000005e-4Initial program 33.1%
distribute-rgt1-in99.7%
associate-/l/100.0%
div-sub33.3%
associate-/l*33.3%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 98.3%
+-commutative98.3%
Simplified98.3%
if -1.00000000000000005e-4 < wj Initial program 73.5%
distribute-rgt1-in73.5%
associate-/l/73.5%
div-sub73.5%
associate-/l*73.5%
*-inverses74.3%
/-rgt-identity74.3%
Simplified74.3%
Taylor expanded in wj around 0 98.5%
Taylor expanded in x around 0 98.4%
+-commutative98.4%
unpow298.4%
fma-def98.4%
associate-*r*98.4%
*-commutative98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (wj x)
:precision binary64
(if (<= x -4.6e-243)
(/ (* x (- 1.0 wj)) (+ wj 1.0))
(if (<= x 3.7e-289)
(* wj (+ wj (* x -2.0)))
(* x (- (/ 1.0 (+ wj 1.0)) (/ wj (+ wj 1.0)))))))
double code(double wj, double x) {
double tmp;
if (x <= -4.6e-243) {
tmp = (x * (1.0 - wj)) / (wj + 1.0);
} else if (x <= 3.7e-289) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x * ((1.0 / (wj + 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 (x <= (-4.6d-243)) then
tmp = (x * (1.0d0 - wj)) / (wj + 1.0d0)
else if (x <= 3.7d-289) then
tmp = wj * (wj + (x * (-2.0d0)))
else
tmp = x * ((1.0d0 / (wj + 1.0d0)) - (wj / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= -4.6e-243) {
tmp = (x * (1.0 - wj)) / (wj + 1.0);
} else if (x <= 3.7e-289) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x * ((1.0 / (wj + 1.0)) - (wj / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -4.6e-243: tmp = (x * (1.0 - wj)) / (wj + 1.0) elif x <= 3.7e-289: tmp = wj * (wj + (x * -2.0)) else: tmp = x * ((1.0 / (wj + 1.0)) - (wj / (wj + 1.0))) return tmp
function code(wj, x) tmp = 0.0 if (x <= -4.6e-243) tmp = Float64(Float64(x * Float64(1.0 - wj)) / Float64(wj + 1.0)); elseif (x <= 3.7e-289) tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); else tmp = Float64(x * Float64(Float64(1.0 / Float64(wj + 1.0)) - Float64(wj / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= -4.6e-243) tmp = (x * (1.0 - wj)) / (wj + 1.0); elseif (x <= 3.7e-289) tmp = wj * (wj + (x * -2.0)); else tmp = x * ((1.0 / (wj + 1.0)) - (wj / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -4.6e-243], N[(N[(x * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.7e-289], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{-243}:\\
\;\;\;\;\frac{x \cdot \left(1 - wj\right)}{wj + 1}\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-289}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{1}{wj + 1} - \frac{wj}{wj + 1}\right)\\
\end{array}
\end{array}
if x < -4.6e-243Initial program 71.1%
distribute-rgt1-in73.6%
associate-/l/73.6%
div-sub71.1%
associate-/l*71.1%
*-inverses75.2%
/-rgt-identity75.2%
Simplified75.2%
Taylor expanded in wj around 0 71.1%
mul-1-neg71.1%
unsub-neg71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in x around inf 84.4%
*-commutative84.4%
sub-div84.4%
associate-*l/84.4%
+-commutative84.4%
Applied egg-rr84.4%
if -4.6e-243 < x < 3.69999999999999989e-289Initial program 10.4%
distribute-rgt1-in16.6%
associate-/l/16.6%
div-sub10.4%
associate-/l*10.4%
*-inverses16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 93.5%
Taylor expanded in x around 0 93.5%
Taylor expanded in wj around inf 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
*-commutative76.0%
associate-*r*76.0%
distribute-rgt-out76.0%
Simplified76.0%
if 3.69999999999999989e-289 < x Initial program 82.4%
distribute-rgt1-in82.4%
associate-/l/82.4%
div-sub82.4%
associate-/l*82.4%
*-inverses82.4%
/-rgt-identity82.4%
Simplified82.4%
Taylor expanded in wj around 0 81.6%
mul-1-neg81.6%
unsub-neg81.6%
*-commutative81.6%
Simplified81.6%
Taylor expanded in x around inf 91.5%
Final simplification87.2%
(FPCore (wj x) :precision binary64 (if (or (<= x -5.4e-244) (not (<= x 2.3e-289))) (/ x (/ (+ wj 1.0) (- 1.0 wj))) (* wj (+ wj (* x -2.0)))))
double code(double wj, double x) {
double tmp;
if ((x <= -5.4e-244) || !(x <= 2.3e-289)) {
tmp = x / ((wj + 1.0) / (1.0 - wj));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-5.4d-244)) .or. (.not. (x <= 2.3d-289))) then
tmp = x / ((wj + 1.0d0) / (1.0d0 - wj))
else
tmp = wj * (wj + (x * (-2.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if ((x <= -5.4e-244) || !(x <= 2.3e-289)) {
tmp = x / ((wj + 1.0) / (1.0 - wj));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -5.4e-244) or not (x <= 2.3e-289): tmp = x / ((wj + 1.0) / (1.0 - wj)) else: tmp = wj * (wj + (x * -2.0)) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -5.4e-244) || !(x <= 2.3e-289)) tmp = Float64(x / Float64(Float64(wj + 1.0) / Float64(1.0 - wj))); else tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if ((x <= -5.4e-244) || ~((x <= 2.3e-289))) tmp = x / ((wj + 1.0) / (1.0 - wj)); else tmp = wj * (wj + (x * -2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[Or[LessEqual[x, -5.4e-244], N[Not[LessEqual[x, 2.3e-289]], $MachinePrecision]], N[(x / N[(N[(wj + 1.0), $MachinePrecision] / N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{-244} \lor \neg \left(x \leq 2.3 \cdot 10^{-289}\right):\\
\;\;\;\;\frac{x}{\frac{wj + 1}{1 - wj}}\\
\mathbf{else}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\end{array}
\end{array}
if x < -5.3999999999999999e-244 or 2.3000000000000002e-289 < x Initial program 76.7%
distribute-rgt1-in78.0%
associate-/l/78.0%
div-sub76.7%
associate-/l*76.7%
*-inverses78.8%
/-rgt-identity78.8%
Simplified78.8%
Taylor expanded in wj around 0 76.3%
mul-1-neg76.3%
unsub-neg76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in x around inf 87.9%
expm1-log1p-u61.8%
expm1-udef26.8%
sub-div26.8%
associate-*r/26.8%
+-commutative26.8%
Applied egg-rr26.8%
expm1-def61.8%
expm1-log1p87.9%
associate-/l*87.9%
Simplified87.9%
if -5.3999999999999999e-244 < x < 2.3000000000000002e-289Initial program 10.4%
distribute-rgt1-in16.6%
associate-/l/16.6%
div-sub10.4%
associate-/l*10.4%
*-inverses16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 93.5%
Taylor expanded in x around 0 93.5%
Taylor expanded in wj around inf 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
*-commutative76.0%
associate-*r*76.0%
distribute-rgt-out76.0%
Simplified76.0%
Final simplification87.2%
(FPCore (wj x)
:precision binary64
(if (<= x -1.1e-244)
(/ (* x (- 1.0 wj)) (+ wj 1.0))
(if (<= x 1.5e-285)
(* wj (+ wj (* x -2.0)))
(/ x (/ (+ wj 1.0) (- 1.0 wj))))))
double code(double wj, double x) {
double tmp;
if (x <= -1.1e-244) {
tmp = (x * (1.0 - wj)) / (wj + 1.0);
} else if (x <= 1.5e-285) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x / ((wj + 1.0) / (1.0 - wj));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.1d-244)) then
tmp = (x * (1.0d0 - wj)) / (wj + 1.0d0)
else if (x <= 1.5d-285) then
tmp = wj * (wj + (x * (-2.0d0)))
else
tmp = x / ((wj + 1.0d0) / (1.0d0 - wj))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= -1.1e-244) {
tmp = (x * (1.0 - wj)) / (wj + 1.0);
} else if (x <= 1.5e-285) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x / ((wj + 1.0) / (1.0 - wj));
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -1.1e-244: tmp = (x * (1.0 - wj)) / (wj + 1.0) elif x <= 1.5e-285: tmp = wj * (wj + (x * -2.0)) else: tmp = x / ((wj + 1.0) / (1.0 - wj)) return tmp
function code(wj, x) tmp = 0.0 if (x <= -1.1e-244) tmp = Float64(Float64(x * Float64(1.0 - wj)) / Float64(wj + 1.0)); elseif (x <= 1.5e-285) tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); else tmp = Float64(x / Float64(Float64(wj + 1.0) / Float64(1.0 - wj))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= -1.1e-244) tmp = (x * (1.0 - wj)) / (wj + 1.0); elseif (x <= 1.5e-285) tmp = wj * (wj + (x * -2.0)); else tmp = x / ((wj + 1.0) / (1.0 - wj)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -1.1e-244], N[(N[(x * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.5e-285], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[(wj + 1.0), $MachinePrecision] / N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-244}:\\
\;\;\;\;\frac{x \cdot \left(1 - wj\right)}{wj + 1}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-285}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{wj + 1}{1 - wj}}\\
\end{array}
\end{array}
if x < -1.09999999999999992e-244Initial program 71.1%
distribute-rgt1-in73.6%
associate-/l/73.6%
div-sub71.1%
associate-/l*71.1%
*-inverses75.2%
/-rgt-identity75.2%
Simplified75.2%
Taylor expanded in wj around 0 71.1%
mul-1-neg71.1%
unsub-neg71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in x around inf 84.4%
*-commutative84.4%
sub-div84.4%
associate-*l/84.4%
+-commutative84.4%
Applied egg-rr84.4%
if -1.09999999999999992e-244 < x < 1.50000000000000002e-285Initial program 10.4%
distribute-rgt1-in16.6%
associate-/l/16.6%
div-sub10.4%
associate-/l*10.4%
*-inverses16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 93.5%
Taylor expanded in x around 0 93.5%
Taylor expanded in wj around inf 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
*-commutative76.0%
associate-*r*76.0%
distribute-rgt-out76.0%
Simplified76.0%
if 1.50000000000000002e-285 < x Initial program 82.4%
distribute-rgt1-in82.4%
associate-/l/82.4%
div-sub82.4%
associate-/l*82.4%
*-inverses82.4%
/-rgt-identity82.4%
Simplified82.4%
Taylor expanded in wj around 0 81.6%
mul-1-neg81.6%
unsub-neg81.6%
*-commutative81.6%
Simplified81.6%
Taylor expanded in x around inf 91.5%
expm1-log1p-u86.8%
expm1-udef49.4%
sub-div49.4%
associate-*r/49.4%
+-commutative49.4%
Applied egg-rr49.4%
expm1-def86.8%
expm1-log1p91.5%
associate-/l*91.5%
Simplified91.5%
Final simplification87.2%
(FPCore (wj x) :precision binary64 (if (or (<= x -8e-245) (not (<= x 9.2e-290))) (+ x (* -2.0 (* wj x))) (* wj (+ wj (* x -2.0)))))
double code(double wj, double x) {
double tmp;
if ((x <= -8e-245) || !(x <= 9.2e-290)) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-8d-245)) .or. (.not. (x <= 9.2d-290))) then
tmp = x + ((-2.0d0) * (wj * x))
else
tmp = wj * (wj + (x * (-2.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if ((x <= -8e-245) || !(x <= 9.2e-290)) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -8e-245) or not (x <= 9.2e-290): tmp = x + (-2.0 * (wj * x)) else: tmp = wj * (wj + (x * -2.0)) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -8e-245) || !(x <= 9.2e-290)) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); else tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if ((x <= -8e-245) || ~((x <= 9.2e-290))) tmp = x + (-2.0 * (wj * x)); else tmp = wj * (wj + (x * -2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[Or[LessEqual[x, -8e-245], N[Not[LessEqual[x, 9.2e-290]], $MachinePrecision]], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{-245} \lor \neg \left(x \leq 9.2 \cdot 10^{-290}\right):\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\end{array}
\end{array}
if x < -7.9999999999999994e-245 or 9.2000000000000003e-290 < x Initial program 76.7%
distribute-rgt1-in78.0%
associate-/l/78.0%
div-sub76.7%
associate-/l*76.7%
*-inverses78.8%
/-rgt-identity78.8%
Simplified78.8%
Taylor expanded in wj around 0 87.8%
*-commutative87.8%
Simplified87.8%
if -7.9999999999999994e-245 < x < 9.2000000000000003e-290Initial program 10.4%
distribute-rgt1-in16.6%
associate-/l/16.6%
div-sub10.4%
associate-/l*10.4%
*-inverses16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 93.5%
Taylor expanded in x around 0 93.5%
Taylor expanded in wj around inf 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
*-commutative76.0%
associate-*r*76.0%
distribute-rgt-out76.0%
Simplified76.0%
Final simplification87.1%
(FPCore (wj x) :precision binary64 (if (or (<= x -8.5e-244) (not (<= x 9.8e-288))) (/ x (+ 1.0 (* wj 2.0))) (* wj (+ wj (* x -2.0)))))
double code(double wj, double x) {
double tmp;
if ((x <= -8.5e-244) || !(x <= 9.8e-288)) {
tmp = x / (1.0 + (wj * 2.0));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-8.5d-244)) .or. (.not. (x <= 9.8d-288))) then
tmp = x / (1.0d0 + (wj * 2.0d0))
else
tmp = wj * (wj + (x * (-2.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if ((x <= -8.5e-244) || !(x <= 9.8e-288)) {
tmp = x / (1.0 + (wj * 2.0));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -8.5e-244) or not (x <= 9.8e-288): tmp = x / (1.0 + (wj * 2.0)) else: tmp = wj * (wj + (x * -2.0)) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -8.5e-244) || !(x <= 9.8e-288)) tmp = Float64(x / Float64(1.0 + Float64(wj * 2.0))); else tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if ((x <= -8.5e-244) || ~((x <= 9.8e-288))) tmp = x / (1.0 + (wj * 2.0)); else tmp = wj * (wj + (x * -2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[Or[LessEqual[x, -8.5e-244], N[Not[LessEqual[x, 9.8e-288]], $MachinePrecision]], N[(x / N[(1.0 + N[(wj * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-244} \lor \neg \left(x \leq 9.8 \cdot 10^{-288}\right):\\
\;\;\;\;\frac{x}{1 + wj \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\end{array}
\end{array}
if x < -8.4999999999999999e-244 or 9.80000000000000053e-288 < x Initial program 76.7%
distribute-rgt1-in78.0%
associate-/l/78.0%
div-sub76.7%
associate-/l*76.7%
*-inverses78.8%
/-rgt-identity78.8%
Simplified78.8%
Taylor expanded in x around inf 89.8%
+-commutative89.8%
Simplified89.8%
Taylor expanded in wj around 0 87.9%
*-commutative87.9%
Simplified87.9%
if -8.4999999999999999e-244 < x < 9.80000000000000053e-288Initial program 10.4%
distribute-rgt1-in16.6%
associate-/l/16.6%
div-sub10.4%
associate-/l*10.4%
*-inverses16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 93.5%
Taylor expanded in x around 0 93.5%
Taylor expanded in wj around inf 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
*-commutative76.0%
associate-*r*76.0%
distribute-rgt-out76.0%
Simplified76.0%
Final simplification87.1%
(FPCore (wj x) :precision binary64 (if (<= x -7.5e-244) x (if (<= x 3.5e-291) (* wj (+ wj (* x -2.0))) x)))
double code(double wj, double x) {
double tmp;
if (x <= -7.5e-244) {
tmp = x;
} else if (x <= 3.5e-291) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-7.5d-244)) then
tmp = x
else if (x <= 3.5d-291) then
tmp = wj * (wj + (x * (-2.0d0)))
else
tmp = x
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= -7.5e-244) {
tmp = x;
} else if (x <= 3.5e-291) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x;
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -7.5e-244: tmp = x elif x <= 3.5e-291: tmp = wj * (wj + (x * -2.0)) else: tmp = x return tmp
function code(wj, x) tmp = 0.0 if (x <= -7.5e-244) tmp = x; elseif (x <= 3.5e-291) tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); else tmp = x; end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= -7.5e-244) tmp = x; elseif (x <= 3.5e-291) tmp = wj * (wj + (x * -2.0)); else tmp = x; end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -7.5e-244], x, If[LessEqual[x, 3.5e-291], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-244}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{-291}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.5000000000000003e-244 or 3.49999999999999996e-291 < x Initial program 76.7%
distribute-rgt1-in78.0%
associate-/l/78.0%
div-sub76.7%
associate-/l*76.7%
*-inverses78.8%
/-rgt-identity78.8%
Simplified78.8%
Taylor expanded in wj around 0 87.1%
if -7.5000000000000003e-244 < x < 3.49999999999999996e-291Initial program 10.4%
distribute-rgt1-in16.6%
associate-/l/16.6%
div-sub10.4%
associate-/l*10.4%
*-inverses16.6%
/-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 93.5%
Taylor expanded in x around 0 93.5%
Taylor expanded in wj around inf 76.0%
+-commutative76.0%
unpow276.0%
associate-*r*76.0%
*-commutative76.0%
associate-*r*76.0%
distribute-rgt-out76.0%
Simplified76.0%
Final simplification86.4%
(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 72.6%
distribute-rgt1-in74.1%
associate-/l/74.2%
div-sub72.6%
associate-/l*72.6%
*-inverses74.9%
/-rgt-identity74.9%
Simplified74.9%
Taylor expanded in wj around inf 4.1%
Final simplification4.1%
(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 72.6%
distribute-rgt1-in74.1%
associate-/l/74.2%
div-sub72.6%
associate-/l*72.6%
*-inverses74.9%
/-rgt-identity74.9%
Simplified74.9%
Taylor expanded in wj around 0 83.1%
Final simplification83.1%
(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 2024021
(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))))))