
(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 (* wj (exp wj))) (t_1 (+ (* x -4.0) (* x 1.5))))
(if (<= (- wj (/ (- t_0 x) (+ (exp wj) t_0))) 2e-16)
(+
x
(+
(* -2.0 (* wj x))
(+
(*
(pow wj 3.0)
(- -1.0 (+ (* x -3.0) (+ (* -2.0 t_1) (* x 0.6666666666666666)))))
(* (pow wj 2.0) (- 1.0 t_1)))))
(- wj (/ (- wj (* x (exp (- wj)))) (+ wj 1.0))))))
double code(double wj, double x) {
double t_0 = wj * exp(wj);
double t_1 = (x * -4.0) + (x * 1.5);
double tmp;
if ((wj - ((t_0 - x) / (exp(wj) + t_0))) <= 2e-16) {
tmp = x + ((-2.0 * (wj * x)) + ((pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (pow(wj, 2.0) * (1.0 - t_1))));
} else {
tmp = wj - ((wj - (x * exp(-wj))) / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = wj * exp(wj)
t_1 = (x * (-4.0d0)) + (x * 1.5d0)
if ((wj - ((t_0 - x) / (exp(wj) + t_0))) <= 2d-16) then
tmp = x + (((-2.0d0) * (wj * x)) + (((wj ** 3.0d0) * ((-1.0d0) - ((x * (-3.0d0)) + (((-2.0d0) * t_1) + (x * 0.6666666666666666d0))))) + ((wj ** 2.0d0) * (1.0d0 - t_1))))
else
tmp = wj - ((wj - (x * exp(-wj))) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = wj * Math.exp(wj);
double t_1 = (x * -4.0) + (x * 1.5);
double tmp;
if ((wj - ((t_0 - x) / (Math.exp(wj) + t_0))) <= 2e-16) {
tmp = x + ((-2.0 * (wj * x)) + ((Math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (Math.pow(wj, 2.0) * (1.0 - t_1))));
} else {
tmp = wj - ((wj - (x * Math.exp(-wj))) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): t_0 = wj * math.exp(wj) t_1 = (x * -4.0) + (x * 1.5) tmp = 0 if (wj - ((t_0 - x) / (math.exp(wj) + t_0))) <= 2e-16: tmp = x + ((-2.0 * (wj * x)) + ((math.pow(wj, 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + (math.pow(wj, 2.0) * (1.0 - t_1)))) else: tmp = wj - ((wj - (x * math.exp(-wj))) / (wj + 1.0)) return tmp
function code(wj, x) t_0 = Float64(wj * exp(wj)) t_1 = Float64(Float64(x * -4.0) + Float64(x * 1.5)) tmp = 0.0 if (Float64(wj - Float64(Float64(t_0 - x) / Float64(exp(wj) + t_0))) <= 2e-16) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64(Float64((wj ^ 3.0) * Float64(-1.0 - Float64(Float64(x * -3.0) + Float64(Float64(-2.0 * t_1) + Float64(x * 0.6666666666666666))))) + Float64((wj ^ 2.0) * Float64(1.0 - t_1))))); else tmp = Float64(wj - Float64(Float64(wj - Float64(x * exp(Float64(-wj)))) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) t_0 = wj * exp(wj); t_1 = (x * -4.0) + (x * 1.5); tmp = 0.0; if ((wj - ((t_0 - x) / (exp(wj) + t_0))) <= 2e-16) tmp = x + ((-2.0 * (wj * x)) + (((wj ^ 3.0) * (-1.0 - ((x * -3.0) + ((-2.0 * t_1) + (x * 0.6666666666666666))))) + ((wj ^ 2.0) * (1.0 - t_1)))); else tmp = wj - ((wj - (x * exp(-wj))) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(wj - N[(N[(t$95$0 - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e-16], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[wj, 3.0], $MachinePrecision] * N[(-1.0 - N[(N[(x * -3.0), $MachinePrecision] + N[(N[(-2.0 * t$95$1), $MachinePrecision] + N[(x * 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(wj - N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := wj \cdot e^{wj}\\
t_1 := x \cdot -4 + x \cdot 1.5\\
\mathbf{if}\;wj - \frac{t\_0 - x}{e^{wj} + t\_0} \leq 2 \cdot 10^{-16}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + \left({wj}^{3} \cdot \left(-1 - \left(x \cdot -3 + \left(-2 \cdot t\_1 + x \cdot 0.6666666666666666\right)\right)\right) + {wj}^{2} \cdot \left(1 - t\_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - x \cdot e^{-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))))) < 2e-16Initial program 65.5%
distribute-rgt1-in65.5%
associate-/l/65.4%
div-sub65.4%
associate-/l*65.4%
*-inverses65.4%
*-rgt-identity65.4%
Simplified65.4%
Taylor expanded in wj around 0 99.4%
if 2e-16 < (-.f64 wj (/.f64 (-.f64 (*.f64 wj (exp.f64 wj)) x) (+.f64 (exp.f64 wj) (*.f64 wj (exp.f64 wj))))) Initial program 96.3%
distribute-rgt1-in98.7%
associate-/l/98.7%
div-sub96.3%
associate-/l*96.3%
*-inverses99.9%
*-rgt-identity99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.9%
rec-exp99.9%
Applied egg-rr99.9%
Final simplification99.6%
(FPCore (wj x) :precision binary64 (+ x (+ (* -2.0 (* wj x)) (* (pow wj 2.0) (- 1.0 (+ (* x -4.0) (* x 1.5)))))))
double code(double wj, double x) {
return x + ((-2.0 * (wj * x)) + (pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + (((-2.0d0) * (wj * x)) + ((wj ** 2.0d0) * (1.0d0 - ((x * (-4.0d0)) + (x * 1.5d0)))))
end function
public static double code(double wj, double x) {
return x + ((-2.0 * (wj * x)) + (Math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))));
}
def code(wj, x): return x + ((-2.0 * (wj * x)) + (math.pow(wj, 2.0) * (1.0 - ((x * -4.0) + (x * 1.5)))))
function code(wj, x) return Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + Float64((wj ^ 2.0) * Float64(1.0 - Float64(Float64(x * -4.0) + Float64(x * 1.5)))))) end
function tmp = code(wj, x) tmp = x + ((-2.0 * (wj * x)) + ((wj ^ 2.0) * (1.0 - ((x * -4.0) + (x * 1.5))))); end
code[wj_, x_] := N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - N[(N[(x * -4.0), $MachinePrecision] + N[(x * 1.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2} \cdot \left(1 - \left(x \cdot -4 + x \cdot 1.5\right)\right)\right)
\end{array}
Initial program 75.4%
distribute-rgt1-in76.1%
associate-/l/76.1%
div-sub75.3%
associate-/l*75.3%
*-inverses76.5%
*-rgt-identity76.5%
Simplified76.5%
Taylor expanded in wj around 0 97.2%
Final simplification97.2%
(FPCore (wj x)
:precision binary64
(if (<= x -1.32e-208)
(+ x (* -2.0 (* wj x)))
(if (<= x 3.8e-295)
(* wj (+ wj (* x -2.0)))
(/ x (* (exp wj) (+ wj 1.0))))))
double code(double wj, double x) {
double tmp;
if (x <= -1.32e-208) {
tmp = x + (-2.0 * (wj * x));
} else if (x <= 3.8e-295) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x / (exp(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 <= (-1.32d-208)) then
tmp = x + ((-2.0d0) * (wj * x))
else if (x <= 3.8d-295) then
tmp = wj * (wj + (x * (-2.0d0)))
else
tmp = x / (exp(wj) * (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= -1.32e-208) {
tmp = x + (-2.0 * (wj * x));
} else if (x <= 3.8e-295) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x / (Math.exp(wj) * (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -1.32e-208: tmp = x + (-2.0 * (wj * x)) elif x <= 3.8e-295: tmp = wj * (wj + (x * -2.0)) else: tmp = x / (math.exp(wj) * (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (x <= -1.32e-208) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); elseif (x <= 3.8e-295) tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); else tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= -1.32e-208) tmp = x + (-2.0 * (wj * x)); elseif (x <= 3.8e-295) tmp = wj * (wj + (x * -2.0)); else tmp = x / (exp(wj) * (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -1.32e-208], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.8e-295], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{-208}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-295}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\end{array}
\end{array}
if x < -1.3199999999999999e-208Initial program 79.5%
distribute-rgt1-in79.5%
associate-/l/79.5%
div-sub79.5%
associate-/l*79.5%
*-inverses80.4%
*-rgt-identity80.4%
Simplified80.4%
Taylor expanded in wj around 0 91.9%
*-commutative91.9%
Simplified91.9%
if -1.3199999999999999e-208 < x < 3.80000000000000018e-295Initial program 17.2%
distribute-rgt1-in17.2%
associate-/l/16.6%
div-sub16.6%
associate-/l*16.6%
*-inverses16.6%
*-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 96.6%
Taylor expanded in x around 0 96.6%
Taylor expanded in wj around inf 73.1%
+-commutative73.1%
unpow273.1%
*-commutative73.1%
associate-*r*73.1%
distribute-rgt-out73.1%
Simplified73.1%
if 3.80000000000000018e-295 < x Initial program 84.1%
distribute-rgt1-in85.7%
associate-/l/85.8%
div-sub84.1%
associate-/l*84.1%
*-inverses85.8%
*-rgt-identity85.8%
Simplified85.8%
Taylor expanded in x around inf 93.1%
+-commutative93.1%
Simplified93.1%
Final simplification90.6%
(FPCore (wj x)
:precision binary64
(if (<= x -9.6e-209)
(+ x (* -2.0 (* wj x)))
(if (<= x 5.2e-295)
(* wj (+ wj (* x -2.0)))
(/ (/ x (+ wj 1.0)) (exp wj)))))
double code(double wj, double x) {
double tmp;
if (x <= -9.6e-209) {
tmp = x + (-2.0 * (wj * x));
} else if (x <= 5.2e-295) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = (x / (wj + 1.0)) / exp(wj);
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-9.6d-209)) then
tmp = x + ((-2.0d0) * (wj * x))
else if (x <= 5.2d-295) then
tmp = wj * (wj + (x * (-2.0d0)))
else
tmp = (x / (wj + 1.0d0)) / exp(wj)
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (x <= -9.6e-209) {
tmp = x + (-2.0 * (wj * x));
} else if (x <= 5.2e-295) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = (x / (wj + 1.0)) / Math.exp(wj);
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -9.6e-209: tmp = x + (-2.0 * (wj * x)) elif x <= 5.2e-295: tmp = wj * (wj + (x * -2.0)) else: tmp = (x / (wj + 1.0)) / math.exp(wj) return tmp
function code(wj, x) tmp = 0.0 if (x <= -9.6e-209) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); elseif (x <= 5.2e-295) tmp = Float64(wj * Float64(wj + Float64(x * -2.0))); else tmp = Float64(Float64(x / Float64(wj + 1.0)) / exp(wj)); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (x <= -9.6e-209) tmp = x + (-2.0 * (wj * x)); elseif (x <= 5.2e-295) tmp = wj * (wj + (x * -2.0)); else tmp = (x / (wj + 1.0)) / exp(wj); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -9.6e-209], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.2e-295], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] / N[Exp[wj], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.6 \cdot 10^{-209}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-295}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{wj + 1}}{e^{wj}}\\
\end{array}
\end{array}
if x < -9.6000000000000004e-209Initial program 79.5%
distribute-rgt1-in79.5%
associate-/l/79.5%
div-sub79.5%
associate-/l*79.5%
*-inverses80.4%
*-rgt-identity80.4%
Simplified80.4%
Taylor expanded in wj around 0 91.9%
*-commutative91.9%
Simplified91.9%
if -9.6000000000000004e-209 < x < 5.1999999999999997e-295Initial program 17.2%
distribute-rgt1-in17.2%
associate-/l/16.6%
div-sub16.6%
associate-/l*16.6%
*-inverses16.6%
*-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 96.6%
Taylor expanded in x around 0 96.6%
Taylor expanded in wj around inf 73.1%
+-commutative73.1%
unpow273.1%
*-commutative73.1%
associate-*r*73.1%
distribute-rgt-out73.1%
Simplified73.1%
if 5.1999999999999997e-295 < x Initial program 84.1%
distribute-rgt1-in85.7%
associate-/l/85.8%
div-sub84.1%
associate-/l*84.1%
*-inverses85.8%
*-rgt-identity85.8%
Simplified85.8%
Taylor expanded in x around inf 93.1%
+-commutative93.1%
Simplified93.1%
associate-/r*93.1%
div-inv93.1%
Applied egg-rr93.1%
Taylor expanded in x around 0 93.1%
+-commutative93.1%
associate-/l/93.1%
Simplified93.1%
Final simplification90.6%
(FPCore (wj x) :precision binary64 (if (<= wj 8.4e-9) (+ x (+ (* -2.0 (* wj x)) (pow wj 2.0))) (- wj (/ (- wj (* x (exp (- wj)))) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 8.4e-9) {
tmp = x + ((-2.0 * (wj * x)) + pow(wj, 2.0));
} else {
tmp = wj - ((wj - (x * exp(-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 <= 8.4d-9) then
tmp = x + (((-2.0d0) * (wj * x)) + (wj ** 2.0d0))
else
tmp = wj - ((wj - (x * exp(-wj))) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 8.4e-9) {
tmp = x + ((-2.0 * (wj * x)) + Math.pow(wj, 2.0));
} else {
tmp = wj - ((wj - (x * Math.exp(-wj))) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 8.4e-9: tmp = x + ((-2.0 * (wj * x)) + math.pow(wj, 2.0)) else: tmp = wj - ((wj - (x * math.exp(-wj))) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 8.4e-9) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + (wj ^ 2.0))); else tmp = Float64(wj - Float64(Float64(wj - Float64(x * exp(Float64(-wj)))) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 8.4e-9) tmp = x + ((-2.0 * (wj * x)) + (wj ^ 2.0)); else tmp = wj - ((wj - (x * exp(-wj))) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 8.4e-9], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(N[(wj - N[(x * N[Exp[(-wj)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 8.4 \cdot 10^{-9}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - x \cdot e^{-wj}}{wj + 1}\\
\end{array}
\end{array}
if wj < 8.40000000000000077e-9Initial program 75.1%
distribute-rgt1-in75.9%
associate-/l/75.8%
div-sub75.0%
associate-/l*75.0%
*-inverses75.8%
*-rgt-identity75.8%
Simplified75.8%
Taylor expanded in wj around 0 98.6%
Taylor expanded in x around 0 98.6%
if 8.40000000000000077e-9 < wj Initial program 84.9%
distribute-rgt1-in84.9%
associate-/l/85.3%
div-sub85.3%
associate-/l*85.3%
*-inverses99.6%
*-rgt-identity99.6%
Simplified99.6%
clear-num99.2%
associate-/r/99.6%
rec-exp99.8%
Applied egg-rr99.8%
Final simplification98.7%
(FPCore (wj x) :precision binary64 (if (<= wj 8.4e-9) (+ x (+ (* -2.0 (* wj x)) (pow wj 2.0))) (+ wj (/ (- wj (/ x (exp wj))) (- -1.0 wj)))))
double code(double wj, double x) {
double tmp;
if (wj <= 8.4e-9) {
tmp = x + ((-2.0 * (wj * x)) + pow(wj, 2.0));
} else {
tmp = wj + ((wj - (x / exp(wj))) / (-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 <= 8.4d-9) then
tmp = x + (((-2.0d0) * (wj * x)) + (wj ** 2.0d0))
else
tmp = wj + ((wj - (x / exp(wj))) / ((-1.0d0) - wj))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 8.4e-9) {
tmp = x + ((-2.0 * (wj * x)) + Math.pow(wj, 2.0));
} else {
tmp = wj + ((wj - (x / Math.exp(wj))) / (-1.0 - wj));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 8.4e-9: tmp = x + ((-2.0 * (wj * x)) + math.pow(wj, 2.0)) else: tmp = wj + ((wj - (x / math.exp(wj))) / (-1.0 - wj)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 8.4e-9) tmp = Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + (wj ^ 2.0))); else tmp = Float64(wj + Float64(Float64(wj - Float64(x / exp(wj))) / Float64(-1.0 - wj))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 8.4e-9) tmp = x + ((-2.0 * (wj * x)) + (wj ^ 2.0)); else tmp = wj + ((wj - (x / exp(wj))) / (-1.0 - wj)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 8.4e-9], N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - wj), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 8.4 \cdot 10^{-9}:\\
\;\;\;\;x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{wj - \frac{x}{e^{wj}}}{-1 - wj}\\
\end{array}
\end{array}
if wj < 8.40000000000000077e-9Initial program 75.1%
distribute-rgt1-in75.9%
associate-/l/75.8%
div-sub75.0%
associate-/l*75.0%
*-inverses75.8%
*-rgt-identity75.8%
Simplified75.8%
Taylor expanded in wj around 0 98.6%
Taylor expanded in x around 0 98.6%
if 8.40000000000000077e-9 < wj Initial program 84.9%
distribute-rgt1-in84.9%
associate-/l/85.3%
div-sub85.3%
associate-/l*85.3%
*-inverses99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification98.6%
(FPCore (wj x) :precision binary64 (+ x (+ (* -2.0 (* wj x)) (pow wj 2.0))))
double code(double wj, double x) {
return x + ((-2.0 * (wj * x)) + pow(wj, 2.0));
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = x + (((-2.0d0) * (wj * x)) + (wj ** 2.0d0))
end function
public static double code(double wj, double x) {
return x + ((-2.0 * (wj * x)) + Math.pow(wj, 2.0));
}
def code(wj, x): return x + ((-2.0 * (wj * x)) + math.pow(wj, 2.0))
function code(wj, x) return Float64(x + Float64(Float64(-2.0 * Float64(wj * x)) + (wj ^ 2.0))) end
function tmp = code(wj, x) tmp = x + ((-2.0 * (wj * x)) + (wj ^ 2.0)); end
code[wj_, x_] := N[(x + N[(N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision] + N[Power[wj, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(-2 \cdot \left(wj \cdot x\right) + {wj}^{2}\right)
\end{array}
Initial program 75.4%
distribute-rgt1-in76.1%
associate-/l/76.1%
div-sub75.3%
associate-/l*75.3%
*-inverses76.5%
*-rgt-identity76.5%
Simplified76.5%
Taylor expanded in wj around 0 97.2%
Taylor expanded in x around 0 97.0%
Final simplification97.0%
(FPCore (wj x) :precision binary64 (if (or (<= x -9.6e-209) (not (<= x 2e-298))) (+ x (* -2.0 (* wj x))) (* wj (+ wj (* x -2.0)))))
double code(double wj, double x) {
double tmp;
if ((x <= -9.6e-209) || !(x <= 2e-298)) {
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 <= (-9.6d-209)) .or. (.not. (x <= 2d-298))) 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 <= -9.6e-209) || !(x <= 2e-298)) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj * (wj + (x * -2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if (x <= -9.6e-209) or not (x <= 2e-298): tmp = x + (-2.0 * (wj * x)) else: tmp = wj * (wj + (x * -2.0)) return tmp
function code(wj, x) tmp = 0.0 if ((x <= -9.6e-209) || !(x <= 2e-298)) 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 <= -9.6e-209) || ~((x <= 2e-298))) 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, -9.6e-209], N[Not[LessEqual[x, 2e-298]], $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 -9.6 \cdot 10^{-209} \lor \neg \left(x \leq 2 \cdot 10^{-298}\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 < -9.6000000000000004e-209 or 1.99999999999999982e-298 < x Initial program 81.9%
distribute-rgt1-in82.8%
associate-/l/82.8%
div-sub81.9%
associate-/l*81.9%
*-inverses83.3%
*-rgt-identity83.3%
Simplified83.3%
Taylor expanded in wj around 0 90.5%
*-commutative90.5%
Simplified90.5%
if -9.6000000000000004e-209 < x < 1.99999999999999982e-298Initial program 17.2%
distribute-rgt1-in17.2%
associate-/l/16.6%
div-sub16.6%
associate-/l*16.6%
*-inverses16.6%
*-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 96.6%
Taylor expanded in x around 0 96.6%
Taylor expanded in wj around inf 73.1%
+-commutative73.1%
unpow273.1%
*-commutative73.1%
associate-*r*73.1%
distribute-rgt-out73.1%
Simplified73.1%
Final simplification88.7%
(FPCore (wj x) :precision binary64 (if (<= x -7.2e-208) x (if (<= x 5.2e-298) (* wj (+ wj (* x -2.0))) x)))
double code(double wj, double x) {
double tmp;
if (x <= -7.2e-208) {
tmp = x;
} else if (x <= 5.2e-298) {
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.2d-208)) then
tmp = x
else if (x <= 5.2d-298) 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.2e-208) {
tmp = x;
} else if (x <= 5.2e-298) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x;
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -7.2e-208: tmp = x elif x <= 5.2e-298: tmp = wj * (wj + (x * -2.0)) else: tmp = x return tmp
function code(wj, x) tmp = 0.0 if (x <= -7.2e-208) tmp = x; elseif (x <= 5.2e-298) 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.2e-208) tmp = x; elseif (x <= 5.2e-298) tmp = wj * (wj + (x * -2.0)); else tmp = x; end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -7.2e-208], x, If[LessEqual[x, 5.2e-298], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-208}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-298}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.1999999999999997e-208 or 5.1999999999999998e-298 < x Initial program 81.9%
distribute-rgt1-in82.8%
associate-/l/82.8%
div-sub81.9%
associate-/l*81.9%
*-inverses83.3%
*-rgt-identity83.3%
Simplified83.3%
Taylor expanded in wj around 0 90.0%
if -7.1999999999999997e-208 < x < 5.1999999999999998e-298Initial program 17.2%
distribute-rgt1-in17.2%
associate-/l/16.6%
div-sub16.6%
associate-/l*16.6%
*-inverses16.6%
*-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 96.6%
Taylor expanded in x around 0 96.6%
Taylor expanded in wj around inf 73.1%
+-commutative73.1%
unpow273.1%
*-commutative73.1%
associate-*r*73.1%
distribute-rgt-out73.1%
Simplified73.1%
Final simplification88.3%
(FPCore (wj x) :precision binary64 (if (<= x -9.6e-209) (+ x (* -2.0 (* wj x))) (if (<= x 8.2e-296) (* wj (+ wj (* x -2.0))) (/ x (+ 1.0 (* wj 2.0))))))
double code(double wj, double x) {
double tmp;
if (x <= -9.6e-209) {
tmp = x + (-2.0 * (wj * x));
} else if (x <= 8.2e-296) {
tmp = wj * (wj + (x * -2.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 <= (-9.6d-209)) then
tmp = x + ((-2.0d0) * (wj * x))
else if (x <= 8.2d-296) then
tmp = wj * (wj + (x * (-2.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 <= -9.6e-209) {
tmp = x + (-2.0 * (wj * x));
} else if (x <= 8.2e-296) {
tmp = wj * (wj + (x * -2.0));
} else {
tmp = x / (1.0 + (wj * 2.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if x <= -9.6e-209: tmp = x + (-2.0 * (wj * x)) elif x <= 8.2e-296: tmp = wj * (wj + (x * -2.0)) else: tmp = x / (1.0 + (wj * 2.0)) return tmp
function code(wj, x) tmp = 0.0 if (x <= -9.6e-209) tmp = Float64(x + Float64(-2.0 * Float64(wj * x))); elseif (x <= 8.2e-296) tmp = Float64(wj * Float64(wj + Float64(x * -2.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 <= -9.6e-209) tmp = x + (-2.0 * (wj * x)); elseif (x <= 8.2e-296) tmp = wj * (wj + (x * -2.0)); else tmp = x / (1.0 + (wj * 2.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[x, -9.6e-209], N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.2e-296], N[(wj * N[(wj + N[(x * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(1.0 + N[(wj * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.6 \cdot 10^{-209}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{-296}:\\
\;\;\;\;wj \cdot \left(wj + x \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{1 + wj \cdot 2}\\
\end{array}
\end{array}
if x < -9.6000000000000004e-209Initial program 79.5%
distribute-rgt1-in79.5%
associate-/l/79.5%
div-sub79.5%
associate-/l*79.5%
*-inverses80.4%
*-rgt-identity80.4%
Simplified80.4%
Taylor expanded in wj around 0 91.9%
*-commutative91.9%
Simplified91.9%
if -9.6000000000000004e-209 < x < 8.19999999999999988e-296Initial program 17.2%
distribute-rgt1-in17.2%
associate-/l/16.6%
div-sub16.6%
associate-/l*16.6%
*-inverses16.6%
*-rgt-identity16.6%
Simplified16.6%
Taylor expanded in wj around 0 96.6%
Taylor expanded in x around 0 96.6%
Taylor expanded in wj around inf 73.1%
+-commutative73.1%
unpow273.1%
*-commutative73.1%
associate-*r*73.1%
distribute-rgt-out73.1%
Simplified73.1%
if 8.19999999999999988e-296 < x Initial program 84.1%
distribute-rgt1-in85.7%
associate-/l/85.8%
div-sub84.1%
associate-/l*84.1%
*-inverses85.8%
*-rgt-identity85.8%
Simplified85.8%
Taylor expanded in x around inf 93.1%
+-commutative93.1%
Simplified93.1%
Taylor expanded in wj around 0 89.5%
*-commutative89.5%
Simplified89.5%
Final simplification88.8%
(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 75.4%
distribute-rgt1-in76.1%
associate-/l/76.1%
div-sub75.3%
associate-/l*75.3%
*-inverses76.5%
*-rgt-identity76.5%
Simplified76.5%
Taylor expanded in wj around inf 4.0%
Final simplification4.0%
(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 75.4%
distribute-rgt1-in76.1%
associate-/l/76.1%
div-sub75.3%
associate-/l*75.3%
*-inverses76.5%
*-rgt-identity76.5%
Simplified76.5%
Taylor expanded in wj around 0 83.4%
Final simplification83.4%
(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 2024059
(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))))))