exp(-100) / (exp(-100) + exp(-101))

Percentage Accurate: 98.4% → 100.0%
Time: 1.9s
Alternatives: 1
Speedup: 0.8×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-100}\\ \frac{t\_0}{t\_0 + e^{-101}} \end{array} \end{array} \]
(FPCore ()
 :precision binary64
 (let* ((t_0 (exp (- 100.0)))) (/ t_0 (+ t_0 (exp (- 101.0))))))
double code() {
	double t_0 = exp(-100.0);
	return t_0 / (t_0 + exp(-101.0));
}
real(8) function code()
    real(8) :: t_0
    t_0 = exp(-100.0d0)
    code = t_0 / (t_0 + exp(-101.0d0))
end function
public static double code() {
	double t_0 = Math.exp(-100.0);
	return t_0 / (t_0 + Math.exp(-101.0));
}
def code():
	t_0 = math.exp(-100.0)
	return t_0 / (t_0 + math.exp(-101.0))
function code()
	t_0 = exp(Float64(-100.0))
	return Float64(t_0 / Float64(t_0 + exp(Float64(-101.0))))
end
function tmp = code()
	t_0 = exp(-100.0);
	tmp = t_0 / (t_0 + exp(-101.0));
end
code[] := Block[{t$95$0 = N[Exp[(-100.0)], $MachinePrecision]}, N[(t$95$0 / N[(t$95$0 + N[Exp[(-101.0)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-100}\\
\frac{t\_0}{t\_0 + e^{-101}}
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 1 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-100}\\ \frac{t\_0}{t\_0 + e^{-101}} \end{array} \end{array} \]
(FPCore ()
 :precision binary64
 (let* ((t_0 (exp (- 100.0)))) (/ t_0 (+ t_0 (exp (- 101.0))))))
double code() {
	double t_0 = exp(-100.0);
	return t_0 / (t_0 + exp(-101.0));
}
real(8) function code()
    real(8) :: t_0
    t_0 = exp(-100.0d0)
    code = t_0 / (t_0 + exp(-101.0d0))
end function
public static double code() {
	double t_0 = Math.exp(-100.0);
	return t_0 / (t_0 + Math.exp(-101.0));
}
def code():
	t_0 = math.exp(-100.0)
	return t_0 / (t_0 + math.exp(-101.0))
function code()
	t_0 = exp(Float64(-100.0))
	return Float64(t_0 / Float64(t_0 + exp(Float64(-101.0))))
end
function tmp = code()
	t_0 = exp(-100.0);
	tmp = t_0 / (t_0 + exp(-101.0));
end
code[] := Block[{t$95$0 = N[Exp[(-100.0)], $MachinePrecision]}, N[(t$95$0 / N[(t$95$0 + N[Exp[(-101.0)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-100}\\
\frac{t\_0}{t\_0 + e^{-101}}
\end{array}
\end{array}

Alternative 1: 100.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ {\left(e^{100} \cdot \left(e^{-101} + e^{-100}\right)\right)}^{-1} \end{array} \]
(FPCore ()
 :precision binary64
 (pow (* (exp 100.0) (+ (exp -101.0) (exp -100.0))) -1.0))
double code() {
	return pow((exp(100.0) * (exp(-101.0) + exp(-100.0))), -1.0);
}
real(8) function code()
    code = (exp(100.0d0) * (exp((-101.0d0)) + exp((-100.0d0)))) ** (-1.0d0)
end function
public static double code() {
	return Math.pow((Math.exp(100.0) * (Math.exp(-101.0) + Math.exp(-100.0))), -1.0);
}
def code():
	return math.pow((math.exp(100.0) * (math.exp(-101.0) + math.exp(-100.0))), -1.0)
function code()
	return Float64(exp(100.0) * Float64(exp(-101.0) + exp(-100.0))) ^ -1.0
end
function tmp = code()
	tmp = (exp(100.0) * (exp(-101.0) + exp(-100.0))) ^ -1.0;
end
code[] := N[Power[N[(N[Exp[100.0], $MachinePrecision] * N[(N[Exp[-101.0], $MachinePrecision] + N[Exp[-100.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}

\\
{\left(e^{100} \cdot \left(e^{-101} + e^{-100}\right)\right)}^{-1}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\frac{e^{-100}}{e^{-100} + e^{-101}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{e^{-100}}{e^{-100} + e^{-101}}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{-100} + e^{-101}}{e^{-100}}}} \]
    3. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{-100} + e^{-101}}{e^{-100}}}} \]
    4. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{e^{-100}}{e^{-100} + e^{-101}}}}} \]
    5. associate-/r/N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{e^{-100}} \cdot \left(e^{-100} + e^{-101}\right)}} \]
    6. lower-*.f64N/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{e^{-100}} \cdot \left(e^{-100} + e^{-101}\right)}} \]
    7. lift-exp.f64N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{e^{-100}}} \cdot \left(e^{-100} + e^{-101}\right)} \]
    8. rec-expN/A

      \[\leadsto \frac{1}{\color{blue}{e^{\mathsf{neg}\left(\left(-100\right)\right)}} \cdot \left(e^{-100} + e^{-101}\right)} \]
    9. lift-neg.f64N/A

      \[\leadsto \frac{1}{e^{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(100\right)\right)}\right)} \cdot \left(e^{-100} + e^{-101}\right)} \]
    10. metadata-evalN/A

      \[\leadsto \frac{1}{e^{\mathsf{neg}\left(\color{blue}{-100}\right)} \cdot \left(e^{-100} + e^{-101}\right)} \]
    11. metadata-evalN/A

      \[\leadsto \frac{1}{e^{\color{blue}{100}} \cdot \left(e^{-100} + e^{-101}\right)} \]
    12. lower-exp.f64100.0

      \[\leadsto \frac{1}{\color{blue}{e^{100}} \cdot \left(e^{-100} + e^{-101}\right)} \]
    13. lift-+.f64N/A

      \[\leadsto \frac{1}{e^{100} \cdot \color{blue}{\left(e^{-100} + e^{-101}\right)}} \]
    14. +-commutativeN/A

      \[\leadsto \frac{1}{e^{100} \cdot \color{blue}{\left(e^{-101} + e^{-100}\right)}} \]
    15. lower-+.f64100.0

      \[\leadsto \frac{1}{e^{100} \cdot \color{blue}{\left(e^{-101} + e^{-100}\right)}} \]
    16. lift-neg.f64N/A

      \[\leadsto \frac{1}{e^{100} \cdot \left(e^{\color{blue}{\mathsf{neg}\left(101\right)}} + e^{-100}\right)} \]
    17. metadata-eval100.0

      \[\leadsto \frac{1}{e^{100} \cdot \left(e^{\color{blue}{-101}} + e^{-100}\right)} \]
    18. lift-neg.f64N/A

      \[\leadsto \frac{1}{e^{100} \cdot \left(e^{-101} + e^{\color{blue}{\mathsf{neg}\left(100\right)}}\right)} \]
    19. metadata-eval100.0

      \[\leadsto \frac{1}{e^{100} \cdot \left(e^{-101} + e^{\color{blue}{-100}}\right)} \]
  4. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{1}{e^{100} \cdot \left(e^{-101} + e^{-100}\right)}} \]
  5. Final simplification100.0%

    \[\leadsto {\left(e^{100} \cdot \left(e^{-101} + e^{-100}\right)\right)}^{-1} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore ()
  :name "exp(-100) / (exp(-100) + exp(-101))"
  :precision binary64
  (/ (exp (- 100.0)) (+ (exp (- 100.0)) (exp (- 101.0)))))