Average Error: 0.3 → 0.3
Time: 40.3s
Precision: binary64
Cost: 162176
\[\left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 1\right) \land \left(0 \leq s \land s \leq 1.0651631\right)\]
\[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
\[\begin{array}{l} t_0 := e^{-\mathsf{log1p}\left(e^{\frac{\pi}{s}}\right)}\\ t_1 := \left(t_0 - e^{-\mathsf{log1p}\left(e^{\frac{\pi}{-s}}\right)}\right) \cdot u - t_0\\ \left(-s\right) \cdot \log \left(\frac{-1 - t_1}{t_1}\right) \end{array} \]
(FPCore (u s)
 :precision binary64
 (*
  (- s)
  (log
   (-
    (/
     1.0
     (+
      (*
       u
       (- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) (/ 1.0 (+ 1.0 (exp (/ PI s))))))
      (/ 1.0 (+ 1.0 (exp (/ PI s))))))
    1.0))))
(FPCore (u s)
 :precision binary64
 (let* ((t_0 (exp (- (log1p (exp (/ PI s))))))
        (t_1 (- (* (- t_0 (exp (- (log1p (exp (/ PI (- s))))))) u) t_0)))
   (* (- s) (log (/ (- -1.0 t_1) t_1)))))
double code(double u, double s) {
	return -s * log(((1.0 / ((u * ((1.0 / (1.0 + exp((-((double) M_PI) / s)))) - (1.0 / (1.0 + exp((((double) M_PI) / s)))))) + (1.0 / (1.0 + exp((((double) M_PI) / s)))))) - 1.0));
}
double code(double u, double s) {
	double t_0 = exp(-log1p(exp((((double) M_PI) / s))));
	double t_1 = ((t_0 - exp(-log1p(exp((((double) M_PI) / -s))))) * u) - t_0;
	return -s * log(((-1.0 - t_1) / t_1));
}
public static double code(double u, double s) {
	return -s * Math.log(((1.0 / ((u * ((1.0 / (1.0 + Math.exp((-Math.PI / s)))) - (1.0 / (1.0 + Math.exp((Math.PI / s)))))) + (1.0 / (1.0 + Math.exp((Math.PI / s)))))) - 1.0));
}
public static double code(double u, double s) {
	double t_0 = Math.exp(-Math.log1p(Math.exp((Math.PI / s))));
	double t_1 = ((t_0 - Math.exp(-Math.log1p(Math.exp((Math.PI / -s))))) * u) - t_0;
	return -s * Math.log(((-1.0 - t_1) / t_1));
}
def code(u, s):
	return -s * math.log(((1.0 / ((u * ((1.0 / (1.0 + math.exp((-math.pi / s)))) - (1.0 / (1.0 + math.exp((math.pi / s)))))) + (1.0 / (1.0 + math.exp((math.pi / s)))))) - 1.0))
def code(u, s):
	t_0 = math.exp(-math.log1p(math.exp((math.pi / s))))
	t_1 = ((t_0 - math.exp(-math.log1p(math.exp((math.pi / -s))))) * u) - t_0
	return -s * math.log(((-1.0 - t_1) / t_1))
function code(u, s)
	return Float64(Float64(-s) * log(Float64(Float64(1.0 / Float64(Float64(u * Float64(Float64(1.0 / Float64(1.0 + exp(Float64(Float64(-pi) / s)))) - Float64(1.0 / Float64(1.0 + exp(Float64(pi / s)))))) + Float64(1.0 / Float64(1.0 + exp(Float64(pi / s)))))) - 1.0)))
end
function code(u, s)
	t_0 = exp(Float64(-log1p(exp(Float64(pi / s)))))
	t_1 = Float64(Float64(Float64(t_0 - exp(Float64(-log1p(exp(Float64(pi / Float64(-s))))))) * u) - t_0)
	return Float64(Float64(-s) * log(Float64(Float64(-1.0 - t_1) / t_1)))
end
code[u_, s_] := N[((-s) * N[Log[N[(N[(1.0 / N[(N[(u * N[(N[(1.0 / N[(1.0 + N[Exp[N[((-Pi) / s), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[(1.0 + N[Exp[N[(Pi / s), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(1.0 + N[Exp[N[(Pi / s), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[u_, s_] := Block[{t$95$0 = N[Exp[(-N[Log[1 + N[Exp[N[(Pi / s), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(t$95$0 - N[Exp[(-N[Log[1 + N[Exp[N[(Pi / (-s)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * u), $MachinePrecision] - t$95$0), $MachinePrecision]}, N[((-s) * N[Log[N[(N[(-1.0 - t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right)
\begin{array}{l}
t_0 := e^{-\mathsf{log1p}\left(e^{\frac{\pi}{s}}\right)}\\
t_1 := \left(t_0 - e^{-\mathsf{log1p}\left(e^{\frac{\pi}{-s}}\right)}\right) \cdot u - t_0\\
\left(-s\right) \cdot \log \left(\frac{-1 - t_1}{t_1}\right)
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.3

    \[\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right) \]
  2. Applied egg-rr0.3

    \[\leadsto \left(-s\right) \cdot \log \color{blue}{\left(\frac{-1 - \left(\left(e^{-\mathsf{log1p}\left(e^{\frac{\pi}{s}}\right)} - e^{-\mathsf{log1p}\left(e^{\frac{\pi}{-s}}\right)}\right) \cdot u - e^{-\mathsf{log1p}\left(e^{\frac{\pi}{s}}\right)}\right)}{\left(e^{-\mathsf{log1p}\left(e^{\frac{\pi}{s}}\right)} - e^{-\mathsf{log1p}\left(e^{\frac{\pi}{-s}}\right)}\right) \cdot u - e^{-\mathsf{log1p}\left(e^{\frac{\pi}{s}}\right)}}\right)} \]

Alternatives

Alternative 1
Error0.3
Cost46720
\[\begin{array}{l} t_0 := \frac{1}{1 + e^{\frac{\pi}{s}}}\\ \left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - t_0\right) + t_0} - 1\right) \end{array} \]
Alternative 2
Error54.4
Cost13828
\[\begin{array}{l} t_0 := \mathsf{log1p}\left(\frac{1}{s}\right)\\ t_1 := t_0 \cdot \left(-s\right)\\ \mathbf{if}\;t_1 \ne 0:\\ \;\;\;\;\frac{2}{\frac{\frac{-2}{s}}{t_0}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error54.4
Cost6912
\[\left(-s \cdot s\right) + s \cdot \log s \]
Alternative 4
Error54.4
Cost6784
\[\left(-\mathsf{log1p}\left(\frac{1}{s}\right)\right) \cdot s \]
Alternative 5
Error54.4
Cost6592
\[s \cdot \log s \]
Alternative 6
Error60.6
Cost64
\[-1 \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (u s)
  :name "Sample trimmed logistic on [-pi, pi]"
  :precision binary64
  :pre (and (and (<= 2.328306437e-10 u) (<= u 1.0)) (and (<= 0.0 s) (<= s 1.0651631)))
  (* (- s) (log (- (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) (/ 1.0 (+ 1.0 (exp (/ PI s)))))) (/ 1.0 (+ 1.0 (exp (/ PI s)))))) 1.0))))