Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 20.5s
Alternatives: 22
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 22 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: 78.8% 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 -1 \cdot 10^{-253} \lor \neg \left(t\_1 \leq 4 \cdot 10^{-193}\right):\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{EAccept}{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 -1e-253) (not (<= t_1 4e-193)))
     (+ t_0 (/ NaChar (+ 1.0 (exp (/ EAccept 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 <= -1e-253) || !(t_1 <= 4e-193)) {
		tmp = t_0 + (NaChar / (1.0 + exp((EAccept / 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 <= (-1d-253)) .or. (.not. (t_1 <= 4d-193))) then
        tmp = t_0 + (nachar / (1.0d0 + exp((eaccept / 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 <= -1e-253) || !(t_1 <= 4e-193)) {
		tmp = t_0 + (NaChar / (1.0 + Math.exp((EAccept / 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 <= -1e-253) or not (t_1 <= 4e-193):
		tmp = t_0 + (NaChar / (1.0 + math.exp((EAccept / 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 <= -1e-253) || !(t_1 <= 4e-193))
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / 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 <= -1e-253) || ~((t_1 <= 4e-193)))
		tmp = t_0 + (NaChar / (1.0 + exp((EAccept / 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, -1e-253], N[Not[LessEqual[t$95$1, 4e-193]], $MachinePrecision]], N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / 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 -1 \cdot 10^{-253} \lor \neg \left(t\_1 \leq 4 \cdot 10^{-193}\right):\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{EAccept}{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))))) < -1.0000000000000001e-253 or 4.0000000000000002e-193 < (+.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 EAccept 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}{EAccept}}{KbT}}} \]
    4. Step-by-step derivation
      1. Applied rewrites75.6%

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

      if -1.0000000000000001e-253 < (+.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.0000000000000002e-193

      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-+.f6493.0

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

        \[\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 simplification78.8%

      \[\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^{-253} \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^{-193}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 3: 67.9% 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}}}\\ t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ t_2 := t\_0 + t\_1\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-224}:\\ \;\;\;\;t\_0 + 0.5 \cdot NaChar\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-153}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + t\_1\\ \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 (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))
            (t_2 (+ t_0 t_1)))
       (if (<= t_2 -5e-224)
         (+ t_0 (* 0.5 NaChar))
         (if (<= t_2 5e-153)
           (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor (+ Vef mu)) Ec) KbT))))
           (+ (* 0.5 NdChar) t_1)))))
    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 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)));
    	double t_2 = t_0 + t_1;
    	double tmp;
    	if (t_2 <= -5e-224) {
    		tmp = t_0 + (0.5 * NaChar);
    	} else if (t_2 <= 5e-153) {
    		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
    	} else {
    		tmp = (0.5 * NdChar) + t_1;
    	}
    	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) :: t_2
        real(8) :: tmp
        t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
        t_1 = nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt)))
        t_2 = t_0 + t_1
        if (t_2 <= (-5d-224)) then
            tmp = t_0 + (0.5d0 * nachar)
        else if (t_2 <= 5d-153) then
            tmp = ndchar / (1.0d0 + exp((((edonor + (vef + mu)) - ec) / kbt)))
        else
            tmp = (0.5d0 * ndchar) + t_1
        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 = NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)));
    	double t_2 = t_0 + t_1;
    	double tmp;
    	if (t_2 <= -5e-224) {
    		tmp = t_0 + (0.5 * NaChar);
    	} else if (t_2 <= 5e-153) {
    		tmp = NdChar / (1.0 + Math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
    	} else {
    		tmp = (0.5 * NdChar) + t_1;
    	}
    	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 = NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)))
    	t_2 = t_0 + t_1
    	tmp = 0
    	if t_2 <= -5e-224:
    		tmp = t_0 + (0.5 * NaChar)
    	elif t_2 <= 5e-153:
    		tmp = NdChar / (1.0 + math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)))
    	else:
    		tmp = (0.5 * NdChar) + t_1
    	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(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))
    	t_2 = Float64(t_0 + t_1)
    	tmp = 0.0
    	if (t_2 <= -5e-224)
    		tmp = Float64(t_0 + Float64(0.5 * NaChar));
    	elseif (t_2 <= 5e-153)
    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Float64(Vef + mu)) - Ec) / KbT))));
    	else
    		tmp = Float64(Float64(0.5 * NdChar) + t_1);
    	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 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)));
    	t_2 = t_0 + t_1;
    	tmp = 0.0;
    	if (t_2 <= -5e-224)
    		tmp = t_0 + (0.5 * NaChar);
    	elseif (t_2 <= 5e-153)
    		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
    	else
    		tmp = (0.5 * NdChar) + t_1;
    	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[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-224], N[(t$95$0 + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-153], N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + N[(Vef + mu), $MachinePrecision]), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $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 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    t_2 := t\_0 + t\_1\\
    \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-224}:\\
    \;\;\;\;t\_0 + 0.5 \cdot NaChar\\
    
    \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-153}:\\
    \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\
    
    \mathbf{else}:\\
    \;\;\;\;0.5 \cdot NdChar + t\_1\\
    
    
    \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))))) < -4.9999999999999999e-224

      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-*.f6471.5

          \[\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 rewrites71.5%

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

      if -4.9999999999999999e-224 < (+.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.00000000000000033e-153

      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-+.f6484.5

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

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

      if 5.00000000000000033e-153 < (+.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 NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
      4. Step-by-step derivation
        1. lower-*.f6473.5

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

        \[\leadsto \color{blue}{0.5 \cdot NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
    3. Recombined 3 regimes into one program.
    4. Final simplification75.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^{-224}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + 0.5 \cdot NaChar\\ \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^{-153}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 41.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 -5 \cdot 10^{-279} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-120}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{EDonor \cdot \left(NaChar + \frac{NaChar \cdot \left(\left(Vef + mu\right) - Ec\right)}{EDonor}\right)}{KbT}\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 (or (<= t_0 -5e-279) (not (<= t_0 2e-120)))
         (fma 0.5 NaChar (* 0.5 NdChar))
         (*
          NaChar
          (/
           NdChar
           (fma
            2.0
            NaChar
            (/
             (* EDonor (+ NaChar (/ (* NaChar (- (+ Vef mu) Ec)) EDonor)))
             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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if ((t_0 <= -5e-279) || !(t_0 <= 2e-120)) {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	} else {
    		tmp = NaChar * (NdChar / fma(2.0, NaChar, ((EDonor * (NaChar + ((NaChar * ((Vef + mu) - Ec)) / EDonor))) / KbT)));
    	}
    	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-279) || !(t_0 <= 2e-120))
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	else
    		tmp = Float64(NaChar * Float64(NdChar / fma(2.0, NaChar, Float64(Float64(EDonor * Float64(NaChar + Float64(Float64(NaChar * Float64(Float64(Vef + mu) - Ec)) / EDonor))) / KbT))));
    	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[Or[LessEqual[t$95$0, -5e-279], N[Not[LessEqual[t$95$0, 2e-120]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar * N[(NdChar / N[(2.0 * NaChar + N[(N[(EDonor * N[(NaChar + N[(N[(NaChar * N[(N[(Vef + mu), $MachinePrecision] - Ec), $MachinePrecision]), $MachinePrecision] / EDonor), $MachinePrecision]), $MachinePrecision]), $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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-279} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-120}\right):\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{EDonor \cdot \left(NaChar + \frac{NaChar \cdot \left(\left(Vef + mu\right) - Ec\right)}{EDonor}\right)}{KbT}\right)}\\
    
    
    \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.99999999999999969e-279 or 1.99999999999999996e-120 < (+.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-*.f6442.2

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

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

      if -4.99999999999999969e-279 < (+.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.99999999999999996e-120

      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 NaChar around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
        6. lower-+.f6452.4

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      11. Applied rewrites52.4%

        \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      12. Taylor expanded in EDonor around inf

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

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

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

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

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

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{EDonor \cdot \left(NaChar + \frac{NaChar \cdot \left(\left(Vef + mu\right) - Ec\right)}{EDonor}\right)}{KbT}\right)} \]
        6. lower-+.f6456.3

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{EDonor \cdot \left(NaChar + \frac{NaChar \cdot \left(\left(Vef + mu\right) - Ec\right)}{EDonor}\right)}{KbT}\right)} \]
      14. Applied rewrites56.3%

        \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{EDonor \cdot \left(NaChar + \frac{NaChar \cdot \left(\left(Vef + mu\right) - Ec\right)}{EDonor}\right)}{KbT}\right)} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification44.9%

      \[\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^{-279} \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 2 \cdot 10^{-120}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{EDonor \cdot \left(NaChar + \frac{NaChar \cdot \left(\left(Vef + mu\right) - Ec\right)}{EDonor}\right)}{KbT}\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 5: 40.3% 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^{-279} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-120}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\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 (or (<= t_0 -5e-279) (not (<= t_0 2e-120)))
         (fma 0.5 NaChar (* 0.5 NdChar))
         (*
          NaChar
          (/
           NdChar
           (fma 2.0 NaChar (/ (* NaChar (- (+ 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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if ((t_0 <= -5e-279) || !(t_0 <= 2e-120)) {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	} else {
    		tmp = NaChar * (NdChar / fma(2.0, NaChar, ((NaChar * ((EDonor + (Vef + mu)) - Ec)) / KbT)));
    	}
    	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-279) || !(t_0 <= 2e-120))
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	else
    		tmp = Float64(NaChar * Float64(NdChar / fma(2.0, NaChar, Float64(Float64(NaChar * Float64(Float64(EDonor + Float64(Vef + mu)) - Ec)) / KbT))));
    	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[Or[LessEqual[t$95$0, -5e-279], N[Not[LessEqual[t$95$0, 2e-120]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar * N[(NdChar / N[(2.0 * NaChar + N[(N[(NaChar * N[(N[(EDonor + N[(Vef + mu), $MachinePrecision]), $MachinePrecision] - Ec), $MachinePrecision]), $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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-279} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-120}\right):\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)}\\
    
    
    \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.99999999999999969e-279 or 1.99999999999999996e-120 < (+.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-*.f6442.2

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

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

      if -4.99999999999999969e-279 < (+.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.99999999999999996e-120

      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 NaChar around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
        6. lower-+.f6452.4

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      11. Applied rewrites52.4%

        \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification44.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^{-279} \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 2 \cdot 10^{-120}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 36.9% 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 -2 \cdot 10^{-189} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{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))))
              (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
       (if (or (<= t_0 -2e-189) (not (<= t_0 5e-153)))
         (fma 0.5 NaChar (* 0.5 NdChar))
         (/ NaChar (- (+ 2.0 (/ (+ EAccept (+ Ev Vef)) KbT)) (/ mu 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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if ((t_0 <= -2e-189) || !(t_0 <= 5e-153)) {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	} else {
    		tmp = NaChar / ((2.0 + ((EAccept + (Ev + Vef)) / KbT)) - (mu / KbT));
    	}
    	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 <= -2e-189) || !(t_0 <= 5e-153))
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	else
    		tmp = Float64(NaChar / Float64(Float64(2.0 + Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT)) - Float64(mu / KbT)));
    	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[Or[LessEqual[t$95$0, -2e-189], N[Not[LessEqual[t$95$0, 5e-153]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[(2.0 + N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision] - N[(mu / KbT), $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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-189} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{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))))) < -2.00000000000000014e-189 or 5.00000000000000033e-153 < (+.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-*.f6444.1

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

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

      if -2.00000000000000014e-189 < (+.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.00000000000000033e-153

      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-+.f6476.9

          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
      5. Applied rewrites76.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.2

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

        \[\leadsto \frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \color{blue}{\frac{mu}{KbT}}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification43.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 -2 \cdot 10^{-189} \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 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{\left(2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}\right) - \frac{mu}{KbT}}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 34.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 -4 \cdot 10^{-312} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{\left(-Ec\right) \cdot NaChar}{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))))
              (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
       (if (or (<= t_0 -4e-312) (not (<= t_0 5e-153)))
         (fma 0.5 NaChar (* 0.5 NdChar))
         (* NaChar (/ NdChar (/ (* (- Ec) NaChar) 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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if ((t_0 <= -4e-312) || !(t_0 <= 5e-153)) {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	} else {
    		tmp = NaChar * (NdChar / ((-Ec * NaChar) / KbT));
    	}
    	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 <= -4e-312) || !(t_0 <= 5e-153))
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	else
    		tmp = Float64(NaChar * Float64(NdChar / Float64(Float64(Float64(-Ec) * NaChar) / KbT)));
    	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[Or[LessEqual[t$95$0, -4e-312], N[Not[LessEqual[t$95$0, 5e-153]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar * N[(NdChar / N[(N[((-Ec) * NaChar), $MachinePrecision] / KbT), $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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-312} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{\left(-Ec\right) \cdot NaChar}{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))))) < -3.9999999999988e-312 or 5.00000000000000033e-153 < (+.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-*.f6441.3

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

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

      if -3.9999999999988e-312 < (+.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.00000000000000033e-153

      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 NaChar around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
        6. lower-+.f6455.6

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      11. Applied rewrites55.6%

        \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      12. Taylor expanded in Ec around inf

        \[\leadsto NaChar \cdot \frac{NdChar}{-1 \cdot \frac{Ec \cdot NaChar}{KbT}} \]
      13. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto NaChar \cdot \frac{NdChar}{-1 \cdot \frac{Ec \cdot NaChar}{KbT}} \]
        2. lower-/.f64N/A

          \[\leadsto NaChar \cdot \frac{NdChar}{-1 \cdot \frac{Ec \cdot NaChar}{KbT}} \]
        3. lower-*.f6437.8

          \[\leadsto NaChar \cdot \frac{NdChar}{-1 \cdot \frac{Ec \cdot NaChar}{KbT}} \]
      14. Applied rewrites37.8%

        \[\leadsto NaChar \cdot \frac{NdChar}{-1 \cdot \frac{Ec \cdot NaChar}{KbT}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification40.7%

      \[\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 -4 \cdot 10^{-312} \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 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{\left(-Ec\right) \cdot NaChar}{KbT}}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 35.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 -4 \cdot 10^{-312} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{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))))
              (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
       (if (or (<= t_0 -4e-312) (not (<= t_0 5e-153)))
         (fma 0.5 NaChar (* 0.5 NdChar))
         (* NaChar (/ NdChar (/ (* NaChar Vef) 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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if ((t_0 <= -4e-312) || !(t_0 <= 5e-153)) {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	} else {
    		tmp = NaChar * (NdChar / ((NaChar * Vef) / KbT));
    	}
    	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 <= -4e-312) || !(t_0 <= 5e-153))
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	else
    		tmp = Float64(NaChar * Float64(NdChar / Float64(Float64(NaChar * Vef) / KbT)));
    	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[Or[LessEqual[t$95$0, -4e-312], N[Not[LessEqual[t$95$0, 5e-153]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar * N[(NdChar / N[(N[(NaChar * Vef), $MachinePrecision] / KbT), $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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-312} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{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))))) < -3.9999999999988e-312 or 5.00000000000000033e-153 < (+.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-*.f6441.3

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

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

      if -3.9999999999988e-312 < (+.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.00000000000000033e-153

      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 NaChar around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
        6. lower-+.f6455.6

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      11. Applied rewrites55.6%

        \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      12. Taylor expanded in Vef around inf

        \[\leadsto NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{KbT}} \]
      13. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{KbT}} \]
        2. lower-*.f6431.6

          \[\leadsto NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{KbT}} \]
      14. Applied rewrites31.6%

        \[\leadsto NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{KbT}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification39.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 -4 \cdot 10^{-312} \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 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{NaChar \cdot Vef}{KbT}}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 9: 33.6% 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^{-279} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{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))))
              (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
       (if (or (<= t_0 -5e-279) (not (<= t_0 5e-153)))
         (fma 0.5 NaChar (* 0.5 NdChar))
         (* NaChar (/ NdChar (/ (* EDonor NaChar) 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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
    	double tmp;
    	if ((t_0 <= -5e-279) || !(t_0 <= 5e-153)) {
    		tmp = fma(0.5, NaChar, (0.5 * NdChar));
    	} else {
    		tmp = NaChar * (NdChar / ((EDonor * NaChar) / KbT));
    	}
    	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-279) || !(t_0 <= 5e-153))
    		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
    	else
    		tmp = Float64(NaChar * Float64(NdChar / Float64(Float64(EDonor * NaChar) / KbT)));
    	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[Or[LessEqual[t$95$0, -5e-279], N[Not[LessEqual[t$95$0, 5e-153]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar * N[(NdChar / N[(N[(EDonor * NaChar), $MachinePrecision] / KbT), $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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
    \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-279} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-153}\right):\\
    \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{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.99999999999999969e-279 or 5.00000000000000033e-153 < (+.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-*.f6441.5

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

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

      if -4.99999999999999969e-279 < (+.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.00000000000000033e-153

      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 NaChar around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
        6. lower-+.f6454.6

          \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      11. Applied rewrites54.6%

        \[\leadsto NaChar \cdot \frac{NdChar}{\mathsf{fma}\left(2, NaChar, \frac{NaChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)} \]
      12. Taylor expanded in EDonor around inf

        \[\leadsto NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{KbT}} \]
      13. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{KbT}} \]
        2. lower-*.f6431.0

          \[\leadsto NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{KbT}} \]
      14. Applied rewrites31.0%

        \[\leadsto NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{KbT}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification39.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 -5 \cdot 10^{-279} \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 5 \cdot 10^{-153}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;NaChar \cdot \frac{NdChar}{\frac{EDonor \cdot NaChar}{KbT}}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 10: 42.0% accurate, 1.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{if}\;KbT \leq -2.45 \cdot 10^{+160}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;KbT \leq -2.1 \cdot 10^{+87}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;KbT \leq -4.6 \cdot 10^{-223}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{elif}\;KbT \leq 1.55 \cdot 10^{-155}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}}\\ \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
     :precision binary64
     (let* ((t_0 (fma 0.5 NaChar (* 0.5 NdChar))))
       (if (<= KbT -2.45e+160)
         t_0
         (if (<= KbT -2.1e+87)
           (/ NdChar (+ 1.0 (exp (/ Vef KbT))))
           (if (<= KbT -4.6e-223)
             (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))
             (if (<= KbT 1.55e-155)
               (/ NdChar (+ 1.0 (exp (/ mu KbT))))
               (if (<= KbT 6.6e+123) (/ NaChar (+ 1.0 (exp (/ Ev KbT)))) 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 = fma(0.5, NaChar, (0.5 * NdChar));
    	double tmp;
    	if (KbT <= -2.45e+160) {
    		tmp = t_0;
    	} else if (KbT <= -2.1e+87) {
    		tmp = NdChar / (1.0 + exp((Vef / KbT)));
    	} else if (KbT <= -4.6e-223) {
    		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
    	} else if (KbT <= 1.55e-155) {
    		tmp = NdChar / (1.0 + exp((mu / KbT)));
    	} else if (KbT <= 6.6e+123) {
    		tmp = NaChar / (1.0 + exp((Ev / KbT)));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
    	t_0 = fma(0.5, NaChar, Float64(0.5 * NdChar))
    	tmp = 0.0
    	if (KbT <= -2.45e+160)
    		tmp = t_0;
    	elseif (KbT <= -2.1e+87)
    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT))));
    	elseif (KbT <= -4.6e-223)
    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
    	elseif (KbT <= 1.55e-155)
    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT))));
    	elseif (KbT <= 6.6e+123)
    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[KbT, -2.45e+160], t$95$0, If[LessEqual[KbT, -2.1e+87], N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, -4.6e-223], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 1.55e-155], N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 6.6e+123], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
    \mathbf{if}\;KbT \leq -2.45 \cdot 10^{+160}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;KbT \leq -2.1 \cdot 10^{+87}:\\
    \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\
    
    \mathbf{elif}\;KbT \leq -4.6 \cdot 10^{-223}:\\
    \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
    
    \mathbf{elif}\;KbT \leq 1.55 \cdot 10^{-155}:\\
    \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}}\\
    
    \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\
    \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 5 regimes
    2. if KbT < -2.4500000000000001e160 or 6.60000000000000006e123 < KbT

      1. Initial program 99.9%

        \[\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-*.f6471.7

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

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

      if -2.4500000000000001e160 < KbT < -2.1e87

      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-+.f6458.3

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

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

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

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

        if -2.1e87 < KbT < -4.5999999999999999e-223

        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-+.f6468.4

            \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
        5. Applied rewrites68.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 rewrites39.8%

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

          if -4.5999999999999999e-223 < KbT < 1.55e-155

          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-+.f6478.8

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

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

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

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

            if 1.55e-155 < KbT < 6.60000000000000006e123

            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.0

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

              \[\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 rewrites43.9%

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

            Alternative 11: 42.0% accurate, 1.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{if}\;KbT \leq -2.45 \cdot 10^{+160}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;KbT \leq -2.1 \cdot 10^{+87}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\ \mathbf{elif}\;KbT \leq -5.6 \cdot 10^{-221}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{elif}\;KbT \leq 1.35 \cdot 10^{-156}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
             :precision binary64
             (let* ((t_0 (fma 0.5 NaChar (* 0.5 NdChar))))
               (if (<= KbT -2.45e+160)
                 t_0
                 (if (<= KbT -2.1e+87)
                   (/ NdChar (+ 1.0 (exp (/ Vef KbT))))
                   (if (<= KbT -5.6e-221)
                     (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))
                     (if (<= KbT 1.35e-156)
                       (/ NdChar (+ 1.0 (exp (/ EDonor KbT))))
                       (if (<= KbT 6.6e+123) (/ NaChar (+ 1.0 (exp (/ Ev KbT)))) 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 = fma(0.5, NaChar, (0.5 * NdChar));
            	double tmp;
            	if (KbT <= -2.45e+160) {
            		tmp = t_0;
            	} else if (KbT <= -2.1e+87) {
            		tmp = NdChar / (1.0 + exp((Vef / KbT)));
            	} else if (KbT <= -5.6e-221) {
            		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
            	} else if (KbT <= 1.35e-156) {
            		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
            	} else if (KbT <= 6.6e+123) {
            		tmp = NaChar / (1.0 + exp((Ev / KbT)));
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
            	t_0 = fma(0.5, NaChar, Float64(0.5 * NdChar))
            	tmp = 0.0
            	if (KbT <= -2.45e+160)
            		tmp = t_0;
            	elseif (KbT <= -2.1e+87)
            		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT))));
            	elseif (KbT <= -5.6e-221)
            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
            	elseif (KbT <= 1.35e-156)
            		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT))));
            	elseif (KbT <= 6.6e+123)
            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[KbT, -2.45e+160], t$95$0, If[LessEqual[KbT, -2.1e+87], N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, -5.6e-221], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 1.35e-156], N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 6.6e+123], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
            \mathbf{if}\;KbT \leq -2.45 \cdot 10^{+160}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;KbT \leq -2.1 \cdot 10^{+87}:\\
            \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\
            
            \mathbf{elif}\;KbT \leq -5.6 \cdot 10^{-221}:\\
            \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
            
            \mathbf{elif}\;KbT \leq 1.35 \cdot 10^{-156}:\\
            \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\
            
            \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\
            \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 5 regimes
            2. if KbT < -2.4500000000000001e160 or 6.60000000000000006e123 < KbT

              1. Initial program 99.9%

                \[\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-*.f6471.7

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

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

              if -2.4500000000000001e160 < KbT < -2.1e87

              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-+.f6458.3

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

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

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

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

                if -2.1e87 < KbT < -5.60000000000000039e-221

                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-+.f6469.6

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

                  \[\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 rewrites40.5%

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

                  if -5.60000000000000039e-221 < KbT < 1.35000000000000006e-156

                  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-+.f6479.2

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

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

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

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

                    if 1.35000000000000006e-156 < KbT < 6.60000000000000006e123

                    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.0

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

                      \[\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 rewrites43.9%

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

                    Alternative 12: 65.7% accurate, 1.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NaChar \leq -9.8 \cdot 10^{-136}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \mathbf{elif}\;NaChar \leq 5.9 \cdot 10^{-55}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \end{array} \end{array} \]
                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                     :precision binary64
                     (if (<= NaChar -9.8e-136)
                       (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))
                       (if (<= NaChar 5.9e-55)
                         (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor (+ Vef mu)) Ec) KbT))))
                         (+
                          (* 0.5 NdChar)
                          (/ 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) {
                    	double tmp;
                    	if (NaChar <= -9.8e-136) {
                    		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                    	} else if (NaChar <= 5.9e-55) {
                    		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
                    	} else {
                    		tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - 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 (nachar <= (-9.8d-136)) then
                            tmp = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
                        else if (nachar <= 5.9d-55) then
                            tmp = ndchar / (1.0d0 + exp((((edonor + (vef + mu)) - ec) / kbt)))
                        else
                            tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - 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 (NaChar <= -9.8e-136) {
                    		tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                    	} else if (NaChar <= 5.9e-55) {
                    		tmp = NdChar / (1.0 + Math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
                    	} else {
                    		tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                    	}
                    	return tmp;
                    }
                    
                    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                    	tmp = 0
                    	if NaChar <= -9.8e-136:
                    		tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)))
                    	elif NaChar <= 5.9e-55:
                    		tmp = NdChar / (1.0 + math.exp((((EDonor + (Vef + mu)) - Ec) / KbT)))
                    	else:
                    		tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
                    	return tmp
                    
                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                    	tmp = 0.0
                    	if (NaChar <= -9.8e-136)
                    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT))));
                    	elseif (NaChar <= 5.9e-55)
                    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Float64(Vef + mu)) - Ec) / KbT))));
                    	else
                    		tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))));
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                    	tmp = 0.0;
                    	if (NaChar <= -9.8e-136)
                    		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
                    	elseif (NaChar <= 5.9e-55)
                    		tmp = NdChar / (1.0 + exp((((EDonor + (Vef + mu)) - Ec) / KbT)));
                    	else
                    		tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[NaChar, -9.8e-136], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[NaChar, 5.9e-55], N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + N[(Vef + mu), $MachinePrecision]), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $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}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;NaChar \leq -9.8 \cdot 10^{-136}:\\
                    \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
                    
                    \mathbf{elif}\;NaChar \leq 5.9 \cdot 10^{-55}:\\
                    \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if NaChar < -9.7999999999999999e-136

                      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.1

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

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

                      if -9.7999999999999999e-136 < NaChar < 5.8999999999999998e-55

                      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-+.f6476.8

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

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

                      if 5.8999999999999998e-55 < NaChar

                      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 NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                      4. Step-by-step derivation
                        1. lower-*.f6474.6

                          \[\leadsto 0.5 \cdot \color{blue}{NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                      5. Applied rewrites74.6%

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

                      \[\leadsto \begin{array}{l} \mathbf{if}\;NaChar \leq -9.8 \cdot 10^{-136}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \mathbf{elif}\;NaChar \leq 5.9 \cdot 10^{-55}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \end{array} \]
                    5. Add Preprocessing

                    Alternative 13: 41.9% accurate, 1.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{if}\;KbT \leq -3 \cdot 10^{+138}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;KbT \leq -5.6 \cdot 10^{-221}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{elif}\;KbT \leq 1.35 \cdot 10^{-156}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                     :precision binary64
                     (let* ((t_0 (fma 0.5 NaChar (* 0.5 NdChar))))
                       (if (<= KbT -3e+138)
                         t_0
                         (if (<= KbT -5.6e-221)
                           (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))
                           (if (<= KbT 1.35e-156)
                             (/ NdChar (+ 1.0 (exp (/ EDonor KbT))))
                             (if (<= KbT 6.6e+123) (/ NaChar (+ 1.0 (exp (/ Ev KbT)))) 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 = fma(0.5, NaChar, (0.5 * NdChar));
                    	double tmp;
                    	if (KbT <= -3e+138) {
                    		tmp = t_0;
                    	} else if (KbT <= -5.6e-221) {
                    		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                    	} else if (KbT <= 1.35e-156) {
                    		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                    	} else if (KbT <= 6.6e+123) {
                    		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                    	t_0 = fma(0.5, NaChar, Float64(0.5 * NdChar))
                    	tmp = 0.0
                    	if (KbT <= -3e+138)
                    		tmp = t_0;
                    	elseif (KbT <= -5.6e-221)
                    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                    	elseif (KbT <= 1.35e-156)
                    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT))));
                    	elseif (KbT <= 6.6e+123)
                    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
                    	else
                    		tmp = t_0;
                    	end
                    	return tmp
                    end
                    
                    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[KbT, -3e+138], t$95$0, If[LessEqual[KbT, -5.6e-221], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 1.35e-156], N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 6.6e+123], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
                    \mathbf{if}\;KbT \leq -3 \cdot 10^{+138}:\\
                    \;\;\;\;t\_0\\
                    
                    \mathbf{elif}\;KbT \leq -5.6 \cdot 10^{-221}:\\
                    \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                    
                    \mathbf{elif}\;KbT \leq 1.35 \cdot 10^{-156}:\\
                    \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\
                    
                    \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\
                    \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_0\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 4 regimes
                    2. if KbT < -3.0000000000000001e138 or 6.60000000000000006e123 < KbT

                      1. Initial program 99.9%

                        \[\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-*.f6468.9

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

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

                      if -3.0000000000000001e138 < KbT < -5.60000000000000039e-221

                      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-+.f6469.4

                          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}} \]
                      5. Applied rewrites69.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 rewrites36.8%

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

                        if -5.60000000000000039e-221 < KbT < 1.35000000000000006e-156

                        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-+.f6479.2

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

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

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

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

                          if 1.35000000000000006e-156 < KbT < 6.60000000000000006e123

                          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.0

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

                            \[\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 rewrites43.9%

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

                          Alternative 14: 69.5% accurate, 1.9× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NaChar \leq -9.8 \cdot 10^{-136} \lor \neg \left(NaChar \leq 8 \cdot 10^{-73}\right):\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{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
                           (if (or (<= NaChar -9.8e-136) (not (<= NaChar 8e-73)))
                             (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) 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 tmp;
                          	if ((NaChar <= -9.8e-136) || !(NaChar <= 8e-73)) {
                          		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / 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) :: tmp
                              if ((nachar <= (-9.8d-136)) .or. (.not. (nachar <= 8d-73))) then
                                  tmp = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / 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 tmp;
                          	if ((NaChar <= -9.8e-136) || !(NaChar <= 8e-73)) {
                          		tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / 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):
                          	tmp = 0
                          	if (NaChar <= -9.8e-136) or not (NaChar <= 8e-73):
                          		tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / 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)
                          	tmp = 0.0
                          	if ((NaChar <= -9.8e-136) || !(NaChar <= 8e-73))
                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / 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)
                          	tmp = 0.0;
                          	if ((NaChar <= -9.8e-136) || ~((NaChar <= 8e-73)))
                          		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / 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_] := If[Or[LessEqual[NaChar, -9.8e-136], N[Not[LessEqual[NaChar, 8e-73]], $MachinePrecision]], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $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}
                          \mathbf{if}\;NaChar \leq -9.8 \cdot 10^{-136} \lor \neg \left(NaChar \leq 8 \cdot 10^{-73}\right):\\
                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{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 NaChar < -9.7999999999999999e-136 or 7.99999999999999998e-73 < NaChar

                            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-+.f6471.3

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

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

                            if -9.7999999999999999e-136 < NaChar < 7.99999999999999998e-73

                            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-+.f6478.7

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

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

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

                          Alternative 15: 62.9% accurate, 1.9× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -1620000000000 \lor \neg \left(NdChar \leq 6 \cdot 10^{+182}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - 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 -1620000000000.0) (not (<= NdChar 6e+182)))
                             (/ NdChar (+ 1.0 (exp (/ (- 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 <= -1620000000000.0) || !(NdChar <= 6e+182)) {
                          		tmp = NdChar / (1.0 + exp(((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 <= (-1620000000000.0d0)) .or. (.not. (ndchar <= 6d+182))) then
                                  tmp = ndchar / (1.0d0 + exp(((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 <= -1620000000000.0) || !(NdChar <= 6e+182)) {
                          		tmp = NdChar / (1.0 + Math.exp(((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 <= -1620000000000.0) or not (NdChar <= 6e+182):
                          		tmp = NdChar / (1.0 + math.exp(((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 <= -1620000000000.0) || !(NdChar <= 6e+182))
                          		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(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 <= -1620000000000.0) || ~((NdChar <= 6e+182)))
                          		tmp = NdChar / (1.0 + exp(((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, -1620000000000.0], N[Not[LessEqual[NdChar, 6e+182]], $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[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;NdChar \leq -1620000000000 \lor \neg \left(NdChar \leq 6 \cdot 10^{+182}\right):\\
                          \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - 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 < -1.62e12 or 6.0000000000000004e182 < 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-+.f6476.6

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

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

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

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

                              if -1.62e12 < NdChar < 6.0000000000000004e182

                              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-+.f6471.2

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

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

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

                            Alternative 16: 41.7% accurate, 1.9× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{if}\;KbT \leq -3 \cdot 10^{+138}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;KbT \leq 2.6 \cdot 10^{-299}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                             :precision binary64
                             (let* ((t_0 (fma 0.5 NaChar (* 0.5 NdChar))))
                               (if (<= KbT -3e+138)
                                 t_0
                                 (if (<= KbT 2.6e-299)
                                   (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))
                                   (if (<= KbT 6.6e+123) (/ NaChar (+ 1.0 (exp (/ Ev KbT)))) 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 = fma(0.5, NaChar, (0.5 * NdChar));
                            	double tmp;
                            	if (KbT <= -3e+138) {
                            		tmp = t_0;
                            	} else if (KbT <= 2.6e-299) {
                            		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                            	} else if (KbT <= 6.6e+123) {
                            		tmp = NaChar / (1.0 + exp((Ev / KbT)));
                            	} else {
                            		tmp = t_0;
                            	}
                            	return tmp;
                            }
                            
                            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                            	t_0 = fma(0.5, NaChar, Float64(0.5 * NdChar))
                            	tmp = 0.0
                            	if (KbT <= -3e+138)
                            		tmp = t_0;
                            	elseif (KbT <= 2.6e-299)
                            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                            	elseif (KbT <= 6.6e+123)
                            		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))));
                            	else
                            		tmp = t_0;
                            	end
                            	return tmp
                            end
                            
                            code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[KbT, -3e+138], t$95$0, If[LessEqual[KbT, 2.6e-299], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 6.6e+123], N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
                            \mathbf{if}\;KbT \leq -3 \cdot 10^{+138}:\\
                            \;\;\;\;t\_0\\
                            
                            \mathbf{elif}\;KbT \leq 2.6 \cdot 10^{-299}:\\
                            \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                            
                            \mathbf{elif}\;KbT \leq 6.6 \cdot 10^{+123}:\\
                            \;\;\;\;\frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;t\_0\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if KbT < -3.0000000000000001e138 or 6.60000000000000006e123 < KbT

                              1. Initial program 99.9%

                                \[\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-*.f6468.9

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

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

                              if -3.0000000000000001e138 < KbT < 2.5999999999999999e-299

                              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.5

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

                                \[\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 rewrites36.8%

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

                                if 2.5999999999999999e-299 < KbT < 6.60000000000000006e123

                                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-+.f6457.3

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

                                  \[\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 rewrites38.8%

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

                                Alternative 17: 53.0% accurate, 2.0× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -3.1 \cdot 10^{-13} \lor \neg \left(NdChar \leq 3.1 \cdot 10^{+182}\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.1e-13) (not (<= NdChar 3.1e+182)))
                                   (/ 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.1e-13) || !(NdChar <= 3.1e+182)) {
                                		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.1d-13)) .or. (.not. (ndchar <= 3.1d+182))) 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.1e-13) || !(NdChar <= 3.1e+182)) {
                                		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.1e-13) or not (NdChar <= 3.1e+182):
                                		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.1e-13) || !(NdChar <= 3.1e+182))
                                		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.1e-13) || ~((NdChar <= 3.1e+182)))
                                		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.1e-13], N[Not[LessEqual[NdChar, 3.1e+182]], $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.1 \cdot 10^{-13} \lor \neg \left(NdChar \leq 3.1 \cdot 10^{+182}\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.0999999999999999e-13 or 3.09999999999999996e182 < 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-+.f6476.1

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

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

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

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

                                    if -3.0999999999999999e-13 < NdChar < 3.09999999999999996e182

                                    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-+.f6471.5

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

                                      \[\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 rewrites60.8%

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

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -3.1 \cdot 10^{-13} \lor \neg \left(NdChar \leq 3.1 \cdot 10^{+182}\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 18: 50.0% accurate, 2.0× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -2.4 \cdot 10^{+17}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\ \mathbf{elif}\;NdChar \leq 4.5 \cdot 10^{+182}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\ \end{array} \end{array} \]
                                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                     :precision binary64
                                     (if (<= NdChar -2.4e+17)
                                       (/ NdChar (+ 1.0 (exp (/ EDonor KbT))))
                                       (if (<= NdChar 4.5e+182)
                                         (/ NaChar (+ 1.0 (exp (/ (- Vef mu) KbT))))
                                         (/ NdChar (+ 1.0 (exp (/ Vef 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.4e+17) {
                                    		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                                    	} else if (NdChar <= 4.5e+182) {
                                    		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                    	} else {
                                    		tmp = NdChar / (1.0 + exp((Vef / 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.4d+17)) then
                                            tmp = ndchar / (1.0d0 + exp((edonor / kbt)))
                                        else if (ndchar <= 4.5d+182) then
                                            tmp = nachar / (1.0d0 + exp(((vef - mu) / kbt)))
                                        else
                                            tmp = ndchar / (1.0d0 + exp((vef / 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.4e+17) {
                                    		tmp = NdChar / (1.0 + Math.exp((EDonor / KbT)));
                                    	} else if (NdChar <= 4.5e+182) {
                                    		tmp = NaChar / (1.0 + Math.exp(((Vef - mu) / KbT)));
                                    	} else {
                                    		tmp = NdChar / (1.0 + Math.exp((Vef / KbT)));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                    	tmp = 0
                                    	if NdChar <= -2.4e+17:
                                    		tmp = NdChar / (1.0 + math.exp((EDonor / KbT)))
                                    	elif NdChar <= 4.5e+182:
                                    		tmp = NaChar / (1.0 + math.exp(((Vef - mu) / KbT)))
                                    	else:
                                    		tmp = NdChar / (1.0 + math.exp((Vef / KbT)))
                                    	return tmp
                                    
                                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                    	tmp = 0.0
                                    	if (NdChar <= -2.4e+17)
                                    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT))));
                                    	elseif (NdChar <= 4.5e+182)
                                    		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Vef - mu) / KbT))));
                                    	else
                                    		tmp = Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT))));
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                    	tmp = 0.0;
                                    	if (NdChar <= -2.4e+17)
                                    		tmp = NdChar / (1.0 + exp((EDonor / KbT)));
                                    	elseif (NdChar <= 4.5e+182)
                                    		tmp = NaChar / (1.0 + exp(((Vef - mu) / KbT)));
                                    	else
                                    		tmp = NdChar / (1.0 + exp((Vef / KbT)));
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[NdChar, -2.4e+17], N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[NdChar, 4.5e+182], N[(NaChar / N[(1.0 + N[Exp[N[(N[(Vef - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;NdChar \leq -2.4 \cdot 10^{+17}:\\
                                    \;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}}\\
                                    
                                    \mathbf{elif}\;NdChar \leq 4.5 \cdot 10^{+182}:\\
                                    \;\;\;\;\frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}}\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 3 regimes
                                    2. if NdChar < -2.4e17

                                      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-+.f6472.0

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

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

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

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

                                        if -2.4e17 < NdChar < 4.50000000000000029e182

                                        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.8

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

                                          \[\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 rewrites60.5%

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

                                          if 4.50000000000000029e182 < 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-+.f64100.0

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

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

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

                                              \[\leadsto \frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} \]
                                          8. Recombined 3 regimes into one program.
                                          9. Add Preprocessing

                                          Alternative 19: 41.6% accurate, 2.0× speedup?

                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;KbT \leq -3 \cdot 10^{+138} \lor \neg \left(KbT \leq 4.8 \cdot 10^{+87}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \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 (<= KbT -3e+138) (not (<= KbT 4.8e+87)))
                                             (fma 0.5 NaChar (* 0.5 NdChar))
                                             (/ 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 ((KbT <= -3e+138) || !(KbT <= 4.8e+87)) {
                                          		tmp = fma(0.5, NaChar, (0.5 * NdChar));
                                          	} else {
                                          		tmp = NaChar / (1.0 + exp((EAccept / KbT)));
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                          	tmp = 0.0
                                          	if ((KbT <= -3e+138) || !(KbT <= 4.8e+87))
                                          		tmp = fma(0.5, NaChar, Float64(0.5 * NdChar));
                                          	else
                                          		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))));
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[KbT, -3e+138], N[Not[LessEqual[KbT, 4.8e+87]], $MachinePrecision]], N[(0.5 * NaChar + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                          
                                          \begin{array}{l}
                                          
                                          \\
                                          \begin{array}{l}
                                          \mathbf{if}\;KbT \leq -3 \cdot 10^{+138} \lor \neg \left(KbT \leq 4.8 \cdot 10^{+87}\right):\\
                                          \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
                                          
                                          
                                          \end{array}
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if KbT < -3.0000000000000001e138 or 4.79999999999999963e87 < KbT

                                            1. Initial program 99.9%

                                              \[\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-*.f6466.2

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

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

                                            if -3.0000000000000001e138 < KbT < 4.79999999999999963e87

                                            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 rewrites35.1%

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

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;KbT \leq -3 \cdot 10^{+138} \lor \neg \left(KbT \leq 4.8 \cdot 10^{+87}\right):\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \]
                                            10. Add Preprocessing

                                            Alternative 20: 22.5% accurate, 15.3× speedup?

                                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NdChar \leq -2.2 \cdot 10^{+17} \lor \neg \left(NdChar \leq 5.8 \cdot 10^{+184}\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 -2.2e+17) (not (<= NdChar 5.8e+184)))
                                               (* 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 <= -2.2e+17) || !(NdChar <= 5.8e+184)) {
                                            		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 <= (-2.2d+17)) .or. (.not. (ndchar <= 5.8d+184))) 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 <= -2.2e+17) || !(NdChar <= 5.8e+184)) {
                                            		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 <= -2.2e+17) or not (NdChar <= 5.8e+184):
                                            		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 <= -2.2e+17) || !(NdChar <= 5.8e+184))
                                            		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 <= -2.2e+17) || ~((NdChar <= 5.8e+184)))
                                            		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, -2.2e+17], N[Not[LessEqual[NdChar, 5.8e+184]], $MachinePrecision]], N[(0.5 * NdChar), $MachinePrecision], N[(0.5 * NaChar), $MachinePrecision]]
                                            
                                            \begin{array}{l}
                                            
                                            \\
                                            \begin{array}{l}
                                            \mathbf{if}\;NdChar \leq -2.2 \cdot 10^{+17} \lor \neg \left(NdChar \leq 5.8 \cdot 10^{+184}\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 < -2.2e17 or 5.7999999999999998e184 < 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-*.f6435.8

                                                  \[\leadsto \mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right) \]
                                              5. Applied rewrites35.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-*.f6432.7

                                                  \[\leadsto 0.5 \cdot NdChar \]
                                              8. Applied rewrites32.7%

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

                                              if -2.2e17 < NdChar < 5.7999999999999998e184

                                              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-+.f6471.0

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

                                                \[\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.7

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

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

                                              \[\leadsto \begin{array}{l} \mathbf{if}\;NdChar \leq -2.2 \cdot 10^{+17} \lor \neg \left(NdChar \leq 5.8 \cdot 10^{+184}\right):\\ \;\;\;\;0.5 \cdot NdChar\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NaChar\\ \end{array} \]
                                            5. Add Preprocessing

                                            Alternative 21: 27.6% 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-*.f6434.5

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

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

                                            Alternative 22: 18.1% 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-*.f6434.5

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

                                              \[\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-*.f6420.4

                                                \[\leadsto 0.5 \cdot NdChar \]
                                            8. Applied rewrites20.4%

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

                                            Reproduce

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