?

Average Error: 13.7 → 0.7
Time: 1.9min
Precision: binary64
Cost: 7936

?

\[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
\[\frac{wj \cdot x + \left({wj}^{2} \cdot \left(\left(0.5 \cdot x + -1 \cdot x\right) - 1\right) + -1 \cdot x\right)}{-1 - wj} \]
(FPCore (wj x)
 :precision binary64
 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x)
 :precision binary64
 (/
  (+ (* wj x) (+ (* (pow wj 2.0) (- (+ (* 0.5 x) (* -1.0 x)) 1.0)) (* -1.0 x)))
  (- -1.0 wj)))
double code(double wj, double x) {
	return wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))));
}
double code(double wj, double x) {
	return ((wj * x) + ((pow(wj, 2.0) * (((0.5 * x) + (-1.0 * x)) - 1.0)) + (-1.0 * x))) / (-1.0 - wj);
}
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))))
end function
real(8) function code(wj, x)
    real(8), intent (in) :: wj
    real(8), intent (in) :: x
    code = ((wj * x) + (((wj ** 2.0d0) * (((0.5d0 * x) + ((-1.0d0) * x)) - 1.0d0)) + ((-1.0d0) * x))) / ((-1.0d0) - wj)
end function
public static double code(double wj, double x) {
	return wj - (((wj * Math.exp(wj)) - x) / (Math.exp(wj) + (wj * Math.exp(wj))));
}
public static double code(double wj, double x) {
	return ((wj * x) + ((Math.pow(wj, 2.0) * (((0.5 * x) + (-1.0 * x)) - 1.0)) + (-1.0 * x))) / (-1.0 - wj);
}
def code(wj, x):
	return wj - (((wj * math.exp(wj)) - x) / (math.exp(wj) + (wj * math.exp(wj))))
def code(wj, x):
	return ((wj * x) + ((math.pow(wj, 2.0) * (((0.5 * x) + (-1.0 * x)) - 1.0)) + (-1.0 * x))) / (-1.0 - wj)
function code(wj, x)
	return Float64(wj - Float64(Float64(Float64(wj * exp(wj)) - x) / Float64(exp(wj) + Float64(wj * exp(wj)))))
end
function code(wj, x)
	return Float64(Float64(Float64(wj * x) + Float64(Float64((wj ^ 2.0) * Float64(Float64(Float64(0.5 * x) + Float64(-1.0 * x)) - 1.0)) + Float64(-1.0 * x))) / Float64(-1.0 - wj))
end
function tmp = code(wj, x)
	tmp = wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))));
end
function tmp = code(wj, x)
	tmp = ((wj * x) + (((wj ^ 2.0) * (((0.5 * x) + (-1.0 * x)) - 1.0)) + (-1.0 * x))) / (-1.0 - wj);
end
code[wj_, x_] := N[(wj - N[(N[(N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[(N[Exp[wj], $MachinePrecision] + N[(wj * N[Exp[wj], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[wj_, x_] := N[(N[(N[(wj * x), $MachinePrecision] + N[(N[(N[Power[wj, 2.0], $MachinePrecision] * N[(N[(N[(0.5 * x), $MachinePrecision] + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - wj), $MachinePrecision]), $MachinePrecision]
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\frac{wj \cdot x + \left({wj}^{2} \cdot \left(\left(0.5 \cdot x + -1 \cdot x\right) - 1\right) + -1 \cdot x\right)}{-1 - wj}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.7
Target13.1
Herbie0.7
\[wj - \left(\frac{wj}{wj + 1} - \frac{x}{e^{wj} + wj \cdot e^{wj}}\right) \]

Derivation?

  1. Initial program 13.7

    \[wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \]
  2. Simplified13.1

    \[\leadsto \color{blue}{wj + \frac{\frac{x}{e^{wj}} - wj}{1 + wj}} \]
    Proof
  3. Applied egg-rr13.1

    \[\leadsto \color{blue}{\frac{\left(wj - \frac{x}{e^{wj}}\right) + \left(1 + wj\right) \cdot \left(-wj\right)}{-1 - wj}} \]
  4. Taylor expanded in wj around 0 0.7

    \[\leadsto \frac{\color{blue}{wj \cdot x + \left({wj}^{2} \cdot \left(\left(0.5 \cdot x + -1 \cdot x\right) - 1\right) + -1 \cdot x\right)}}{-1 - wj} \]

Alternatives

Alternative 1
Error9.0
Cost7112
\[\begin{array}{l} t_0 := \frac{x}{\left(1 + wj\right) \cdot e^{wj}}\\ \mathbf{if}\;x \leq -1.05 \cdot 10^{-291}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-256}:\\ \;\;\;\;\frac{\left(-wj\right) \cdot wj}{-1 - wj}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error2.2
Cost7040
\[{wj}^{2} + \left(-2 \cdot \left(wj \cdot x\right) + x\right) \]
Alternative 3
Error9.5
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-292}:\\ \;\;\;\;\frac{x}{wj \cdot 2 - -1}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-257}:\\ \;\;\;\;\frac{\left(-wj\right) \cdot wj}{-1 - wj}\\ \mathbf{else}:\\ \;\;\;\;\frac{wj \cdot x - x}{-1 - wj}\\ \end{array} \]
Alternative 4
Error9.5
Cost776
\[\begin{array}{l} t_0 := \frac{x}{wj \cdot 2 - -1}\\ \mathbf{if}\;x \leq -3.5 \cdot 10^{-291}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-257}:\\ \;\;\;\;\frac{\left(-wj\right) \cdot wj}{-1 - wj}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.7
Cost712
\[\begin{array}{l} t_0 := -2 \cdot \left(wj \cdot x\right) + x\\ \mathbf{if}\;x \leq -3.15 \cdot 10^{-291}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-257}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error9.6
Cost712
\[\begin{array}{l} t_0 := \frac{x}{wj \cdot 2 - -1}\\ \mathbf{if}\;x \leq -2.3 \cdot 10^{-291}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-256}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error10.1
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{-291}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-255}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x - wj \cdot x\\ \end{array} \]
Alternative 8
Error10.0
Cost584
\[\begin{array}{l} t_0 := \frac{x}{wj - -1}\\ \mathbf{if}\;x \leq -9 \cdot 10^{-292}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-255}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error10.1
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7.4 \cdot 10^{-291}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-257}:\\ \;\;\;\;wj \cdot wj\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error61.2
Cost64
\[wj \]
Alternative 11
Error9.8
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023033 
(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))))))