
(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 12 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))) (t_1 (* wj (exp wj))))
(if (<= (+ wj (/ (- x t_1) (+ (exp wj) t_1))) 4e-17)
(+
(*
(pow wj 3.0)
(- (- (- -1.0 (* -2.0 t_0)) (* x -3.0)) (* x 0.6666666666666666)))
(+ (* (- 1.0 t_0) (pow wj 2.0)) (+ x (* -2.0 (* wj x)))))
(+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0))))))
double code(double wj, double x) {
double t_0 = (x * -4.0) + (x * 1.5);
double t_1 = wj * exp(wj);
double tmp;
if ((wj + ((x - t_1) / (exp(wj) + t_1))) <= 4e-17) {
tmp = (pow(wj, 3.0) * (((-1.0 - (-2.0 * t_0)) - (x * -3.0)) - (x * 0.6666666666666666))) + (((1.0 - t_0) * pow(wj, 2.0)) + (x + (-2.0 * (wj * x))));
} 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 = (x * (-4.0d0)) + (x * 1.5d0)
t_1 = wj * exp(wj)
if ((wj + ((x - t_1) / (exp(wj) + t_1))) <= 4d-17) then
tmp = ((wj ** 3.0d0) * ((((-1.0d0) - ((-2.0d0) * t_0)) - (x * (-3.0d0))) - (x * 0.6666666666666666d0))) + (((1.0d0 - t_0) * (wj ** 2.0d0)) + (x + ((-2.0d0) * (wj * x))))
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 = (x * -4.0) + (x * 1.5);
double t_1 = wj * Math.exp(wj);
double tmp;
if ((wj + ((x - t_1) / (Math.exp(wj) + t_1))) <= 4e-17) {
tmp = (Math.pow(wj, 3.0) * (((-1.0 - (-2.0 * t_0)) - (x * -3.0)) - (x * 0.6666666666666666))) + (((1.0 - t_0) * Math.pow(wj, 2.0)) + (x + (-2.0 * (wj * x))));
} else {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): t_0 = (x * -4.0) + (x * 1.5) t_1 = wj * math.exp(wj) tmp = 0 if (wj + ((x - t_1) / (math.exp(wj) + t_1))) <= 4e-17: tmp = (math.pow(wj, 3.0) * (((-1.0 - (-2.0 * t_0)) - (x * -3.0)) - (x * 0.6666666666666666))) + (((1.0 - t_0) * math.pow(wj, 2.0)) + (x + (-2.0 * (wj * x)))) else: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) t_0 = Float64(Float64(x * -4.0) + Float64(x * 1.5)) t_1 = Float64(wj * exp(wj)) tmp = 0.0 if (Float64(wj + Float64(Float64(x - t_1) / Float64(exp(wj) + t_1))) <= 4e-17) tmp = Float64(Float64((wj ^ 3.0) * Float64(Float64(Float64(-1.0 - Float64(-2.0 * t_0)) - Float64(x * -3.0)) - Float64(x * 0.6666666666666666))) + Float64(Float64(Float64(1.0 - t_0) * (wj ^ 2.0)) + Float64(x + Float64(-2.0 * Float64(wj * x))))); 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 = (x * -4.0) + (x * 1.5); t_1 = wj * exp(wj); tmp = 0.0; if ((wj + ((x - t_1) / (exp(wj) + t_1))) <= 4e-17) tmp = ((wj ^ 3.0) * (((-1.0 - (-2.0 * t_0)) - (x * -3.0)) - (x * 0.6666666666666666))) + (((1.0 - t_0) * (wj ^ 2.0)) + (x + (-2.0 * (wj * x)))); else tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.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]}, Block[{t$95$1 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$1), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e-17], N[(N[(N[Power[wj, 3.0], $MachinePrecision] * N[(N[(N[(-1.0 - N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] - N[(x * -3.0), $MachinePrecision]), $MachinePrecision] - N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 - t$95$0), $MachinePrecision] * N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision] + N[(x + N[(-2.0 * N[(wj * x), $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 := x \cdot -4 + x \cdot 1.5\\
t_1 := wj \cdot e^{wj}\\
\mathbf{if}\;wj + \frac{x - t_1}{e^{wj} + t_1} \leq 4 \cdot 10^{-17}:\\
\;\;\;\;{wj}^{3} \cdot \left(\left(\left(-1 - -2 \cdot t_0\right) - x \cdot -3\right) - x \cdot 0.6666666666666666\right) + \left(\left(1 - t_0\right) \cdot {wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\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))))) < 4.00000000000000029e-17Initial program 70.9%
div-sub70.9%
associate-/l*70.9%
distribute-rgt1-in70.9%
associate-/l*70.9%
*-inverses70.9%
/-rgt-identity70.9%
distribute-rgt1-in71.5%
associate-/l/71.5%
div-sub71.5%
Simplified71.5%
Taylor expanded in wj around 0 99.4%
if 4.00000000000000029e-17 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 97.7%
div-sub97.7%
associate-/l*97.7%
distribute-rgt1-in97.7%
associate-/l*97.7%
*-inverses99.1%
/-rgt-identity99.1%
distribute-rgt1-in99.1%
associate-/l/99.1%
div-sub99.1%
Simplified99.1%
Final simplification99.3%
(FPCore (wj x) :precision binary64 (- (+ (+ x (* -2.0 (* wj x))) (* wj wj)) (pow wj 3.0)))
double code(double wj, double x) {
return ((x + (-2.0 * (wj * x))) + (wj * wj)) - pow(wj, 3.0);
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = ((x + ((-2.0d0) * (wj * x))) + (wj * wj)) - (wj ** 3.0d0)
end function
public static double code(double wj, double x) {
return ((x + (-2.0 * (wj * x))) + (wj * wj)) - Math.pow(wj, 3.0);
}
def code(wj, x): return ((x + (-2.0 * (wj * x))) + (wj * wj)) - math.pow(wj, 3.0)
function code(wj, x) return Float64(Float64(Float64(x + Float64(-2.0 * Float64(wj * x))) + Float64(wj * wj)) - (wj ^ 3.0)) end
function tmp = code(wj, x) tmp = ((x + (-2.0 * (wj * x))) + (wj * wj)) - (wj ^ 3.0); end
code[wj_, x_] := N[(N[(N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(wj * wj), $MachinePrecision]), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + -2 \cdot \left(wj \cdot x\right)\right) + wj \cdot wj\right) - {wj}^{3}
\end{array}
Initial program 78.6%
div-sub78.6%
associate-/l*78.5%
distribute-rgt1-in78.6%
associate-/l*78.6%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in79.3%
associate-/l/79.4%
div-sub79.4%
Simplified79.4%
Taylor expanded in wj around 0 97.5%
Taylor expanded in x around 0 97.2%
unpow297.2%
Simplified97.2%
Taylor expanded in x around 0 97.2%
Final simplification97.2%
(FPCore (wj x) :precision binary64 (if (or (<= x -3.6e-193) (not (<= x 7.4e-289))) (* (/ x (+ wj 1.0)) (/ 1.0 (exp wj))) (- (* wj wj) (pow wj 3.0))))
double code(double wj, double x) {
double tmp;
if ((x <= -3.6e-193) || !(x <= 7.4e-289)) {
tmp = (x / (wj + 1.0)) * (1.0 / exp(wj));
} else {
tmp = (wj * wj) - 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 ((x <= (-3.6d-193)) .or. (.not. (x <= 7.4d-289))) then
tmp = (x / (wj + 1.0d0)) * (1.0d0 / exp(wj))
else
tmp = (wj * wj) - (wj ** 3.0d0)
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if ((x <= -3.6e-193) || !(x <= 7.4e-289)) {
tmp = (x / (wj + 1.0)) * (1.0 / Math.exp(wj));
} else {
tmp = (wj * wj) - Math.pow(wj, 3.0);
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -3.6e-193) or not (x <= 7.4e-289): tmp = (x / (wj + 1.0)) * (1.0 / math.exp(wj)) else: tmp = (wj * wj) - math.pow(wj, 3.0) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -3.6e-193) || !(x <= 7.4e-289)) tmp = Float64(Float64(x / Float64(wj + 1.0)) * Float64(1.0 / exp(wj))); else tmp = Float64(Float64(wj * wj) - (wj ^ 3.0)); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if ((x <= -3.6e-193) || ~((x <= 7.4e-289))) tmp = (x / (wj + 1.0)) * (1.0 / exp(wj)); else tmp = (wj * wj) - (wj ^ 3.0); end tmp_2 = tmp; end
code[wj_, x_] := If[Or[LessEqual[x, -3.6e-193], N[Not[LessEqual[x, 7.4e-289]], $MachinePrecision]], N[(N[(x / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(wj * wj), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{-193} \lor \neg \left(x \leq 7.4 \cdot 10^{-289}\right):\\
\;\;\;\;\frac{x}{wj + 1} \cdot \frac{1}{e^{wj}}\\
\mathbf{else}:\\
\;\;\;\;wj \cdot wj - {wj}^{3}\\
\end{array}
\end{array}
if x < -3.5999999999999999e-193 or 7.39999999999999977e-289 < x Initial program 86.7%
div-sub86.7%
associate-/l*86.7%
distribute-rgt1-in86.7%
associate-/l*86.7%
*-inverses86.7%
/-rgt-identity86.7%
distribute-rgt1-in87.1%
associate-/l/87.2%
div-sub87.2%
Simplified87.2%
clear-num87.0%
inv-pow87.0%
Applied egg-rr87.0%
unpow-187.0%
Simplified87.0%
Taylor expanded in x around inf 92.3%
+-commutative92.3%
Simplified92.3%
associate-/r*92.3%
div-inv92.3%
+-commutative92.3%
Applied egg-rr92.3%
if -3.5999999999999999e-193 < x < 7.39999999999999977e-289Initial program 23.5%
div-sub23.5%
associate-/l*23.4%
distribute-rgt1-in23.5%
associate-/l*23.5%
*-inverses26.5%
/-rgt-identity26.5%
distribute-rgt1-in26.5%
associate-/l/26.5%
div-sub26.5%
Simplified26.5%
Taylor expanded in wj around 0 94.9%
Taylor expanded in x around 0 94.9%
unpow294.9%
Simplified94.9%
Taylor expanded in x around 0 94.9%
Taylor expanded in wj around inf 68.9%
mul-1-neg68.9%
unsub-neg68.9%
unpow268.9%
Simplified68.9%
Final simplification89.3%
(FPCore (wj x) :precision binary64 (if (<= wj -5.7e-9) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0))) (+ (pow wj 2.0) (+ x (* -2.0 (* wj x))))))
double code(double wj, double x) {
double tmp;
if (wj <= -5.7e-9) {
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = pow(wj, 2.0) + (x + (-2.0 * (wj * x)));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= (-5.7d-9)) then
tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0d0))
else
tmp = (wj ** 2.0d0) + (x + ((-2.0d0) * (wj * x)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -5.7e-9) {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
} else {
tmp = Math.pow(wj, 2.0) + (x + (-2.0 * (wj * x)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -5.7e-9: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) else: tmp = math.pow(wj, 2.0) + (x + (-2.0 * (wj * x))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -5.7e-9) tmp = Float64(wj + Float64(Float64(Float64(x / exp(wj)) - wj) / Float64(wj + 1.0))); else tmp = Float64((wj ^ 2.0) + Float64(x + Float64(-2.0 * Float64(wj * x)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -5.7e-9) tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); else tmp = (wj ^ 2.0) + (x + (-2.0 * (wj * x))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -5.7e-9], N[(wj + N[(N[(N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[wj, 2.0], $MachinePrecision] + N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -5.7 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;{wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)\\
\end{array}
\end{array}
if wj < -5.6999999999999998e-9Initial program 79.0%
div-sub79.0%
associate-/l*79.0%
distribute-rgt1-in79.5%
associate-/l*79.5%
*-inverses79.5%
/-rgt-identity79.5%
distribute-rgt1-in93.6%
associate-/l/93.8%
div-sub93.8%
Simplified93.8%
if -5.6999999999999998e-9 < wj Initial program 78.5%
div-sub78.5%
associate-/l*78.5%
distribute-rgt1-in78.5%
associate-/l*78.5%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in78.9%
associate-/l/78.9%
div-sub78.9%
Simplified78.9%
Taylor expanded in wj around 0 99.0%
Taylor expanded in x around 0 98.8%
unpow298.8%
Simplified98.8%
Taylor expanded in x around 0 98.8%
Taylor expanded in wj around 0 98.0%
Final simplification97.9%
(FPCore (wj x) :precision binary64 (if (or (<= x -5.4e-193) (not (<= x 1.12e-274))) (/ x (* (exp wj) (+ wj 1.0))) (- (* wj wj) (pow wj 3.0))))
double code(double wj, double x) {
double tmp;
if ((x <= -5.4e-193) || !(x <= 1.12e-274)) {
tmp = x / (exp(wj) * (wj + 1.0));
} else {
tmp = (wj * wj) - 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 ((x <= (-5.4d-193)) .or. (.not. (x <= 1.12d-274))) then
tmp = x / (exp(wj) * (wj + 1.0d0))
else
tmp = (wj * wj) - (wj ** 3.0d0)
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if ((x <= -5.4e-193) || !(x <= 1.12e-274)) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = (wj * wj) - Math.pow(wj, 3.0);
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -5.4e-193) or not (x <= 1.12e-274): tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = (wj * wj) - math.pow(wj, 3.0) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -5.4e-193) || !(x <= 1.12e-274)) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); else tmp = Float64(Float64(wj * wj) - (wj ^ 3.0)); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if ((x <= -5.4e-193) || ~((x <= 1.12e-274))) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = (wj * wj) - (wj ^ 3.0); end tmp_2 = tmp; end
code[wj_, x_] := If[Or[LessEqual[x, -5.4e-193], N[Not[LessEqual[x, 1.12e-274]], $MachinePrecision]], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(wj * wj), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.4 \cdot 10^{-193} \lor \neg \left(x \leq 1.12 \cdot 10^{-274}\right):\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;wj \cdot wj - {wj}^{3}\\
\end{array}
\end{array}
if x < -5.3999999999999998e-193 or 1.11999999999999998e-274 < x Initial program 86.7%
div-sub86.7%
associate-/l*86.7%
distribute-rgt1-in86.7%
associate-/l*86.7%
*-inverses86.7%
/-rgt-identity86.7%
distribute-rgt1-in87.1%
associate-/l/87.2%
div-sub87.2%
Simplified87.2%
Taylor expanded in x around inf 92.3%
if -5.3999999999999998e-193 < x < 1.11999999999999998e-274Initial program 23.5%
div-sub23.5%
associate-/l*23.4%
distribute-rgt1-in23.5%
associate-/l*23.5%
*-inverses26.5%
/-rgt-identity26.5%
distribute-rgt1-in26.5%
associate-/l/26.5%
div-sub26.5%
Simplified26.5%
Taylor expanded in wj around 0 94.9%
Taylor expanded in x around 0 94.9%
unpow294.9%
Simplified94.9%
Taylor expanded in x around 0 94.9%
Taylor expanded in wj around inf 68.9%
mul-1-neg68.9%
unsub-neg68.9%
unpow268.9%
Simplified68.9%
Final simplification89.3%
(FPCore (wj x) :precision binary64 (if (<= x -8e-196) (+ wj (/ (- (- x (* wj x)) wj) (+ wj 1.0))) (if (<= x 7.5e-284) (- (* wj wj) (pow wj 3.0)) (/ x (+ 1.0 (* wj 2.0))))))
double code(double wj, double x) {
double tmp;
if (x <= -8e-196) {
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0));
} else if (x <= 7.5e-284) {
tmp = (wj * wj) - pow(wj, 3.0);
} else {
tmp = x / (1.0 + (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 (x <= (-8d-196)) then
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0d0))
else if (x <= 7.5d-284) then
tmp = (wj * wj) - (wj ** 3.0d0)
else
tmp = x / (1.0d0 + (wj * 2.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= -8e-196) {
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0));
} else if (x <= 7.5e-284) {
tmp = (wj * wj) - Math.pow(wj, 3.0);
} else {
tmp = x / (1.0 + (wj * 2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -8e-196: tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0)) elif x <= 7.5e-284: tmp = (wj * wj) - math.pow(wj, 3.0) else: tmp = x / (1.0 + (wj * 2.0)) return tmp
function code(wj, x) tmp = 0.0 if (x <= -8e-196) tmp = Float64(wj + Float64(Float64(Float64(x - Float64(wj * x)) - wj) / Float64(wj + 1.0))); elseif (x <= 7.5e-284) tmp = Float64(Float64(wj * wj) - (wj ^ 3.0)); else tmp = Float64(x / Float64(1.0 + Float64(wj * 2.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= -8e-196) tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0)); elseif (x <= 7.5e-284) tmp = (wj * wj) - (wj ^ 3.0); else tmp = x / (1.0 + (wj * 2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -8e-196], N[(wj + N[(N[(N[(x - N[(wj * x), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e-284], N[(N[(wj * wj), $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision], N[(x / N[(1.0 + N[(wj * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{-196}:\\
\;\;\;\;wj + \frac{\left(x - wj \cdot x\right) - wj}{wj + 1}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-284}:\\
\;\;\;\;wj \cdot wj - {wj}^{3}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 + wj \cdot 2}\\
\end{array}
\end{array}
if x < -8.0000000000000004e-196Initial program 90.5%
div-sub90.5%
associate-/l*90.5%
distribute-rgt1-in90.5%
associate-/l*90.5%
*-inverses91.5%
/-rgt-identity91.5%
distribute-rgt1-in92.5%
associate-/l/92.5%
div-sub92.5%
Simplified92.5%
Taylor expanded in wj around 0 89.2%
+-commutative89.2%
mul-1-neg89.2%
unsub-neg89.2%
*-commutative89.2%
Simplified89.2%
if -8.0000000000000004e-196 < x < 7.4999999999999999e-284Initial program 24.9%
div-sub24.9%
associate-/l*24.7%
distribute-rgt1-in24.8%
associate-/l*24.8%
*-inverses24.8%
/-rgt-identity24.8%
distribute-rgt1-in24.8%
associate-/l/24.8%
div-sub24.8%
Simplified24.8%
Taylor expanded in wj around 0 97.8%
Taylor expanded in x around 0 97.8%
unpow297.8%
Simplified97.8%
Taylor expanded in x around 0 97.8%
Taylor expanded in wj around inf 71.2%
mul-1-neg71.2%
unsub-neg71.2%
unpow271.2%
Simplified71.2%
if 7.4999999999999999e-284 < x Initial program 82.2%
div-sub82.2%
associate-/l*82.2%
distribute-rgt1-in82.2%
associate-/l*82.2%
*-inverses82.2%
/-rgt-identity82.2%
distribute-rgt1-in82.2%
associate-/l/82.2%
div-sub82.2%
Simplified82.2%
clear-num82.0%
inv-pow82.0%
Applied egg-rr82.0%
unpow-182.0%
Simplified82.0%
Taylor expanded in x around inf 91.6%
+-commutative91.6%
Simplified91.6%
Taylor expanded in wj around 0 90.4%
*-commutative90.4%
Simplified90.4%
Final simplification87.6%
(FPCore (wj x) :precision binary64 (+ (pow wj 2.0) (+ x (* -2.0 (* wj x)))))
double code(double wj, double x) {
return pow(wj, 2.0) + (x + (-2.0 * (wj * x)));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = (wj ** 2.0d0) + (x + ((-2.0d0) * (wj * x)))
end function
public static double code(double wj, double x) {
return Math.pow(wj, 2.0) + (x + (-2.0 * (wj * x)));
}
def code(wj, x): return math.pow(wj, 2.0) + (x + (-2.0 * (wj * x)))
function code(wj, x) return Float64((wj ^ 2.0) + Float64(x + Float64(-2.0 * Float64(wj * x)))) end
function tmp = code(wj, x) tmp = (wj ^ 2.0) + (x + (-2.0 * (wj * x))); end
code[wj_, x_] := N[(N[Power[wj, 2.0], $MachinePrecision] + N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{wj}^{2} + \left(x + -2 \cdot \left(wj \cdot x\right)\right)
\end{array}
Initial program 78.6%
div-sub78.6%
associate-/l*78.5%
distribute-rgt1-in78.6%
associate-/l*78.6%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in79.3%
associate-/l/79.4%
div-sub79.4%
Simplified79.4%
Taylor expanded in wj around 0 97.5%
Taylor expanded in x around 0 97.2%
unpow297.2%
Simplified97.2%
Taylor expanded in x around 0 97.2%
Taylor expanded in wj around 0 96.2%
Final simplification96.2%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (/ (+ (* wj x) (- wj x)) (+ wj 1.0))))
(if (<= wj 9.6e-15)
(* x (/ (- 1.0 wj) (+ wj 1.0)))
(/
(+ (* wj wj) (* t_0 (/ (- (- x wj) (* wj x)) (+ wj 1.0))))
(+ wj t_0)))))
double code(double wj, double x) {
double t_0 = ((wj * x) + (wj - x)) / (wj + 1.0);
double tmp;
if (wj <= 9.6e-15) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = ((wj * wj) + (t_0 * (((x - wj) - (wj * x)) / (wj + 1.0)))) / (wj + 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 = ((wj * x) + (wj - x)) / (wj + 1.0d0)
if (wj <= 9.6d-15) then
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
else
tmp = ((wj * wj) + (t_0 * (((x - wj) - (wj * x)) / (wj + 1.0d0)))) / (wj + t_0)
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = ((wj * x) + (wj - x)) / (wj + 1.0);
double tmp;
if (wj <= 9.6e-15) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = ((wj * wj) + (t_0 * (((x - wj) - (wj * x)) / (wj + 1.0)))) / (wj + t_0);
}
return tmp;
}
def code(wj, x): t_0 = ((wj * x) + (wj - x)) / (wj + 1.0) tmp = 0 if wj <= 9.6e-15: tmp = x * ((1.0 - wj) / (wj + 1.0)) else: tmp = ((wj * wj) + (t_0 * (((x - wj) - (wj * x)) / (wj + 1.0)))) / (wj + t_0) return tmp
function code(wj, x) t_0 = Float64(Float64(Float64(wj * x) + Float64(wj - x)) / Float64(wj + 1.0)) tmp = 0.0 if (wj <= 9.6e-15) tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); else tmp = Float64(Float64(Float64(wj * wj) + Float64(t_0 * Float64(Float64(Float64(x - wj) - Float64(wj * x)) / Float64(wj + 1.0)))) / Float64(wj + t_0)); end return tmp end
function tmp_2 = code(wj, x) t_0 = ((wj * x) + (wj - x)) / (wj + 1.0); tmp = 0.0; if (wj <= 9.6e-15) tmp = x * ((1.0 - wj) / (wj + 1.0)); else tmp = ((wj * wj) + (t_0 * (((x - wj) - (wj * x)) / (wj + 1.0)))) / (wj + t_0); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(N[(N[(wj * x), $MachinePrecision] + N[(wj - x), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, 9.6e-15], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(wj * wj), $MachinePrecision] + N[(t$95$0 * N[(N[(N[(x - wj), $MachinePrecision] - N[(wj * x), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{wj \cdot x + \left(wj - x\right)}{wj + 1}\\
\mathbf{if}\;wj \leq 9.6 \cdot 10^{-15}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{wj \cdot wj + t_0 \cdot \frac{\left(x - wj\right) - wj \cdot x}{wj + 1}}{wj + t_0}\\
\end{array}
\end{array}
if wj < 9.5999999999999998e-15Initial program 79.2%
div-sub79.2%
associate-/l*79.2%
distribute-rgt1-in79.2%
associate-/l*79.2%
*-inverses79.2%
/-rgt-identity79.2%
distribute-rgt1-in79.6%
associate-/l/79.6%
div-sub79.6%
Simplified79.6%
Taylor expanded in wj around 0 78.2%
+-commutative78.2%
mul-1-neg78.2%
unsub-neg78.2%
*-commutative78.2%
Simplified78.2%
Taylor expanded in x around inf 75.7%
associate-/l*75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in x around -inf 84.9%
sub-neg84.9%
metadata-eval84.9%
*-commutative84.9%
associate-*r/84.9%
neg-mul-184.9%
distribute-rgt-neg-in84.9%
distribute-neg-frac84.9%
+-commutative84.9%
distribute-neg-in84.9%
metadata-eval84.9%
unsub-neg84.9%
Simplified84.9%
if 9.5999999999999998e-15 < wj Initial program 64.3%
div-sub64.3%
associate-/l*64.3%
distribute-rgt1-in64.3%
associate-/l*64.3%
*-inverses73.4%
/-rgt-identity73.4%
distribute-rgt1-in73.4%
associate-/l/73.7%
div-sub73.7%
Simplified73.7%
Taylor expanded in wj around 0 60.0%
+-commutative60.0%
mul-1-neg60.0%
unsub-neg60.0%
*-commutative60.0%
Simplified60.0%
flip--61.2%
associate--r-61.2%
+-commutative61.2%
associate--r-61.2%
+-commutative61.2%
associate--r-61.2%
+-commutative61.2%
Applied egg-rr61.2%
Final simplification83.9%
(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 78.6%
div-sub78.6%
associate-/l*78.5%
distribute-rgt1-in78.6%
associate-/l*78.6%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in79.3%
associate-/l/79.4%
div-sub79.4%
Simplified79.4%
Taylor expanded in wj around 0 82.3%
Final simplification82.3%
(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}
\\
\frac{x}{1 + wj \cdot 2}
\end{array}
Initial program 78.6%
div-sub78.6%
associate-/l*78.5%
distribute-rgt1-in78.6%
associate-/l*78.6%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in79.3%
associate-/l/79.4%
div-sub79.4%
Simplified79.4%
clear-num79.2%
inv-pow79.2%
Applied egg-rr79.2%
unpow-179.2%
Simplified79.2%
Taylor expanded in x around inf 84.2%
+-commutative84.2%
Simplified84.2%
Taylor expanded in wj around 0 82.4%
*-commutative82.4%
Simplified82.4%
Final simplification82.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 78.6%
div-sub78.6%
associate-/l*78.5%
distribute-rgt1-in78.6%
associate-/l*78.6%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in79.3%
associate-/l/79.4%
div-sub79.4%
Simplified79.4%
Taylor expanded in wj around inf 3.8%
Final simplification3.8%
(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 78.6%
div-sub78.6%
associate-/l*78.5%
distribute-rgt1-in78.6%
associate-/l*78.6%
*-inverses78.9%
/-rgt-identity78.9%
distribute-rgt1-in79.3%
associate-/l/79.4%
div-sub79.4%
Simplified79.4%
Taylor expanded in wj around 0 81.7%
Final simplification81.7%
(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 2023274
(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))))))