
(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 15 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))))
(if (<= (+ wj (/ (- x t_0) (+ (exp wj) t_0))) 5e-20)
(+
x
(+
(* -2.0 (* wj x))
(- (* (pow wj 2.0) (- 1.0 (+ (* x -4.0) (* x 1.5)))) (pow wj 3.0))))
(+ wj (* (/ (- wj (/ x (exp wj))) (fma wj wj -1.0)) (- 1.0 wj))))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double tmp;
if ((wj + ((x - t_0) / (exp(wj) + t_0))) <= 5e-20) {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))) - pow(wj, 3.0)));
} else {
tmp = wj + (((wj - (x / exp(wj))) / fma(wj, wj, -1.0)) * (1.0 - wj));
}
return tmp;
}
function code(wj, x) t_0 = Float64(wj * exp(wj)) tmp = 0.0 if (Float64(wj + Float64(Float64(x - t_0) / Float64(exp(wj) + t_0))) <= 5e-20) 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)))); else tmp = Float64(wj + Float64(Float64(Float64(wj - Float64(x / exp(wj))) / fma(wj, wj, -1.0)) * Float64(1.0 - wj))); end return tmp end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj + N[(N[(x - t$95$0), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e-20], 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], N[(wj + N[(N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj * wj + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
\mathbf{if}\;wj + \frac{x - t_0}{e^{wj} + t_0} \leq 5 \cdot 10^{-20}:\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\
\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.9999999999999999e-20Initial program 71.9%
distribute-rgt1-in71.9%
associate-/l/71.9%
div-sub71.9%
associate-/l*71.9%
*-inverses71.9%
/-rgt-identity71.9%
Simplified71.9%
Taylor expanded in wj around 0 98.9%
Taylor expanded in x around 0 98.9%
if 4.9999999999999999e-20 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 96.9%
distribute-rgt1-in96.8%
associate-/l/96.7%
div-sub96.7%
associate-/l*96.7%
*-inverses99.4%
/-rgt-identity99.4%
Simplified99.4%
flip-+99.4%
associate-/r/99.6%
metadata-eval99.6%
fma-neg99.6%
metadata-eval99.6%
sub-neg99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.1%
(FPCore (wj x) :precision binary64 (if (<= wj 1.4e-10) (+ x (- (pow wj 2.0) (pow wj 3.0))) (+ wj (* (/ (- wj (/ x (exp wj))) (fma wj wj -1.0)) (- 1.0 wj)))))
double code(double wj, double x) {
double tmp;
if (wj <= 1.4e-10) {
tmp = x + (pow(wj, 2.0) - pow(wj, 3.0));
} else {
tmp = wj + (((wj - (x / exp(wj))) / fma(wj, wj, -1.0)) * (1.0 - wj));
}
return tmp;
}
function code(wj, x) tmp = 0.0 if (wj <= 1.4e-10) tmp = Float64(x + Float64((wj ^ 2.0) - (wj ^ 3.0))); else tmp = Float64(wj + Float64(Float64(Float64(wj - Float64(x / exp(wj))) / fma(wj, wj, -1.0)) * Float64(1.0 - wj))); end return tmp end
code[wj_, x_] := If[LessEqual[wj, 1.4e-10], N[(x + N[(N[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj * wj + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 1.4 \cdot 10^{-10}:\\
\;\;\;\;x + \left({wj}^{2} - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(wj, wj, -1\right)} \cdot \left(1 - wj\right)\\
\end{array}
\end{array}
if wj < 1.40000000000000008e-10Initial program 79.6%
distribute-rgt1-in79.6%
associate-/l/79.6%
div-sub79.6%
associate-/l*79.6%
*-inverses79.6%
/-rgt-identity79.6%
Simplified79.6%
Taylor expanded in wj around 0 98.8%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 99.1%
+-commutative99.1%
mul-1-neg99.1%
unsub-neg99.1%
Simplified99.1%
if 1.40000000000000008e-10 < wj Initial program 70.2%
distribute-rgt1-in69.3%
associate-/l/69.3%
div-sub69.3%
associate-/l*69.3%
*-inverses94.3%
/-rgt-identity94.3%
Simplified94.3%
flip-+94.1%
associate-/r/95.9%
metadata-eval95.9%
fma-neg95.9%
metadata-eval95.9%
sub-neg95.9%
metadata-eval95.9%
Applied egg-rr95.9%
Final simplification99.0%
(FPCore (wj x) :precision binary64 (if (<= wj 1.6e-10) (+ x (- (pow wj 2.0) (pow wj 3.0))) (- wj (pow (/ (+ wj 1.0) (- wj (/ x (exp wj)))) -1.0))))
double code(double wj, double x) {
double tmp;
if (wj <= 1.6e-10) {
tmp = x + (pow(wj, 2.0) - pow(wj, 3.0));
} else {
tmp = wj - pow(((wj + 1.0) / (wj - (x / exp(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.6d-10) then
tmp = x + ((wj ** 2.0d0) - (wj ** 3.0d0))
else
tmp = wj - (((wj + 1.0d0) / (wj - (x / exp(wj)))) ** (-1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 1.6e-10) {
tmp = x + (Math.pow(wj, 2.0) - Math.pow(wj, 3.0));
} else {
tmp = wj - Math.pow(((wj + 1.0) / (wj - (x / Math.exp(wj)))), -1.0);
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 1.6e-10: tmp = x + (math.pow(wj, 2.0) - math.pow(wj, 3.0)) else: tmp = wj - math.pow(((wj + 1.0) / (wj - (x / math.exp(wj)))), -1.0) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 1.6e-10) tmp = Float64(x + Float64((wj ^ 2.0) - (wj ^ 3.0))); else tmp = Float64(wj - (Float64(Float64(wj + 1.0) / Float64(wj - Float64(x / exp(wj)))) ^ -1.0)); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 1.6e-10) tmp = x + ((wj ^ 2.0) - (wj ^ 3.0)); else tmp = wj - (((wj + 1.0) / (wj - (x / exp(wj)))) ^ -1.0); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 1.6e-10], N[(x + N[(N[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[Power[N[(N[(wj + 1.0), $MachinePrecision] / N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 1.6 \cdot 10^{-10}:\\
\;\;\;\;x + \left({wj}^{2} - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;wj - {\left(\frac{wj + 1}{wj - \frac{x}{e^{wj}}}\right)}^{-1}\\
\end{array}
\end{array}
if wj < 1.5999999999999999e-10Initial program 79.6%
distribute-rgt1-in79.6%
associate-/l/79.6%
div-sub79.6%
associate-/l*79.6%
*-inverses79.6%
/-rgt-identity79.6%
Simplified79.6%
Taylor expanded in wj around 0 98.8%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 99.1%
+-commutative99.1%
mul-1-neg99.1%
unsub-neg99.1%
Simplified99.1%
if 1.5999999999999999e-10 < wj Initial program 70.2%
distribute-rgt1-in69.3%
associate-/l/69.3%
div-sub69.3%
associate-/l*69.3%
*-inverses94.3%
/-rgt-identity94.3%
Simplified94.3%
clear-num94.5%
inv-pow94.5%
Applied egg-rr94.5%
Final simplification99.0%
(FPCore (wj x) :precision binary64 (if (<= wj 2.25e-10) (+ 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 (wj <= 2.25e-10) {
tmp = 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 (wj <= 2.25d-10) then
tmp = 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 (wj <= 2.25e-10) {
tmp = 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 wj <= 2.25e-10: tmp = 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 (wj <= 2.25e-10) tmp = Float64(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 (wj <= 2.25e-10) tmp = 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[wj, 2.25e-10], N[(x + N[(N[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $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}\;wj \leq 2.25 \cdot 10^{-10}:\\
\;\;\;\;x + \left({wj}^{2} - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 2.25e-10Initial program 79.6%
distribute-rgt1-in79.6%
associate-/l/79.6%
div-sub79.6%
associate-/l*79.6%
*-inverses79.6%
/-rgt-identity79.6%
Simplified79.6%
Taylor expanded in wj around 0 98.8%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 99.1%
+-commutative99.1%
mul-1-neg99.1%
unsub-neg99.1%
Simplified99.1%
if 2.25e-10 < wj Initial program 70.2%
distribute-rgt1-in69.3%
associate-/l/69.3%
div-sub69.3%
associate-/l*69.3%
*-inverses94.3%
/-rgt-identity94.3%
Simplified94.3%
Final simplification99.0%
(FPCore (wj x) :precision binary64 (if (<= wj 2.15e-10) (+ x (* wj (- wj (pow wj 2.0)))) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 2.15e-10) {
tmp = x + (wj * (wj - pow(wj, 2.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 (wj <= 2.15d-10) then
tmp = x + (wj * (wj - (wj ** 2.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 (wj <= 2.15e-10) {
tmp = x + (wj * (wj - Math.pow(wj, 2.0)));
} else {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 2.15e-10: tmp = x + (wj * (wj - math.pow(wj, 2.0))) else: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 2.15e-10) tmp = Float64(x + Float64(wj * Float64(wj - (wj ^ 2.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 (wj <= 2.15e-10) tmp = x + (wj * (wj - (wj ^ 2.0))); else tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 2.15e-10], N[(x + N[(wj * N[(wj - N[Power[wj, 2.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}\;wj \leq 2.15 \cdot 10^{-10}:\\
\;\;\;\;x + wj \cdot \left(wj - {wj}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 2.15000000000000007e-10Initial program 79.6%
distribute-rgt1-in79.6%
associate-/l/79.6%
div-sub79.6%
associate-/l*79.6%
*-inverses79.6%
/-rgt-identity79.6%
Simplified79.6%
Taylor expanded in wj around 0 98.8%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 99.1%
+-commutative99.1%
mul-1-neg99.1%
unsub-neg99.1%
Simplified99.1%
unpow299.1%
cube-mult99.1%
unpow299.1%
distribute-lft-out--99.1%
Applied egg-rr99.1%
if 2.15000000000000007e-10 < wj Initial program 70.2%
distribute-rgt1-in69.3%
associate-/l/69.3%
div-sub69.3%
associate-/l*69.3%
*-inverses94.3%
/-rgt-identity94.3%
Simplified94.3%
Final simplification99.0%
(FPCore (wj x) :precision binary64 (+ x (* wj (- wj (pow wj 2.0)))))
double code(double wj, double x) {
return x + (wj * (wj - pow(wj, 2.0)));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + (wj * (wj - (wj ** 2.0d0)))
end function
public static double code(double wj, double x) {
return x + (wj * (wj - Math.pow(wj, 2.0)));
}
def code(wj, x): return x + (wj * (wj - math.pow(wj, 2.0)))
function code(wj, x) return Float64(x + Float64(wj * Float64(wj - (wj ^ 2.0)))) end
function tmp = code(wj, x) tmp = x + (wj * (wj - (wj ^ 2.0))); end
code[wj_, x_] := N[(x + N[(wj * N[(wj - N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + wj \cdot \left(wj - {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 97.1%
Taylor expanded in x around 0 97.2%
Taylor expanded in x around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
unpow297.1%
cube-mult97.1%
unpow297.1%
distribute-lft-out--97.1%
Applied egg-rr97.1%
Final simplification97.1%
(FPCore (wj x) :precision binary64 (+ x (* (pow wj 2.0) (- 1.0 wj))))
double code(double wj, double x) {
return x + (pow(wj, 2.0) * (1.0 - wj));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + ((wj ** 2.0d0) * (1.0d0 - wj))
end function
public static double code(double wj, double x) {
return x + (Math.pow(wj, 2.0) * (1.0 - wj));
}
def code(wj, x): return x + (math.pow(wj, 2.0) * (1.0 - wj))
function code(wj, x) return Float64(x + Float64((wj ^ 2.0) * Float64(1.0 - wj))) end
function tmp = code(wj, x) tmp = x + ((wj ^ 2.0) * (1.0 - wj)); end
code[wj_, x_] := N[(x + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + {wj}^{2} \cdot \left(1 - wj\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 97.1%
Taylor expanded in x around 0 97.2%
Taylor expanded in x around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
*-un-lft-identity97.1%
cube-mult97.1%
unpow297.1%
distribute-rgt-out--97.1%
Applied egg-rr97.1%
Final simplification97.1%
(FPCore (wj x) :precision binary64 (fma wj wj x))
double code(double wj, double x) {
return fma(wj, wj, x);
}
function code(wj, x) return fma(wj, wj, x) end
code[wj_, x_] := N[(wj * wj + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(wj, wj, 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 97.1%
Taylor expanded in x around 0 97.2%
Taylor expanded in x around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Taylor expanded in wj around 0 96.8%
+-commutative96.8%
unpow296.8%
fma-def96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (wj x) :precision binary64 (if (<= wj 7.6e-5) (+ x (* -2.0 (* wj x))) (* wj (+ 1.0 (/ -1.0 (+ wj 1.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= 7.6e-5) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj * (1.0 + (-1.0 / (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 <= 7.6d-5) then
tmp = x + ((-2.0d0) * (wj * x))
else
tmp = wj * (1.0d0 + ((-1.0d0) / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 7.6e-5) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj * (1.0 + (-1.0 / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 7.6e-5: tmp = x + (-2.0 * (wj * x)) else: tmp = wj * (1.0 + (-1.0 / (wj + 1.0))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 7.6e-5) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); else tmp = Float64(wj * Float64(1.0 + Float64(-1.0 / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 7.6e-5) tmp = x + (-2.0 * (wj * x)); else tmp = wj * (1.0 + (-1.0 / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 7.6e-5], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj * N[(1.0 + N[(-1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 7.6 \cdot 10^{-5}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj \cdot \left(1 + \frac{-1}{wj + 1}\right)\\
\end{array}
\end{array}
if wj < 7.6000000000000004e-5Initial program 79.8%
distribute-rgt1-in79.8%
associate-/l/79.8%
div-sub79.8%
associate-/l*79.8%
*-inverses79.8%
/-rgt-identity79.8%
Simplified79.8%
Taylor expanded in wj around 0 87.2%
*-commutative87.2%
Simplified87.2%
if 7.6000000000000004e-5 < wj Initial program 60.5%
distribute-rgt1-in59.3%
associate-/l/59.6%
div-sub59.6%
associate-/l*59.6%
*-inverses92.9%
/-rgt-identity92.9%
Simplified92.9%
Taylor expanded in x around 0 77.3%
+-commutative77.3%
Simplified77.3%
clear-num77.4%
inv-pow77.4%
Applied egg-rr77.4%
unpow-177.4%
Simplified77.4%
*-un-lft-identity77.4%
associate-/r/77.3%
distribute-rgt-out--77.9%
Applied egg-rr77.9%
Final simplification87.0%
(FPCore (wj x) :precision binary64 (if (<= wj 5e-6) (+ x (* -2.0 (* wj x))) (+ wj (/ -1.0 (+ 1.0 (/ 1.0 wj))))))
double code(double wj, double x) {
double tmp;
if (wj <= 5e-6) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj + (-1.0 / (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 (wj <= 5d-6) then
tmp = x + ((-2.0d0) * (wj * x))
else
tmp = wj + ((-1.0d0) / (1.0d0 + (1.0d0 / wj)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 5e-6) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj + (-1.0 / (1.0 + (1.0 / wj)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 5e-6: tmp = x + (-2.0 * (wj * x)) else: tmp = wj + (-1.0 / (1.0 + (1.0 / wj))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 5e-6) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); else tmp = Float64(wj + Float64(-1.0 / Float64(1.0 + Float64(1.0 / wj)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 5e-6) tmp = x + (-2.0 * (wj * x)); else tmp = wj + (-1.0 / (1.0 + (1.0 / wj))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 5e-6], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(-1.0 / N[(1.0 + N[(1.0 / wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 5 \cdot 10^{-6}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{-1}{1 + \frac{1}{wj}}\\
\end{array}
\end{array}
if wj < 5.00000000000000041e-6Initial program 79.8%
distribute-rgt1-in79.8%
associate-/l/79.8%
div-sub79.8%
associate-/l*79.8%
*-inverses79.8%
/-rgt-identity79.8%
Simplified79.8%
Taylor expanded in wj around 0 87.2%
*-commutative87.2%
Simplified87.2%
if 5.00000000000000041e-6 < wj Initial program 60.5%
distribute-rgt1-in59.3%
associate-/l/59.6%
div-sub59.6%
associate-/l*59.6%
*-inverses92.9%
/-rgt-identity92.9%
Simplified92.9%
Taylor expanded in x around 0 77.3%
+-commutative77.3%
Simplified77.3%
clear-num77.4%
inv-pow77.4%
Applied egg-rr77.4%
unpow-177.4%
Simplified77.4%
Taylor expanded in wj around 0 78.0%
Final simplification87.0%
(FPCore (wj x) :precision binary64 (if (<= wj 5.5e-5) (+ x (* -2.0 (* wj x))) (- wj (/ wj (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 5.5e-5) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = 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 (wj <= 5.5d-5) then
tmp = x + ((-2.0d0) * (wj * x))
else
tmp = wj - (wj / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 5.5e-5) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj - (wj / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 5.5e-5: tmp = x + (-2.0 * (wj * x)) else: tmp = wj - (wj / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 5.5e-5) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); else tmp = Float64(wj - Float64(wj / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 5.5e-5) tmp = x + (-2.0 * (wj * x)); else tmp = wj - (wj / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 5.5e-5], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 5.5000000000000002e-5Initial program 79.8%
distribute-rgt1-in79.8%
associate-/l/79.8%
div-sub79.8%
associate-/l*79.8%
*-inverses79.8%
/-rgt-identity79.8%
Simplified79.8%
Taylor expanded in wj around 0 87.2%
*-commutative87.2%
Simplified87.2%
if 5.5000000000000002e-5 < wj Initial program 60.5%
distribute-rgt1-in59.3%
associate-/l/59.6%
div-sub59.6%
associate-/l*59.6%
*-inverses92.9%
/-rgt-identity92.9%
Simplified92.9%
Taylor expanded in x around 0 77.3%
+-commutative77.3%
Simplified77.3%
Final simplification87.0%
(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.8%
Taylor expanded in wj around 0 85.3%
associate-*r*85.3%
*-commutative85.3%
associate-*l*84.9%
Simplified84.9%
Taylor expanded in x around 0 85.3%
Final simplification85.3%
(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 85.3%
*-commutative85.3%
Simplified85.3%
Final simplification85.3%
(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 85.0%
Final simplification85.0%
(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 2023322
(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))))))