
(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 17 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 (exp wj))))
(if (<= wj -1.45e-7)
(+ wj (/ (- t_0 wj) (+ wj 1.0)))
(if (<= wj 1.48e-8)
(+ x (+ (- (pow wj 2.0) (pow wj 3.0)) (* -2.0 (* wj x))))
(+ wj (* (- wj t_0) (/ -1.0 (+ wj 1.0))))))))
double code(double wj, double x) {
double t_0 = x / exp(wj);
double tmp;
if (wj <= -1.45e-7) {
tmp = wj + ((t_0 - wj) / (wj + 1.0));
} else if (wj <= 1.48e-8) {
tmp = x + ((pow(wj, 2.0) - pow(wj, 3.0)) + (-2.0 * (wj * x)));
} else {
tmp = wj + ((wj - t_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) :: t_0
real(8) :: tmp
t_0 = x / exp(wj)
if (wj <= (-1.45d-7)) then
tmp = wj + ((t_0 - wj) / (wj + 1.0d0))
else if (wj <= 1.48d-8) then
tmp = x + (((wj ** 2.0d0) - (wj ** 3.0d0)) + ((-2.0d0) * (wj * x)))
else
tmp = wj + ((wj - t_0) * ((-1.0d0) / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = x / Math.exp(wj);
double tmp;
if (wj <= -1.45e-7) {
tmp = wj + ((t_0 - wj) / (wj + 1.0));
} else if (wj <= 1.48e-8) {
tmp = x + ((Math.pow(wj, 2.0) - Math.pow(wj, 3.0)) + (-2.0 * (wj * x)));
} else {
tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): t_0 = x / math.exp(wj) tmp = 0 if wj <= -1.45e-7: tmp = wj + ((t_0 - wj) / (wj + 1.0)) elif wj <= 1.48e-8: tmp = x + ((math.pow(wj, 2.0) - math.pow(wj, 3.0)) + (-2.0 * (wj * x))) else: tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0))) return tmp
function code(wj, x) t_0 = Float64(x / exp(wj)) tmp = 0.0 if (wj <= -1.45e-7) tmp = Float64(wj + Float64(Float64(t_0 - wj) / Float64(wj + 1.0))); elseif (wj <= 1.48e-8) tmp = Float64(x + Float64(Float64((wj ^ 2.0) - (wj ^ 3.0)) + Float64(-2.0 * Float64(wj * x)))); else tmp = Float64(wj + Float64(Float64(wj - t_0) * Float64(-1.0 / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) t_0 = x / exp(wj); tmp = 0.0; if (wj <= -1.45e-7) tmp = wj + ((t_0 - wj) / (wj + 1.0)); elseif (wj <= 1.48e-8) tmp = x + (((wj ^ 2.0) - (wj ^ 3.0)) + (-2.0 * (wj * x))); else tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -1.45e-7], N[(wj + N[(N[(t$95$0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, 1.48e-8], N[(x + N[(N[(N[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(wj - t$95$0), $MachinePrecision] * N[(-1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{e^{wj}}\\
\mathbf{if}\;wj \leq -1.45 \cdot 10^{-7}:\\
\;\;\;\;wj + \frac{t_0 - wj}{wj + 1}\\
\mathbf{elif}\;wj \leq 1.48 \cdot 10^{-8}:\\
\;\;\;\;x + \left(\left({wj}^{2} - {wj}^{3}\right) + -2 \cdot \left(wj \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \left(wj - t_0\right) \cdot \frac{-1}{wj + 1}\\
\end{array}
\end{array}
if wj < -1.4499999999999999e-7Initial program 58.9%
distribute-rgt1-in95.9%
associate-/l/96.2%
div-sub58.7%
associate-/l*58.7%
*-inverses96.2%
/-rgt-identity96.2%
Simplified96.2%
if -1.4499999999999999e-7 < wj < 1.48e-8Initial program 77.2%
distribute-rgt1-in77.2%
associate-/l/77.1%
div-sub77.1%
associate-/l*77.1%
*-inverses77.1%
/-rgt-identity77.1%
Simplified77.1%
Taylor expanded in wj around 0 99.6%
Taylor expanded in x around 0 99.6%
Taylor expanded in x around 0 100.0%
if 1.48e-8 < wj Initial program 55.6%
distribute-rgt1-in55.1%
associate-/l/55.0%
div-sub54.9%
associate-/l*54.9%
*-inverses96.6%
/-rgt-identity96.6%
Simplified96.6%
clear-num97.0%
associate-/r/97.1%
Applied egg-rr97.1%
Final simplification99.7%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (/ x (exp wj))))
(if (<= wj -1e-14)
(+ wj (/ (- t_0 wj) (+ wj 1.0)))
(if (<= wj 2.45e-11)
(+ x (- (pow wj 2.0) (pow wj 3.0)))
(+ wj (* (- wj t_0) (/ -1.0 (+ wj 1.0))))))))
double code(double wj, double x) {
double t_0 = x / exp(wj);
double tmp;
if (wj <= -1e-14) {
tmp = wj + ((t_0 - wj) / (wj + 1.0));
} else if (wj <= 2.45e-11) {
tmp = x + (pow(wj, 2.0) - pow(wj, 3.0));
} else {
tmp = wj + ((wj - t_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) :: t_0
real(8) :: tmp
t_0 = x / exp(wj)
if (wj <= (-1d-14)) then
tmp = wj + ((t_0 - wj) / (wj + 1.0d0))
else if (wj <= 2.45d-11) then
tmp = x + ((wj ** 2.0d0) - (wj ** 3.0d0))
else
tmp = wj + ((wj - t_0) * ((-1.0d0) / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = x / Math.exp(wj);
double tmp;
if (wj <= -1e-14) {
tmp = wj + ((t_0 - wj) / (wj + 1.0));
} else if (wj <= 2.45e-11) {
tmp = x + (Math.pow(wj, 2.0) - Math.pow(wj, 3.0));
} else {
tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): t_0 = x / math.exp(wj) tmp = 0 if wj <= -1e-14: tmp = wj + ((t_0 - wj) / (wj + 1.0)) elif wj <= 2.45e-11: tmp = x + (math.pow(wj, 2.0) - math.pow(wj, 3.0)) else: tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0))) return tmp
function code(wj, x) t_0 = Float64(x / exp(wj)) tmp = 0.0 if (wj <= -1e-14) tmp = Float64(wj + Float64(Float64(t_0 - wj) / Float64(wj + 1.0))); elseif (wj <= 2.45e-11) tmp = Float64(x + Float64((wj ^ 2.0) - (wj ^ 3.0))); else tmp = Float64(wj + Float64(Float64(wj - t_0) * Float64(-1.0 / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) t_0 = x / exp(wj); tmp = 0.0; if (wj <= -1e-14) tmp = wj + ((t_0 - wj) / (wj + 1.0)); elseif (wj <= 2.45e-11) tmp = x + ((wj ^ 2.0) - (wj ^ 3.0)); else tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -1e-14], N[(wj + N[(N[(t$95$0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, 2.45e-11], N[(x + N[(N[Power[wj, 2.0], $MachinePrecision] - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(wj - t$95$0), $MachinePrecision] * N[(-1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{e^{wj}}\\
\mathbf{if}\;wj \leq -1 \cdot 10^{-14}:\\
\;\;\;\;wj + \frac{t_0 - wj}{wj + 1}\\
\mathbf{elif}\;wj \leq 2.45 \cdot 10^{-11}:\\
\;\;\;\;x + \left({wj}^{2} - {wj}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \left(wj - t_0\right) \cdot \frac{-1}{wj + 1}\\
\end{array}
\end{array}
if wj < -9.99999999999999999e-15Initial program 71.4%
distribute-rgt1-in94.2%
associate-/l/94.4%
div-sub71.3%
associate-/l*71.3%
*-inverses94.4%
/-rgt-identity94.4%
Simplified94.4%
if -9.99999999999999999e-15 < wj < 2.4499999999999999e-11Initial program 76.6%
distribute-rgt1-in76.6%
associate-/l/76.6%
div-sub76.6%
associate-/l*76.6%
*-inverses76.6%
/-rgt-identity76.6%
Simplified76.6%
Taylor expanded in wj around 0 99.5%
Taylor expanded in x around 0 99.5%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
if 2.4499999999999999e-11 < wj Initial program 61.8%
distribute-rgt1-in61.4%
associate-/l/61.3%
div-sub61.2%
associate-/l*61.2%
*-inverses96.9%
/-rgt-identity96.9%
Simplified96.9%
clear-num97.2%
associate-/r/97.4%
Applied egg-rr97.4%
Final simplification99.5%
(FPCore (wj x)
:precision binary64
(let* ((t_0 (/ x (exp wj))))
(if (<= wj -5.8e-9)
(+ wj (/ (- t_0 wj) (+ wj 1.0)))
(if (<= wj 6.2e-9)
(+ (+ x (* -2.0 (* wj x))) (* (pow wj 2.0) (- 1.0 (* x -2.5))))
(+ wj (* (- wj t_0) (/ -1.0 (+ wj 1.0))))))))
double code(double wj, double x) {
double t_0 = x / exp(wj);
double tmp;
if (wj <= -5.8e-9) {
tmp = wj + ((t_0 - wj) / (wj + 1.0));
} else if (wj <= 6.2e-9) {
tmp = (x + (-2.0 * (wj * x))) + (pow(wj, 2.0) * (1.0 - (x * -2.5)));
} else {
tmp = wj + ((wj - t_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) :: t_0
real(8) :: tmp
t_0 = x / exp(wj)
if (wj <= (-5.8d-9)) then
tmp = wj + ((t_0 - wj) / (wj + 1.0d0))
else if (wj <= 6.2d-9) then
tmp = (x + ((-2.0d0) * (wj * x))) + ((wj ** 2.0d0) * (1.0d0 - (x * (-2.5d0))))
else
tmp = wj + ((wj - t_0) * ((-1.0d0) / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double t_0 = x / Math.exp(wj);
double tmp;
if (wj <= -5.8e-9) {
tmp = wj + ((t_0 - wj) / (wj + 1.0));
} else if (wj <= 6.2e-9) {
tmp = (x + (-2.0 * (wj * x))) + (Math.pow(wj, 2.0) * (1.0 - (x * -2.5)));
} else {
tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): t_0 = x / math.exp(wj) tmp = 0 if wj <= -5.8e-9: tmp = wj + ((t_0 - wj) / (wj + 1.0)) elif wj <= 6.2e-9: tmp = (x + (-2.0 * (wj * x))) + (math.pow(wj, 2.0) * (1.0 - (x * -2.5))) else: tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0))) return tmp
function code(wj, x) t_0 = Float64(x / exp(wj)) tmp = 0.0 if (wj <= -5.8e-9) tmp = Float64(wj + Float64(Float64(t_0 - wj) / Float64(wj + 1.0))); elseif (wj <= 6.2e-9) tmp = Float64(Float64(x + Float64(-2.0 * Float64(wj * x))) + Float64((wj ^ 2.0) * Float64(1.0 - Float64(x * -2.5)))); else tmp = Float64(wj + Float64(Float64(wj - t_0) * Float64(-1.0 / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) t_0 = x / exp(wj); tmp = 0.0; if (wj <= -5.8e-9) tmp = wj + ((t_0 - wj) / (wj + 1.0)); elseif (wj <= 6.2e-9) tmp = (x + (-2.0 * (wj * x))) + ((wj ^ 2.0) * (1.0 - (x * -2.5))); else tmp = wj + ((wj - t_0) * (-1.0 / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := Block[{t$95$0 = N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[wj, -5.8e-9], N[(wj + N[(N[(t$95$0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, 6.2e-9], N[(N[(x + N[(-2.0 * N[(wj * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[wj, 2.0], $MachinePrecision] * N[(1.0 - N[(x * -2.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(wj - t$95$0), $MachinePrecision] * N[(-1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{e^{wj}}\\
\mathbf{if}\;wj \leq -5.8 \cdot 10^{-9}:\\
\;\;\;\;wj + \frac{t_0 - wj}{wj + 1}\\
\mathbf{elif}\;wj \leq 6.2 \cdot 10^{-9}:\\
\;\;\;\;\left(x + -2 \cdot \left(wj \cdot x\right)\right) + {wj}^{2} \cdot \left(1 - x \cdot -2.5\right)\\
\mathbf{else}:\\
\;\;\;\;wj + \left(wj - t_0\right) \cdot \frac{-1}{wj + 1}\\
\end{array}
\end{array}
if wj < -5.79999999999999982e-9Initial program 58.9%
distribute-rgt1-in95.9%
associate-/l/96.2%
div-sub58.7%
associate-/l*58.7%
*-inverses96.2%
/-rgt-identity96.2%
Simplified96.2%
if -5.79999999999999982e-9 < wj < 6.2000000000000001e-9Initial program 77.2%
distribute-rgt1-in77.2%
associate-/l/77.1%
div-sub77.1%
associate-/l*77.1%
*-inverses77.1%
/-rgt-identity77.1%
Simplified77.1%
add-sqr-sqrt39.6%
pow239.6%
Applied egg-rr39.6%
Taylor expanded in wj around 0 56.6%
unpow256.6%
add-sqr-sqrt99.3%
associate-+r+99.3%
*-commutative99.3%
distribute-rgt-out99.8%
metadata-eval99.8%
Applied egg-rr99.8%
if 6.2000000000000001e-9 < wj Initial program 55.6%
distribute-rgt1-in55.1%
associate-/l/55.0%
div-sub54.9%
associate-/l*54.9%
*-inverses96.6%
/-rgt-identity96.6%
Simplified96.6%
clear-num97.0%
associate-/r/97.1%
Applied egg-rr97.1%
Final simplification99.5%
(FPCore (wj x) :precision binary64 (if (<= wj 3.5e-35) (/ x (* (exp wj) (+ wj 1.0))) (+ wj (* (- wj (/ x (exp wj))) (/ -1.0 (+ wj 1.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x / (exp(wj) * (wj + 1.0));
} else {
tmp = wj + ((wj - (x / exp(wj))) * (-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 <= 3.5d-35) then
tmp = x / (exp(wj) * (wj + 1.0d0))
else
tmp = wj + ((wj - (x / exp(wj))) * ((-1.0d0) / (wj + 1.0d0)))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = wj + ((wj - (x / Math.exp(wj))) * (-1.0 / (wj + 1.0)));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 3.5e-35: tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = wj + ((wj - (x / math.exp(wj))) * (-1.0 / (wj + 1.0))) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 3.5e-35) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); else tmp = Float64(wj + Float64(Float64(wj - Float64(x / exp(wj))) * Float64(-1.0 / Float64(wj + 1.0)))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 3.5e-35) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = wj + ((wj - (x / exp(wj))) * (-1.0 / (wj + 1.0))); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 3.5e-35], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(wj - N[(x / N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 3.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;wj + \left(wj - \frac{x}{e^{wj}}\right) \cdot \frac{-1}{wj + 1}\\
\end{array}
\end{array}
if wj < 3.49999999999999996e-35Initial program 77.2%
distribute-rgt1-in78.4%
associate-/l/78.4%
div-sub77.2%
associate-/l*77.2%
*-inverses78.4%
/-rgt-identity78.4%
Simplified78.4%
Taylor expanded in x around inf 87.5%
associate-/r*87.5%
+-commutative87.5%
associate-/r*87.5%
Simplified87.5%
if 3.49999999999999996e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
clear-num81.8%
associate-/r/81.9%
Applied egg-rr81.9%
Final simplification87.1%
(FPCore (wj x) :precision binary64 (if (<= wj 3.5e-35) (/ x (* (exp wj) (+ wj 1.0))) (+ wj (/ (- (* x (exp (- wj))) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x / (exp(wj) * (wj + 1.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 <= 3.5d-35) then
tmp = x / (exp(wj) * (wj + 1.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 <= 3.5e-35) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = wj + (((x * Math.exp(-wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 3.5e-35: tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = wj + (((x * math.exp(-wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 3.5e-35) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); else tmp = Float64(wj + Float64(Float64(Float64(x * exp(Float64(-wj))) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 3.5e-35) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = wj + (((x * exp(-wj)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 3.5e-35], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.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 3.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{x \cdot e^{-wj} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 3.49999999999999996e-35Initial program 77.2%
distribute-rgt1-in78.4%
associate-/l/78.4%
div-sub77.2%
associate-/l*77.2%
*-inverses78.4%
/-rgt-identity78.4%
Simplified78.4%
Taylor expanded in x around inf 87.5%
associate-/r*87.5%
+-commutative87.5%
associate-/r*87.5%
Simplified87.5%
if 3.49999999999999996e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
clear-num81.4%
associate-/r/81.4%
rec-exp81.8%
Applied egg-rr81.8%
Final simplification87.1%
(FPCore (wj x) :precision binary64 (if (<= wj 3.5e-35) (/ x (* (exp wj) (+ wj 1.0))) (+ wj (/ (- (/ x (exp wj)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x / (exp(wj) * (wj + 1.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 <= 3.5d-35) then
tmp = x / (exp(wj) * (wj + 1.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 <= 3.5e-35) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = wj + (((x / Math.exp(wj)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 3.5e-35: tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = wj + (((x / math.exp(wj)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 3.5e-35) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.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 <= 3.5e-35) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = wj + (((x / exp(wj)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 3.5e-35], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.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 3.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 3.49999999999999996e-35Initial program 77.2%
distribute-rgt1-in78.4%
associate-/l/78.4%
div-sub77.2%
associate-/l*77.2%
*-inverses78.4%
/-rgt-identity78.4%
Simplified78.4%
Taylor expanded in x around inf 87.5%
associate-/r*87.5%
+-commutative87.5%
associate-/r*87.5%
Simplified87.5%
if 3.49999999999999996e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
Final simplification87.1%
(FPCore (wj x) :precision binary64 (if (<= wj 7.5) (/ x (* (exp wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 7.5) {
tmp = x / (exp(wj) * (wj + 1.0));
} 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 <= 7.5d0) then
tmp = x / (exp(wj) * (wj + 1.0d0))
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 <= 7.5) {
tmp = x / (Math.exp(wj) * (wj + 1.0));
} else {
tmp = wj - (wj / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 7.5: tmp = x / (math.exp(wj) * (wj + 1.0)) else: tmp = wj - (wj / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 7.5) tmp = Float64(x / Float64(exp(wj) * Float64(wj + 1.0))); 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 <= 7.5) tmp = x / (exp(wj) * (wj + 1.0)); else tmp = wj - (wj / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 7.5], N[(x / N[(N[Exp[wj], $MachinePrecision] * N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 7.5:\\
\;\;\;\;\frac{x}{e^{wj} \cdot \left(wj + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 7.5Initial program 77.1%
distribute-rgt1-in78.2%
associate-/l/78.2%
div-sub77.0%
associate-/l*77.0%
*-inverses78.2%
/-rgt-identity78.2%
Simplified78.2%
Taylor expanded in x around inf 85.9%
associate-/r*85.9%
+-commutative85.9%
associate-/r*85.9%
Simplified85.9%
if 7.5 < wj Initial program 0.0%
distribute-rgt1-in0.0%
associate-/l/0.0%
div-sub0.0%
associate-/l*0.0%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
Simplified100.0%
Final simplification86.2%
(FPCore (wj x)
:precision binary64
(if (<= wj -5.5e-17)
(+ wj (/ (- (- x (* wj x)) wj) (+ wj 1.0)))
(if (<= wj 3.2e-35)
(- x (pow wj 3.0))
(+ wj (/ (- (/ 1.0 (/ (+ wj 1.0) x)) wj) (+ wj 1.0))))))
double code(double wj, double x) {
double tmp;
if (wj <= -5.5e-17) {
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0));
} else if (wj <= 3.2e-35) {
tmp = x - pow(wj, 3.0);
} else {
tmp = wj + (((1.0 / ((wj + 1.0) / x)) - 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-17)) then
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0d0))
else if (wj <= 3.2d-35) then
tmp = x - (wj ** 3.0d0)
else
tmp = wj + (((1.0d0 / ((wj + 1.0d0) / x)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= -5.5e-17) {
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0));
} else if (wj <= 3.2e-35) {
tmp = x - Math.pow(wj, 3.0);
} else {
tmp = wj + (((1.0 / ((wj + 1.0) / x)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= -5.5e-17: tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0)) elif wj <= 3.2e-35: tmp = x - math.pow(wj, 3.0) else: tmp = wj + (((1.0 / ((wj + 1.0) / x)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= -5.5e-17) tmp = Float64(wj + Float64(Float64(Float64(x - Float64(wj * x)) - wj) / Float64(wj + 1.0))); elseif (wj <= 3.2e-35) tmp = Float64(x - (wj ^ 3.0)); else tmp = Float64(wj + Float64(Float64(Float64(1.0 / Float64(Float64(wj + 1.0) / x)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= -5.5e-17) tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0)); elseif (wj <= 3.2e-35) tmp = x - (wj ^ 3.0); else tmp = wj + (((1.0 / ((wj + 1.0) / x)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, -5.5e-17], N[(wj + N[(N[(N[(x - N[(wj * x), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[wj, 3.2e-35], N[(x - N[Power[wj, 3.0], $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(1.0 / N[(N[(wj + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq -5.5 \cdot 10^{-17}:\\
\;\;\;\;wj + \frac{\left(x - wj \cdot x\right) - wj}{wj + 1}\\
\mathbf{elif}\;wj \leq 3.2 \cdot 10^{-35}:\\
\;\;\;\;x - {wj}^{3}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{1}{\frac{wj + 1}{x}} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < -5.50000000000000001e-17Initial program 65.8%
distribute-rgt1-in85.5%
associate-/l/85.5%
div-sub65.5%
associate-/l*65.5%
*-inverses85.5%
/-rgt-identity85.5%
Simplified85.5%
Taylor expanded in wj around 0 59.4%
mul-1-neg59.4%
unsub-neg59.4%
*-commutative59.4%
Simplified59.4%
if -5.50000000000000001e-17 < wj < 3.1999999999999998e-35Initial program 77.9%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub77.9%
associate-/l*77.9%
*-inverses77.9%
/-rgt-identity77.9%
Simplified77.9%
Taylor expanded in wj around 0 99.6%
Taylor expanded in x around 0 99.6%
Taylor expanded in wj around inf 89.4%
neg-mul-189.4%
Simplified89.4%
if 3.1999999999999998e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
Taylor expanded in wj around 0 66.4%
+-commutative66.4%
Simplified66.4%
clear-num66.5%
inv-pow66.5%
Applied egg-rr66.5%
unpow-166.5%
Simplified66.5%
Final simplification86.0%
(FPCore (wj x) :precision binary64 (if (<= wj 3.5e-35) (* x (/ (- 1.0 wj) (+ wj 1.0))) (+ wj (/ (- (/ 1.0 (/ (+ wj 1.0) x)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((1.0 / ((wj + 1.0) / x)) - 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 <= 3.5d-35) then
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
else
tmp = wj + (((1.0d0 / ((wj + 1.0d0) / x)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((1.0 / ((wj + 1.0) / x)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 3.5e-35: tmp = x * ((1.0 - wj) / (wj + 1.0)) else: tmp = wj + (((1.0 / ((wj + 1.0) / x)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 3.5e-35) tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); else tmp = Float64(wj + Float64(Float64(Float64(1.0 / Float64(Float64(wj + 1.0) / x)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 3.5e-35) tmp = x * ((1.0 - wj) / (wj + 1.0)); else tmp = wj + (((1.0 / ((wj + 1.0) / x)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 3.5e-35], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(1.0 / N[(N[(wj + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 3.5 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{1}{\frac{wj + 1}{x}} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 3.49999999999999996e-35Initial program 77.2%
distribute-rgt1-in78.4%
associate-/l/78.4%
div-sub77.2%
associate-/l*77.2%
*-inverses78.4%
/-rgt-identity78.4%
Simplified78.4%
Taylor expanded in wj around 0 76.8%
mul-1-neg76.8%
unsub-neg76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in x around inf 85.8%
+-commutative85.8%
+-commutative85.8%
Simplified85.8%
Taylor expanded in x around 0 85.8%
div-sub85.8%
Simplified85.8%
if 3.49999999999999996e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
Taylor expanded in wj around 0 66.4%
+-commutative66.4%
Simplified66.4%
clear-num66.5%
inv-pow66.5%
Applied egg-rr66.5%
unpow-166.5%
Simplified66.5%
Final simplification84.5%
(FPCore (wj x) :precision binary64 (if (<= wj 3.5e-35) (* x (/ (- 1.0 wj) (+ wj 1.0))) (+ wj (/ (- (- x (* wj x)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((x - (wj * x)) - 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 <= 3.5d-35) then
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
else
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 3.5e-35: tmp = x * ((1.0 - wj) / (wj + 1.0)) else: tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 3.5e-35) tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); else tmp = Float64(wj + Float64(Float64(Float64(x - Float64(wj * x)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 3.5e-35) tmp = x * ((1.0 - wj) / (wj + 1.0)); else tmp = wj + (((x - (wj * x)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 3.5e-35], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x - N[(wj * x), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 3.5 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\left(x - wj \cdot x\right) - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 3.49999999999999996e-35Initial program 77.2%
distribute-rgt1-in78.4%
associate-/l/78.4%
div-sub77.2%
associate-/l*77.2%
*-inverses78.4%
/-rgt-identity78.4%
Simplified78.4%
Taylor expanded in wj around 0 76.8%
mul-1-neg76.8%
unsub-neg76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in x around inf 85.8%
+-commutative85.8%
+-commutative85.8%
Simplified85.8%
Taylor expanded in x around 0 85.8%
div-sub85.8%
Simplified85.8%
if 3.49999999999999996e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
Taylor expanded in wj around 0 65.4%
mul-1-neg65.4%
unsub-neg65.4%
*-commutative65.4%
Simplified65.4%
Final simplification84.4%
(FPCore (wj x) :precision binary64 (if (<= wj 3.5e-35) (* x (/ (- 1.0 wj) (+ wj 1.0))) (+ wj (/ (- (/ x (+ wj 1.0)) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((x / (wj + 1.0)) - wj) / (wj + 1.0));
}
return tmp;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
real(8) :: tmp
if (wj <= 3.5d-35) then
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
else
tmp = wj + (((x / (wj + 1.0d0)) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 3.5e-35) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((x / (wj + 1.0)) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 3.5e-35: tmp = x * ((1.0 - wj) / (wj + 1.0)) else: tmp = wj + (((x / (wj + 1.0)) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 3.5e-35) tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); else tmp = Float64(wj + Float64(Float64(Float64(x / Float64(wj + 1.0)) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 3.5e-35) tmp = x * ((1.0 - wj) / (wj + 1.0)); else tmp = wj + (((x / (wj + 1.0)) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 3.5e-35], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 3.5 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{wj + 1} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 3.49999999999999996e-35Initial program 77.2%
distribute-rgt1-in78.4%
associate-/l/78.4%
div-sub77.2%
associate-/l*77.2%
*-inverses78.4%
/-rgt-identity78.4%
Simplified78.4%
Taylor expanded in wj around 0 76.8%
mul-1-neg76.8%
unsub-neg76.8%
*-commutative76.8%
Simplified76.8%
Taylor expanded in x around inf 85.8%
+-commutative85.8%
+-commutative85.8%
Simplified85.8%
Taylor expanded in x around 0 85.8%
div-sub85.8%
Simplified85.8%
if 3.49999999999999996e-35 < wj Initial program 54.2%
distribute-rgt1-in53.9%
associate-/l/53.8%
div-sub53.7%
associate-/l*53.7%
*-inverses81.5%
/-rgt-identity81.5%
Simplified81.5%
Taylor expanded in wj around 0 66.4%
+-commutative66.4%
Simplified66.4%
Final simplification84.4%
(FPCore (wj x) :precision binary64 (if (<= wj 9e-7) (* x (/ (- 1.0 wj) (+ wj 1.0))) (+ wj (/ (- (/ x wj) wj) (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 9e-7) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((x / 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 <= 9d-7) then
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
else
tmp = wj + (((x / wj) - wj) / (wj + 1.0d0))
end if
code = tmp
end function
public static double code(double wj, double x) {
double tmp;
if (wj <= 9e-7) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj + (((x / wj) - wj) / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 9e-7: tmp = x * ((1.0 - wj) / (wj + 1.0)) else: tmp = wj + (((x / wj) - wj) / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 9e-7) tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); else tmp = Float64(wj + Float64(Float64(Float64(x / wj) - wj) / Float64(wj + 1.0))); end return tmp end
function tmp_2 = code(wj, x) tmp = 0.0; if (wj <= 9e-7) tmp = x * ((1.0 - wj) / (wj + 1.0)); else tmp = wj + (((x / wj) - wj) / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 9e-7], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj + N[(N[(N[(x / wj), $MachinePrecision] - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 9 \cdot 10^{-7}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;wj + \frac{\frac{x}{wj} - wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 8.99999999999999959e-7Initial program 76.6%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub76.6%
associate-/l*76.6%
*-inverses77.9%
/-rgt-identity77.9%
Simplified77.9%
Taylor expanded in wj around 0 76.3%
mul-1-neg76.3%
unsub-neg76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in x around inf 85.0%
+-commutative85.0%
+-commutative85.0%
Simplified85.0%
Taylor expanded in x around 0 85.0%
div-sub85.0%
Simplified85.0%
if 8.99999999999999959e-7 < wj Initial program 51.5%
distribute-rgt1-in51.0%
associate-/l/51.0%
div-sub50.8%
associate-/l*50.8%
*-inverses96.3%
/-rgt-identity96.3%
Simplified96.3%
Taylor expanded in wj around 0 71.6%
+-commutative71.6%
Simplified71.6%
Taylor expanded in wj around inf 66.1%
Final simplification84.2%
(FPCore (wj x) :precision binary64 (if (<= wj 8e-6) (* x (/ (- 1.0 wj) (+ wj 1.0))) (- wj (/ wj (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 8e-6) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} 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 <= 8d-6) then
tmp = x * ((1.0d0 - wj) / (wj + 1.0d0))
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 <= 8e-6) {
tmp = x * ((1.0 - wj) / (wj + 1.0));
} else {
tmp = wj - (wj / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 8e-6: tmp = x * ((1.0 - wj) / (wj + 1.0)) else: tmp = wj - (wj / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 8e-6) tmp = Float64(x * Float64(Float64(1.0 - wj) / Float64(wj + 1.0))); 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 <= 8e-6) tmp = x * ((1.0 - wj) / (wj + 1.0)); else tmp = wj - (wj / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 8e-6], N[(x * N[(N[(1.0 - wj), $MachinePrecision] / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(wj - N[(wj / N[(wj + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;wj \leq 8 \cdot 10^{-6}:\\
\;\;\;\;x \cdot \frac{1 - wj}{wj + 1}\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 7.99999999999999964e-6Initial program 76.6%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub76.6%
associate-/l*76.6%
*-inverses77.9%
/-rgt-identity77.9%
Simplified77.9%
Taylor expanded in wj around 0 76.3%
mul-1-neg76.3%
unsub-neg76.3%
*-commutative76.3%
Simplified76.3%
Taylor expanded in x around inf 85.0%
+-commutative85.0%
+-commutative85.0%
Simplified85.0%
Taylor expanded in x around 0 85.0%
div-sub85.0%
Simplified85.0%
if 7.99999999999999964e-6 < wj Initial program 51.5%
distribute-rgt1-in51.0%
associate-/l/51.0%
div-sub50.8%
associate-/l*50.8%
*-inverses96.3%
/-rgt-identity96.3%
Simplified96.3%
Taylor expanded in x around 0 62.0%
+-commutative62.0%
Simplified62.0%
Final simplification84.0%
(FPCore (wj x) :precision binary64 (if (<= wj 4e-8) (+ x (* -2.0 (* wj x))) (- wj (/ wj (+ wj 1.0)))))
double code(double wj, double x) {
double tmp;
if (wj <= 4e-8) {
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 <= 4d-8) 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 <= 4e-8) {
tmp = x + (-2.0 * (wj * x));
} else {
tmp = wj - (wj / (wj + 1.0));
}
return tmp;
}
def code(wj, x): tmp = 0 if wj <= 4e-8: tmp = x + (-2.0 * (wj * x)) else: tmp = wj - (wj / (wj + 1.0)) return tmp
function code(wj, x) tmp = 0.0 if (wj <= 4e-8) 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 <= 4e-8) tmp = x + (-2.0 * (wj * x)); else tmp = wj - (wj / (wj + 1.0)); end tmp_2 = tmp; end
code[wj_, x_] := If[LessEqual[wj, 4e-8], 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 4 \cdot 10^{-8}:\\
\;\;\;\;x + -2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj}{wj + 1}\\
\end{array}
\end{array}
if wj < 4.0000000000000001e-8Initial program 76.6%
distribute-rgt1-in77.9%
associate-/l/77.9%
div-sub76.6%
associate-/l*76.6%
*-inverses77.9%
/-rgt-identity77.9%
Simplified77.9%
Taylor expanded in wj around 0 85.0%
*-commutative85.0%
Simplified85.0%
if 4.0000000000000001e-8 < wj Initial program 51.5%
distribute-rgt1-in51.0%
associate-/l/51.0%
div-sub50.8%
associate-/l*50.8%
*-inverses96.3%
/-rgt-identity96.3%
Simplified96.3%
Taylor expanded in x around 0 62.0%
+-commutative62.0%
Simplified62.0%
Final simplification84.0%
(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 75.6%
distribute-rgt1-in76.7%
associate-/l/76.7%
div-sub75.5%
associate-/l*75.5%
*-inverses78.6%
/-rgt-identity78.6%
Simplified78.6%
Taylor expanded in wj around 0 81.7%
*-commutative81.7%
Simplified81.7%
Final simplification81.7%
(FPCore (wj x) :precision binary64 wj)
double code(double wj, double x) {
return wj;
}
real(8) function code(wj, x)
real(8), intent (in) :: wj
real(8), intent (in) :: x
code = wj
end function
public static double code(double wj, double x) {
return wj;
}
def code(wj, x): return wj
function code(wj, x) return wj end
function tmp = code(wj, x) tmp = wj; end
code[wj_, x_] := wj
\begin{array}{l}
\\
wj
\end{array}
Initial program 75.6%
distribute-rgt1-in76.7%
associate-/l/76.7%
div-sub75.5%
associate-/l*75.5%
*-inverses78.6%
/-rgt-identity78.6%
Simplified78.6%
Taylor expanded in wj around inf 4.7%
Final simplification4.7%
(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.6%
distribute-rgt1-in76.7%
associate-/l/76.7%
div-sub75.5%
associate-/l*75.5%
*-inverses78.6%
/-rgt-identity78.6%
Simplified78.6%
Taylor expanded in wj around 0 80.8%
Final simplification80.8%
(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 2023321
(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))))))