Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 9.8s
Alternatives: 23
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (+
  (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
  (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))))
end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
\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 23 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: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (+
  (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
  (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))))
end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (+
  (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
  (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \]
  4. Add Preprocessing

Alternative 2: 79.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\ t_1 := t\_0 + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-235} \lor \neg \left(t\_1 \leq 4 \cdot 10^{-235}\right):\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
        (t_1
         (+
          t_0
          (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
   (if (or (<= t_1 -5e-235) (not (<= t_1 4e-235)))
     (+ t_0 (/ NaChar (+ 1.0 (exp (/ Ev KbT)))))
     (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor (+ Vef mu)) Ec) KbT)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	double t_1 = t_0 + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
	double tmp;
	if ((t_1 <= -5e-235) || !(t_1 <= 4e-235)) {
		tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT))));
	} else {
		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
    t_1 = t_0 + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
    if ((t_1 <= (-5d-235)) .or. (.not. (t_1 <= 4d-235))) then
        tmp = t_0 + (nachar / (1.0d0 + exp((ev / kbt))))
    else
        tmp = ndchar / (1.0d0 + exp((((edonor + (vef + mu)) - ec) / kbt)))
    end if
    code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	double t_1 = t_0 + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
	double tmp;
	if ((t_1 <= -5e-235) || !(t_1 <= 4e-235)) {
		tmp = t_0 + (NaChar / (1.0 + Math.exp((Ev / KbT))));
	} else {
		tmp = NdChar / (1.0 + Math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))
	t_1 = t_0 + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
	tmp = 0
	if (t_1 <= -5e-235) or not (t_1 <= 4e-235):
		tmp = t_0 + (NaChar / (1.0 + math.exp((Ev / KbT))))
	else:
		tmp = NdChar / (1.0 + math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)))
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT))))
	t_1 = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
	tmp = 0.0
	if ((t_1 <= -5e-235) || !(t_1 <= 4e-235))
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT)))));
	else
		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Float64(Vef + mu)) - Ec) / KbT))));
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	t_1 = t_0 + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
	tmp = 0.0;
	if ((t_1 <= -5e-235) || ~((t_1 <= 4e-235)))
		tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT))));
	else
		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e-235], N[Not[LessEqual[t$95$1, 4e-235]], $MachinePrecision]], N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + N[(Vef + mu), $MachinePrecision]), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := t\_0 + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-235} \lor \neg \left(t\_1 \leq 4 \cdot 10^{-235}\right):\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.9999999999999998e-235 or 3.9999999999999998e-235 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

    1. Initial program 100.0%

      \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
    2. Add Preprocessing
    3. Taylor expanded in Ev around inf

      \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
    4. Step-by-step derivation
      1. Applied rewrites78.9%

        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]

      if -4.9999999999999998e-235 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 3.9999999999999998e-235

      1. Initial program 100.0%

        \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
      2. Add Preprocessing
      3. Taylor expanded in NdChar around inf

        \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
      4. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
        2. lower-+.f64N/A

          \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
        3. lower-exp.f64N/A

          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
        5. lower--.f64N/A

          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
        6. lower-+.f64N/A

          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
        7. lower-+.f6492.8

          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
      5. Applied rewrites92.8%

        \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification82.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-235} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 4 \cdot 10^{-235}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 3: 40.1% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
     :precision binary64
     (let* ((t_0
             (+
              (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
              (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
       (if (<= t_0 -1e-230)
         (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
         (if (<= t_0 5e-246)
           (/
            NdChar
            (-
             (+
              2.0
              (/
               (/
                (- (* EDonor EDonor) (* (+ Vef mu) (+ Vef mu)))
                (- EDonor (+ Vef mu)))
               KbT))
             (/ Ec KbT)))
           (fma 0.5 NaChar (* 0.5 NdChar))))))
    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
    	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if (t_0 <= -1e-230) {
    		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
    	} else if (t_0 <= 5e-246) {
    		tmp = NdChar / ((2.0 + ((((EDonor * EDonor) - ((Vef + mu) * (Vef + mu))) / (EDonor - (Vef + mu))) / KbT)) - (Ec / KbT));
    	} else {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	}
    	return tmp;
    }
    
    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
    	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
    	tmp = 0.0
    	if (t_0 <= -1e-230)
    		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
    	elseif (t_0 <= 5e-246)
    		tmp = Float64(NdChar / Float64(Float64(2.0 + Float64(Float64(Float64(Float64(EDonor * EDonor) - Float64(Float64(Vef + mu) * Float64(Vef + mu))) / Float64(EDonor - Float64(Vef + mu))) / KbT)) - Float64(Ec / KbT)));
    	else
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	end
    	return tmp
    end
    
    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-230], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-246], N[(NdChar / N[(N[(2.0 + N[(N[(N[(N[(EDonor * EDonor), $MachinePrecision] - N[(N[(Vef + mu), $MachinePrecision] * N[(Vef + mu), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(EDonor - N[(Vef + mu), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision] - N[(Ec / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\
    \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\
    \;\;\;\;\frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000005e-230

      1. Initial program 100.0%

        \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. frac-addN/A

          \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
        2. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
      4. Applied rewrites52.6%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
      5. Taylor expanded in KbT around inf

        \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
      6. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
        2. lower-fma.f64N/A

          \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
        3. lower-*.f6434.0

          \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
      7. Applied rewrites34.0%

        \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

      if -1.00000000000000005e-230 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.9999999999999997e-246

      1. Initial program 100.0%

        \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
      2. Add Preprocessing
      3. Taylor expanded in Ev around inf

        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
      4. Step-by-step derivation
        1. Applied rewrites56.8%

          \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
        2. Taylor expanded in NdChar around inf

          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
        3. Step-by-step derivation
          1. frac-addN/A

            \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
          2. lower-/.f64N/A

            \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
          3. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
          4. lower-exp.f64N/A

            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
          5. lower-/.f64N/A

            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
          6. lower--.f64N/A

            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
          7. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
          8. lower-+.f6492.7

            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
        4. Applied rewrites92.7%

          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
        5. Taylor expanded in KbT around inf

          \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \color{blue}{\frac{Ec}{KbT}}} \]
        6. Step-by-step derivation
          1. div-add-revN/A

            \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \frac{Vef + mu}{KbT}\right)\right) - \frac{Ec}{KbT}} \]
          2. div-addN/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
          3. lower--.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{\color{blue}{KbT}}} \]
          4. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
          5. lower-/.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
          6. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
          7. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
          8. lower-/.f6436.1

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
        7. Applied rewrites36.1%

          \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \color{blue}{\frac{Ec}{KbT}}} \]
        8. Step-by-step derivation
          1. flip-+N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          2. lower-/.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          3. lower--.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          4. lower-*.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          5. lower-*.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          6. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          7. lower-+.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          8. lower--.f64N/A

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
          9. lower-+.f6449.5

            \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]
        9. Applied rewrites49.5%

          \[\leadsto \frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}} \]

        if 4.9999999999999997e-246 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

        1. Initial program 100.0%

          \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
        2. Add Preprocessing
        3. Taylor expanded in KbT around inf

          \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
        4. Step-by-step derivation
          1. lower-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
          2. lower-*.f6437.4

            \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
        5. Applied rewrites37.4%

          \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
      5. Recombined 3 regimes into one program.
      6. Final simplification39.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{\frac{EDonor \cdot EDonor - \left(Vef + mu\right) \cdot \left(Vef + mu\right)}{EDonor - \left(Vef + mu\right)}}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
      7. Add Preprocessing

      Alternative 4: 40.4% accurate, 0.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
      (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
       :precision binary64
       (let* ((t_0
               (+
                (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
         (if (<= t_0 -1e-230)
           (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
           (if (<= t_0 5e-246)
             (/
              NdChar
              (-
               (+ 2.0 (/ (+ EDonor (/ (- (* Vef Vef) (* mu mu)) (- Vef mu))) KbT))
               (/ Ec KbT)))
             (fma 0.5 NaChar (* 0.5 NdChar))))))
      double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
      	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
      	double tmp;
      	if (t_0 <= -1e-230) {
      		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
      	} else if (t_0 <= 5e-246) {
      		tmp = NdChar / ((2.0 + ((EDonor + (((Vef * Vef) - (mu * mu)) / (Vef - mu))) / KbT)) - (Ec / KbT));
      	} else {
      		tmp = fma(0.5, NaChar, (0.5 * NdChar));
      	}
      	return tmp;
      }
      
      function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
      	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
      	tmp = 0.0
      	if (t_0 <= -1e-230)
      		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
      	elseif (t_0 <= 5e-246)
      		tmp = Float64(NdChar / Float64(Float64(2.0 + Float64(Float64(EDonor + Float64(Float64(Float64(Vef * Vef) - Float64(mu * mu)) / Float64(Vef - mu))) / KbT)) - Float64(Ec / KbT)));
      	else
      		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
      	end
      	return tmp
      end
      
      code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-230], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-246], N[(NdChar / N[(N[(2.0 + N[(N[(EDonor + N[(N[(N[(Vef * Vef), $MachinePrecision] - N[(mu * mu), $MachinePrecision]), $MachinePrecision] / N[(Vef - mu), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision] - N[(Ec / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
      \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\
      \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
      
      \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\
      \;\;\;\;\frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}}\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000005e-230

        1. Initial program 100.0%

          \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. frac-addN/A

            \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
          2. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
        4. Applied rewrites52.6%

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
        5. Taylor expanded in KbT around inf

          \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
        6. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
          2. lower-fma.f64N/A

            \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
          3. lower-*.f6434.0

            \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
        7. Applied rewrites34.0%

          \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

        if -1.00000000000000005e-230 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.9999999999999997e-246

        1. Initial program 100.0%

          \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
        2. Add Preprocessing
        3. Taylor expanded in Ev around inf

          \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
        4. Step-by-step derivation
          1. Applied rewrites56.8%

            \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
          2. Taylor expanded in NdChar around inf

            \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
          3. Step-by-step derivation
            1. frac-addN/A

              \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
            2. lower-/.f64N/A

              \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
            3. lower-+.f64N/A

              \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
            4. lower-exp.f64N/A

              \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
            6. lower--.f64N/A

              \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
            7. lower-+.f64N/A

              \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
            8. lower-+.f6492.7

              \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
          4. Applied rewrites92.7%

            \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
          5. Taylor expanded in KbT around inf

            \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \color{blue}{\frac{Ec}{KbT}}} \]
          6. Step-by-step derivation
            1. div-add-revN/A

              \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \frac{Vef + mu}{KbT}\right)\right) - \frac{Ec}{KbT}} \]
            2. div-addN/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
            3. lower--.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{\color{blue}{KbT}}} \]
            4. lower-+.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
            6. lower-+.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
            7. lower-+.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
            8. lower-/.f6436.1

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
          7. Applied rewrites36.1%

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \color{blue}{\frac{Ec}{KbT}}} \]
          8. Step-by-step derivation
            1. flip-+N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]
            2. lower-/.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]
            3. lower--.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]
            4. lower-*.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]
            5. lower-*.f64N/A

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]
            6. lower--.f6447.9

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]
          9. Applied rewrites47.9%

            \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}} \]

          if 4.9999999999999997e-246 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

          1. Initial program 100.0%

            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          2. Add Preprocessing
          3. Taylor expanded in KbT around inf

            \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
          4. Step-by-step derivation
            1. lower-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
            2. lower-*.f6437.4

              \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
          5. Applied rewrites37.4%

            \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
        5. Recombined 3 regimes into one program.
        6. Final simplification38.6%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{EDonor + \frac{Vef \cdot Vef - mu \cdot mu}{Vef - mu}}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
        7. Add Preprocessing

        Alternative 5: 37.0% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-154}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-173}:\\ \;\;\;\;\frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
        (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
         :precision binary64
         (let* ((t_0
                 (+
                  (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                  (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
           (if (<= t_0 -5e-154)
             (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
             (if (<= t_0 1e-173)
               (/ NaChar (- (+ 2.0 (/ (+ EAccept (+ Ev Vef)) KbT)) (/ mu KbT)))
               (fma 0.5 NaChar (* 0.5 NdChar))))))
        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
        	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
        	double tmp;
        	if (t_0 <= -5e-154) {
        		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
        	} else if (t_0 <= 1e-173) {
        		tmp = NaChar / ((2.0 + ((EAccept + (Ev + Vef)) / KbT)) - (mu / KbT));
        	} else {
        		tmp = fma(0.5, NaChar, (0.5 * NdChar));
        	}
        	return tmp;
        }
        
        function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
        	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
        	tmp = 0.0
        	if (t_0 <= -5e-154)
        		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
        	elseif (t_0 <= 1e-173)
        		tmp = Float64(NaChar / Float64(Float64(2.0 + Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT)) - Float64(mu / KbT)));
        	else
        		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
        	end
        	return tmp
        end
        
        code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-154], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-173], N[(NaChar / N[(N[(2.0 + N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision] - N[(mu / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
        \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-154}:\\
        \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
        
        \mathbf{elif}\;t\_0 \leq 10^{-173}:\\
        \;\;\;\;\frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -5.0000000000000002e-154

          1. Initial program 100.0%

            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. frac-addN/A

              \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
            2. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
          4. Applied rewrites55.5%

            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
          5. Taylor expanded in KbT around inf

            \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
          6. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
            2. lower-fma.f64N/A

              \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
            3. lower-*.f6434.4

              \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
          7. Applied rewrites34.4%

            \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

          if -5.0000000000000002e-154 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-173

          1. Initial program 100.0%

            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          2. Add Preprocessing
          3. Taylor expanded in NdChar around 0

            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
          4. Step-by-step derivation
            1. lower-/.f64N/A

              \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
            2. lower-+.f64N/A

              \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
            3. lower-exp.f64N/A

              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
            4. lower-/.f64N/A

              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
            5. lower--.f64N/A

              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
            6. lower-+.f64N/A

              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
            7. lower-+.f6482.9

              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
          5. Applied rewrites82.9%

            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
          6. Taylor expanded in KbT around inf

            \[\leadsto \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \color{blue}{\frac{mu}{KbT}}} \]
          7. Step-by-step derivation
            1. lower--.f64N/A

              \[\leadsto \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{\color{blue}{KbT}}} \]
            2. div-add-revN/A

              \[\leadsto \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Ev + Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
            3. div-addN/A

              \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}} \]
            4. lower-+.f64N/A

              \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}} \]
            5. lower-/.f64N/A

              \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}} \]
            6. lower-+.f64N/A

              \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}} \]
            7. lower-+.f64N/A

              \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}} \]
            8. lower-/.f6441.4

              \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}} \]
          8. Applied rewrites41.4%

            \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \color{blue}{\frac{mu}{KbT}}} \]

          if 1e-173 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

          1. Initial program 100.0%

            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          2. Add Preprocessing
          3. Taylor expanded in KbT around inf

            \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
          4. Step-by-step derivation
            1. lower-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
            2. lower-*.f6439.2

              \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
          5. Applied rewrites39.2%

            \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification38.2%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-154}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 10^{-173}:\\ \;\;\;\;\frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
        5. Add Preprocessing

        Alternative 6: 36.8% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{Vef}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
        (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
         :precision binary64
         (let* ((t_0
                 (+
                  (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                  (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
           (if (<= t_0 -1e-230)
             (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
             (if (<= t_0 5e-246)
               (/ NdChar (- (+ 2.0 (/ Vef KbT)) (/ Ec KbT)))
               (fma 0.5 NaChar (* 0.5 NdChar))))))
        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
        	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
        	double tmp;
        	if (t_0 <= -1e-230) {
        		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
        	} else if (t_0 <= 5e-246) {
        		tmp = NdChar / ((2.0 + (Vef / KbT)) - (Ec / KbT));
        	} else {
        		tmp = fma(0.5, NaChar, (0.5 * NdChar));
        	}
        	return tmp;
        }
        
        function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
        	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
        	tmp = 0.0
        	if (t_0 <= -1e-230)
        		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
        	elseif (t_0 <= 5e-246)
        		tmp = Float64(NdChar / Float64(Float64(2.0 + Float64(Vef / KbT)) - Float64(Ec / KbT)));
        	else
        		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
        	end
        	return tmp
        end
        
        code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-230], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-246], N[(NdChar / N[(N[(2.0 + N[(Vef / KbT), $MachinePrecision]), $MachinePrecision] - N[(Ec / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
        \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\
        \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
        
        \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\
        \;\;\;\;\frac{NdChar}{\left(2 + \frac{Vef}{KbT}\right) - \frac{Ec}{KbT}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000005e-230

          1. Initial program 100.0%

            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. frac-addN/A

              \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
            2. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
          4. Applied rewrites52.6%

            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
          5. Taylor expanded in KbT around inf

            \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
          6. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
            2. lower-fma.f64N/A

              \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
            3. lower-*.f6434.0

              \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
          7. Applied rewrites34.0%

            \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

          if -1.00000000000000005e-230 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.9999999999999997e-246

          1. Initial program 100.0%

            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          2. Add Preprocessing
          3. Taylor expanded in Ev around inf

            \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
          4. Step-by-step derivation
            1. Applied rewrites56.8%

              \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
            2. Taylor expanded in NdChar around inf

              \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
            3. Step-by-step derivation
              1. frac-addN/A

                \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
              2. lower-/.f64N/A

                \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
              3. lower-+.f64N/A

                \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
              4. lower-exp.f64N/A

                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
              5. lower-/.f64N/A

                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
              6. lower--.f64N/A

                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
              7. lower-+.f64N/A

                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
              8. lower-+.f6492.7

                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
            4. Applied rewrites92.7%

              \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
            5. Taylor expanded in KbT around inf

              \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \color{blue}{\frac{Ec}{KbT}}} \]
            6. Step-by-step derivation
              1. div-add-revN/A

                \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \frac{Vef + mu}{KbT}\right)\right) - \frac{Ec}{KbT}} \]
              2. div-addN/A

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
              3. lower--.f64N/A

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{\color{blue}{KbT}}} \]
              4. lower-+.f64N/A

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
              5. lower-/.f64N/A

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
              6. lower-+.f64N/A

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
              7. lower-+.f64N/A

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
              8. lower-/.f6436.1

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
            7. Applied rewrites36.1%

              \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \color{blue}{\frac{Ec}{KbT}}} \]
            8. Taylor expanded in Vef around inf

              \[\leadsto \frac{NdChar}{\left(2 + \frac{Vef}{KbT}\right) - \frac{Ec}{KbT}} \]
            9. Step-by-step derivation
              1. lower-/.f6438.8

                \[\leadsto \frac{NdChar}{\left(2 + \frac{Vef}{KbT}\right) - \frac{Ec}{KbT}} \]
            10. Applied rewrites38.8%

              \[\leadsto \frac{NdChar}{\left(2 + \frac{Vef}{KbT}\right) - \frac{Ec}{KbT}} \]

            if 4.9999999999999997e-246 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

            1. Initial program 100.0%

              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
            2. Add Preprocessing
            3. Taylor expanded in KbT around inf

              \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
            4. Step-by-step derivation
              1. lower-fma.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
              2. lower-*.f6437.4

                \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
            5. Applied rewrites37.4%

              \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
          5. Recombined 3 regimes into one program.
          6. Final simplification36.4%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{Vef}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
          7. Add Preprocessing

          Alternative 7: 35.5% accurate, 0.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{EDonor}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
           :precision binary64
           (let* ((t_0
                   (+
                    (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                    (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
             (if (<= t_0 -1e-230)
               (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
               (if (<= t_0 5e-246)
                 (/ NdChar (- (+ 2.0 (/ EDonor KbT)) (/ Ec KbT)))
                 (fma 0.5 NaChar (* 0.5 NdChar))))))
          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
          	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
          	double tmp;
          	if (t_0 <= -1e-230) {
          		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
          	} else if (t_0 <= 5e-246) {
          		tmp = NdChar / ((2.0 + (EDonor / KbT)) - (Ec / KbT));
          	} else {
          		tmp = fma(0.5, NaChar, (0.5 * NdChar));
          	}
          	return tmp;
          }
          
          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
          	tmp = 0.0
          	if (t_0 <= -1e-230)
          		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
          	elseif (t_0 <= 5e-246)
          		tmp = Float64(NdChar / Float64(Float64(2.0 + Float64(EDonor / KbT)) - Float64(Ec / KbT)));
          	else
          		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
          	end
          	return tmp
          end
          
          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-230], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-246], N[(NdChar / N[(N[(2.0 + N[(EDonor / KbT), $MachinePrecision]), $MachinePrecision] - N[(Ec / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
          \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-230}:\\
          \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
          
          \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-246}:\\
          \;\;\;\;\frac{NdChar}{\left(2 + \frac{EDonor}{KbT}\right) - \frac{Ec}{KbT}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000005e-230

            1. Initial program 100.0%

              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. frac-addN/A

                \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
              2. lower-/.f64N/A

                \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
            4. Applied rewrites52.6%

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
            5. Taylor expanded in KbT around inf

              \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
            6. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
              2. lower-fma.f64N/A

                \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
              3. lower-*.f6434.0

                \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
            7. Applied rewrites34.0%

              \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

            if -1.00000000000000005e-230 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.9999999999999997e-246

            1. Initial program 100.0%

              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
            2. Add Preprocessing
            3. Taylor expanded in Ev around inf

              \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
            4. Step-by-step derivation
              1. Applied rewrites56.8%

                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
              2. Taylor expanded in NdChar around inf

                \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
              3. Step-by-step derivation
                1. frac-addN/A

                  \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                2. lower-/.f64N/A

                  \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                3. lower-+.f64N/A

                  \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                4. lower-exp.f64N/A

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                5. lower-/.f64N/A

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                6. lower--.f64N/A

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                7. lower-+.f64N/A

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                8. lower-+.f6492.7

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
              4. Applied rewrites92.7%

                \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
              5. Taylor expanded in KbT around inf

                \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \color{blue}{\frac{Ec}{KbT}}} \]
              6. Step-by-step derivation
                1. div-add-revN/A

                  \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \frac{Vef + mu}{KbT}\right)\right) - \frac{Ec}{KbT}} \]
                2. div-addN/A

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
                3. lower--.f64N/A

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{\color{blue}{KbT}}} \]
                4. lower-+.f64N/A

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
                5. lower-/.f64N/A

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
                6. lower-+.f64N/A

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
                7. lower-+.f64N/A

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
                8. lower-/.f6436.1

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} \]
              7. Applied rewrites36.1%

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \color{blue}{\frac{Ec}{KbT}}} \]
              8. Taylor expanded in EDonor around inf

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor}{KbT}\right) - \frac{Ec}{KbT}} \]
              9. Step-by-step derivation
                1. lower-/.f6425.2

                  \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor}{KbT}\right) - \frac{Ec}{KbT}} \]
              10. Applied rewrites25.2%

                \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor}{KbT}\right) - \frac{Ec}{KbT}} \]

              if 4.9999999999999997e-246 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

              1. Initial program 100.0%

                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
              2. Add Preprocessing
              3. Taylor expanded in KbT around inf

                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
              4. Step-by-step derivation
                1. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                2. lower-*.f6437.4

                  \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
              5. Applied rewrites37.4%

                \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
            5. Recombined 3 regimes into one program.
            6. Final simplification33.1%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -1 \cdot 10^{-230}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-246}:\\ \;\;\;\;\frac{NdChar}{\left(2 + \frac{EDonor}{KbT}\right) - \frac{Ec}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
            7. Add Preprocessing

            Alternative 8: 30.4% accurate, 0.5× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-154}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-173}:\\ \;\;\;\;NdChar \cdot \left(0.5 \cdot \frac{NaChar}{NdChar}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
             :precision binary64
             (let* ((t_0
                     (+
                      (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                      (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
               (if (<= t_0 -5e-154)
                 (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
                 (if (<= t_0 1e-173)
                   (* NdChar (* 0.5 (/ NaChar NdChar)))
                   (fma 0.5 NaChar (* 0.5 NdChar))))))
            double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
            	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
            	double tmp;
            	if (t_0 <= -5e-154) {
            		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
            	} else if (t_0 <= 1e-173) {
            		tmp = NdChar * (0.5 * (NaChar / NdChar));
            	} else {
            		tmp = fma(0.5, NaChar, (0.5 * NdChar));
            	}
            	return tmp;
            }
            
            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
            	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
            	tmp = 0.0
            	if (t_0 <= -5e-154)
            		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
            	elseif (t_0 <= 1e-173)
            		tmp = Float64(NdChar * Float64(0.5 * Float64(NaChar / NdChar)));
            	else
            		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
            	end
            	return tmp
            end
            
            code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-154], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-173], N[(NdChar * N[(0.5 * N[(NaChar / NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
            \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-154}:\\
            \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
            
            \mathbf{elif}\;t\_0 \leq 10^{-173}:\\
            \;\;\;\;NdChar \cdot \left(0.5 \cdot \frac{NaChar}{NdChar}\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -5.0000000000000002e-154

              1. Initial program 100.0%

                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. frac-addN/A

                  \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                2. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
              4. Applied rewrites55.5%

                \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
              5. Taylor expanded in KbT around inf

                \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
              6. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                2. lower-fma.f64N/A

                  \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
                3. lower-*.f6434.4

                  \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
              7. Applied rewrites34.4%

                \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

              if -5.0000000000000002e-154 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-173

              1. Initial program 100.0%

                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
              2. Add Preprocessing
              3. Taylor expanded in KbT around inf

                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
              4. Step-by-step derivation
                1. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                2. lower-*.f648.5

                  \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
              5. Applied rewrites8.5%

                \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
              6. Taylor expanded in NdChar around inf

                \[\leadsto NdChar \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{2} \cdot \frac{NaChar}{NdChar}\right)} \]
              7. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto NdChar \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{2} \cdot \frac{NaChar}{NdChar}}\right) \]
                2. lower-+.f64N/A

                  \[\leadsto NdChar \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\frac{NaChar}{NdChar}}\right) \]
                3. lower-*.f64N/A

                  \[\leadsto NdChar \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \frac{NaChar}{\color{blue}{NdChar}}\right) \]
                4. lower-/.f648.4

                  \[\leadsto NdChar \cdot \left(0.5 + 0.5 \cdot \frac{NaChar}{NdChar}\right) \]
              8. Applied rewrites8.4%

                \[\leadsto NdChar \cdot \color{blue}{\left(0.5 + 0.5 \cdot \frac{NaChar}{NdChar}\right)} \]
              9. Taylor expanded in NdChar around 0

                \[\leadsto NdChar \cdot \left(\frac{1}{2} \cdot \frac{NaChar}{\color{blue}{NdChar}}\right) \]
              10. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto NdChar \cdot \left(\frac{1}{2} \cdot \frac{NaChar}{NdChar}\right) \]
                2. lower-/.f6421.8

                  \[\leadsto NdChar \cdot \left(0.5 \cdot \frac{NaChar}{NdChar}\right) \]
              11. Applied rewrites21.8%

                \[\leadsto NdChar \cdot \left(0.5 \cdot \frac{NaChar}{\color{blue}{NdChar}}\right) \]

              if 1e-173 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

              1. Initial program 100.0%

                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
              2. Add Preprocessing
              3. Taylor expanded in KbT around inf

                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
              4. Step-by-step derivation
                1. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                2. lower-*.f6439.2

                  \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
              5. Applied rewrites39.2%

                \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
            3. Recombined 3 regimes into one program.
            4. Final simplification32.0%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-154}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 10^{-173}:\\ \;\;\;\;NdChar \cdot \left(0.5 \cdot \frac{NaChar}{NdChar}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
            5. Add Preprocessing

            Alternative 9: 40.0% accurate, 1.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + e^{\frac{Vef}{KbT}}\\ \mathbf{if}\;EDonor \leq -2.9 \cdot 10^{+108}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{elif}\;EDonor \leq -4.5 \cdot 10^{-294}:\\ \;\;\;\;\frac{NaChar}{t\_0}\\ \mathbf{elif}\;EDonor \leq 1.75 \cdot 10^{-218}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}}\\ \mathbf{elif}\;EDonor \leq 5.2 \cdot 10^{-168} \lor \neg \left(EDonor \leq 2.65 \cdot 10^{+132}\right):\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{t\_0}\\ \end{array} \end{array} \]
            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
             :precision binary64
             (let* ((t_0 (+ 1.0 (exp (/ Vef KbT)))))
               (if (<= EDonor -2.9e+108)
                 (/ NdChar (+ 1.0 (exp (/ EDonor KbT))))
                 (if (<= EDonor -4.5e-294)
                   (/ NaChar t_0)
                   (if (<= EDonor 1.75e-218)
                     (/ NdChar (+ 1.0 (exp (/ mu KbT))))
                     (if (or (<= EDonor 5.2e-168) (not (<= EDonor 2.65e+132)))
                       (/ NaChar (+ 1.0 (exp (/ Ev KbT))))
                       (/ NdChar t_0)))))))
            double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
            	double t_0 = 1.0 + exp((Vef / KbT));
            	double tmp;
            	if (EDonor <= -2.9e+108) {
            		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
            	} else if (EDonor <= -4.5e-294) {
            		tmp = NaChar / t_0;
            	} else if (EDonor <= 1.75e-218) {
            		tmp = NdChar / (1.0 + exp((mu / KbT)));
            	} else if ((EDonor <= 5.2e-168) || !(EDonor <= 2.65e+132)) {
            		tmp = NaChar / (1.0 + exp((Ev / KbT)));
            	} else {
            		tmp = NdChar / t_0;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
            use fmin_fmax_functions
                real(8), intent (in) :: ndchar
                real(8), intent (in) :: ec
                real(8), intent (in) :: vef
                real(8), intent (in) :: edonor
                real(8), intent (in) :: mu
                real(8), intent (in) :: kbt
                real(8), intent (in) :: nachar
                real(8), intent (in) :: ev
                real(8), intent (in) :: eaccept
                real(8) :: t_0
                real(8) :: tmp
                t_0 = 1.0d0 + exp((vef / kbt))
                if (edonor <= (-2.9d+108)) then
                    tmp = ndchar / (1.0d0 + exp((edonor / kbt)))
                else if (edonor <= (-4.5d-294)) then
                    tmp = nachar / t_0
                else if (edonor <= 1.75d-218) then
                    tmp = ndchar / (1.0d0 + exp((mu / kbt)))
                else if ((edonor <= 5.2d-168) .or. (.not. (edonor <= 2.65d+132))) then
                    tmp = nachar / (1.0d0 + exp((ev / kbt)))
                else
                    tmp = ndchar / t_0
                end if
                code = tmp
            end function
            
            public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
            	double t_0 = 1.0 + Math.exp((Vef / KbT));
            	double tmp;
            	if (EDonor <= -2.9e+108) {
            		tmp = NdChar / (1.0 + Math.exp((EDonor / KbT)));
            	} else if (EDonor <= -4.5e-294) {
            		tmp = NaChar / t_0;
            	} else if (EDonor <= 1.75e-218) {
            		tmp = NdChar / (1.0 + Math.exp((mu / KbT)));
            	} else if ((EDonor <= 5.2e-168) || !(EDonor <= 2.65e+132)) {
            		tmp = NaChar / (1.0 + Math.exp((Ev / KbT)));
            	} else {
            		tmp = NdChar / t_0;
            	}
            	return tmp;
            }
            
            def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
            	t_0 = 1.0 + math.exp((Vef / KbT))
            	tmp = 0
            	if EDonor <= -2.9e+108:
            		tmp = NdChar / (1.0 + math.exp((EDonor / KbT)))
            	elif EDonor <= -4.5e-294:
            		tmp = NaChar / t_0
            	elif EDonor <= 1.75e-218:
            		tmp = NdChar / (1.0 + math.exp((mu / KbT)))
            	elif (EDonor <= 5.2e-168) or not (EDonor <= 2.65e+132):
            		tmp = NaChar / (1.0 + math.exp((Ev / KbT)))
            	else:
            		tmp = NdChar / t_0
            	return tmp
            
            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
            	t_0 = Float64(1.0 + exp(Float64(Vef / KbT)))
            	tmp = 0.0
            	if (EDonor <= -2.9e+108)
            		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT))));
            	elseif (EDonor <= -4.5e-294)
            		tmp = Float64(NaChar / t_0);
            	elseif (EDonor <= 1.75e-218)
            		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT))));
            	elseif ((EDonor <= 5.2e-168) || !(EDonor <= 2.65e+132))
            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
            	else
            		tmp = Float64(NdChar / t_0);
            	end
            	return tmp
            end
            
            function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
            	t_0 = 1.0 + exp((Vef / KbT));
            	tmp = 0.0;
            	if (EDonor <= -2.9e+108)
            		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
            	elseif (EDonor <= -4.5e-294)
            		tmp = NaChar / t_0;
            	elseif (EDonor <= 1.75e-218)
            		tmp = NdChar / (1.0 + exp((mu / KbT)));
            	elseif ((EDonor <= 5.2e-168) || ~((EDonor <= 2.65e+132)))
            		tmp = NaChar / (1.0 + exp((Ev / KbT)));
            	else
            		tmp = NdChar / t_0;
            	end
            	tmp_2 = tmp;
            end
            
            code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[EDonor, -2.9e+108], N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[EDonor, -4.5e-294], N[(NaChar / t$95$0), $MachinePrecision], If[LessEqual[EDonor, 1.75e-218], N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[EDonor, 5.2e-168], N[Not[LessEqual[EDonor, 2.65e+132]], $MachinePrecision]], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NdChar / t$95$0), $MachinePrecision]]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := 1 + e^{\frac{Vef}{KbT}}\\
            \mathbf{if}\;EDonor \leq -2.9 \cdot 10^{+108}:\\
            \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\
            
            \mathbf{elif}\;EDonor \leq -4.5 \cdot 10^{-294}:\\
            \;\;\;\;\frac{NaChar}{t\_0}\\
            
            \mathbf{elif}\;EDonor \leq 1.75 \cdot 10^{-218}:\\
            \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}}\\
            
            \mathbf{elif}\;EDonor \leq 5.2 \cdot 10^{-168} \lor \neg \left(EDonor \leq 2.65 \cdot 10^{+132}\right):\\
            \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{NdChar}{t\_0}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 5 regimes
            2. if EDonor < -2.90000000000000007e108

              1. Initial program 100.0%

                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
              2. Add Preprocessing
              3. Taylor expanded in Ev around inf

                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
              4. Step-by-step derivation
                1. Applied rewrites70.5%

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                2. Taylor expanded in NdChar around inf

                  \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                3. Step-by-step derivation
                  1. frac-addN/A

                    \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                  2. lower-/.f64N/A

                    \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                  3. lower-+.f64N/A

                    \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                  4. lower-exp.f64N/A

                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                  5. lower-/.f64N/A

                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                  6. lower--.f64N/A

                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                  7. lower-+.f64N/A

                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                  8. lower-+.f6462.8

                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                4. Applied rewrites62.8%

                  \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                5. Taylor expanded in EDonor around inf

                  \[\leadsto \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} \]
                6. Step-by-step derivation
                  1. Applied rewrites56.1%

                    \[\leadsto \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} \]

                  if -2.90000000000000007e108 < EDonor < -4.49999999999999981e-294

                  1. Initial program 100.0%

                    \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                  2. Add Preprocessing
                  3. Taylor expanded in NdChar around 0

                    \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                  4. Step-by-step derivation
                    1. lower-/.f64N/A

                      \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                    2. lower-+.f64N/A

                      \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                    3. lower-exp.f64N/A

                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                    4. lower-/.f64N/A

                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                    5. lower--.f64N/A

                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                    6. lower-+.f64N/A

                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                    7. lower-+.f6475.9

                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                  5. Applied rewrites75.9%

                    \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                  6. Taylor expanded in Vef around inf

                    \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]
                  7. Step-by-step derivation
                    1. Applied rewrites52.3%

                      \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]

                    if -4.49999999999999981e-294 < EDonor < 1.75e-218

                    1. Initial program 100.0%

                      \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                    2. Add Preprocessing
                    3. Taylor expanded in Ev around inf

                      \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                    4. Step-by-step derivation
                      1. Applied rewrites88.8%

                        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                      2. Taylor expanded in NdChar around inf

                        \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                      3. Step-by-step derivation
                        1. frac-addN/A

                          \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                        2. lower-/.f64N/A

                          \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                        3. lower-+.f64N/A

                          \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                        4. lower-exp.f64N/A

                          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                        5. lower-/.f64N/A

                          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                        6. lower--.f64N/A

                          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                        7. lower-+.f64N/A

                          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                        8. lower-+.f6480.2

                          \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                      4. Applied rewrites80.2%

                        \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                      5. Taylor expanded in mu around inf

                        \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} \]
                      6. Step-by-step derivation
                        1. Applied rewrites70.2%

                          \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} \]

                        if 1.75e-218 < EDonor < 5.2000000000000002e-168 or 2.65e132 < EDonor

                        1. Initial program 100.0%

                          \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                        2. Add Preprocessing
                        3. Taylor expanded in NdChar around 0

                          \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                        4. Step-by-step derivation
                          1. lower-/.f64N/A

                            \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                          2. lower-+.f64N/A

                            \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                          3. lower-exp.f64N/A

                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                          4. lower-/.f64N/A

                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                          5. lower--.f64N/A

                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                          6. lower-+.f64N/A

                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                          7. lower-+.f6470.2

                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                        5. Applied rewrites70.2%

                          \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                        6. Taylor expanded in Ev around inf

                          \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]
                        7. Step-by-step derivation
                          1. Applied rewrites50.4%

                            \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]

                          if 5.2000000000000002e-168 < EDonor < 2.65e132

                          1. Initial program 100.0%

                            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                          2. Add Preprocessing
                          3. Taylor expanded in Ev around inf

                            \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                          4. Step-by-step derivation
                            1. Applied rewrites70.5%

                              \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                            2. Taylor expanded in NdChar around inf

                              \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                            3. Step-by-step derivation
                              1. frac-addN/A

                                \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                              2. lower-/.f64N/A

                                \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                              3. lower-+.f64N/A

                                \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                              4. lower-exp.f64N/A

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                              5. lower-/.f64N/A

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                              6. lower--.f64N/A

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                              7. lower-+.f64N/A

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                              8. lower-+.f6472.2

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                            4. Applied rewrites72.2%

                              \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                            5. Taylor expanded in Vef around inf

                              \[\leadsto \frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} \]
                            6. Step-by-step derivation
                              1. Applied rewrites51.6%

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} \]
                            7. Recombined 5 regimes into one program.
                            8. Final simplification54.1%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;EDonor \leq -2.9 \cdot 10^{+108}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{elif}\;EDonor \leq -4.5 \cdot 10^{-294}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;EDonor \leq 1.75 \cdot 10^{-218}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}}\\ \mathbf{elif}\;EDonor \leq 5.2 \cdot 10^{-168} \lor \neg \left(EDonor \leq 2.65 \cdot 10^{+132}\right):\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\ \end{array} \]
                            9. Add Preprocessing

                            Alternative 10: 38.5% accurate, 1.8× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + e^{\frac{Vef}{KbT}}\\ \mathbf{if}\;EAccept \leq -1.3 \cdot 10^{-257}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 1.7 \cdot 10^{-187}:\\ \;\;\;\;\frac{NdChar}{t\_0}\\ \mathbf{elif}\;EAccept \leq 2.2 \cdot 10^{-34}:\\ \;\;\;\;\frac{NaChar}{t\_0}\\ \mathbf{elif}\;EAccept \leq 7 \cdot 10^{+45}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \end{array} \]
                            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                             :precision binary64
                             (let* ((t_0 (+ 1.0 (exp (/ Vef KbT)))))
                               (if (<= EAccept -1.3e-257)
                                 (/ NaChar (+ 1.0 (exp (/ Ev KbT))))
                                 (if (<= EAccept 1.7e-187)
                                   (/ NdChar t_0)
                                   (if (<= EAccept 2.2e-34)
                                     (/ NaChar t_0)
                                     (if (<= EAccept 7e+45)
                                       (/ NdChar (+ 1.0 (exp (/ EDonor KbT))))
                                       (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))))))))
                            double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                            	double t_0 = 1.0 + exp((Vef / KbT));
                            	double tmp;
                            	if (EAccept <= -1.3e-257) {
                            		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                            	} else if (EAccept <= 1.7e-187) {
                            		tmp = NdChar / t_0;
                            	} else if (EAccept <= 2.2e-34) {
                            		tmp = NaChar / t_0;
                            	} else if (EAccept <= 7e+45) {
                            		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                            	} else {
                            		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                            	}
                            	return tmp;
                            }
                            
                            module fmin_fmax_functions
                                implicit none
                                private
                                public fmax
                                public fmin
                            
                                interface fmax
                                    module procedure fmax88
                                    module procedure fmax44
                                    module procedure fmax84
                                    module procedure fmax48
                                end interface
                                interface fmin
                                    module procedure fmin88
                                    module procedure fmin44
                                    module procedure fmin84
                                    module procedure fmin48
                                end interface
                            contains
                                real(8) function fmax88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmax44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmax84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmax48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                end function
                                real(8) function fmin88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmin44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmin84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmin48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                end function
                            end module
                            
                            real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                            use fmin_fmax_functions
                                real(8), intent (in) :: ndchar
                                real(8), intent (in) :: ec
                                real(8), intent (in) :: vef
                                real(8), intent (in) :: edonor
                                real(8), intent (in) :: mu
                                real(8), intent (in) :: kbt
                                real(8), intent (in) :: nachar
                                real(8), intent (in) :: ev
                                real(8), intent (in) :: eaccept
                                real(8) :: t_0
                                real(8) :: tmp
                                t_0 = 1.0d0 + exp((vef / kbt))
                                if (eaccept <= (-1.3d-257)) then
                                    tmp = nachar / (1.0d0 + exp((ev / kbt)))
                                else if (eaccept <= 1.7d-187) then
                                    tmp = ndchar / t_0
                                else if (eaccept <= 2.2d-34) then
                                    tmp = nachar / t_0
                                else if (eaccept <= 7d+45) then
                                    tmp = ndchar / (1.0d0 + exp((edonor / kbt)))
                                else
                                    tmp = nachar / (1.0d0 + exp((eaccept / kbt)))
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                            	double t_0 = 1.0 + Math.exp((Vef / KbT));
                            	double tmp;
                            	if (EAccept <= -1.3e-257) {
                            		tmp = NaChar / (1.0 + Math.exp((Ev / KbT)));
                            	} else if (EAccept <= 1.7e-187) {
                            		tmp = NdChar / t_0;
                            	} else if (EAccept <= 2.2e-34) {
                            		tmp = NaChar / t_0;
                            	} else if (EAccept <= 7e+45) {
                            		tmp = NdChar / (1.0 + Math.exp((EDonor / KbT)));
                            	} else {
                            		tmp = NaChar / (1.0 + Math.exp((EAccept / KbT)));
                            	}
                            	return tmp;
                            }
                            
                            def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                            	t_0 = 1.0 + math.exp((Vef / KbT))
                            	tmp = 0
                            	if EAccept <= -1.3e-257:
                            		tmp = NaChar / (1.0 + math.exp((Ev / KbT)))
                            	elif EAccept <= 1.7e-187:
                            		tmp = NdChar / t_0
                            	elif EAccept <= 2.2e-34:
                            		tmp = NaChar / t_0
                            	elif EAccept <= 7e+45:
                            		tmp = NdChar / (1.0 + math.exp((EDonor / KbT)))
                            	else:
                            		tmp = NaChar / (1.0 + math.exp((EAccept / KbT)))
                            	return tmp
                            
                            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                            	t_0 = Float64(1.0 + exp(Float64(Vef / KbT)))
                            	tmp = 0.0
                            	if (EAccept <= -1.3e-257)
                            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
                            	elseif (EAccept <= 1.7e-187)
                            		tmp = Float64(NdChar / t_0);
                            	elseif (EAccept <= 2.2e-34)
                            		tmp = Float64(NaChar / t_0);
                            	elseif (EAccept <= 7e+45)
                            		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT))));
                            	else
                            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                            	t_0 = 1.0 + exp((Vef / KbT));
                            	tmp = 0.0;
                            	if (EAccept <= -1.3e-257)
                            		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                            	elseif (EAccept <= 1.7e-187)
                            		tmp = NdChar / t_0;
                            	elseif (EAccept <= 2.2e-34)
                            		tmp = NaChar / t_0;
                            	elseif (EAccept <= 7e+45)
                            		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                            	else
                            		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[EAccept, -1.3e-257], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[EAccept, 1.7e-187], N[(NdChar / t$95$0), $MachinePrecision], If[LessEqual[EAccept, 2.2e-34], N[(NaChar / t$95$0), $MachinePrecision], If[LessEqual[EAccept, 7e+45], N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := 1 + e^{\frac{Vef}{KbT}}\\
                            \mathbf{if}\;EAccept \leq -1.3 \cdot 10^{-257}:\\
                            \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
                            
                            \mathbf{elif}\;EAccept \leq 1.7 \cdot 10^{-187}:\\
                            \;\;\;\;\frac{NdChar}{t\_0}\\
                            
                            \mathbf{elif}\;EAccept \leq 2.2 \cdot 10^{-34}:\\
                            \;\;\;\;\frac{NaChar}{t\_0}\\
                            
                            \mathbf{elif}\;EAccept \leq 7 \cdot 10^{+45}:\\
                            \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 5 regimes
                            2. if EAccept < -1.3e-257

                              1. Initial program 100.0%

                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                              2. Add Preprocessing
                              3. Taylor expanded in NdChar around 0

                                \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                              4. Step-by-step derivation
                                1. lower-/.f64N/A

                                  \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                2. lower-+.f64N/A

                                  \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                3. lower-exp.f64N/A

                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                4. lower-/.f64N/A

                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                5. lower--.f64N/A

                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                6. lower-+.f64N/A

                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                7. lower-+.f6460.2

                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                              5. Applied rewrites60.2%

                                \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                              6. Taylor expanded in Ev around inf

                                \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]
                              7. Step-by-step derivation
                                1. Applied rewrites36.5%

                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]

                                if -1.3e-257 < EAccept < 1.7000000000000001e-187

                                1. Initial program 100.0%

                                  \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                2. Add Preprocessing
                                3. Taylor expanded in Ev around inf

                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites73.1%

                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                  2. Taylor expanded in NdChar around inf

                                    \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                  3. Step-by-step derivation
                                    1. frac-addN/A

                                      \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                    2. lower-/.f64N/A

                                      \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                    3. lower-+.f64N/A

                                      \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                    4. lower-exp.f64N/A

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                    5. lower-/.f64N/A

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                    6. lower--.f64N/A

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                    7. lower-+.f64N/A

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                    8. lower-+.f6466.8

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                  4. Applied rewrites66.8%

                                    \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                  5. Taylor expanded in Vef around inf

                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} \]
                                  6. Step-by-step derivation
                                    1. Applied rewrites39.9%

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} \]

                                    if 1.7000000000000001e-187 < EAccept < 2.1999999999999999e-34

                                    1. Initial program 100.0%

                                      \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in NdChar around 0

                                      \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                    4. Step-by-step derivation
                                      1. lower-/.f64N/A

                                        \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                      2. lower-+.f64N/A

                                        \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                      3. lower-exp.f64N/A

                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                      4. lower-/.f64N/A

                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                      5. lower--.f64N/A

                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                      6. lower-+.f64N/A

                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                      7. lower-+.f6464.1

                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                    5. Applied rewrites64.1%

                                      \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                    6. Taylor expanded in Vef around inf

                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites49.3%

                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]

                                      if 2.1999999999999999e-34 < EAccept < 7.00000000000000046e45

                                      1. Initial program 100.0%

                                        \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in Ev around inf

                                        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                      4. Step-by-step derivation
                                        1. Applied rewrites71.8%

                                          \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                        2. Taylor expanded in NdChar around inf

                                          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                        3. Step-by-step derivation
                                          1. frac-addN/A

                                            \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                          2. lower-/.f64N/A

                                            \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                          3. lower-+.f64N/A

                                            \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                          4. lower-exp.f64N/A

                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                          5. lower-/.f64N/A

                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                          6. lower--.f64N/A

                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                          7. lower-+.f64N/A

                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                          8. lower-+.f6469.5

                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                        4. Applied rewrites69.5%

                                          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                        5. Taylor expanded in EDonor around inf

                                          \[\leadsto \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites53.8%

                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} \]

                                          if 7.00000000000000046e45 < EAccept

                                          1. Initial program 100.0%

                                            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in NdChar around 0

                                            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                          4. Step-by-step derivation
                                            1. lower-/.f64N/A

                                              \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                            2. lower-+.f64N/A

                                              \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                            3. lower-exp.f64N/A

                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                            4. lower-/.f64N/A

                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                            5. lower--.f64N/A

                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                            6. lower-+.f64N/A

                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                            7. lower-+.f6472.8

                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                          5. Applied rewrites72.8%

                                            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                          6. Taylor expanded in EAccept around inf

                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                          7. Step-by-step derivation
                                            1. Applied rewrites54.4%

                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                          8. Recombined 5 regimes into one program.
                                          9. Final simplification43.2%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;EAccept \leq -1.3 \cdot 10^{-257}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 1.7 \cdot 10^{-187}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 2.2 \cdot 10^{-34}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 7 \cdot 10^{+45}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \]
                                          10. Add Preprocessing

                                          Alternative 11: 70.0% accurate, 1.9× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -2.9 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \end{array} \end{array} \]
                                          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                           :precision binary64
                                           (if (or (<= NdChar -2.9e-59) (not (<= NdChar 1.4e-36)))
                                             (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor (+ Vef mu)) Ec) KbT))))
                                             (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))))
                                          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                          	double tmp;
                                          	if ((NdChar <= -2.9e-59) || !(NdChar <= 1.4e-36)) {
                                          		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
                                          	} else {
                                          		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          module fmin_fmax_functions
                                              implicit none
                                              private
                                              public fmax
                                              public fmin
                                          
                                              interface fmax
                                                  module procedure fmax88
                                                  module procedure fmax44
                                                  module procedure fmax84
                                                  module procedure fmax48
                                              end interface
                                              interface fmin
                                                  module procedure fmin88
                                                  module procedure fmin44
                                                  module procedure fmin84
                                                  module procedure fmin48
                                              end interface
                                          contains
                                              real(8) function fmax88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmax44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmax84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmax48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmin44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmin48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                              end function
                                          end module
                                          
                                          real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                          use fmin_fmax_functions
                                              real(8), intent (in) :: ndchar
                                              real(8), intent (in) :: ec
                                              real(8), intent (in) :: vef
                                              real(8), intent (in) :: edonor
                                              real(8), intent (in) :: mu
                                              real(8), intent (in) :: kbt
                                              real(8), intent (in) :: nachar
                                              real(8), intent (in) :: ev
                                              real(8), intent (in) :: eaccept
                                              real(8) :: tmp
                                              if ((ndchar <= (-2.9d-59)) .or. (.not. (ndchar <= 1.4d-36))) then
                                                  tmp = ndchar / (1.0d0 + exp((((edonor + (vef + mu)) - ec) / kbt)))
                                              else
                                                  tmp = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
                                              end if
                                              code = tmp
                                          end function
                                          
                                          public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                          	double tmp;
                                          	if ((NdChar <= -2.9e-59) || !(NdChar <= 1.4e-36)) {
                                          		tmp = NdChar / (1.0 + Math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
                                          	} else {
                                          		tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                          	tmp = 0
                                          	if (NdChar <= -2.9e-59) or not (NdChar <= 1.4e-36):
                                          		tmp = NdChar / (1.0 + math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)))
                                          	else:
                                          		tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)))
                                          	return tmp
                                          
                                          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                          	tmp = 0.0
                                          	if ((NdChar <= -2.9e-59) || !(NdChar <= 1.4e-36))
                                          		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Float64(Vef + mu)) - Ec) / KbT))));
                                          	else
                                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT))));
                                          	end
                                          	return tmp
                                          end
                                          
                                          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                          	tmp = 0.0;
                                          	if ((NdChar <= -2.9e-59) || ~((NdChar <= 1.4e-36)))
                                          		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
                                          	else
                                          		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                                          	end
                                          	tmp_2 = tmp;
                                          end
                                          
                                          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NdChar, -2.9e-59], N[Not[LessEqual[NdChar, 1.4e-36]], $MachinePrecision]], N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + N[(Vef + mu), $MachinePrecision]), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;NdChar \leq -2.9 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\
                                          \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if NdChar < -2.90000000000000016e-59 or 1.4000000000000001e-36 < NdChar

                                            1. Initial program 100.0%

                                              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in NdChar around inf

                                              \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                            4. Step-by-step derivation
                                              1. lower-/.f64N/A

                                                \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                              2. lower-+.f64N/A

                                                \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                              3. lower-exp.f64N/A

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                              4. lower-/.f64N/A

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                              5. lower--.f64N/A

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                              6. lower-+.f64N/A

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                              7. lower-+.f6473.4

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                            5. Applied rewrites73.4%

                                              \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]

                                            if -2.90000000000000016e-59 < NdChar < 1.4000000000000001e-36

                                            1. Initial program 100.0%

                                              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in NdChar around 0

                                              \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                            4. Step-by-step derivation
                                              1. lower-/.f64N/A

                                                \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                              2. lower-+.f64N/A

                                                \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                              3. lower-exp.f64N/A

                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                              4. lower-/.f64N/A

                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                              5. lower--.f64N/A

                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                              6. lower-+.f64N/A

                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                              7. lower-+.f6478.0

                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                            5. Applied rewrites78.0%

                                              \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                          3. Recombined 2 regimes into one program.
                                          4. Final simplification75.4%

                                            \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -2.9 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \end{array} \]
                                          5. Add Preprocessing

                                          Alternative 12: 65.5% accurate, 1.9× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -3.2 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \end{array} \end{array} \]
                                          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                           :precision binary64
                                           (if (or (<= NdChar -3.2e-59) (not (<= NdChar 1.4e-36)))
                                             (/ NdChar (+ 1.0 (exp (/ (- (+ Vef mu) Ec) KbT))))
                                             (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))))
                                          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                          	double tmp;
                                          	if ((NdChar <= -3.2e-59) || !(NdChar <= 1.4e-36)) {
                                          		tmp = NdChar / (1.0 + exp((((Vef + mu) - Ec) / KbT)));
                                          	} else {
                                          		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          module fmin_fmax_functions
                                              implicit none
                                              private
                                              public fmax
                                              public fmin
                                          
                                              interface fmax
                                                  module procedure fmax88
                                                  module procedure fmax44
                                                  module procedure fmax84
                                                  module procedure fmax48
                                              end interface
                                              interface fmin
                                                  module procedure fmin88
                                                  module procedure fmin44
                                                  module procedure fmin84
                                                  module procedure fmin48
                                              end interface
                                          contains
                                              real(8) function fmax88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmax44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmax84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmax48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin88(x, y) result (res)
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(4) function fmin44(x, y) result (res)
                                                  real(4), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                              end function
                                              real(8) function fmin84(x, y) result(res)
                                                  real(8), intent (in) :: x
                                                  real(4), intent (in) :: y
                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                              end function
                                              real(8) function fmin48(x, y) result(res)
                                                  real(4), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                              end function
                                          end module
                                          
                                          real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                          use fmin_fmax_functions
                                              real(8), intent (in) :: ndchar
                                              real(8), intent (in) :: ec
                                              real(8), intent (in) :: vef
                                              real(8), intent (in) :: edonor
                                              real(8), intent (in) :: mu
                                              real(8), intent (in) :: kbt
                                              real(8), intent (in) :: nachar
                                              real(8), intent (in) :: ev
                                              real(8), intent (in) :: eaccept
                                              real(8) :: tmp
                                              if ((ndchar <= (-3.2d-59)) .or. (.not. (ndchar <= 1.4d-36))) then
                                                  tmp = ndchar / (1.0d0 + exp((((vef + mu) - ec) / kbt)))
                                              else
                                                  tmp = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
                                              end if
                                              code = tmp
                                          end function
                                          
                                          public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                          	double tmp;
                                          	if ((NdChar <= -3.2e-59) || !(NdChar <= 1.4e-36)) {
                                          		tmp = NdChar / (1.0 + Math.exp((((Vef + mu) - Ec) / KbT)));
                                          	} else {
                                          		tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                          	tmp = 0
                                          	if (NdChar <= -3.2e-59) or not (NdChar <= 1.4e-36):
                                          		tmp = NdChar / (1.0 + math.exp((((Vef + mu) - Ec) / KbT)))
                                          	else:
                                          		tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)))
                                          	return tmp
                                          
                                          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                          	tmp = 0.0
                                          	if ((NdChar <= -3.2e-59) || !(NdChar <= 1.4e-36))
                                          		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(Vef + mu) - Ec) / KbT))));
                                          	else
                                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT))));
                                          	end
                                          	return tmp
                                          end
                                          
                                          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                          	tmp = 0.0;
                                          	if ((NdChar <= -3.2e-59) || ~((NdChar <= 1.4e-36)))
                                          		tmp = NdChar / (1.0 + exp((((Vef + mu) - Ec) / KbT)));
                                          	else
                                          		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                                          	end
                                          	tmp_2 = tmp;
                                          end
                                          
                                          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NdChar, -3.2e-59], N[Not[LessEqual[NdChar, 1.4e-36]], $MachinePrecision]], N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(Vef + mu), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;NdChar \leq -3.2 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\
                                          \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if NdChar < -3.1999999999999999e-59 or 1.4000000000000001e-36 < NdChar

                                            1. Initial program 100.0%

                                              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in Ev around inf

                                              \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                            4. Step-by-step derivation
                                              1. Applied rewrites75.5%

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                              2. Taylor expanded in NdChar around inf

                                                \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                              3. Step-by-step derivation
                                                1. frac-addN/A

                                                  \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                2. lower-/.f64N/A

                                                  \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                3. lower-+.f64N/A

                                                  \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                4. lower-exp.f64N/A

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                5. lower-/.f64N/A

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                6. lower--.f64N/A

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                7. lower-+.f64N/A

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                8. lower-+.f6473.4

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                              4. Applied rewrites73.4%

                                                \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                              5. Taylor expanded in EDonor around 0

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} \]
                                              6. Step-by-step derivation
                                                1. lower-+.f6468.6

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} \]
                                              7. Applied rewrites68.6%

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} \]

                                              if -3.1999999999999999e-59 < NdChar < 1.4000000000000001e-36

                                              1. Initial program 100.0%

                                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in NdChar around 0

                                                \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                              4. Step-by-step derivation
                                                1. lower-/.f64N/A

                                                  \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                2. lower-+.f64N/A

                                                  \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                3. lower-exp.f64N/A

                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                4. lower-/.f64N/A

                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                5. lower--.f64N/A

                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                6. lower-+.f64N/A

                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                7. lower-+.f6478.0

                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                              5. Applied rewrites78.0%

                                                \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                            5. Recombined 2 regimes into one program.
                                            6. Final simplification72.7%

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -3.2 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \end{array} \]
                                            7. Add Preprocessing

                                            Alternative 13: 58.6% accurate, 1.9× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -2.9 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \end{array} \end{array} \]
                                            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                             :precision binary64
                                             (if (or (<= NdChar -2.9e-59) (not (<= NdChar 1.4e-36)))
                                               (/ NdChar (+ 1.0 (exp (/ (- (+ Vef mu) Ec) KbT))))
                                               (/ NaChar (+ 1.0 (exp (/ (- Vef mu) KbT))))))
                                            double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                            	double tmp;
                                            	if ((NdChar <= -2.9e-59) || !(NdChar <= 1.4e-36)) {
                                            		tmp = NdChar / (1.0 + exp((((Vef + mu) - Ec) / KbT)));
                                            	} else {
                                            		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                            	}
                                            	return tmp;
                                            }
                                            
                                            module fmin_fmax_functions
                                                implicit none
                                                private
                                                public fmax
                                                public fmin
                                            
                                                interface fmax
                                                    module procedure fmax88
                                                    module procedure fmax44
                                                    module procedure fmax84
                                                    module procedure fmax48
                                                end interface
                                                interface fmin
                                                    module procedure fmin88
                                                    module procedure fmin44
                                                    module procedure fmin84
                                                    module procedure fmin48
                                                end interface
                                            contains
                                                real(8) function fmax88(x, y) result (res)
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                end function
                                                real(4) function fmax44(x, y) result (res)
                                                    real(4), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                end function
                                                real(8) function fmax84(x, y) result(res)
                                                    real(8), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                end function
                                                real(8) function fmax48(x, y) result(res)
                                                    real(4), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                end function
                                                real(8) function fmin88(x, y) result (res)
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                end function
                                                real(4) function fmin44(x, y) result (res)
                                                    real(4), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                end function
                                                real(8) function fmin84(x, y) result(res)
                                                    real(8), intent (in) :: x
                                                    real(4), intent (in) :: y
                                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                end function
                                                real(8) function fmin48(x, y) result(res)
                                                    real(4), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                end function
                                            end module
                                            
                                            real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                            use fmin_fmax_functions
                                                real(8), intent (in) :: ndchar
                                                real(8), intent (in) :: ec
                                                real(8), intent (in) :: vef
                                                real(8), intent (in) :: edonor
                                                real(8), intent (in) :: mu
                                                real(8), intent (in) :: kbt
                                                real(8), intent (in) :: nachar
                                                real(8), intent (in) :: ev
                                                real(8), intent (in) :: eaccept
                                                real(8) :: tmp
                                                if ((ndchar <= (-2.9d-59)) .or. (.not. (ndchar <= 1.4d-36))) then
                                                    tmp = ndchar / (1.0d0 + exp((((vef + mu) - ec) / kbt)))
                                                else
                                                    tmp = nachar / (1.0d0 + exp(((vef - mu) / kbt)))
                                                end if
                                                code = tmp
                                            end function
                                            
                                            public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                            	double tmp;
                                            	if ((NdChar <= -2.9e-59) || !(NdChar <= 1.4e-36)) {
                                            		tmp = NdChar / (1.0 + Math.exp((((Vef + mu) - Ec) / KbT)));
                                            	} else {
                                            		tmp = NaChar / (1.0 + Math.exp(((Vef - mu) / KbT)));
                                            	}
                                            	return tmp;
                                            }
                                            
                                            def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                            	tmp = 0
                                            	if (NdChar <= -2.9e-59) or not (NdChar <= 1.4e-36):
                                            		tmp = NdChar / (1.0 + math.exp((((Vef + mu) - Ec) / KbT)))
                                            	else:
                                            		tmp = NaChar / (1.0 + math.exp(((Vef - mu) / KbT)))
                                            	return tmp
                                            
                                            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                            	tmp = 0.0
                                            	if ((NdChar <= -2.9e-59) || !(NdChar <= 1.4e-36))
                                            		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(Vef + mu) - Ec) / KbT))));
                                            	else
                                            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Vef - mu) / KbT))));
                                            	end
                                            	return tmp
                                            end
                                            
                                            function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                            	tmp = 0.0;
                                            	if ((NdChar <= -2.9e-59) || ~((NdChar <= 1.4e-36)))
                                            		tmp = NdChar / (1.0 + exp((((Vef + mu) - Ec) / KbT)));
                                            	else
                                            		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                            	end
                                            	tmp_2 = tmp;
                                            end
                                            
                                            code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NdChar, -2.9e-59], N[Not[LessEqual[NdChar, 1.4e-36]], $MachinePrecision]], N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(Vef + mu), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(N[(Vef - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;NdChar \leq -2.9 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\
                                            \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}}\\
                                            
                                            \mathbf{else}:\\
                                            \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\
                                            
                                            
                                            \end{array}
                                            \end{array}
                                            
                                            Derivation
                                            1. Split input into 2 regimes
                                            2. if NdChar < -2.90000000000000016e-59 or 1.4000000000000001e-36 < NdChar

                                              1. Initial program 100.0%

                                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                              2. Add Preprocessing
                                              3. Taylor expanded in Ev around inf

                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                              4. Step-by-step derivation
                                                1. Applied rewrites75.5%

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                                2. Taylor expanded in NdChar around inf

                                                  \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                3. Step-by-step derivation
                                                  1. frac-addN/A

                                                    \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                  2. lower-/.f64N/A

                                                    \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                  3. lower-+.f64N/A

                                                    \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                  4. lower-exp.f64N/A

                                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                  5. lower-/.f64N/A

                                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                  6. lower--.f64N/A

                                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                  7. lower-+.f64N/A

                                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                  8. lower-+.f6473.4

                                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                4. Applied rewrites73.4%

                                                  \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                5. Taylor expanded in EDonor around 0

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} \]
                                                6. Step-by-step derivation
                                                  1. lower-+.f6468.6

                                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} \]
                                                7. Applied rewrites68.6%

                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} \]

                                                if -2.90000000000000016e-59 < NdChar < 1.4000000000000001e-36

                                                1. Initial program 100.0%

                                                  \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in NdChar around 0

                                                  \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                4. Step-by-step derivation
                                                  1. lower-/.f64N/A

                                                    \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                  2. lower-+.f64N/A

                                                    \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                  3. lower-exp.f64N/A

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                  4. lower-/.f64N/A

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                  5. lower--.f64N/A

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                  6. lower-+.f64N/A

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                  7. lower-+.f6478.0

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                5. Applied rewrites78.0%

                                                  \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                6. Taylor expanded in Vef around inf

                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites64.7%

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
                                                8. Recombined 2 regimes into one program.
                                                9. Final simplification66.9%

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -2.9 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \end{array} \]
                                                10. Add Preprocessing

                                                Alternative 14: 39.4% accurate, 1.9× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;EAccept \leq -6 \cdot 10^{-215}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 2.2 \cdot 10^{-34}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 7 \cdot 10^{+45}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \end{array} \]
                                                (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                 :precision binary64
                                                 (if (<= EAccept -6e-215)
                                                   (/ NaChar (+ 1.0 (exp (/ Ev KbT))))
                                                   (if (<= EAccept 2.2e-34)
                                                     (/ NaChar (+ 1.0 (exp (/ Vef KbT))))
                                                     (if (<= EAccept 7e+45)
                                                       (/ NdChar (+ 1.0 (exp (/ EDonor KbT))))
                                                       (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))))))
                                                double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                	double tmp;
                                                	if (EAccept <= -6e-215) {
                                                		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                                                	} else if (EAccept <= 2.2e-34) {
                                                		tmp = NaChar / (1.0 + exp((Vef / KbT)));
                                                	} else if (EAccept <= 7e+45) {
                                                		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                                                	} else {
                                                		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                module fmin_fmax_functions
                                                    implicit none
                                                    private
                                                    public fmax
                                                    public fmin
                                                
                                                    interface fmax
                                                        module procedure fmax88
                                                        module procedure fmax44
                                                        module procedure fmax84
                                                        module procedure fmax48
                                                    end interface
                                                    interface fmin
                                                        module procedure fmin88
                                                        module procedure fmin44
                                                        module procedure fmin84
                                                        module procedure fmin48
                                                    end interface
                                                contains
                                                    real(8) function fmax88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmax44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmax48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin88(x, y) result (res)
                                                        real(8), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(4) function fmin44(x, y) result (res)
                                                        real(4), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin84(x, y) result(res)
                                                        real(8), intent (in) :: x
                                                        real(4), intent (in) :: y
                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                    end function
                                                    real(8) function fmin48(x, y) result(res)
                                                        real(4), intent (in) :: x
                                                        real(8), intent (in) :: y
                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                    end function
                                                end module
                                                
                                                real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                use fmin_fmax_functions
                                                    real(8), intent (in) :: ndchar
                                                    real(8), intent (in) :: ec
                                                    real(8), intent (in) :: vef
                                                    real(8), intent (in) :: edonor
                                                    real(8), intent (in) :: mu
                                                    real(8), intent (in) :: kbt
                                                    real(8), intent (in) :: nachar
                                                    real(8), intent (in) :: ev
                                                    real(8), intent (in) :: eaccept
                                                    real(8) :: tmp
                                                    if (eaccept <= (-6d-215)) then
                                                        tmp = nachar / (1.0d0 + exp((ev / kbt)))
                                                    else if (eaccept <= 2.2d-34) then
                                                        tmp = nachar / (1.0d0 + exp((vef / kbt)))
                                                    else if (eaccept <= 7d+45) then
                                                        tmp = ndchar / (1.0d0 + exp((edonor / kbt)))
                                                    else
                                                        tmp = nachar / (1.0d0 + exp((eaccept / kbt)))
                                                    end if
                                                    code = tmp
                                                end function
                                                
                                                public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                	double tmp;
                                                	if (EAccept <= -6e-215) {
                                                		tmp = NaChar / (1.0 + Math.exp((Ev / KbT)));
                                                	} else if (EAccept <= 2.2e-34) {
                                                		tmp = NaChar / (1.0 + Math.exp((Vef / KbT)));
                                                	} else if (EAccept <= 7e+45) {
                                                		tmp = NdChar / (1.0 + Math.exp((EDonor / KbT)));
                                                	} else {
                                                		tmp = NaChar / (1.0 + Math.exp((EAccept / KbT)));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                	tmp = 0
                                                	if EAccept <= -6e-215:
                                                		tmp = NaChar / (1.0 + math.exp((Ev / KbT)))
                                                	elif EAccept <= 2.2e-34:
                                                		tmp = NaChar / (1.0 + math.exp((Vef / KbT)))
                                                	elif EAccept <= 7e+45:
                                                		tmp = NdChar / (1.0 + math.exp((EDonor / KbT)))
                                                	else:
                                                		tmp = NaChar / (1.0 + math.exp((EAccept / KbT)))
                                                	return tmp
                                                
                                                function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                	tmp = 0.0
                                                	if (EAccept <= -6e-215)
                                                		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
                                                	elseif (EAccept <= 2.2e-34)
                                                		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Vef / KbT))));
                                                	elseif (EAccept <= 7e+45)
                                                		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT))));
                                                	else
                                                		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                                                	end
                                                	return tmp
                                                end
                                                
                                                function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                	tmp = 0.0;
                                                	if (EAccept <= -6e-215)
                                                		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                                                	elseif (EAccept <= 2.2e-34)
                                                		tmp = NaChar / (1.0 + exp((Vef / KbT)));
                                                	elseif (EAccept <= 7e+45)
                                                		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                                                	else
                                                		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                	end
                                                	tmp_2 = tmp;
                                                end
                                                
                                                code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[EAccept, -6e-215], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[EAccept, 2.2e-34], N[(NaChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[EAccept, 7e+45], N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;EAccept \leq -6 \cdot 10^{-215}:\\
                                                \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
                                                
                                                \mathbf{elif}\;EAccept \leq 2.2 \cdot 10^{-34}:\\
                                                \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\
                                                
                                                \mathbf{elif}\;EAccept \leq 7 \cdot 10^{+45}:\\
                                                \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 4 regimes
                                                2. if EAccept < -6.00000000000000051e-215

                                                  1. Initial program 100.0%

                                                    \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                  2. Add Preprocessing
                                                  3. Taylor expanded in NdChar around 0

                                                    \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                  4. Step-by-step derivation
                                                    1. lower-/.f64N/A

                                                      \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                    2. lower-+.f64N/A

                                                      \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                    3. lower-exp.f64N/A

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                    4. lower-/.f64N/A

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                    5. lower--.f64N/A

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                    6. lower-+.f64N/A

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                    7. lower-+.f6459.8

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                  5. Applied rewrites59.8%

                                                    \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                  6. Taylor expanded in Ev around inf

                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]
                                                  7. Step-by-step derivation
                                                    1. Applied rewrites36.1%

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]

                                                    if -6.00000000000000051e-215 < EAccept < 2.1999999999999999e-34

                                                    1. Initial program 100.0%

                                                      \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in NdChar around 0

                                                      \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                    4. Step-by-step derivation
                                                      1. lower-/.f64N/A

                                                        \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                      2. lower-+.f64N/A

                                                        \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                      3. lower-exp.f64N/A

                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                      4. lower-/.f64N/A

                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                      5. lower--.f64N/A

                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                      6. lower-+.f64N/A

                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                      7. lower-+.f6461.4

                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                    5. Applied rewrites61.4%

                                                      \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                    6. Taylor expanded in Vef around inf

                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]
                                                    7. Step-by-step derivation
                                                      1. Applied rewrites45.2%

                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]

                                                      if 2.1999999999999999e-34 < EAccept < 7.00000000000000046e45

                                                      1. Initial program 100.0%

                                                        \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                      2. Add Preprocessing
                                                      3. Taylor expanded in Ev around inf

                                                        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                                      4. Step-by-step derivation
                                                        1. Applied rewrites71.8%

                                                          \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                                        2. Taylor expanded in NdChar around inf

                                                          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                        3. Step-by-step derivation
                                                          1. frac-addN/A

                                                            \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                          2. lower-/.f64N/A

                                                            \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                          3. lower-+.f64N/A

                                                            \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                          4. lower-exp.f64N/A

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                          5. lower-/.f64N/A

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                          6. lower--.f64N/A

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                          7. lower-+.f64N/A

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                          8. lower-+.f6469.5

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                        4. Applied rewrites69.5%

                                                          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                        5. Taylor expanded in EDonor around inf

                                                          \[\leadsto \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} \]
                                                        6. Step-by-step derivation
                                                          1. Applied rewrites53.8%

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} \]

                                                          if 7.00000000000000046e45 < EAccept

                                                          1. Initial program 100.0%

                                                            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                          2. Add Preprocessing
                                                          3. Taylor expanded in NdChar around 0

                                                            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                          4. Step-by-step derivation
                                                            1. lower-/.f64N/A

                                                              \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                            2. lower-+.f64N/A

                                                              \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                            3. lower-exp.f64N/A

                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                            4. lower-/.f64N/A

                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                            5. lower--.f64N/A

                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                            6. lower-+.f64N/A

                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                            7. lower-+.f6472.8

                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                          5. Applied rewrites72.8%

                                                            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                          6. Taylor expanded in EAccept around inf

                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                          7. Step-by-step derivation
                                                            1. Applied rewrites54.4%

                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                          8. Recombined 4 regimes into one program.
                                                          9. Final simplification43.6%

                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;EAccept \leq -6 \cdot 10^{-215}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 2.2 \cdot 10^{-34}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;EAccept \leq 7 \cdot 10^{+45}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \]
                                                          10. Add Preprocessing

                                                          Alternative 15: 52.3% accurate, 2.0× speedup?

                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -3.4 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \end{array} \end{array} \]
                                                          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                           :precision binary64
                                                           (if (or (<= NdChar -3.4e-59) (not (<= NdChar 1.4e-36)))
                                                             (/ NdChar (+ 1.0 (exp (/ (- mu Ec) KbT))))
                                                             (/ NaChar (+ 1.0 (exp (/ (- Vef mu) KbT))))))
                                                          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                          	double tmp;
                                                          	if ((NdChar <= -3.4e-59) || !(NdChar <= 1.4e-36)) {
                                                          		tmp = NdChar / (1.0 + exp(((mu - Ec) / KbT)));
                                                          	} else {
                                                          		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          module fmin_fmax_functions
                                                              implicit none
                                                              private
                                                              public fmax
                                                              public fmin
                                                          
                                                              interface fmax
                                                                  module procedure fmax88
                                                                  module procedure fmax44
                                                                  module procedure fmax84
                                                                  module procedure fmax48
                                                              end interface
                                                              interface fmin
                                                                  module procedure fmin88
                                                                  module procedure fmin44
                                                                  module procedure fmin84
                                                                  module procedure fmin48
                                                              end interface
                                                          contains
                                                              real(8) function fmax88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmax44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmax48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin88(x, y) result (res)
                                                                  real(8), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(4) function fmin44(x, y) result (res)
                                                                  real(4), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin84(x, y) result(res)
                                                                  real(8), intent (in) :: x
                                                                  real(4), intent (in) :: y
                                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                              end function
                                                              real(8) function fmin48(x, y) result(res)
                                                                  real(4), intent (in) :: x
                                                                  real(8), intent (in) :: y
                                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                              end function
                                                          end module
                                                          
                                                          real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                          use fmin_fmax_functions
                                                              real(8), intent (in) :: ndchar
                                                              real(8), intent (in) :: ec
                                                              real(8), intent (in) :: vef
                                                              real(8), intent (in) :: edonor
                                                              real(8), intent (in) :: mu
                                                              real(8), intent (in) :: kbt
                                                              real(8), intent (in) :: nachar
                                                              real(8), intent (in) :: ev
                                                              real(8), intent (in) :: eaccept
                                                              real(8) :: tmp
                                                              if ((ndchar <= (-3.4d-59)) .or. (.not. (ndchar <= 1.4d-36))) then
                                                                  tmp = ndchar / (1.0d0 + exp(((mu - ec) / kbt)))
                                                              else
                                                                  tmp = nachar / (1.0d0 + exp(((vef - mu) / kbt)))
                                                              end if
                                                              code = tmp
                                                          end function
                                                          
                                                          public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                          	double tmp;
                                                          	if ((NdChar <= -3.4e-59) || !(NdChar <= 1.4e-36)) {
                                                          		tmp = NdChar / (1.0 + Math.exp(((mu - Ec) / KbT)));
                                                          	} else {
                                                          		tmp = NaChar / (1.0 + Math.exp(((Vef - mu) / KbT)));
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                          	tmp = 0
                                                          	if (NdChar <= -3.4e-59) or not (NdChar <= 1.4e-36):
                                                          		tmp = NdChar / (1.0 + math.exp(((mu - Ec) / KbT)))
                                                          	else:
                                                          		tmp = NaChar / (1.0 + math.exp(((Vef - mu) / KbT)))
                                                          	return tmp
                                                          
                                                          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                          	tmp = 0.0
                                                          	if ((NdChar <= -3.4e-59) || !(NdChar <= 1.4e-36))
                                                          		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(mu - Ec) / KbT))));
                                                          	else
                                                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Vef - mu) / KbT))));
                                                          	end
                                                          	return tmp
                                                          end
                                                          
                                                          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                          	tmp = 0.0;
                                                          	if ((NdChar <= -3.4e-59) || ~((NdChar <= 1.4e-36)))
                                                          		tmp = NdChar / (1.0 + exp(((mu - Ec) / KbT)));
                                                          	else
                                                          		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                                          	end
                                                          	tmp_2 = tmp;
                                                          end
                                                          
                                                          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NdChar, -3.4e-59], N[Not[LessEqual[NdChar, 1.4e-36]], $MachinePrecision]], N[(NdChar / N[(1.0 + N[Exp[N[(N[(mu - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(N[(Vef - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                          
                                                          \begin{array}{l}
                                                          
                                                          \\
                                                          \begin{array}{l}
                                                          \mathbf{if}\;NdChar \leq -3.4 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\
                                                          \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}}\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\
                                                          
                                                          
                                                          \end{array}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if NdChar < -3.40000000000000018e-59 or 1.4000000000000001e-36 < NdChar

                                                            1. Initial program 100.0%

                                                              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                            2. Add Preprocessing
                                                            3. Taylor expanded in Ev around inf

                                                              \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                                            4. Step-by-step derivation
                                                              1. Applied rewrites75.5%

                                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\color{blue}{Ev}}{KbT}}} \]
                                                              2. Taylor expanded in NdChar around inf

                                                                \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                              3. Step-by-step derivation
                                                                1. frac-addN/A

                                                                  \[\leadsto \frac{\color{blue}{NdChar}}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                                2. lower-/.f64N/A

                                                                  \[\leadsto \frac{NdChar}{\color{blue}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                                3. lower-+.f64N/A

                                                                  \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                                4. lower-exp.f64N/A

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                                5. lower-/.f64N/A

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                                6. lower--.f64N/A

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                                7. lower-+.f64N/A

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                                8. lower-+.f6473.4

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}} \]
                                                              4. Applied rewrites73.4%

                                                                \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}} \]
                                                              5. Taylor expanded in mu around inf

                                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}} \]
                                                              6. Step-by-step derivation
                                                                1. Applied rewrites56.7%

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}} \]

                                                                if -3.40000000000000018e-59 < NdChar < 1.4000000000000001e-36

                                                                1. Initial program 100.0%

                                                                  \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                2. Add Preprocessing
                                                                3. Taylor expanded in NdChar around 0

                                                                  \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                4. Step-by-step derivation
                                                                  1. lower-/.f64N/A

                                                                    \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                  2. lower-+.f64N/A

                                                                    \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                  3. lower-exp.f64N/A

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                  4. lower-/.f64N/A

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                  5. lower--.f64N/A

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                  6. lower-+.f64N/A

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                  7. lower-+.f6478.0

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                5. Applied rewrites78.0%

                                                                  \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                6. Taylor expanded in Vef around inf

                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
                                                                7. Step-by-step derivation
                                                                  1. Applied rewrites64.7%

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
                                                                8. Recombined 2 regimes into one program.
                                                                9. Final simplification60.2%

                                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -3.4 \cdot 10^{-59} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \end{array} \]
                                                                10. Add Preprocessing

                                                                Alternative 16: 50.6% accurate, 2.0× speedup?

                                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;KbT \leq -1.3 \cdot 10^{+164}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;KbT \leq 5.6 \cdot 10^{+202}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{2 - \frac{Ec}{KbT}} + 0.5 \cdot NaChar\\ \end{array} \end{array} \]
                                                                (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                 :precision binary64
                                                                 (if (<= KbT -1.3e+164)
                                                                   (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
                                                                   (if (<= KbT 5.6e+202)
                                                                     (/ NaChar (+ 1.0 (exp (/ (- Vef mu) KbT))))
                                                                     (+ (/ NdChar (- 2.0 (/ Ec KbT))) (* 0.5 NaChar)))))
                                                                double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                	double tmp;
                                                                	if (KbT <= -1.3e+164) {
                                                                		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
                                                                	} else if (KbT <= 5.6e+202) {
                                                                		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                                                	} else {
                                                                		tmp = (NdChar / (2.0 - (Ec / KbT))) + (0.5 * NaChar);
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                	tmp = 0.0
                                                                	if (KbT <= -1.3e+164)
                                                                		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
                                                                	elseif (KbT <= 5.6e+202)
                                                                		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Vef - mu) / KbT))));
                                                                	else
                                                                		tmp = Float64(Float64(NdChar / Float64(2.0 - Float64(Ec / KbT))) + Float64(0.5 * NaChar));
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, -1.3e+164], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 5.6e+202], N[(NaChar / N[(1.0 + N[Exp[N[(N[(Vef - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(NdChar / N[(2.0 - N[(Ec / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]
                                                                
                                                                \begin{array}{l}
                                                                
                                                                \\
                                                                \begin{array}{l}
                                                                \mathbf{if}\;KbT \leq -1.3 \cdot 10^{+164}:\\
                                                                \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
                                                                
                                                                \mathbf{elif}\;KbT \leq 5.6 \cdot 10^{+202}:\\
                                                                \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;\frac{NdChar}{2 - \frac{Ec}{KbT}} + 0.5 \cdot NaChar\\
                                                                
                                                                
                                                                \end{array}
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 3 regimes
                                                                2. if KbT < -1.3e164

                                                                  1. Initial program 100.0%

                                                                    \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                  2. Add Preprocessing
                                                                  3. Step-by-step derivation
                                                                    1. frac-addN/A

                                                                      \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                                                                    2. lower-/.f64N/A

                                                                      \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                                                                  4. Applied rewrites72.7%

                                                                    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
                                                                  5. Taylor expanded in KbT around inf

                                                                    \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                                                                  6. Step-by-step derivation
                                                                    1. lower-*.f64N/A

                                                                      \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                                                                    2. lower-fma.f64N/A

                                                                      \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
                                                                    3. lower-*.f6465.1

                                                                      \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
                                                                  7. Applied rewrites65.1%

                                                                    \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

                                                                  if -1.3e164 < KbT < 5.60000000000000032e202

                                                                  1. Initial program 100.0%

                                                                    \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                  2. Add Preprocessing
                                                                  3. Taylor expanded in NdChar around 0

                                                                    \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                  4. Step-by-step derivation
                                                                    1. lower-/.f64N/A

                                                                      \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                    2. lower-+.f64N/A

                                                                      \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                    3. lower-exp.f64N/A

                                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                    4. lower-/.f64N/A

                                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                    5. lower--.f64N/A

                                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                    6. lower-+.f64N/A

                                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                    7. lower-+.f6463.7

                                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                  5. Applied rewrites63.7%

                                                                    \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                  6. Taylor expanded in Vef around inf

                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
                                                                  7. Step-by-step derivation
                                                                    1. Applied rewrites52.8%

                                                                      \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]

                                                                    if 5.60000000000000032e202 < KbT

                                                                    1. Initial program 100.0%

                                                                      \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                    2. Add Preprocessing
                                                                    3. Taylor expanded in KbT around inf

                                                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \color{blue}{\frac{1}{2} \cdot NaChar} \]
                                                                    4. Step-by-step derivation
                                                                      1. lower-*.f6497.7

                                                                        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + 0.5 \cdot \color{blue}{NaChar} \]
                                                                    5. Applied rewrites97.7%

                                                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \color{blue}{0.5 \cdot NaChar} \]
                                                                    6. Taylor expanded in KbT around inf

                                                                      \[\leadsto \frac{NdChar}{\color{blue}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \frac{Ec}{KbT}}} + \frac{1}{2} \cdot NaChar \]
                                                                    7. Step-by-step derivation
                                                                      1. lower--.f64N/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \color{blue}{\frac{Ec}{KbT}}} + \frac{1}{2} \cdot NaChar \]
                                                                      2. lower-+.f64N/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \frac{\color{blue}{Ec}}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                      3. div-add-revN/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \left(\frac{EDonor}{KbT} + \frac{Vef + mu}{KbT}\right)\right) - \frac{Ec}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                      4. div-addN/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                      5. lower-/.f64N/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                      6. lower-+.f64N/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                      7. lower-+.f64N/A

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                      8. lower-/.f6497.7

                                                                        \[\leadsto \frac{NdChar}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{\color{blue}{KbT}}} + 0.5 \cdot NaChar \]
                                                                    8. Applied rewrites97.7%

                                                                      \[\leadsto \frac{NdChar}{\color{blue}{\left(2 + \frac{EDonor + \left(Vef + mu\right)}{KbT}\right) - \frac{Ec}{KbT}}} + 0.5 \cdot NaChar \]
                                                                    9. Taylor expanded in KbT around inf

                                                                      \[\leadsto \frac{NdChar}{2 - \frac{\color{blue}{Ec}}{KbT}} + \frac{1}{2} \cdot NaChar \]
                                                                    10. Step-by-step derivation
                                                                      1. Applied rewrites97.7%

                                                                        \[\leadsto \frac{NdChar}{2 - \frac{\color{blue}{Ec}}{KbT}} + 0.5 \cdot NaChar \]
                                                                    11. Recombined 3 regimes into one program.
                                                                    12. Final simplification57.7%

                                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;KbT \leq -1.3 \cdot 10^{+164}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;KbT \leq 5.6 \cdot 10^{+202}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{2 - \frac{Ec}{KbT}} + 0.5 \cdot NaChar\\ \end{array} \]
                                                                    13. Add Preprocessing

                                                                    Alternative 17: 44.1% accurate, 2.0× speedup?

                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;Vef \leq -1.5 \cdot 10^{+37} \lor \neg \left(Vef \leq 1.18 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \end{array} \]
                                                                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                     :precision binary64
                                                                     (if (or (<= Vef -1.5e+37) (not (<= Vef 1.18e+36)))
                                                                       (/ NaChar (+ 1.0 (exp (/ Vef KbT))))
                                                                       (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))))
                                                                    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                    	double tmp;
                                                                    	if ((Vef <= -1.5e+37) || !(Vef <= 1.18e+36)) {
                                                                    		tmp = NaChar / (1.0 + exp((Vef / KbT)));
                                                                    	} else {
                                                                    		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    module fmin_fmax_functions
                                                                        implicit none
                                                                        private
                                                                        public fmax
                                                                        public fmin
                                                                    
                                                                        interface fmax
                                                                            module procedure fmax88
                                                                            module procedure fmax44
                                                                            module procedure fmax84
                                                                            module procedure fmax48
                                                                        end interface
                                                                        interface fmin
                                                                            module procedure fmin88
                                                                            module procedure fmin44
                                                                            module procedure fmin84
                                                                            module procedure fmin48
                                                                        end interface
                                                                    contains
                                                                        real(8) function fmax88(x, y) result (res)
                                                                            real(8), intent (in) :: x
                                                                            real(8), intent (in) :: y
                                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                        end function
                                                                        real(4) function fmax44(x, y) result (res)
                                                                            real(4), intent (in) :: x
                                                                            real(4), intent (in) :: y
                                                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                        end function
                                                                        real(8) function fmax84(x, y) result(res)
                                                                            real(8), intent (in) :: x
                                                                            real(4), intent (in) :: y
                                                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                        end function
                                                                        real(8) function fmax48(x, y) result(res)
                                                                            real(4), intent (in) :: x
                                                                            real(8), intent (in) :: y
                                                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                        end function
                                                                        real(8) function fmin88(x, y) result (res)
                                                                            real(8), intent (in) :: x
                                                                            real(8), intent (in) :: y
                                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                        end function
                                                                        real(4) function fmin44(x, y) result (res)
                                                                            real(4), intent (in) :: x
                                                                            real(4), intent (in) :: y
                                                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                        end function
                                                                        real(8) function fmin84(x, y) result(res)
                                                                            real(8), intent (in) :: x
                                                                            real(4), intent (in) :: y
                                                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                        end function
                                                                        real(8) function fmin48(x, y) result(res)
                                                                            real(4), intent (in) :: x
                                                                            real(8), intent (in) :: y
                                                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                        end function
                                                                    end module
                                                                    
                                                                    real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                                    use fmin_fmax_functions
                                                                        real(8), intent (in) :: ndchar
                                                                        real(8), intent (in) :: ec
                                                                        real(8), intent (in) :: vef
                                                                        real(8), intent (in) :: edonor
                                                                        real(8), intent (in) :: mu
                                                                        real(8), intent (in) :: kbt
                                                                        real(8), intent (in) :: nachar
                                                                        real(8), intent (in) :: ev
                                                                        real(8), intent (in) :: eaccept
                                                                        real(8) :: tmp
                                                                        if ((vef <= (-1.5d+37)) .or. (.not. (vef <= 1.18d+36))) then
                                                                            tmp = nachar / (1.0d0 + exp((vef / kbt)))
                                                                        else
                                                                            tmp = nachar / (1.0d0 + exp((eaccept / kbt)))
                                                                        end if
                                                                        code = tmp
                                                                    end function
                                                                    
                                                                    public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                    	double tmp;
                                                                    	if ((Vef <= -1.5e+37) || !(Vef <= 1.18e+36)) {
                                                                    		tmp = NaChar / (1.0 + Math.exp((Vef / KbT)));
                                                                    	} else {
                                                                    		tmp = NaChar / (1.0 + Math.exp((EAccept / KbT)));
                                                                    	}
                                                                    	return tmp;
                                                                    }
                                                                    
                                                                    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                                    	tmp = 0
                                                                    	if (Vef <= -1.5e+37) or not (Vef <= 1.18e+36):
                                                                    		tmp = NaChar / (1.0 + math.exp((Vef / KbT)))
                                                                    	else:
                                                                    		tmp = NaChar / (1.0 + math.exp((EAccept / KbT)))
                                                                    	return tmp
                                                                    
                                                                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                    	tmp = 0.0
                                                                    	if ((Vef <= -1.5e+37) || !(Vef <= 1.18e+36))
                                                                    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Vef / KbT))));
                                                                    	else
                                                                    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                                                                    	end
                                                                    	return tmp
                                                                    end
                                                                    
                                                                    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                    	tmp = 0.0;
                                                                    	if ((Vef <= -1.5e+37) || ~((Vef <= 1.18e+36)))
                                                                    		tmp = NaChar / (1.0 + exp((Vef / KbT)));
                                                                    	else
                                                                    		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                                    	end
                                                                    	tmp_2 = tmp;
                                                                    end
                                                                    
                                                                    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[Vef, -1.5e+37], N[Not[LessEqual[Vef, 1.18e+36]], $MachinePrecision]], N[(NaChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                    
                                                                    \begin{array}{l}
                                                                    
                                                                    \\
                                                                    \begin{array}{l}
                                                                    \mathbf{if}\;Vef \leq -1.5 \cdot 10^{+37} \lor \neg \left(Vef \leq 1.18 \cdot 10^{+36}\right):\\
                                                                    \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\
                                                                    
                                                                    \mathbf{else}:\\
                                                                    \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                                                                    
                                                                    
                                                                    \end{array}
                                                                    \end{array}
                                                                    
                                                                    Derivation
                                                                    1. Split input into 2 regimes
                                                                    2. if Vef < -1.50000000000000011e37 or 1.17999999999999997e36 < Vef

                                                                      1. Initial program 100.0%

                                                                        \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                      2. Add Preprocessing
                                                                      3. Taylor expanded in NdChar around 0

                                                                        \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                      4. Step-by-step derivation
                                                                        1. lower-/.f64N/A

                                                                          \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                        2. lower-+.f64N/A

                                                                          \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                        3. lower-exp.f64N/A

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                        4. lower-/.f64N/A

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                        5. lower--.f64N/A

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                        6. lower-+.f64N/A

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                        7. lower-+.f6467.7

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                      5. Applied rewrites67.7%

                                                                        \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                      6. Taylor expanded in Vef around inf

                                                                        \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]
                                                                      7. Step-by-step derivation
                                                                        1. Applied rewrites55.3%

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef}{KbT}}} \]

                                                                        if -1.50000000000000011e37 < Vef < 1.17999999999999997e36

                                                                        1. Initial program 100.0%

                                                                          \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                        2. Add Preprocessing
                                                                        3. Taylor expanded in NdChar around 0

                                                                          \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                        4. Step-by-step derivation
                                                                          1. lower-/.f64N/A

                                                                            \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                          2. lower-+.f64N/A

                                                                            \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                          3. lower-exp.f64N/A

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                          4. lower-/.f64N/A

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                          5. lower--.f64N/A

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                          6. lower-+.f64N/A

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                          7. lower-+.f6456.8

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                        5. Applied rewrites56.8%

                                                                          \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                        6. Taylor expanded in EAccept around inf

                                                                          \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                                        7. Step-by-step derivation
                                                                          1. Applied rewrites34.9%

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                                        8. Recombined 2 regimes into one program.
                                                                        9. Final simplification43.7%

                                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;Vef \leq -1.5 \cdot 10^{+37} \lor \neg \left(Vef \leq 1.18 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \]
                                                                        10. Add Preprocessing

                                                                        Alternative 18: 40.6% accurate, 2.0× speedup?

                                                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;KbT \leq -8.5 \cdot 10^{+163}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;KbT \leq 4.2 \cdot 10^{+23}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \end{array} \]
                                                                        (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                         :precision binary64
                                                                         (if (<= KbT -8.5e+163)
                                                                           (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar)))
                                                                           (if (<= KbT 4.2e+23)
                                                                             (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))
                                                                             (fma 0.5 NaChar (* 0.5 NdChar)))))
                                                                        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                        	double tmp;
                                                                        	if (KbT <= -8.5e+163) {
                                                                        		tmp = 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
                                                                        	} else if (KbT <= 4.2e+23) {
                                                                        		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                                        	} else {
                                                                        		tmp = fma(0.5, NaChar, (0.5 * NdChar));
                                                                        	}
                                                                        	return tmp;
                                                                        }
                                                                        
                                                                        function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                        	tmp = 0.0
                                                                        	if (KbT <= -8.5e+163)
                                                                        		tmp = Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)));
                                                                        	elseif (KbT <= 4.2e+23)
                                                                        		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                                                                        	else
                                                                        		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
                                                                        	end
                                                                        	return tmp
                                                                        end
                                                                        
                                                                        code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, -8.5e+163], N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 4.2e+23], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]]]
                                                                        
                                                                        \begin{array}{l}
                                                                        
                                                                        \\
                                                                        \begin{array}{l}
                                                                        \mathbf{if}\;KbT \leq -8.5 \cdot 10^{+163}:\\
                                                                        \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\
                                                                        
                                                                        \mathbf{elif}\;KbT \leq 4.2 \cdot 10^{+23}:\\
                                                                        \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                                                                        
                                                                        \mathbf{else}:\\
                                                                        \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
                                                                        
                                                                        
                                                                        \end{array}
                                                                        \end{array}
                                                                        
                                                                        Derivation
                                                                        1. Split input into 3 regimes
                                                                        2. if KbT < -8.5000000000000003e163

                                                                          1. Initial program 100.0%

                                                                            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                          2. Add Preprocessing
                                                                          3. Step-by-step derivation
                                                                            1. frac-addN/A

                                                                              \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                                                                            2. lower-/.f64N/A

                                                                              \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                                                                          4. Applied rewrites72.7%

                                                                            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
                                                                          5. Taylor expanded in KbT around inf

                                                                            \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                                                                          6. Step-by-step derivation
                                                                            1. lower-*.f64N/A

                                                                              \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                                                                            2. lower-fma.f64N/A

                                                                              \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
                                                                            3. lower-*.f6465.1

                                                                              \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
                                                                          7. Applied rewrites65.1%

                                                                            \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]

                                                                          if -8.5000000000000003e163 < KbT < 4.2000000000000003e23

                                                                          1. Initial program 100.0%

                                                                            \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                          2. Add Preprocessing
                                                                          3. Taylor expanded in NdChar around 0

                                                                            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                          4. Step-by-step derivation
                                                                            1. lower-/.f64N/A

                                                                              \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                            2. lower-+.f64N/A

                                                                              \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                            3. lower-exp.f64N/A

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                            4. lower-/.f64N/A

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                            5. lower--.f64N/A

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                            6. lower-+.f64N/A

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                            7. lower-+.f6466.4

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                          5. Applied rewrites66.4%

                                                                            \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                          6. Taylor expanded in EAccept around inf

                                                                            \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                                          7. Step-by-step derivation
                                                                            1. Applied rewrites35.6%

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]

                                                                            if 4.2000000000000003e23 < KbT

                                                                            1. Initial program 100.0%

                                                                              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                            2. Add Preprocessing
                                                                            3. Taylor expanded in KbT around inf

                                                                              \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                                                            4. Step-by-step derivation
                                                                              1. lower-fma.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                                                                              2. lower-*.f6446.3

                                                                                \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
                                                                            5. Applied rewrites46.3%

                                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
                                                                          8. Recombined 3 regimes into one program.
                                                                          9. Final simplification41.6%

                                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;KbT \leq -8.5 \cdot 10^{+163}:\\ \;\;\;\;0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)\\ \mathbf{elif}\;KbT \leq 4.2 \cdot 10^{+23}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \end{array} \]
                                                                          10. Add Preprocessing

                                                                          Alternative 19: 38.4% accurate, 2.1× speedup?

                                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;Ev \leq -0.0048:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \end{array} \]
                                                                          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                           :precision binary64
                                                                           (if (<= Ev -0.0048)
                                                                             (/ NaChar (+ 1.0 (exp (/ Ev KbT))))
                                                                             (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))))
                                                                          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                          	double tmp;
                                                                          	if (Ev <= -0.0048) {
                                                                          		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                                                                          	} else {
                                                                          		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          module fmin_fmax_functions
                                                                              implicit none
                                                                              private
                                                                              public fmax
                                                                              public fmin
                                                                          
                                                                              interface fmax
                                                                                  module procedure fmax88
                                                                                  module procedure fmax44
                                                                                  module procedure fmax84
                                                                                  module procedure fmax48
                                                                              end interface
                                                                              interface fmin
                                                                                  module procedure fmin88
                                                                                  module procedure fmin44
                                                                                  module procedure fmin84
                                                                                  module procedure fmin48
                                                                              end interface
                                                                          contains
                                                                              real(8) function fmax88(x, y) result (res)
                                                                                  real(8), intent (in) :: x
                                                                                  real(8), intent (in) :: y
                                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                              end function
                                                                              real(4) function fmax44(x, y) result (res)
                                                                                  real(4), intent (in) :: x
                                                                                  real(4), intent (in) :: y
                                                                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                              end function
                                                                              real(8) function fmax84(x, y) result(res)
                                                                                  real(8), intent (in) :: x
                                                                                  real(4), intent (in) :: y
                                                                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                              end function
                                                                              real(8) function fmax48(x, y) result(res)
                                                                                  real(4), intent (in) :: x
                                                                                  real(8), intent (in) :: y
                                                                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                              end function
                                                                              real(8) function fmin88(x, y) result (res)
                                                                                  real(8), intent (in) :: x
                                                                                  real(8), intent (in) :: y
                                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                              end function
                                                                              real(4) function fmin44(x, y) result (res)
                                                                                  real(4), intent (in) :: x
                                                                                  real(4), intent (in) :: y
                                                                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                              end function
                                                                              real(8) function fmin84(x, y) result(res)
                                                                                  real(8), intent (in) :: x
                                                                                  real(4), intent (in) :: y
                                                                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                              end function
                                                                              real(8) function fmin48(x, y) result(res)
                                                                                  real(4), intent (in) :: x
                                                                                  real(8), intent (in) :: y
                                                                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                              end function
                                                                          end module
                                                                          
                                                                          real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                                          use fmin_fmax_functions
                                                                              real(8), intent (in) :: ndchar
                                                                              real(8), intent (in) :: ec
                                                                              real(8), intent (in) :: vef
                                                                              real(8), intent (in) :: edonor
                                                                              real(8), intent (in) :: mu
                                                                              real(8), intent (in) :: kbt
                                                                              real(8), intent (in) :: nachar
                                                                              real(8), intent (in) :: ev
                                                                              real(8), intent (in) :: eaccept
                                                                              real(8) :: tmp
                                                                              if (ev <= (-0.0048d0)) then
                                                                                  tmp = nachar / (1.0d0 + exp((ev / kbt)))
                                                                              else
                                                                                  tmp = nachar / (1.0d0 + exp((eaccept / kbt)))
                                                                              end if
                                                                              code = tmp
                                                                          end function
                                                                          
                                                                          public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                          	double tmp;
                                                                          	if (Ev <= -0.0048) {
                                                                          		tmp = NaChar / (1.0 + Math.exp((Ev / KbT)));
                                                                          	} else {
                                                                          		tmp = NaChar / (1.0 + Math.exp((EAccept / KbT)));
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                                          	tmp = 0
                                                                          	if Ev <= -0.0048:
                                                                          		tmp = NaChar / (1.0 + math.exp((Ev / KbT)))
                                                                          	else:
                                                                          		tmp = NaChar / (1.0 + math.exp((EAccept / KbT)))
                                                                          	return tmp
                                                                          
                                                                          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                          	tmp = 0.0
                                                                          	if (Ev <= -0.0048)
                                                                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
                                                                          	else
                                                                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                                                                          	end
                                                                          	return tmp
                                                                          end
                                                                          
                                                                          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                          	tmp = 0.0;
                                                                          	if (Ev <= -0.0048)
                                                                          		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                                                                          	else
                                                                          		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                                                          	end
                                                                          	tmp_2 = tmp;
                                                                          end
                                                                          
                                                                          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[Ev, -0.0048], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \begin{array}{l}
                                                                          \mathbf{if}\;Ev \leq -0.0048:\\
                                                                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
                                                                          
                                                                          \mathbf{else}:\\
                                                                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                                                                          
                                                                          
                                                                          \end{array}
                                                                          \end{array}
                                                                          
                                                                          Derivation
                                                                          1. Split input into 2 regimes
                                                                          2. if Ev < -0.00479999999999999958

                                                                            1. Initial program 100.0%

                                                                              \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                            2. Add Preprocessing
                                                                            3. Taylor expanded in NdChar around 0

                                                                              \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                            4. Step-by-step derivation
                                                                              1. lower-/.f64N/A

                                                                                \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                              2. lower-+.f64N/A

                                                                                \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                              3. lower-exp.f64N/A

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                              4. lower-/.f64N/A

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                              5. lower--.f64N/A

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                              6. lower-+.f64N/A

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                              7. lower-+.f6460.2

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                            5. Applied rewrites60.2%

                                                                              \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                            6. Taylor expanded in Ev around inf

                                                                              \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]
                                                                            7. Step-by-step derivation
                                                                              1. Applied rewrites51.9%

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}} \]

                                                                              if -0.00479999999999999958 < Ev

                                                                              1. Initial program 100.0%

                                                                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                              2. Add Preprocessing
                                                                              3. Taylor expanded in NdChar around 0

                                                                                \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                              4. Step-by-step derivation
                                                                                1. lower-/.f64N/A

                                                                                  \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                                2. lower-+.f64N/A

                                                                                  \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                                3. lower-exp.f64N/A

                                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                4. lower-/.f64N/A

                                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                5. lower--.f64N/A

                                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                6. lower-+.f64N/A

                                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                7. lower-+.f6462.0

                                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                              5. Applied rewrites62.0%

                                                                                \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                              6. Taylor expanded in EAccept around inf

                                                                                \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                                              7. Step-by-step derivation
                                                                                1. Applied rewrites37.5%

                                                                                  \[\leadsto \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}} \]
                                                                              8. Recombined 2 regimes into one program.
                                                                              9. Add Preprocessing

                                                                              Alternative 20: 23.0% accurate, 15.3× speedup?

                                                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -8.5 \cdot 10^{-62} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;0.5 \cdot NdChar\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NaChar\\ \end{array} \end{array} \]
                                                                              (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                               :precision binary64
                                                                               (if (or (<= NdChar -8.5e-62) (not (<= NdChar 1.4e-36)))
                                                                                 (* 0.5 NdChar)
                                                                                 (* 0.5 NaChar)))
                                                                              double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                              	double tmp;
                                                                              	if ((NdChar <= -8.5e-62) || !(NdChar <= 1.4e-36)) {
                                                                              		tmp = 0.5 * NdChar;
                                                                              	} else {
                                                                              		tmp = 0.5 * NaChar;
                                                                              	}
                                                                              	return tmp;
                                                                              }
                                                                              
                                                                              module fmin_fmax_functions
                                                                                  implicit none
                                                                                  private
                                                                                  public fmax
                                                                                  public fmin
                                                                              
                                                                                  interface fmax
                                                                                      module procedure fmax88
                                                                                      module procedure fmax44
                                                                                      module procedure fmax84
                                                                                      module procedure fmax48
                                                                                  end interface
                                                                                  interface fmin
                                                                                      module procedure fmin88
                                                                                      module procedure fmin44
                                                                                      module procedure fmin84
                                                                                      module procedure fmin48
                                                                                  end interface
                                                                              contains
                                                                                  real(8) function fmax88(x, y) result (res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(4) function fmax44(x, y) result (res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmax84(x, y) result(res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmax48(x, y) result(res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin88(x, y) result (res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(4) function fmin44(x, y) result (res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin84(x, y) result(res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin48(x, y) result(res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                  end function
                                                                              end module
                                                                              
                                                                              real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                                              use fmin_fmax_functions
                                                                                  real(8), intent (in) :: ndchar
                                                                                  real(8), intent (in) :: ec
                                                                                  real(8), intent (in) :: vef
                                                                                  real(8), intent (in) :: edonor
                                                                                  real(8), intent (in) :: mu
                                                                                  real(8), intent (in) :: kbt
                                                                                  real(8), intent (in) :: nachar
                                                                                  real(8), intent (in) :: ev
                                                                                  real(8), intent (in) :: eaccept
                                                                                  real(8) :: tmp
                                                                                  if ((ndchar <= (-8.5d-62)) .or. (.not. (ndchar <= 1.4d-36))) then
                                                                                      tmp = 0.5d0 * ndchar
                                                                                  else
                                                                                      tmp = 0.5d0 * nachar
                                                                                  end if
                                                                                  code = tmp
                                                                              end function
                                                                              
                                                                              public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                              	double tmp;
                                                                              	if ((NdChar <= -8.5e-62) || !(NdChar <= 1.4e-36)) {
                                                                              		tmp = 0.5 * NdChar;
                                                                              	} else {
                                                                              		tmp = 0.5 * NaChar;
                                                                              	}
                                                                              	return tmp;
                                                                              }
                                                                              
                                                                              def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                                              	tmp = 0
                                                                              	if (NdChar <= -8.5e-62) or not (NdChar <= 1.4e-36):
                                                                              		tmp = 0.5 * NdChar
                                                                              	else:
                                                                              		tmp = 0.5 * NaChar
                                                                              	return tmp
                                                                              
                                                                              function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                              	tmp = 0.0
                                                                              	if ((NdChar <= -8.5e-62) || !(NdChar <= 1.4e-36))
                                                                              		tmp = Float64(0.5 * NdChar);
                                                                              	else
                                                                              		tmp = Float64(0.5 * NaChar);
                                                                              	end
                                                                              	return tmp
                                                                              end
                                                                              
                                                                              function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                              	tmp = 0.0;
                                                                              	if ((NdChar <= -8.5e-62) || ~((NdChar <= 1.4e-36)))
                                                                              		tmp = 0.5 * NdChar;
                                                                              	else
                                                                              		tmp = 0.5 * NaChar;
                                                                              	end
                                                                              	tmp_2 = tmp;
                                                                              end
                                                                              
                                                                              code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NdChar, -8.5e-62], N[Not[LessEqual[NdChar, 1.4e-36]], $MachinePrecision]], N[(0.5 * NdChar), $MachinePrecision], N[(0.5 * NaChar), $MachinePrecision]]
                                                                              
                                                                              \begin{array}{l}
                                                                              
                                                                              \\
                                                                              \begin{array}{l}
                                                                              \mathbf{if}\;NdChar \leq -8.5 \cdot 10^{-62} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\
                                                                              \;\;\;\;0.5 \cdot NdChar\\
                                                                              
                                                                              \mathbf{else}:\\
                                                                              \;\;\;\;0.5 \cdot NaChar\\
                                                                              
                                                                              
                                                                              \end{array}
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Split input into 2 regimes
                                                                              2. if NdChar < -8.4999999999999995e-62 or 1.4000000000000001e-36 < NdChar

                                                                                1. Initial program 100.0%

                                                                                  \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                                2. Add Preprocessing
                                                                                3. Taylor expanded in KbT around inf

                                                                                  \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                                                                4. Step-by-step derivation
                                                                                  1. lower-fma.f64N/A

                                                                                    \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                                                                                  2. lower-*.f6426.2

                                                                                    \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
                                                                                5. Applied rewrites26.2%

                                                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
                                                                                6. Taylor expanded in NdChar around inf

                                                                                  \[\leadsto \frac{1}{2} \cdot \color{blue}{NdChar} \]
                                                                                7. Step-by-step derivation
                                                                                  1. lower-*.f6422.9

                                                                                    \[\leadsto 0.5 \cdot NdChar \]
                                                                                8. Applied rewrites22.9%

                                                                                  \[\leadsto 0.5 \cdot \color{blue}{NdChar} \]

                                                                                if -8.4999999999999995e-62 < NdChar < 1.4000000000000001e-36

                                                                                1. Initial program 100.0%

                                                                                  \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                                2. Add Preprocessing
                                                                                3. Taylor expanded in NdChar around 0

                                                                                  \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                                4. Step-by-step derivation
                                                                                  1. lower-/.f64N/A

                                                                                    \[\leadsto \frac{NaChar}{\color{blue}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                                  2. lower-+.f64N/A

                                                                                    \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                                  3. lower-exp.f64N/A

                                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                  4. lower-/.f64N/A

                                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                  5. lower--.f64N/A

                                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                  6. lower-+.f64N/A

                                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                  7. lower-+.f6477.8

                                                                                    \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                                                                                5. Applied rewrites77.8%

                                                                                  \[\leadsto \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                                                6. Taylor expanded in KbT around inf

                                                                                  \[\leadsto \frac{1}{2} \cdot \color{blue}{NaChar} \]
                                                                                7. Step-by-step derivation
                                                                                  1. lower-*.f6429.0

                                                                                    \[\leadsto 0.5 \cdot NaChar \]
                                                                                8. Applied rewrites29.0%

                                                                                  \[\leadsto 0.5 \cdot \color{blue}{NaChar} \]
                                                                              3. Recombined 2 regimes into one program.
                                                                              4. Final simplification25.5%

                                                                                \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -8.5 \cdot 10^{-62} \lor \neg \left(NdChar \leq 1.4 \cdot 10^{-36}\right):\\ \;\;\;\;0.5 \cdot NdChar\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NaChar\\ \end{array} \]
                                                                              5. Add Preprocessing

                                                                              Alternative 21: 28.1% accurate, 16.2× speedup?

                                                                              \[\begin{array}{l} \\ 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \end{array} \]
                                                                              (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                               :precision binary64
                                                                               (* 0.25 (fma 2.0 NaChar (* 2.0 NdChar))))
                                                                              double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                              	return 0.25 * fma(2.0, NaChar, (2.0 * NdChar));
                                                                              }
                                                                              
                                                                              function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                              	return Float64(0.25 * fma(2.0, NaChar, Float64(2.0 * NdChar)))
                                                                              end
                                                                              
                                                                              code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.25 * N[(2.0 * NaChar + N[(2.0 * NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                                                              
                                                                              \begin{array}{l}
                                                                              
                                                                              \\
                                                                              0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Initial program 100.0%

                                                                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                              2. Add Preprocessing
                                                                              3. Step-by-step derivation
                                                                                1. frac-addN/A

                                                                                  \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                                                                                2. lower-/.f64N/A

                                                                                  \[\leadsto \color{blue}{\frac{NdChar \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right) + \left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot NaChar}{\left(1 + e^{\frac{\mathsf{neg}\left(\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(\mathsf{neg}\left(mu\right)\right)}{KbT}}\right)}} \]
                                                                              4. Applied rewrites40.2%

                                                                                \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(NdChar, 1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}, \left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot NaChar\right)}{\left(1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}\right) \cdot \left(1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}\right)}} \]
                                                                              5. Taylor expanded in KbT around inf

                                                                                \[\leadsto \color{blue}{\frac{1}{4} \cdot \left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                                                                              6. Step-by-step derivation
                                                                                1. lower-*.f64N/A

                                                                                  \[\leadsto \frac{1}{4} \cdot \color{blue}{\left(2 \cdot NaChar + 2 \cdot NdChar\right)} \]
                                                                                2. lower-fma.f64N/A

                                                                                  \[\leadsto \frac{1}{4} \cdot \mathsf{fma}\left(2, \color{blue}{NaChar}, 2 \cdot NdChar\right) \]
                                                                                3. lower-*.f6427.8

                                                                                  \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
                                                                              7. Applied rewrites27.8%

                                                                                \[\leadsto \color{blue}{0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right)} \]
                                                                              8. Final simplification27.8%

                                                                                \[\leadsto 0.25 \cdot \mathsf{fma}\left(2, NaChar, 2 \cdot NdChar\right) \]
                                                                              9. Add Preprocessing

                                                                              Alternative 22: 28.2% accurate, 23.0× speedup?

                                                                              \[\begin{array}{l} \\ \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \end{array} \]
                                                                              (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                               :precision binary64
                                                                               (fma 0.5 NaChar (* 0.5 NdChar)))
                                                                              double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                              	return fma(0.5, NaChar, (0.5 * NdChar));
                                                                              }
                                                                              
                                                                              function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                              	return fma(0.5, NaChar, Float64(0.5 * NdChar))
                                                                              end
                                                                              
                                                                              code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]
                                                                              
                                                                              \begin{array}{l}
                                                                              
                                                                              \\
                                                                              \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Initial program 100.0%

                                                                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                              2. Add Preprocessing
                                                                              3. Taylor expanded in KbT around inf

                                                                                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                                                              4. Step-by-step derivation
                                                                                1. lower-fma.f64N/A

                                                                                  \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                                                                                2. lower-*.f6427.8

                                                                                  \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
                                                                              5. Applied rewrites27.8%

                                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
                                                                              6. Add Preprocessing

                                                                              Alternative 23: 18.6% accurate, 46.0× speedup?

                                                                              \[\begin{array}{l} \\ 0.5 \cdot NdChar \end{array} \]
                                                                              (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                               :precision binary64
                                                                               (* 0.5 NdChar))
                                                                              double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                              	return 0.5 * NdChar;
                                                                              }
                                                                              
                                                                              module fmin_fmax_functions
                                                                                  implicit none
                                                                                  private
                                                                                  public fmax
                                                                                  public fmin
                                                                              
                                                                                  interface fmax
                                                                                      module procedure fmax88
                                                                                      module procedure fmax44
                                                                                      module procedure fmax84
                                                                                      module procedure fmax48
                                                                                  end interface
                                                                                  interface fmin
                                                                                      module procedure fmin88
                                                                                      module procedure fmin44
                                                                                      module procedure fmin84
                                                                                      module procedure fmin48
                                                                                  end interface
                                                                              contains
                                                                                  real(8) function fmax88(x, y) result (res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(4) function fmax44(x, y) result (res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmax84(x, y) result(res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmax48(x, y) result(res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin88(x, y) result (res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(4) function fmin44(x, y) result (res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin84(x, y) result(res)
                                                                                      real(8), intent (in) :: x
                                                                                      real(4), intent (in) :: y
                                                                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                                  end function
                                                                                  real(8) function fmin48(x, y) result(res)
                                                                                      real(4), intent (in) :: x
                                                                                      real(8), intent (in) :: y
                                                                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                                  end function
                                                                              end module
                                                                              
                                                                              real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                                              use fmin_fmax_functions
                                                                                  real(8), intent (in) :: ndchar
                                                                                  real(8), intent (in) :: ec
                                                                                  real(8), intent (in) :: vef
                                                                                  real(8), intent (in) :: edonor
                                                                                  real(8), intent (in) :: mu
                                                                                  real(8), intent (in) :: kbt
                                                                                  real(8), intent (in) :: nachar
                                                                                  real(8), intent (in) :: ev
                                                                                  real(8), intent (in) :: eaccept
                                                                                  code = 0.5d0 * ndchar
                                                                              end function
                                                                              
                                                                              public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                              	return 0.5 * NdChar;
                                                                              }
                                                                              
                                                                              def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                                              	return 0.5 * NdChar
                                                                              
                                                                              function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                              	return Float64(0.5 * NdChar)
                                                                              end
                                                                              
                                                                              function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                              	tmp = 0.5 * NdChar;
                                                                              end
                                                                              
                                                                              code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * NdChar), $MachinePrecision]
                                                                              
                                                                              \begin{array}{l}
                                                                              
                                                                              \\
                                                                              0.5 \cdot NdChar
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Initial program 100.0%

                                                                                \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                                              2. Add Preprocessing
                                                                              3. Taylor expanded in KbT around inf

                                                                                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                                                              4. Step-by-step derivation
                                                                                1. lower-fma.f64N/A

                                                                                  \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \color{blue}{NaChar}, \frac{1}{2} \cdot NdChar\right) \]
                                                                                2. lower-*.f6427.8

                                                                                  \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
                                                                              5. Applied rewrites27.8%

                                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
                                                                              6. Taylor expanded in NdChar around inf

                                                                                \[\leadsto \frac{1}{2} \cdot \color{blue}{NdChar} \]
                                                                              7. Step-by-step derivation
                                                                                1. lower-*.f6417.1

                                                                                  \[\leadsto 0.5 \cdot NdChar \]
                                                                              8. Applied rewrites17.1%

                                                                                \[\leadsto 0.5 \cdot \color{blue}{NdChar} \]
                                                                              9. Add Preprocessing

                                                                              Reproduce

                                                                              ?
                                                                              herbie shell --seed 2025044 
                                                                              (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                                :name "Bulmash initializePoisson"
                                                                                :precision binary64
                                                                                (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))