Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 13.2s
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 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. Final simplification99.9%

    \[\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: 81.7% 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 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_2 := \frac{NaChar}{1 + t\_1}\\ t_3 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_2\\ t_4 := t\_0 + t\_2\\ \mathbf{if}\;t\_4 \leq -1 \cdot 10^{-300}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_4 \leq 0:\\ \;\;\;\;\frac{NaChar}{t\_1 + 1}\\ \mathbf{elif}\;t\_4 \leq 10^{-41}:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
        (t_1 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
        (t_2 (/ NaChar (+ 1.0 t_1)))
        (t_3 (+ (/ NdChar (+ 1.0 (exp (/ mu KbT)))) t_2))
        (t_4 (+ t_0 t_2)))
   (if (<= t_4 -1e-300)
     t_3
     (if (<= t_4 0.0)
       (/ NaChar (+ t_1 1.0))
       (if (<= t_4 1e-41)
         t_3
         (+ t_0 (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_2 = NaChar / (1.0 + t_1);
	double t_3 = (NdChar / (1.0 + exp((mu / KbT)))) + t_2;
	double t_4 = t_0 + t_2;
	double tmp;
	if (t_4 <= -1e-300) {
		tmp = t_3;
	} else if (t_4 <= 0.0) {
		tmp = NaChar / (t_1 + 1.0);
	} else if (t_4 <= 1e-41) {
		tmp = t_3;
	} else {
		tmp = t_0 + (NaChar / (1.0 + exp((EAccept / KbT))));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
    t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
    t_2 = nachar / (1.0d0 + t_1)
    t_3 = (ndchar / (1.0d0 + exp((mu / kbt)))) + t_2
    t_4 = t_0 + t_2
    if (t_4 <= (-1d-300)) then
        tmp = t_3
    else if (t_4 <= 0.0d0) then
        tmp = nachar / (t_1 + 1.0d0)
    else if (t_4 <= 1d-41) then
        tmp = t_3
    else
        tmp = t_0 + (nachar / (1.0d0 + exp((eaccept / kbt))))
    end if
    code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_2 = NaChar / (1.0 + t_1);
	double t_3 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + t_2;
	double t_4 = t_0 + t_2;
	double tmp;
	if (t_4 <= -1e-300) {
		tmp = t_3;
	} else if (t_4 <= 0.0) {
		tmp = NaChar / (t_1 + 1.0);
	} else if (t_4 <= 1e-41) {
		tmp = t_3;
	} else {
		tmp = t_0 + (NaChar / (1.0 + Math.exp((EAccept / 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 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
	t_2 = NaChar / (1.0 + t_1)
	t_3 = (NdChar / (1.0 + math.exp((mu / KbT)))) + t_2
	t_4 = t_0 + t_2
	tmp = 0
	if t_4 <= -1e-300:
		tmp = t_3
	elif t_4 <= 0.0:
		tmp = NaChar / (t_1 + 1.0)
	elif t_4 <= 1e-41:
		tmp = t_3
	else:
		tmp = t_0 + (NaChar / (1.0 + math.exp((EAccept / 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 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
	t_2 = Float64(NaChar / Float64(1.0 + t_1))
	t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + t_2)
	t_4 = Float64(t_0 + t_2)
	tmp = 0.0
	if (t_4 <= -1e-300)
		tmp = t_3;
	elseif (t_4 <= 0.0)
		tmp = Float64(NaChar / Float64(t_1 + 1.0));
	elseif (t_4 <= 1e-41)
		tmp = t_3;
	else
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT)))));
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	t_2 = NaChar / (1.0 + t_1);
	t_3 = (NdChar / (1.0 + exp((mu / KbT)))) + t_2;
	t_4 = t_0 + t_2;
	tmp = 0.0;
	if (t_4 <= -1e-300)
		tmp = t_3;
	elseif (t_4 <= 0.0)
		tmp = NaChar / (t_1 + 1.0);
	elseif (t_4 <= 1e-41)
		tmp = t_3;
	else
		tmp = t_0 + (NaChar / (1.0 + exp((EAccept / KbT))));
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, -1e-300], t$95$3, If[LessEqual[t$95$4, 0.0], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e-41], t$95$3, N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $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 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NaChar}{1 + t\_1}\\
t_3 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_2\\
t_4 := t\_0 + t\_2\\
\mathbf{if}\;t\_4 \leq -1 \cdot 10^{-300}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\

\mathbf{elif}\;t\_4 \leq 10^{-41}:\\
\;\;\;\;t\_3\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000003e-300 or 0.0 < (+.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.00000000000000001e-41

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

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

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

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

    if -1.00000000000000003e-300 < (+.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))))) < 0.0

    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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
      2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

    if 1.00000000000000001e-41 < (+.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^{\color{blue}{\frac{EAccept}{KbT}}}} \]
    4. Step-by-step derivation
      1. lower-/.f6484.6

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

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

Alternative 3: 66.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\ t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_2 := \frac{NaChar}{1 + t\_1}\\ t_3 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_2\\ \mathbf{if}\;t\_3 \leq -4 \cdot 10^{-24}:\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + \left(1 + \frac{Vef}{KbT}\right)}\\ \mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-24}:\\ \;\;\;\;\frac{NaChar}{t\_1 + 1}\\ \mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+47}:\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + \left(1 + \frac{Ev}{KbT}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + t\_2\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT)))))
        (t_1 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
        (t_2 (/ NaChar (+ 1.0 t_1)))
        (t_3
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
          t_2)))
   (if (<= t_3 -4e-24)
     (+ t_0 (/ NaChar (+ 1.0 (+ 1.0 (/ Vef KbT)))))
     (if (<= t_3 2e-24)
       (/ NaChar (+ t_1 1.0))
       (if (<= t_3 5e+47)
         (+ t_0 (/ NaChar (+ 1.0 (+ 1.0 (/ Ev KbT)))))
         (+ (* 0.5 NdChar) t_2))))))
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((((EDonor + Vef) - Ec) / KbT)));
	double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_2 = NaChar / (1.0 + t_1);
	double t_3 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_2;
	double tmp;
	if (t_3 <= -4e-24) {
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Vef / KbT))));
	} else if (t_3 <= 2e-24) {
		tmp = NaChar / (t_1 + 1.0);
	} else if (t_3 <= 5e+47) {
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Ev / KbT))));
	} else {
		tmp = (0.5 * NdChar) + t_2;
	}
	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) :: t_3
    real(8) :: tmp
    t_0 = ndchar / (1.0d0 + exp((((edonor + vef) - ec) / kbt)))
    t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
    t_2 = nachar / (1.0d0 + t_1)
    t_3 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_2
    if (t_3 <= (-4d-24)) then
        tmp = t_0 + (nachar / (1.0d0 + (1.0d0 + (vef / kbt))))
    else if (t_3 <= 2d-24) then
        tmp = nachar / (t_1 + 1.0d0)
    else if (t_3 <= 5d+47) then
        tmp = t_0 + (nachar / (1.0d0 + (1.0d0 + (ev / kbt))))
    else
        tmp = (0.5d0 * ndchar) + t_2
    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((((EDonor + Vef) - Ec) / KbT)));
	double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_2 = NaChar / (1.0 + t_1);
	double t_3 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_2;
	double tmp;
	if (t_3 <= -4e-24) {
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Vef / KbT))));
	} else if (t_3 <= 2e-24) {
		tmp = NaChar / (t_1 + 1.0);
	} else if (t_3 <= 5e+47) {
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Ev / KbT))));
	} else {
		tmp = (0.5 * NdChar) + t_2;
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT)))
	t_1 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
	t_2 = NaChar / (1.0 + t_1)
	t_3 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_2
	tmp = 0
	if t_3 <= -4e-24:
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Vef / KbT))))
	elif t_3 <= 2e-24:
		tmp = NaChar / (t_1 + 1.0)
	elif t_3 <= 5e+47:
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Ev / KbT))))
	else:
		tmp = (0.5 * NdChar) + t_2
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT))))
	t_1 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
	t_2 = Float64(NaChar / Float64(1.0 + t_1))
	t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_2)
	tmp = 0.0
	if (t_3 <= -4e-24)
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + Float64(1.0 + Float64(Vef / KbT)))));
	elseif (t_3 <= 2e-24)
		tmp = Float64(NaChar / Float64(t_1 + 1.0));
	elseif (t_3 <= 5e+47)
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + Float64(1.0 + Float64(Ev / KbT)))));
	else
		tmp = Float64(Float64(0.5 * NdChar) + t_2);
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)));
	t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	t_2 = NaChar / (1.0 + t_1);
	t_3 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_2;
	tmp = 0.0;
	if (t_3 <= -4e-24)
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Vef / KbT))));
	elseif (t_3 <= 2e-24)
		tmp = NaChar / (t_1 + 1.0);
	elseif (t_3 <= 5e+47)
		tmp = t_0 + (NaChar / (1.0 + (1.0 + (Ev / KbT))));
	else
		tmp = (0.5 * NdChar) + t_2;
	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[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -4e-24], N[(t$95$0 + N[(NaChar / N[(1.0 + N[(1.0 + N[(Vef / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e-24], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5e+47], N[(t$95$0 + N[(NaChar / N[(1.0 + N[(1.0 + N[(Ev / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$2), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-24}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\

\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{+47}:\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + \left(1 + \frac{Ev}{KbT}\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 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.99999999999999969e-24

    1. Initial program 99.8%

      \[\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}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
    4. Step-by-step derivation
      1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -3.99999999999999969e-24 < (+.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.99999999999999985e-24

      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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
        2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

      if 1.99999999999999985e-24 < (+.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.00000000000000022e47

      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}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
      4. Step-by-step derivation
        1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 5.00000000000000022e47 < (+.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-*.f6475.5

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

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

        \[\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^{-24}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + \left(1 + \frac{Vef}{KbT}\right)}\\ \mathbf{elif}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 2 \cdot 10^{-24}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \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^{+47}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + \left(1 + \frac{Ev}{KbT}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \end{array} \]
      13. Add Preprocessing

      Alternative 4: 66.2% accurate, 0.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_1 := \frac{NaChar}{1 + t\_0}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\ \mathbf{if}\;t\_2 \leq -2 \cdot 10^{-101}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + 1}\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-24}:\\ \;\;\;\;\frac{NaChar}{t\_0 + 1}\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+47}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + \left(1 + \frac{Ev}{KbT}\right)}\\ \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 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
              (t_1 (/ NaChar (+ 1.0 t_0)))
              (t_2
               (+
                (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                t_1)))
         (if (<= t_2 -2e-101)
           (+
            (/ NdChar (+ 1.0 (exp (/ (- (+ mu Vef) Ec) KbT))))
            (/ NaChar (+ 1.0 1.0)))
           (if (<= t_2 2e-24)
             (/ NaChar (+ t_0 1.0))
             (if (<= t_2 5e+47)
               (+
                (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT))))
                (/ NaChar (+ 1.0 (+ 1.0 (/ Ev 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 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
      	double t_1 = NaChar / (1.0 + t_0);
      	double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
      	double tmp;
      	if (t_2 <= -2e-101) {
      		tmp = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + 1.0));
      	} else if (t_2 <= 2e-24) {
      		tmp = NaChar / (t_0 + 1.0);
      	} else if (t_2 <= 5e+47) {
      		tmp = (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + (1.0 + (Ev / 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 = exp(((((ev + vef) + eaccept) - mu) / kbt))
          t_1 = nachar / (1.0d0 + t_0)
          t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
          if (t_2 <= (-2d-101)) then
              tmp = (ndchar / (1.0d0 + exp((((mu + vef) - ec) / kbt)))) + (nachar / (1.0d0 + 1.0d0))
          else if (t_2 <= 2d-24) then
              tmp = nachar / (t_0 + 1.0d0)
          else if (t_2 <= 5d+47) then
              tmp = (ndchar / (1.0d0 + exp((((edonor + vef) - ec) / kbt)))) + (nachar / (1.0d0 + (1.0d0 + (ev / 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 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
      	double t_1 = NaChar / (1.0 + t_0);
      	double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
      	double tmp;
      	if (t_2 <= -2e-101) {
      		tmp = (NdChar / (1.0 + Math.exp((((mu + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + 1.0));
      	} else if (t_2 <= 2e-24) {
      		tmp = NaChar / (t_0 + 1.0);
      	} else if (t_2 <= 5e+47) {
      		tmp = (NdChar / (1.0 + Math.exp((((EDonor + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + (1.0 + (Ev / KbT))));
      	} else {
      		tmp = (0.5 * NdChar) + t_1;
      	}
      	return tmp;
      }
      
      def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
      	t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
      	t_1 = NaChar / (1.0 + t_0)
      	t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1
      	tmp = 0
      	if t_2 <= -2e-101:
      		tmp = (NdChar / (1.0 + math.exp((((mu + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + 1.0))
      	elif t_2 <= 2e-24:
      		tmp = NaChar / (t_0 + 1.0)
      	elif t_2 <= 5e+47:
      		tmp = (NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + (1.0 + (Ev / KbT))))
      	else:
      		tmp = (0.5 * NdChar) + t_1
      	return tmp
      
      function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
      	t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
      	t_1 = Float64(NaChar / Float64(1.0 + t_0))
      	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1)
      	tmp = 0.0
      	if (t_2 <= -2e-101)
      		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(mu + Vef) - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + 1.0)));
      	elseif (t_2 <= 2e-24)
      		tmp = Float64(NaChar / Float64(t_0 + 1.0));
      	elseif (t_2 <= 5e+47)
      		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + Float64(1.0 + Float64(Ev / 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 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
      	t_1 = NaChar / (1.0 + t_0);
      	t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
      	tmp = 0.0;
      	if (t_2 <= -2e-101)
      		tmp = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + 1.0));
      	elseif (t_2 <= 2e-24)
      		tmp = NaChar / (t_0 + 1.0);
      	elseif (t_2 <= 5e+47)
      		tmp = (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + (1.0 + (Ev / 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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -2e-101], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(mu + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-24], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+47], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[(1.0 + N[(Ev / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
      t_1 := \frac{NaChar}{1 + t\_0}\\
      t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\
      \mathbf{if}\;t\_2 \leq -2 \cdot 10^{-101}:\\
      \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + 1}\\
      
      \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-24}:\\
      \;\;\;\;\frac{NaChar}{t\_0 + 1}\\
      
      \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+47}:\\
      \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + \left(1 + \frac{Ev}{KbT}\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;0.5 \cdot NdChar + t\_1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 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.0000000000000001e-101

        1. Initial program 99.8%

          \[\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 mu around inf

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

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

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

          \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
        7. Step-by-step derivation
          1. Applied rewrites47.2%

            \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
          2. Taylor expanded in EDonor around 0

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

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

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

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

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

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

          if -2.0000000000000001e-101 < (+.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.99999999999999985e-24

          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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
            2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

          if 1.99999999999999985e-24 < (+.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.00000000000000022e47

          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}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
          4. Step-by-step derivation
            1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 5.00000000000000022e47 < (+.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-*.f6475.5

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

              \[\leadsto \color{blue}{0.5 \cdot NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
          11. Recombined 4 regimes into one program.
          12. Final simplification69.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 -2 \cdot 10^{-101}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + 1}\\ \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 2 \cdot 10^{-24}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \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^{+47}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + \left(1 + \frac{Ev}{KbT}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \end{array} \]
          13. Add Preprocessing

          Alternative 5: 82.2% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_1 := \frac{NaChar}{1 + t\_0}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{-300} \lor \neg \left(t\_2 \leq 0\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{t\_0 + 1}\\ \end{array} \end{array} \]
          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
           :precision binary64
           (let* ((t_0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
                  (t_1 (/ NaChar (+ 1.0 t_0)))
                  (t_2
                   (+
                    (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                    t_1)))
             (if (or (<= t_2 -1e-300) (not (<= t_2 0.0)))
               (+ (/ NdChar (+ 1.0 (exp (/ mu KbT)))) t_1)
               (/ NaChar (+ t_0 1.0)))))
          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
          	double t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
          	double t_1 = NaChar / (1.0 + t_0);
          	double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
          	double tmp;
          	if ((t_2 <= -1e-300) || !(t_2 <= 0.0)) {
          		tmp = (NdChar / (1.0 + exp((mu / KbT)))) + t_1;
          	} else {
          		tmp = NaChar / (t_0 + 1.0);
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
          use fmin_fmax_functions
              real(8), intent (in) :: ndchar
              real(8), intent (in) :: ec
              real(8), intent (in) :: vef
              real(8), intent (in) :: edonor
              real(8), intent (in) :: mu
              real(8), intent (in) :: kbt
              real(8), intent (in) :: nachar
              real(8), intent (in) :: ev
              real(8), intent (in) :: eaccept
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: t_2
              real(8) :: tmp
              t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
              t_1 = nachar / (1.0d0 + t_0)
              t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
              if ((t_2 <= (-1d-300)) .or. (.not. (t_2 <= 0.0d0))) then
                  tmp = (ndchar / (1.0d0 + exp((mu / kbt)))) + t_1
              else
                  tmp = nachar / (t_0 + 1.0d0)
              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 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
          	double t_1 = NaChar / (1.0 + t_0);
          	double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
          	double tmp;
          	if ((t_2 <= -1e-300) || !(t_2 <= 0.0)) {
          		tmp = (NdChar / (1.0 + Math.exp((mu / KbT)))) + t_1;
          	} else {
          		tmp = NaChar / (t_0 + 1.0);
          	}
          	return tmp;
          }
          
          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
          	t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
          	t_1 = NaChar / (1.0 + t_0)
          	t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1
          	tmp = 0
          	if (t_2 <= -1e-300) or not (t_2 <= 0.0):
          		tmp = (NdChar / (1.0 + math.exp((mu / KbT)))) + t_1
          	else:
          		tmp = NaChar / (t_0 + 1.0)
          	return tmp
          
          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
          	t_1 = Float64(NaChar / Float64(1.0 + t_0))
          	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1)
          	tmp = 0.0
          	if ((t_2 <= -1e-300) || !(t_2 <= 0.0))
          		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + t_1);
          	else
          		tmp = Float64(NaChar / Float64(t_0 + 1.0));
          	end
          	return tmp
          end
          
          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
          	t_1 = NaChar / (1.0 + t_0);
          	t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
          	tmp = 0.0;
          	if ((t_2 <= -1e-300) || ~((t_2 <= 0.0)))
          		tmp = (NdChar / (1.0 + exp((mu / KbT)))) + t_1;
          	else
          		tmp = NaChar / (t_0 + 1.0);
          	end
          	tmp_2 = tmp;
          end
          
          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -1e-300], N[Not[LessEqual[t$95$2, 0.0]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
          t_1 := \frac{NaChar}{1 + t\_0}\\
          t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\
          \mathbf{if}\;t\_2 \leq -1 \cdot 10^{-300} \lor \neg \left(t\_2 \leq 0\right):\\
          \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_1\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{NaChar}{t\_0 + 1}\\
          
          
          \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.00000000000000003e-300 or 0.0 < (+.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 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 mu around inf

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

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

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

            if -1.00000000000000003e-300 < (+.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))))) < 0.0

            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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
              2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -1 \cdot 10^{-300} \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 0\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 6: 68.2% accurate, 0.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_1 := \frac{NaChar}{1 + t\_0}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-54} \lor \neg \left(t\_2 \leq 2 \cdot 10^{-24}\right):\\ \;\;\;\;0.5 \cdot NdChar + t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{t\_0 + 1}\\ \end{array} \end{array} \]
          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
           :precision binary64
           (let* ((t_0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
                  (t_1 (/ NaChar (+ 1.0 t_0)))
                  (t_2
                   (+
                    (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                    t_1)))
             (if (or (<= t_2 -5e-54) (not (<= t_2 2e-24)))
               (+ (* 0.5 NdChar) t_1)
               (/ NaChar (+ t_0 1.0)))))
          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
          	double t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
          	double t_1 = NaChar / (1.0 + t_0);
          	double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
          	double tmp;
          	if ((t_2 <= -5e-54) || !(t_2 <= 2e-24)) {
          		tmp = (0.5 * NdChar) + t_1;
          	} else {
          		tmp = NaChar / (t_0 + 1.0);
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
          use fmin_fmax_functions
              real(8), intent (in) :: ndchar
              real(8), intent (in) :: ec
              real(8), intent (in) :: vef
              real(8), intent (in) :: edonor
              real(8), intent (in) :: mu
              real(8), intent (in) :: kbt
              real(8), intent (in) :: nachar
              real(8), intent (in) :: ev
              real(8), intent (in) :: eaccept
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: t_2
              real(8) :: tmp
              t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
              t_1 = nachar / (1.0d0 + t_0)
              t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
              if ((t_2 <= (-5d-54)) .or. (.not. (t_2 <= 2d-24))) then
                  tmp = (0.5d0 * ndchar) + t_1
              else
                  tmp = nachar / (t_0 + 1.0d0)
              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 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
          	double t_1 = NaChar / (1.0 + t_0);
          	double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
          	double tmp;
          	if ((t_2 <= -5e-54) || !(t_2 <= 2e-24)) {
          		tmp = (0.5 * NdChar) + t_1;
          	} else {
          		tmp = NaChar / (t_0 + 1.0);
          	}
          	return tmp;
          }
          
          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
          	t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
          	t_1 = NaChar / (1.0 + t_0)
          	t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1
          	tmp = 0
          	if (t_2 <= -5e-54) or not (t_2 <= 2e-24):
          		tmp = (0.5 * NdChar) + t_1
          	else:
          		tmp = NaChar / (t_0 + 1.0)
          	return tmp
          
          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
          	t_1 = Float64(NaChar / Float64(1.0 + t_0))
          	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1)
          	tmp = 0.0
          	if ((t_2 <= -5e-54) || !(t_2 <= 2e-24))
          		tmp = Float64(Float64(0.5 * NdChar) + t_1);
          	else
          		tmp = Float64(NaChar / Float64(t_0 + 1.0));
          	end
          	return tmp
          end
          
          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
          	t_1 = NaChar / (1.0 + t_0);
          	t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
          	tmp = 0.0;
          	if ((t_2 <= -5e-54) || ~((t_2 <= 2e-24)))
          		tmp = (0.5 * NdChar) + t_1;
          	else
          		tmp = NaChar / (t_0 + 1.0);
          	end
          	tmp_2 = tmp;
          end
          
          code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e-54], N[Not[LessEqual[t$95$2, 2e-24]], $MachinePrecision]], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
          t_1 := \frac{NaChar}{1 + t\_0}\\
          t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\
          \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-54} \lor \neg \left(t\_2 \leq 2 \cdot 10^{-24}\right):\\
          \;\;\;\;0.5 \cdot NdChar + t\_1\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{NaChar}{t\_0 + 1}\\
          
          
          \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))))) < -5.00000000000000015e-54 or 1.99999999999999985e-24 < (+.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 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 NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
            4. Step-by-step derivation
              1. lower-*.f6466.9

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

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

            if -5.00000000000000015e-54 < (+.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.99999999999999985e-24

            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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
              2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

          Alternative 7: 66.5% accurate, 0.4× speedup?

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

            1. Initial program 99.8%

              \[\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 mu around inf

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

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

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

              \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
            7. Step-by-step derivation
              1. Applied rewrites47.2%

                \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
              2. Taylor expanded in EDonor around 0

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

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

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

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

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

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

              if -2.0000000000000001e-101 < (+.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.99999999999999985e-24

              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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

              if 1.99999999999999985e-24 < (+.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-*.f6471.8

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

                \[\leadsto \color{blue}{0.5 \cdot NdChar} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
            8. Recombined 3 regimes into one program.
            9. Final simplification68.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^{-101}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + 1}\\ \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 2 \cdot 10^{-24}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \end{array} \]
            10. Add Preprocessing

            Alternative 8: 37.7% 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^{-237} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-281}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{\left(\left(Vef + Ev\right) + EAccept\right) - 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 -5e-237) (not (<= t_0 2e-281)))
                 (* 0.5 (+ NaChar NdChar))
                 (/ NaChar (+ 2.0 (/ (- (+ (+ Vef Ev) EAccept) 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 <= -5e-237) || !(t_0 <= 2e-281)) {
            		tmp = 0.5 * (NaChar + NdChar);
            	} else {
            		tmp = NaChar / (2.0 + ((((Vef + Ev) + 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) :: t_0
                real(8) :: tmp
                t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
                if ((t_0 <= (-5d-237)) .or. (.not. (t_0 <= 2d-281))) then
                    tmp = 0.5d0 * (nachar + ndchar)
                else
                    tmp = nachar / (2.0d0 + ((((vef + ev) + 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 t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
            	double tmp;
            	if ((t_0 <= -5e-237) || !(t_0 <= 2e-281)) {
            		tmp = 0.5 * (NaChar + NdChar);
            	} else {
            		tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - mu) / 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)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
            	tmp = 0
            	if (t_0 <= -5e-237) or not (t_0 <= 2e-281):
            		tmp = 0.5 * (NaChar + NdChar)
            	else:
            		tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - 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 <= -5e-237) || !(t_0 <= 2e-281))
            		tmp = Float64(0.5 * Float64(NaChar + NdChar));
            	else
            		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Vef + Ev) + EAccept) - mu) / 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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
            	tmp = 0.0;
            	if ((t_0 <= -5e-237) || ~((t_0 <= 2e-281)))
            		tmp = 0.5 * (NaChar + NdChar);
            	else
            		tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - mu) / KbT));
            	end
            	tmp_2 = 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-237], N[Not[LessEqual[t$95$0, 2e-281]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(Vef + Ev), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $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^{-237} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-281}\right):\\
            \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{NaChar}{2 + \frac{\left(\left(Vef + Ev\right) + EAccept\right) - 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))))) < -5.0000000000000002e-237 or 2e-281 < (+.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 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. distribute-lft-outN/A

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

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

                  \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
              5. Applied rewrites36.4%

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

              if -5.0000000000000002e-237 < (+.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))))) < 2e-281

              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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{NaChar}{2 + \color{blue}{\frac{\left(\left(Vef + Ev\right) + EAccept\right) - mu}{KbT}}} \]
              8. Recombined 2 regimes into one program.
              9. Final simplification42.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 -5 \cdot 10^{-237} \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^{-281}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{\left(\left(Vef + Ev\right) + EAccept\right) - mu}{KbT}}\\ \end{array} \]
              10. Add Preprocessing

              Alternative 9: 33.2% 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^{-237} \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(NaChar \cdot NaChar\right) \cdot 0.5}{NaChar - NdChar}\\ \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-237) (not (<= t_0 0.0)))
                   (* 0.5 (+ NaChar NdChar))
                   (/ (* (* NaChar NaChar) 0.5) (- NaChar NdChar)))))
              double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
              	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
              	double tmp;
              	if ((t_0 <= -5e-237) || !(t_0 <= 0.0)) {
              		tmp = 0.5 * (NaChar + NdChar);
              	} else {
              		tmp = ((NaChar * NaChar) * 0.5) / (NaChar - NdChar);
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
              use fmin_fmax_functions
                  real(8), intent (in) :: ndchar
                  real(8), intent (in) :: ec
                  real(8), intent (in) :: vef
                  real(8), intent (in) :: edonor
                  real(8), intent (in) :: mu
                  real(8), intent (in) :: kbt
                  real(8), intent (in) :: nachar
                  real(8), intent (in) :: ev
                  real(8), intent (in) :: eaccept
                  real(8) :: t_0
                  real(8) :: tmp
                  t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
                  if ((t_0 <= (-5d-237)) .or. (.not. (t_0 <= 0.0d0))) then
                      tmp = 0.5d0 * (nachar + ndchar)
                  else
                      tmp = ((nachar * nachar) * 0.5d0) / (nachar - ndchar)
                  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)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
              	double tmp;
              	if ((t_0 <= -5e-237) || !(t_0 <= 0.0)) {
              		tmp = 0.5 * (NaChar + NdChar);
              	} else {
              		tmp = ((NaChar * NaChar) * 0.5) / (NaChar - NdChar);
              	}
              	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)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
              	tmp = 0
              	if (t_0 <= -5e-237) or not (t_0 <= 0.0):
              		tmp = 0.5 * (NaChar + NdChar)
              	else:
              		tmp = ((NaChar * NaChar) * 0.5) / (NaChar - NdChar)
              	return tmp
              
              function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
              	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
              	tmp = 0.0
              	if ((t_0 <= -5e-237) || !(t_0 <= 0.0))
              		tmp = Float64(0.5 * Float64(NaChar + NdChar));
              	else
              		tmp = Float64(Float64(Float64(NaChar * NaChar) * 0.5) / Float64(NaChar - NdChar));
              	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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
              	tmp = 0.0;
              	if ((t_0 <= -5e-237) || ~((t_0 <= 0.0)))
              		tmp = 0.5 * (NaChar + NdChar);
              	else
              		tmp = ((NaChar * NaChar) * 0.5) / (NaChar - NdChar);
              	end
              	tmp_2 = 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-237], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(N[(N[(NaChar * NaChar), $MachinePrecision] * 0.5), $MachinePrecision] / N[(NaChar - NdChar), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
              \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-237} \lor \neg \left(t\_0 \leq 0\right):\\
              \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;\frac{\left(NaChar \cdot NaChar\right) \cdot 0.5}{NaChar - NdChar}\\
              
              
              \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))))) < -5.0000000000000002e-237 or 0.0 < (+.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 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. distribute-lft-outN/A

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

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                  3. lower-+.f6435.9

                    \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                5. Applied rewrites35.9%

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

                if -5.0000000000000002e-237 < (+.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))))) < 0.0

                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. distribute-lft-outN/A

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

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                  3. lower-+.f642.6

                    \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                5. Applied rewrites2.6%

                  \[\leadsto \color{blue}{0.5 \cdot \left(NaChar + NdChar\right)} \]
                6. Step-by-step derivation
                  1. Applied rewrites5.7%

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

                    \[\leadsto \frac{{NaChar}^{2} \cdot \frac{1}{2}}{NaChar - NdChar} \]
                  3. Step-by-step derivation
                    1. Applied rewrites28.5%

                      \[\leadsto \frac{\left(NaChar \cdot NaChar\right) \cdot 0.5}{NaChar - NdChar} \]
                  4. Recombined 2 regimes into one program.
                  5. Final simplification34.3%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-237} \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 0\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(NaChar \cdot NaChar\right) \cdot 0.5}{NaChar - NdChar}\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 10: 33.0% accurate, 0.5× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-237} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-281}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(NdChar \cdot NdChar\right) \cdot -0.5}{NaChar - NdChar}\\ \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-237) (not (<= t_0 2e-281)))
                       (* 0.5 (+ NaChar NdChar))
                       (/ (* (* NdChar NdChar) -0.5) (- NaChar NdChar)))))
                  double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                  	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                  	double tmp;
                  	if ((t_0 <= -5e-237) || !(t_0 <= 2e-281)) {
                  		tmp = 0.5 * (NaChar + NdChar);
                  	} else {
                  		tmp = ((NdChar * NdChar) * -0.5) / (NaChar - NdChar);
                  	}
                  	return tmp;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                  use fmin_fmax_functions
                      real(8), intent (in) :: ndchar
                      real(8), intent (in) :: ec
                      real(8), intent (in) :: vef
                      real(8), intent (in) :: edonor
                      real(8), intent (in) :: mu
                      real(8), intent (in) :: kbt
                      real(8), intent (in) :: nachar
                      real(8), intent (in) :: ev
                      real(8), intent (in) :: eaccept
                      real(8) :: t_0
                      real(8) :: tmp
                      t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
                      if ((t_0 <= (-5d-237)) .or. (.not. (t_0 <= 2d-281))) then
                          tmp = 0.5d0 * (nachar + ndchar)
                      else
                          tmp = ((ndchar * ndchar) * (-0.5d0)) / (nachar - ndchar)
                      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)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                  	double tmp;
                  	if ((t_0 <= -5e-237) || !(t_0 <= 2e-281)) {
                  		tmp = 0.5 * (NaChar + NdChar);
                  	} else {
                  		tmp = ((NdChar * NdChar) * -0.5) / (NaChar - NdChar);
                  	}
                  	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)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
                  	tmp = 0
                  	if (t_0 <= -5e-237) or not (t_0 <= 2e-281):
                  		tmp = 0.5 * (NaChar + NdChar)
                  	else:
                  		tmp = ((NdChar * NdChar) * -0.5) / (NaChar - NdChar)
                  	return tmp
                  
                  function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                  	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
                  	tmp = 0.0
                  	if ((t_0 <= -5e-237) || !(t_0 <= 2e-281))
                  		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                  	else
                  		tmp = Float64(Float64(Float64(NdChar * NdChar) * -0.5) / Float64(NaChar - NdChar));
                  	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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                  	tmp = 0.0;
                  	if ((t_0 <= -5e-237) || ~((t_0 <= 2e-281)))
                  		tmp = 0.5 * (NaChar + NdChar);
                  	else
                  		tmp = ((NdChar * NdChar) * -0.5) / (NaChar - NdChar);
                  	end
                  	tmp_2 = 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-237], N[Not[LessEqual[t$95$0, 2e-281]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(N[(N[(NdChar * NdChar), $MachinePrecision] * -0.5), $MachinePrecision] / N[(NaChar - NdChar), $MachinePrecision]), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
                  \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-237} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-281}\right):\\
                  \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{\left(NdChar \cdot NdChar\right) \cdot -0.5}{NaChar - NdChar}\\
                  
                  
                  \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))))) < -5.0000000000000002e-237 or 2e-281 < (+.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 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. distribute-lft-outN/A

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

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

                        \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                    5. Applied rewrites36.4%

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

                    if -5.0000000000000002e-237 < (+.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))))) < 2e-281

                    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. distribute-lft-outN/A

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

                        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                      3. lower-+.f642.7

                        \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                    5. Applied rewrites2.7%

                      \[\leadsto \color{blue}{0.5 \cdot \left(NaChar + NdChar\right)} \]
                    6. Step-by-step derivation
                      1. Applied rewrites5.6%

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

                        \[\leadsto \frac{\frac{-1}{2} \cdot {NdChar}^{2}}{\color{blue}{NaChar} - NdChar} \]
                      3. Step-by-step derivation
                        1. Applied rewrites22.5%

                          \[\leadsto \frac{\left(NdChar \cdot NdChar\right) \cdot -0.5}{\color{blue}{NaChar} - NdChar} \]
                      4. Recombined 2 regimes into one program.
                      5. Final simplification33.1%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-237} \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^{-281}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(NdChar \cdot NdChar\right) \cdot -0.5}{NaChar - NdChar}\\ \end{array} \]
                      6. Add Preprocessing

                      Alternative 11: 30.4% accurate, 0.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-249} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-281}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar \cdot mu}{KbT} \cdot 0.25\\ \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-249) (not (<= t_0 2e-281)))
                           (* 0.5 (+ NaChar NdChar))
                           (* (/ (* NaChar mu) KbT) 0.25))))
                      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-249) || !(t_0 <= 2e-281)) {
                      		tmp = 0.5 * (NaChar + NdChar);
                      	} else {
                      		tmp = ((NaChar * mu) / KbT) * 0.25;
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                      use fmin_fmax_functions
                          real(8), intent (in) :: ndchar
                          real(8), intent (in) :: ec
                          real(8), intent (in) :: vef
                          real(8), intent (in) :: edonor
                          real(8), intent (in) :: mu
                          real(8), intent (in) :: kbt
                          real(8), intent (in) :: nachar
                          real(8), intent (in) :: ev
                          real(8), intent (in) :: eaccept
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
                          if ((t_0 <= (-5d-249)) .or. (.not. (t_0 <= 2d-281))) then
                              tmp = 0.5d0 * (nachar + ndchar)
                          else
                              tmp = ((nachar * mu) / kbt) * 0.25d0
                          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)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                      	double tmp;
                      	if ((t_0 <= -5e-249) || !(t_0 <= 2e-281)) {
                      		tmp = 0.5 * (NaChar + NdChar);
                      	} else {
                      		tmp = ((NaChar * mu) / KbT) * 0.25;
                      	}
                      	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)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
                      	tmp = 0
                      	if (t_0 <= -5e-249) or not (t_0 <= 2e-281):
                      		tmp = 0.5 * (NaChar + NdChar)
                      	else:
                      		tmp = ((NaChar * mu) / KbT) * 0.25
                      	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-249) || !(t_0 <= 2e-281))
                      		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                      	else
                      		tmp = Float64(Float64(Float64(NaChar * mu) / KbT) * 0.25);
                      	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)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                      	tmp = 0.0;
                      	if ((t_0 <= -5e-249) || ~((t_0 <= 2e-281)))
                      		tmp = 0.5 * (NaChar + NdChar);
                      	else
                      		tmp = ((NaChar * mu) / KbT) * 0.25;
                      	end
                      	tmp_2 = 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-249], N[Not[LessEqual[t$95$0, 2e-281]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(N[(N[(NaChar * mu), $MachinePrecision] / KbT), $MachinePrecision] * 0.25), $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^{-249} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-281}\right):\\
                      \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{NaChar \cdot mu}{KbT} \cdot 0.25\\
                      
                      
                      \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.9999999999999999e-249 or 2e-281 < (+.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 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. distribute-lft-outN/A

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

                            \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                          3. lower-+.f6435.9

                            \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                        5. Applied rewrites35.9%

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

                        if -4.9999999999999999e-249 < (+.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))))) < 2e-281

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

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

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

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

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

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

                            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{\frac{1}{4} \cdot \left(NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)\right)}{KbT} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                          3. associate-*r/N/A

                            \[\leadsto \left(\mathsf{neg}\left(\left(\color{blue}{\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT}} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                          4. associate-*r/N/A

                            \[\leadsto \left(\mathsf{neg}\left(\left(\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \color{blue}{\frac{1}{4} \cdot \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                          5. distribute-lft-outN/A

                            \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{1}{4} \cdot \left(\frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                          6. distribute-lft-neg-inN/A

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

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

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

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

                          \[\leadsto \frac{1}{4} \cdot \color{blue}{\frac{mu \cdot \left(NaChar + -1 \cdot NdChar\right)}{KbT}} \]
                        10. Step-by-step derivation
                          1. Applied rewrites8.9%

                            \[\leadsto \frac{\mathsf{fma}\left(-1, NdChar, NaChar\right) \cdot mu}{KbT} \cdot \color{blue}{0.25} \]
                          2. Taylor expanded in NdChar around 0

                            \[\leadsto \frac{NaChar \cdot mu}{KbT} \cdot \frac{1}{4} \]
                          3. Step-by-step derivation
                            1. Applied rewrites22.9%

                              \[\leadsto \frac{NaChar \cdot mu}{KbT} \cdot 0.25 \]
                          4. Recombined 2 regimes into one program.
                          5. Final simplification33.0%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-249} \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^{-281}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar \cdot mu}{KbT} \cdot 0.25\\ \end{array} \]
                          6. Add Preprocessing

                          Alternative 12: 68.7% accurate, 1.5× speedup?

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

                            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}{\color{blue}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \frac{Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                            4. Step-by-step derivation
                              1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

                            if -1.40000000000000002e86 < NaChar < 6.1999999999999995e30

                            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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
                            4. Step-by-step derivation
                              1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

                            if 6.1999999999999995e30 < 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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                              2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                          Alternative 13: 65.7% accurate, 1.5× speedup?

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

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

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

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

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

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

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

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

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

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

                            if -3.9000000000000002e93 < NaChar < 5.59999999999999966e30

                            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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
                            4. Step-by-step derivation
                              1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 14: 65.3% accurate, 1.5× speedup?

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

                            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}{\color{blue}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \frac{Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                            4. Step-by-step derivation
                              1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

                            if -1.40000000000000002e86 < NaChar < 5.59999999999999966e30

                            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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
                            4. Step-by-step derivation
                              1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            if 5.59999999999999966e30 < 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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                              2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

                          Alternative 15: 62.8% accurate, 1.8× speedup?

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

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

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

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

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

                              \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
                            7. Step-by-step derivation
                              1. Applied rewrites84.9%

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

                              if -5.2000000000000001e224 < KbT < 4.7999999999999998e142

                              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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                              if 4.7999999999999998e142 < KbT

                              1. Initial program 99.6%

                                \[\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 mu around inf

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

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

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

                                \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
                              7. Step-by-step derivation
                                1. Applied rewrites76.4%

                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
                                2. Taylor expanded in EDonor around inf

                                  \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\frac{EDonor}{KbT}}}} + \frac{NaChar}{1 + 1} \]
                                3. Step-by-step derivation
                                  1. lower-/.f6480.4

                                    \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\frac{EDonor}{KbT}}}} + \frac{NaChar}{1 + 1} \]
                                4. Applied rewrites80.4%

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

                              Alternative 16: 62.8% accurate, 1.8× speedup?

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

                                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}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
                                4. Step-by-step derivation
                                  1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  \[\leadsto \frac{NdChar}{1 + \left(\left(1 + \left(\frac{EDonor}{KbT} + \frac{Vef}{KbT}\right)\right) - \color{blue}{\frac{Ec}{KbT}}\right)} + \frac{NaChar}{1 + \left(1 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}\right)} \]
                                10. Step-by-step derivation
                                  1. Applied rewrites83.0%

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

                                  if -3.8000000000000001e225 < KbT < 4.7999999999999998e142

                                  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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                    2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                                  if 4.7999999999999998e142 < KbT

                                  1. Initial program 99.6%

                                    \[\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 mu around inf

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

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

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

                                    \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites76.4%

                                      \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + \color{blue}{1}} \]
                                    2. Taylor expanded in EDonor around inf

                                      \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\frac{EDonor}{KbT}}}} + \frac{NaChar}{1 + 1} \]
                                    3. Step-by-step derivation
                                      1. lower-/.f6480.4

                                        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\frac{EDonor}{KbT}}}} + \frac{NaChar}{1 + 1} \]
                                    4. Applied rewrites80.4%

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

                                  Alternative 17: 55.6% accurate, 1.8× speedup?

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

                                    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}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
                                    4. Step-by-step derivation
                                      1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \frac{NdChar}{1 + \left(\left(1 + \left(\frac{EDonor}{KbT} + \frac{Vef}{KbT}\right)\right) - \color{blue}{\frac{Ec}{KbT}}\right)} + \frac{NaChar}{1 + \left(1 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}\right)} \]
                                    10. Step-by-step derivation
                                      1. Applied rewrites83.0%

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

                                      if -5.50000000000000035e224 < KbT < -4.30000000000000031e-33

                                      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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                        2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                                        \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}}} \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites45.5%

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

                                        if -4.30000000000000031e-33 < KbT < 4.4999999999999999e142

                                        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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                          2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                                          \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}} \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites55.5%

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

                                          if 4.4999999999999999e142 < KbT

                                          1. Initial program 99.6%

                                            \[\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 mu around inf

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

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

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

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

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

                                              \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{\frac{1}{4} \cdot \left(NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)\right)}{KbT} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                            3. associate-*r/N/A

                                              \[\leadsto \left(\mathsf{neg}\left(\left(\color{blue}{\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT}} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                            4. associate-*r/N/A

                                              \[\leadsto \left(\mathsf{neg}\left(\left(\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \color{blue}{\frac{1}{4} \cdot \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                            5. distribute-lft-outN/A

                                              \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{1}{4} \cdot \left(\frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                            6. distribute-lft-neg-inN/A

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

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

                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}, \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right)} \]
                                          8. Applied rewrites48.7%

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

                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \frac{EDonor \cdot NdChar}{\color{blue}{KbT}}, \frac{1}{2} \cdot \left(NaChar + NdChar\right)\right) \]
                                          10. Step-by-step derivation
                                            1. Applied rewrites72.9%

                                              \[\leadsto \mathsf{fma}\left(-0.25, EDonor \cdot \color{blue}{\frac{NdChar}{KbT}}, 0.5 \cdot \left(NaChar + NdChar\right)\right) \]
                                          11. Recombined 4 regimes into one program.
                                          12. Add Preprocessing

                                          Alternative 18: 62.3% accurate, 1.9× speedup?

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

                                            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}}} + \frac{NaChar}{1 + \color{blue}{\left(\left(1 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}\right)}} \]
                                            4. Step-by-step derivation
                                              1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                              \[\leadsto \frac{NdChar}{1 + \left(\left(1 + \left(\frac{EDonor}{KbT} + \frac{Vef}{KbT}\right)\right) - \color{blue}{\frac{Ec}{KbT}}\right)} + \frac{NaChar}{1 + \left(1 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}\right)} \]
                                            10. Step-by-step derivation
                                              1. Applied rewrites83.0%

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

                                              if -3.8000000000000001e225 < KbT < 5.0000000000000001e142

                                              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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                                              if 5.0000000000000001e142 < KbT

                                              1. Initial program 99.6%

                                                \[\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 mu around inf

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

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

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

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

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

                                                  \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{\frac{1}{4} \cdot \left(NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)\right)}{KbT} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                3. associate-*r/N/A

                                                  \[\leadsto \left(\mathsf{neg}\left(\left(\color{blue}{\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT}} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                4. associate-*r/N/A

                                                  \[\leadsto \left(\mathsf{neg}\left(\left(\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \color{blue}{\frac{1}{4} \cdot \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                5. distribute-lft-outN/A

                                                  \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{1}{4} \cdot \left(\frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                6. distribute-lft-neg-inN/A

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

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

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}, \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right)} \]
                                              8. Applied rewrites48.7%

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

                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \frac{EDonor \cdot NdChar}{\color{blue}{KbT}}, \frac{1}{2} \cdot \left(NaChar + NdChar\right)\right) \]
                                              10. Step-by-step derivation
                                                1. Applied rewrites72.9%

                                                  \[\leadsto \mathsf{fma}\left(-0.25, EDonor \cdot \color{blue}{\frac{NdChar}{KbT}}, 0.5 \cdot \left(NaChar + NdChar\right)\right) \]
                                              11. Recombined 3 regimes into one program.
                                              12. Add Preprocessing

                                              Alternative 19: 55.0% accurate, 1.9× speedup?

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

                                                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}{\color{blue}{\left(2 + \left(\frac{EDonor}{KbT} + \left(\frac{Vef}{KbT} + \frac{mu}{KbT}\right)\right)\right) - \frac{Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                4. Step-by-step derivation
                                                  1. associate--l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  if -4.39999999999999973e163 < KbT < 4.4999999999999999e142

                                                  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 \color{blue}{\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}} \]
                                                    2. +-commutativeN/A

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto \frac{NaChar}{1 + \color{blue}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}} \]
                                                  7. Step-by-step derivation
                                                    1. Applied rewrites53.9%

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

                                                    if 4.4999999999999999e142 < KbT

                                                    1. Initial program 99.6%

                                                      \[\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 mu around inf

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

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

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

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

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

                                                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{\frac{1}{4} \cdot \left(NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)\right)}{KbT} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                      3. associate-*r/N/A

                                                        \[\leadsto \left(\mathsf{neg}\left(\left(\color{blue}{\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT}} + \frac{\frac{1}{4} \cdot \left(NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)\right)}{KbT}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                      4. associate-*r/N/A

                                                        \[\leadsto \left(\mathsf{neg}\left(\left(\frac{1}{4} \cdot \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \color{blue}{\frac{1}{4} \cdot \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}}\right)\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                      5. distribute-lft-outN/A

                                                        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{1}{4} \cdot \left(\frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}\right)}\right)\right) + \left(\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right) \]
                                                      6. distribute-lft-neg-inN/A

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

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

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, \frac{NaChar \cdot \left(\left(EAccept + \left(Ev + Vef\right)\right) - mu\right)}{KbT} + \frac{NdChar \cdot \left(\left(EDonor + \left(Vef + mu\right)\right) - Ec\right)}{KbT}, \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar\right)} \]
                                                    8. Applied rewrites48.7%

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

                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \frac{EDonor \cdot NdChar}{\color{blue}{KbT}}, \frac{1}{2} \cdot \left(NaChar + NdChar\right)\right) \]
                                                    10. Step-by-step derivation
                                                      1. Applied rewrites72.9%

                                                        \[\leadsto \mathsf{fma}\left(-0.25, EDonor \cdot \color{blue}{\frac{NdChar}{KbT}}, 0.5 \cdot \left(NaChar + NdChar\right)\right) \]
                                                    11. Recombined 3 regimes into one program.
                                                    12. Add Preprocessing

                                                    Alternative 20: 22.8% accurate, 15.3× speedup?

                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NaChar \leq -4.8 \cdot 10^{+93} \lor \neg \left(NaChar \leq 1.65 \cdot 10^{+37}\right):\\ \;\;\;\;0.5 \cdot NaChar\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar\\ \end{array} \end{array} \]
                                                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                     :precision binary64
                                                     (if (or (<= NaChar -4.8e+93) (not (<= NaChar 1.65e+37)))
                                                       (* 0.5 NaChar)
                                                       (* 0.5 NdChar)))
                                                    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                    	double tmp;
                                                    	if ((NaChar <= -4.8e+93) || !(NaChar <= 1.65e+37)) {
                                                    		tmp = 0.5 * NaChar;
                                                    	} else {
                                                    		tmp = 0.5 * NdChar;
                                                    	}
                                                    	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 <= (-4.8d+93)) .or. (.not. (nachar <= 1.65d+37))) then
                                                            tmp = 0.5d0 * nachar
                                                        else
                                                            tmp = 0.5d0 * ndchar
                                                        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 <= -4.8e+93) || !(NaChar <= 1.65e+37)) {
                                                    		tmp = 0.5 * NaChar;
                                                    	} else {
                                                    		tmp = 0.5 * NdChar;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                    	tmp = 0
                                                    	if (NaChar <= -4.8e+93) or not (NaChar <= 1.65e+37):
                                                    		tmp = 0.5 * NaChar
                                                    	else:
                                                    		tmp = 0.5 * NdChar
                                                    	return tmp
                                                    
                                                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                    	tmp = 0.0
                                                    	if ((NaChar <= -4.8e+93) || !(NaChar <= 1.65e+37))
                                                    		tmp = Float64(0.5 * NaChar);
                                                    	else
                                                    		tmp = Float64(0.5 * NdChar);
                                                    	end
                                                    	return tmp
                                                    end
                                                    
                                                    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                    	tmp = 0.0;
                                                    	if ((NaChar <= -4.8e+93) || ~((NaChar <= 1.65e+37)))
                                                    		tmp = 0.5 * NaChar;
                                                    	else
                                                    		tmp = 0.5 * NdChar;
                                                    	end
                                                    	tmp_2 = tmp;
                                                    end
                                                    
                                                    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NaChar, -4.8e+93], N[Not[LessEqual[NaChar, 1.65e+37]], $MachinePrecision]], N[(0.5 * NaChar), $MachinePrecision], N[(0.5 * NdChar), $MachinePrecision]]
                                                    
                                                    \begin{array}{l}
                                                    
                                                    \\
                                                    \begin{array}{l}
                                                    \mathbf{if}\;NaChar \leq -4.8 \cdot 10^{+93} \lor \neg \left(NaChar \leq 1.65 \cdot 10^{+37}\right):\\
                                                    \;\;\;\;0.5 \cdot NaChar\\
                                                    
                                                    \mathbf{else}:\\
                                                    \;\;\;\;0.5 \cdot NdChar\\
                                                    
                                                    
                                                    \end{array}
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Split input into 2 regimes
                                                    2. if NaChar < -4.80000000000000021e93 or 1.65e37 < 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 NaChar + \frac{1}{2} \cdot NdChar} \]
                                                      4. Step-by-step derivation
                                                        1. distribute-lft-outN/A

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

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

                                                          \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                                                      5. Applied rewrites33.4%

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

                                                        \[\leadsto \frac{1}{2} \cdot \color{blue}{NaChar} \]
                                                      7. Step-by-step derivation
                                                        1. Applied rewrites28.4%

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

                                                        if -4.80000000000000021e93 < NaChar < 1.65e37

                                                        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. distribute-lft-outN/A

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

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

                                                            \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                                                        5. Applied rewrites25.2%

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

                                                          \[\leadsto \frac{1}{2} \cdot \color{blue}{NdChar} \]
                                                        7. Step-by-step derivation
                                                          1. Applied rewrites23.1%

                                                            \[\leadsto 0.5 \cdot \color{blue}{NdChar} \]
                                                        8. Recombined 2 regimes into one program.
                                                        9. Final simplification25.2%

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;NaChar \leq -4.8 \cdot 10^{+93} \lor \neg \left(NaChar \leq 1.65 \cdot 10^{+37}\right):\\ \;\;\;\;0.5 \cdot NaChar\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar\\ \end{array} \]
                                                        10. Add Preprocessing

                                                        Alternative 21: 27.6% accurate, 30.7× speedup?

                                                        \[\begin{array}{l} \\ 0.5 \cdot \left(NaChar + NdChar\right) \end{array} \]
                                                        (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                         :precision binary64
                                                         (* 0.5 (+ NaChar NdChar)))
                                                        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                        	return 0.5 * (NaChar + 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 * (nachar + 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 * (NaChar + NdChar);
                                                        }
                                                        
                                                        def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                        	return 0.5 * (NaChar + NdChar)
                                                        
                                                        function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                        	return Float64(0.5 * Float64(NaChar + NdChar))
                                                        end
                                                        
                                                        function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                        	tmp = 0.5 * (NaChar + NdChar);
                                                        end
                                                        
                                                        code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        0.5 \cdot \left(NaChar + NdChar\right)
                                                        \end{array}
                                                        
                                                        Derivation
                                                        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. distribute-lft-outN/A

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

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

                                                            \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                                                        5. Applied rewrites28.4%

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

                                                        Alternative 22: 17.6% accurate, 46.0× speedup?

                                                        \[\begin{array}{l} \\ 0.5 \cdot NaChar \end{array} \]
                                                        (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                         :precision binary64
                                                         (* 0.5 NaChar))
                                                        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                        	return 0.5 * NaChar;
                                                        }
                                                        
                                                        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 * nachar
                                                        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 * NaChar;
                                                        }
                                                        
                                                        def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                        	return 0.5 * NaChar
                                                        
                                                        function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                        	return Float64(0.5 * NaChar)
                                                        end
                                                        
                                                        function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                        	tmp = 0.5 * NaChar;
                                                        end
                                                        
                                                        code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * NaChar), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        0.5 \cdot NaChar
                                                        \end{array}
                                                        
                                                        Derivation
                                                        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. distribute-lft-outN/A

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

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

                                                            \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                                                        5. Applied rewrites28.4%

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

                                                          \[\leadsto \frac{1}{2} \cdot \color{blue}{NaChar} \]
                                                        7. Step-by-step derivation
                                                          1. Applied rewrites17.4%

                                                            \[\leadsto 0.5 \cdot \color{blue}{NaChar} \]
                                                          2. Add Preprocessing

                                                          Reproduce

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