Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 13.0s
Alternatives: 32
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 32 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 2: 91.3% 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{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{-299} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-293}\right):\\ \;\;\;\;\frac{NdChar}{e^{\frac{\left(mu + EDonor\right) - Ec}{KbT}} + 1} + \frac{NaChar}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}} + 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
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
          (/ NaChar (+ 1.0 t_0)))))
   (if (or (<= t_1 -4e-299) (not (<= t_1 5e-293)))
     (+
      (/ NdChar (+ (exp (/ (- (+ mu EDonor) Ec) KbT)) 1.0))
      (/ NaChar (+ (exp (/ (- (+ EAccept Ev) mu) KbT)) 1.0)))
     (/ 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 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
	double tmp;
	if ((t_1 <= -4e-299) || !(t_1 <= 5e-293)) {
		tmp = (NdChar / (exp((((mu + EDonor) - Ec) / KbT)) + 1.0)) + (NaChar / (exp((((EAccept + Ev) - mu) / KbT)) + 1.0));
	} 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) :: tmp
    t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
    t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_0))
    if ((t_1 <= (-4d-299)) .or. (.not. (t_1 <= 5d-293))) then
        tmp = (ndchar / (exp((((mu + edonor) - ec) / kbt)) + 1.0d0)) + (nachar / (exp((((eaccept + ev) - mu) / kbt)) + 1.0d0))
    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 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
	double tmp;
	if ((t_1 <= -4e-299) || !(t_1 <= 5e-293)) {
		tmp = (NdChar / (Math.exp((((mu + EDonor) - Ec) / KbT)) + 1.0)) + (NaChar / (Math.exp((((EAccept + Ev) - mu) / KbT)) + 1.0));
	} 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 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0))
	tmp = 0
	if (t_1 <= -4e-299) or not (t_1 <= 5e-293):
		tmp = (NdChar / (math.exp((((mu + EDonor) - Ec) / KbT)) + 1.0)) + (NaChar / (math.exp((((EAccept + Ev) - mu) / KbT)) + 1.0))
	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(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_0)))
	tmp = 0.0
	if ((t_1 <= -4e-299) || !(t_1 <= 5e-293))
		tmp = Float64(Float64(NdChar / Float64(exp(Float64(Float64(Float64(mu + EDonor) - Ec) / KbT)) + 1.0)) + Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT)) + 1.0)));
	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 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
	tmp = 0.0;
	if ((t_1 <= -4e-299) || ~((t_1 <= 5e-293)))
		tmp = (NdChar / (exp((((mu + EDonor) - Ec) / KbT)) + 1.0)) + (NaChar / (exp((((EAccept + Ev) - mu) / KbT)) + 1.0));
	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[(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 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -4e-299], N[Not[LessEqual[t$95$1, 5e-293]], $MachinePrecision]], N[(N[(NdChar / N[(N[Exp[N[(N[(N[(mu + EDonor), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $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{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-299} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-293}\right):\\
\;\;\;\;\frac{NdChar}{e^{\frac{\left(mu + EDonor\right) - Ec}{KbT}} + 1} + \frac{NaChar}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}} + 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))))) < -3.99999999999999997e-299 or 5.0000000000000003e-293 < (+.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 Vef around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999997e-299 < (+.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.0000000000000003e-293

    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 simplification94.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 -4 \cdot 10^{-299} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-293}\right):\\ \;\;\;\;\frac{NdChar}{e^{\frac{\left(mu + EDonor\right) - Ec}{KbT}} + 1} + \frac{NaChar}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.9% 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^{-247} \lor \neg \left(t\_2 \leq 5 \cdot 10^{-293}\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 -2e-247) (not (<= t_2 5e-293)))
     (+ (/ 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 <= -2e-247) || !(t_2 <= 5e-293)) {
		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 <= (-2d-247)) .or. (.not. (t_2 <= 5d-293))) 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 <= -2e-247) || !(t_2 <= 5e-293)) {
		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 <= -2e-247) or not (t_2 <= 5e-293):
		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 <= -2e-247) || !(t_2 <= 5e-293))
		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 <= -2e-247) || ~((t_2 <= 5e-293)))
		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, -2e-247], N[Not[LessEqual[t$95$2, 5e-293]], $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 -2 \cdot 10^{-247} \lor \neg \left(t\_2 \leq 5 \cdot 10^{-293}\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))))) < -2e-247 or 5.0000000000000003e-293 < (+.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 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-/.f6482.6

        \[\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 rewrites82.6%

      \[\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 -2e-247 < (+.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.0000000000000003e-293

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

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

      \[\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 simplification84.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -2 \cdot 10^{-247} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-293}\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 4: 78.5% 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{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-247} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-293}\right):\\ \;\;\;\;\frac{NdChar}{e^{\frac{mu}{KbT}} + 1} + \frac{NaChar}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}} + 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
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
          (/ NaChar (+ 1.0 t_0)))))
   (if (or (<= t_1 -2e-247) (not (<= t_1 5e-293)))
     (+
      (/ NdChar (+ (exp (/ mu KbT)) 1.0))
      (/ NaChar (+ (exp (/ (- (+ EAccept Ev) mu) KbT)) 1.0)))
     (/ 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 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
	double tmp;
	if ((t_1 <= -2e-247) || !(t_1 <= 5e-293)) {
		tmp = (NdChar / (exp((mu / KbT)) + 1.0)) + (NaChar / (exp((((EAccept + Ev) - mu) / KbT)) + 1.0));
	} 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) :: tmp
    t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
    t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_0))
    if ((t_1 <= (-2d-247)) .or. (.not. (t_1 <= 5d-293))) then
        tmp = (ndchar / (exp((mu / kbt)) + 1.0d0)) + (nachar / (exp((((eaccept + ev) - mu) / kbt)) + 1.0d0))
    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 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
	double tmp;
	if ((t_1 <= -2e-247) || !(t_1 <= 5e-293)) {
		tmp = (NdChar / (Math.exp((mu / KbT)) + 1.0)) + (NaChar / (Math.exp((((EAccept + Ev) - mu) / KbT)) + 1.0));
	} 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 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0))
	tmp = 0
	if (t_1 <= -2e-247) or not (t_1 <= 5e-293):
		tmp = (NdChar / (math.exp((mu / KbT)) + 1.0)) + (NaChar / (math.exp((((EAccept + Ev) - mu) / KbT)) + 1.0))
	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(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_0)))
	tmp = 0.0
	if ((t_1 <= -2e-247) || !(t_1 <= 5e-293))
		tmp = Float64(Float64(NdChar / Float64(exp(Float64(mu / KbT)) + 1.0)) + Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT)) + 1.0)));
	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 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
	tmp = 0.0;
	if ((t_1 <= -2e-247) || ~((t_1 <= 5e-293)))
		tmp = (NdChar / (exp((mu / KbT)) + 1.0)) + (NaChar / (exp((((EAccept + Ev) - mu) / KbT)) + 1.0));
	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[(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 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-247], N[Not[LessEqual[t$95$1, 5e-293]], $MachinePrecision]], N[(N[(NdChar / N[(N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $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{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-247} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-293}\right):\\
\;\;\;\;\frac{NdChar}{e^{\frac{mu}{KbT}} + 1} + \frac{NaChar}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}} + 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))))) < -2e-247 or 5.0000000000000003e-293 < (+.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 Vef around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -2e-247 < (+.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.0000000000000003e-293

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

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

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

    Alternative 5: 72.6% 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{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-225} \lor \neg \left(t\_1 \leq 2 \cdot 10^{-61}\right):\\ \;\;\;\;\frac{NdChar}{e^{\frac{mu}{KbT}} + 1} + \frac{NaChar}{e^{\frac{Ev - mu}{KbT}} + 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
             (+
              (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
              (/ NaChar (+ 1.0 t_0)))))
       (if (or (<= t_1 -5e-225) (not (<= t_1 2e-61)))
         (+
          (/ NdChar (+ (exp (/ mu KbT)) 1.0))
          (/ NaChar (+ (exp (/ (- Ev mu) KbT)) 1.0)))
         (/ 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 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
    	double tmp;
    	if ((t_1 <= -5e-225) || !(t_1 <= 2e-61)) {
    		tmp = (NdChar / (exp((mu / KbT)) + 1.0)) + (NaChar / (exp(((Ev - mu) / KbT)) + 1.0));
    	} 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) :: tmp
        t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
        t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_0))
        if ((t_1 <= (-5d-225)) .or. (.not. (t_1 <= 2d-61))) then
            tmp = (ndchar / (exp((mu / kbt)) + 1.0d0)) + (nachar / (exp(((ev - mu) / kbt)) + 1.0d0))
        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 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
    	double tmp;
    	if ((t_1 <= -5e-225) || !(t_1 <= 2e-61)) {
    		tmp = (NdChar / (Math.exp((mu / KbT)) + 1.0)) + (NaChar / (Math.exp(((Ev - mu) / KbT)) + 1.0));
    	} 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 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0))
    	tmp = 0
    	if (t_1 <= -5e-225) or not (t_1 <= 2e-61):
    		tmp = (NdChar / (math.exp((mu / KbT)) + 1.0)) + (NaChar / (math.exp(((Ev - mu) / KbT)) + 1.0))
    	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(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_0)))
    	tmp = 0.0
    	if ((t_1 <= -5e-225) || !(t_1 <= 2e-61))
    		tmp = Float64(Float64(NdChar / Float64(exp(Float64(mu / KbT)) + 1.0)) + Float64(NaChar / Float64(exp(Float64(Float64(Ev - mu) / KbT)) + 1.0)));
    	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 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
    	tmp = 0.0;
    	if ((t_1 <= -5e-225) || ~((t_1 <= 2e-61)))
    		tmp = (NdChar / (exp((mu / KbT)) + 1.0)) + (NaChar / (exp(((Ev - mu) / KbT)) + 1.0));
    	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[(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 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e-225], N[Not[LessEqual[t$95$1, 2e-61]], $MachinePrecision]], N[(N[(NdChar / N[(N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(N[Exp[N[(N[(Ev - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $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{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\
    \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-225} \lor \neg \left(t\_1 \leq 2 \cdot 10^{-61}\right):\\
    \;\;\;\;\frac{NdChar}{e^{\frac{mu}{KbT}} + 1} + \frac{NaChar}{e^{\frac{Ev - mu}{KbT}} + 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.0000000000000001e-225 or 2.0000000000000001e-61 < (+.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 Vef around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{NdChar}{e^{\frac{mu}{KbT}} + 1} + \frac{NaChar}{e^{\frac{Ev - mu}{KbT}} + 1} \]
        3. Step-by-step derivation
          1. Applied rewrites78.0%

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

          if -5.0000000000000001e-225 < (+.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-61

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

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

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

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

        Alternative 6: 39.2% accurate, 0.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + EAccept \cdot \left(\frac{\frac{\left(Ev + Vef\right) - mu}{KbT}}{EAccept} - \frac{-1}{KbT}\right)}\\ \end{array} \end{array} \]
        (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
         :precision binary64
         (let* ((t_0
                 (+
                  (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                  (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
           (if (or (<= t_0 -2e-102) (not (<= t_0 5e-214)))
             (* 0.5 (+ NaChar NdChar))
             (/
              NaChar
              (+
               2.0
               (* EAccept (- (/ (/ (- (+ Ev Vef) mu) KbT) EAccept) (/ -1.0 KbT))))))))
        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
        	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
        	double tmp;
        	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214)) {
        		tmp = 0.5 * (NaChar + NdChar);
        	} else {
        		tmp = NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / 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 <= (-2d-102)) .or. (.not. (t_0 <= 5d-214))) then
                tmp = 0.5d0 * (nachar + ndchar)
            else
                tmp = nachar / (2.0d0 + (eaccept * (((((ev + vef) - mu) / kbt) / eaccept) - ((-1.0d0) / 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 <= -2e-102) || !(t_0 <= 5e-214)) {
        		tmp = 0.5 * (NaChar + NdChar);
        	} else {
        		tmp = NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / 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 <= -2e-102) or not (t_0 <= 5e-214):
        		tmp = 0.5 * (NaChar + NdChar)
        	else:
        		tmp = NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / KbT))))
        	return tmp
        
        function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
        	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
        	tmp = 0.0
        	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214))
        		tmp = Float64(0.5 * Float64(NaChar + NdChar));
        	else
        		tmp = Float64(NaChar / Float64(2.0 + Float64(EAccept * Float64(Float64(Float64(Float64(Float64(Ev + Vef) - mu) / KbT) / EAccept) - Float64(-1.0 / 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 <= -2e-102) || ~((t_0 <= 5e-214)))
        		tmp = 0.5 * (NaChar + NdChar);
        	else
        		tmp = NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / 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, -2e-102], N[Not[LessEqual[t$95$0, 5e-214]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(EAccept * N[(N[(N[(N[(N[(Ev + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision] / EAccept), $MachinePrecision] - N[(-1.0 / 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}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
        \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\
        \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{NaChar}{2 + EAccept \cdot \left(\frac{\frac{\left(Ev + Vef\right) - mu}{KbT}}{EAccept} - \frac{-1}{KbT}\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.99999999999999987e-102 or 4.9999999999999998e-214 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
          4. Step-by-step derivation
            1. 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-+.f6441.0

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

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

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

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

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

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

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

              \[\leadsto \frac{NaChar}{2 + -1 \cdot \left(EAccept \cdot \color{blue}{\left(-1 \cdot \frac{\left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right) - \frac{mu}{KbT}}{EAccept} - \frac{1}{KbT}\right)}\right)} \]
            3. Step-by-step derivation
              1. Applied rewrites49.9%

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

            Alternative 7: 39.6% accurate, 0.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - \frac{1}{KbT}\right) \cdot mu}\\ \end{array} \end{array} \]
            (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
             :precision binary64
             (let* ((t_0
                     (+
                      (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                      (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
               (if (or (<= t_0 -2e-102) (not (<= t_0 5e-214)))
                 (* 0.5 (+ NaChar NdChar))
                 (/
                  NaChar
                  (+ 2.0 (* (- (/ (/ (+ EAccept (+ Ev Vef)) KbT) mu) (/ 1.0 KbT)) mu))))))
            double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
            	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
            	double tmp;
            	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214)) {
            		tmp = 0.5 * (NaChar + NdChar);
            	} else {
            		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - (1.0 / KbT)) * mu));
            	}
            	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 <= (-2d-102)) .or. (.not. (t_0 <= 5d-214))) then
                    tmp = 0.5d0 * (nachar + ndchar)
                else
                    tmp = nachar / (2.0d0 + (((((eaccept + (ev + vef)) / kbt) / mu) - (1.0d0 / kbt)) * mu))
                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 <= -2e-102) || !(t_0 <= 5e-214)) {
            		tmp = 0.5 * (NaChar + NdChar);
            	} else {
            		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - (1.0 / KbT)) * mu));
            	}
            	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 <= -2e-102) or not (t_0 <= 5e-214):
            		tmp = 0.5 * (NaChar + NdChar)
            	else:
            		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - (1.0 / KbT)) * mu))
            	return tmp
            
            function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
            	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
            	tmp = 0.0
            	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214))
            		tmp = Float64(0.5 * Float64(NaChar + NdChar));
            	else
            		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT) / mu) - Float64(1.0 / KbT)) * mu)));
            	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 <= -2e-102) || ~((t_0 <= 5e-214)))
            		tmp = 0.5 * (NaChar + NdChar);
            	else
            		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - (1.0 / KbT)) * mu));
            	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, -2e-102], N[Not[LessEqual[t$95$0, 5e-214]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision] / mu), $MachinePrecision] - N[(1.0 / KbT), $MachinePrecision]), $MachinePrecision] * mu), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
            \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\
            \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - \frac{1}{KbT}\right) \cdot mu}\\
            
            
            \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.99999999999999987e-102 or 4.9999999999999998e-214 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

              1. Initial program 100.0%

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

                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
              4. Step-by-step derivation
                1. 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-+.f6441.0

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

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

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

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

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

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

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

                  \[\leadsto \frac{NaChar}{2 + mu \cdot \left(\left(\frac{EAccept}{KbT \cdot mu} + \left(\frac{Ev}{KbT \cdot mu} + \frac{Vef}{KbT \cdot mu}\right)\right) - \color{blue}{\frac{1}{KbT}}\right)} \]
                3. Step-by-step derivation
                  1. Applied rewrites49.2%

                    \[\leadsto \frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - \frac{1}{KbT}\right) \cdot mu} \]
                4. Recombined 2 regimes into one program.
                5. Final simplification43.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 -2 \cdot 10^{-102} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - \frac{1}{KbT}\right) \cdot mu}\\ \end{array} \]
                6. Add Preprocessing

                Alternative 8: 39.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 -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{Ev + Vef}{EAccept \cdot KbT} - \frac{-1}{KbT}\right) \cdot EAccept}\\ \end{array} \end{array} \]
                (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                 :precision binary64
                 (let* ((t_0
                         (+
                          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                          (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
                   (if (or (<= t_0 -2e-102) (not (<= t_0 5e-214)))
                     (* 0.5 (+ NaChar NdChar))
                     (/
                      NaChar
                      (+ 2.0 (* (- (/ (+ Ev Vef) (* EAccept KbT)) (/ -1.0 KbT)) EAccept))))))
                double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                	double tmp;
                	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214)) {
                		tmp = 0.5 * (NaChar + NdChar);
                	} else {
                		tmp = NaChar / (2.0 + ((((Ev + Vef) / (EAccept * KbT)) - (-1.0 / KbT)) * EAccept));
                	}
                	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 <= (-2d-102)) .or. (.not. (t_0 <= 5d-214))) then
                        tmp = 0.5d0 * (nachar + ndchar)
                    else
                        tmp = nachar / (2.0d0 + ((((ev + vef) / (eaccept * kbt)) - ((-1.0d0) / kbt)) * eaccept))
                    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 <= -2e-102) || !(t_0 <= 5e-214)) {
                		tmp = 0.5 * (NaChar + NdChar);
                	} else {
                		tmp = NaChar / (2.0 + ((((Ev + Vef) / (EAccept * KbT)) - (-1.0 / KbT)) * EAccept));
                	}
                	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 <= -2e-102) or not (t_0 <= 5e-214):
                		tmp = 0.5 * (NaChar + NdChar)
                	else:
                		tmp = NaChar / (2.0 + ((((Ev + Vef) / (EAccept * KbT)) - (-1.0 / KbT)) * EAccept))
                	return tmp
                
                function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
                	tmp = 0.0
                	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214))
                		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                	else
                		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Ev + Vef) / Float64(EAccept * KbT)) - Float64(-1.0 / KbT)) * EAccept)));
                	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 <= -2e-102) || ~((t_0 <= 5e-214)))
                		tmp = 0.5 * (NaChar + NdChar);
                	else
                		tmp = NaChar / (2.0 + ((((Ev + Vef) / (EAccept * KbT)) - (-1.0 / KbT)) * EAccept));
                	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, -2e-102], N[Not[LessEqual[t$95$0, 5e-214]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(Ev + Vef), $MachinePrecision] / N[(EAccept * KbT), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / KbT), $MachinePrecision]), $MachinePrecision] * EAccept), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
                \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\
                \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{NaChar}{2 + \left(\frac{Ev + Vef}{EAccept \cdot KbT} - \frac{-1}{KbT}\right) \cdot EAccept}\\
                
                
                \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.99999999999999987e-102 or 4.9999999999999998e-214 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                  4. Step-by-step derivation
                    1. 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-+.f6441.0

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

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

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

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

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

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

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

                      \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                    3. Step-by-step derivation
                      1. Applied rewrites42.6%

                        \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                      2. Taylor expanded in EAccept around inf

                        \[\leadsto \frac{NaChar}{2 + EAccept \cdot \left(\frac{1}{KbT} + \left(\frac{Ev}{EAccept \cdot KbT} + \color{blue}{\frac{Vef}{EAccept \cdot KbT}}\right)\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites47.5%

                          \[\leadsto \frac{NaChar}{2 + \left(\frac{Ev + Vef}{EAccept \cdot KbT} + \frac{1}{KbT}\right) \cdot EAccept} \]
                      4. Recombined 2 regimes into one program.
                      5. Final simplification43.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 -2 \cdot 10^{-102} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{Ev + Vef}{EAccept \cdot KbT} - \frac{-1}{KbT}\right) \cdot EAccept}\\ \end{array} \]
                      6. Add Preprocessing

                      Alternative 9: 39.9% accurate, 0.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-145} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{\frac{EAccept + Vef}{Ev} + 1}{KbT} \cdot Ev}\\ \end{array} \end{array} \]
                      (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                       :precision binary64
                       (let* ((t_0
                               (+
                                (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                                (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
                         (if (or (<= t_0 -4e-145) (not (<= t_0 5e-214)))
                           (* 0.5 (+ NaChar NdChar))
                           (/ NaChar (+ 2.0 (* (/ (+ (/ (+ EAccept Vef) Ev) 1.0) KbT) Ev))))))
                      double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                      	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                      	double tmp;
                      	if ((t_0 <= -4e-145) || !(t_0 <= 5e-214)) {
                      		tmp = 0.5 * (NaChar + NdChar);
                      	} else {
                      		tmp = NaChar / (2.0 + (((((EAccept + Vef) / Ev) + 1.0) / KbT) * Ev));
                      	}
                      	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 <= (-4d-145)) .or. (.not. (t_0 <= 5d-214))) then
                              tmp = 0.5d0 * (nachar + ndchar)
                          else
                              tmp = nachar / (2.0d0 + (((((eaccept + vef) / ev) + 1.0d0) / kbt) * ev))
                          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 <= -4e-145) || !(t_0 <= 5e-214)) {
                      		tmp = 0.5 * (NaChar + NdChar);
                      	} else {
                      		tmp = NaChar / (2.0 + (((((EAccept + Vef) / Ev) + 1.0) / KbT) * Ev));
                      	}
                      	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 <= -4e-145) or not (t_0 <= 5e-214):
                      		tmp = 0.5 * (NaChar + NdChar)
                      	else:
                      		tmp = NaChar / (2.0 + (((((EAccept + Vef) / Ev) + 1.0) / KbT) * Ev))
                      	return tmp
                      
                      function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                      	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
                      	tmp = 0.0
                      	if ((t_0 <= -4e-145) || !(t_0 <= 5e-214))
                      		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                      	else
                      		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Float64(EAccept + Vef) / Ev) + 1.0) / KbT) * Ev)));
                      	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 <= -4e-145) || ~((t_0 <= 5e-214)))
                      		tmp = 0.5 * (NaChar + NdChar);
                      	else
                      		tmp = NaChar / (2.0 + (((((EAccept + Vef) / Ev) + 1.0) / KbT) * Ev));
                      	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, -4e-145], N[Not[LessEqual[t$95$0, 5e-214]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(N[(EAccept + Vef), $MachinePrecision] / Ev), $MachinePrecision] + 1.0), $MachinePrecision] / KbT), $MachinePrecision] * Ev), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
                      \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-145} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\
                      \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\frac{NaChar}{2 + \frac{\frac{EAccept + Vef}{Ev} + 1}{KbT} \cdot Ev}\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -3.99999999999999966e-145 or 4.9999999999999998e-214 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                        1. Initial program 100.0%

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

                          \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                        4. Step-by-step derivation
                          1. 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-+.f6441.6

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

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

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

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

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

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

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

                            \[\leadsto \frac{NaChar}{2 + -1 \cdot \left(Ev \cdot \color{blue}{\left(-1 \cdot \frac{\left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right) - \frac{mu}{KbT}}{Ev} - \frac{1}{KbT}\right)}\right)} \]
                          3. Step-by-step derivation
                            1. Applied rewrites47.3%

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

                              \[\leadsto \frac{NaChar}{2 + Ev \cdot \left(\frac{1}{KbT} + \left(\frac{EAccept}{Ev \cdot KbT} + \color{blue}{\frac{Vef}{Ev \cdot KbT}}\right)\right)} \]
                            3. Step-by-step derivation
                              1. Applied rewrites45.1%

                                \[\leadsto \frac{NaChar}{2 + \frac{\frac{EAccept + Vef}{Ev} + 1}{KbT} \cdot Ev} \]
                            4. Recombined 2 regimes into one program.
                            5. 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 -4 \cdot 10^{-145} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{\frac{EAccept + Vef}{Ev} + 1}{KbT} \cdot Ev}\\ \end{array} \]
                            6. Add Preprocessing

                            Alternative 10: 37.3% accurate, 0.5× speedup?

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

                              1. Initial program 100.0%

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

                                \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                              4. Step-by-step derivation
                                1. 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-+.f6441.0

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

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

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

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

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

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

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

                              Alternative 11: 36.5% accurate, 0.5× speedup?

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

                                1. Initial program 100.0%

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

                                  \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                4. Step-by-step derivation
                                  1. 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-+.f6441.0

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

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

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

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

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

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

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

                                    \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites42.6%

                                      \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                                    2. Taylor expanded in EAccept around 0

                                      \[\leadsto \frac{NaChar}{2 + \frac{\left(Ev + Vef\right) - mu}{KbT}} \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites42.1%

                                        \[\leadsto \frac{NaChar}{2 + \frac{\left(Ev + Vef\right) - mu}{KbT}} \]
                                    4. Recombined 2 regimes into one program.
                                    5. Final simplification41.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 -2 \cdot 10^{-102} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{\left(Ev + Vef\right) - mu}{KbT}}\\ \end{array} \]
                                    6. Add Preprocessing

                                    Alternative 12: 37.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 -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}}\\ \end{array} \end{array} \]
                                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                     :precision binary64
                                     (let* ((t_0
                                             (+
                                              (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                                              (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
                                       (if (or (<= t_0 -2e-102) (not (<= t_0 5e-214)))
                                         (* 0.5 (+ NaChar NdChar))
                                         (/ NaChar (+ 2.0 (/ (+ EAccept (+ Ev Vef)) KbT))))))
                                    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                    	double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
                                    	double tmp;
                                    	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214)) {
                                    		tmp = 0.5 * (NaChar + NdChar);
                                    	} else {
                                    		tmp = NaChar / (2.0 + ((EAccept + (Ev + Vef)) / KbT));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    module fmin_fmax_functions
                                        implicit none
                                        private
                                        public fmax
                                        public fmin
                                    
                                        interface fmax
                                            module procedure fmax88
                                            module procedure fmax44
                                            module procedure fmax84
                                            module procedure fmax48
                                        end interface
                                        interface fmin
                                            module procedure fmin88
                                            module procedure fmin44
                                            module procedure fmin84
                                            module procedure fmin48
                                        end interface
                                    contains
                                        real(8) function fmax88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmax44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmax84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmax48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmin44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmin48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                        end function
                                    end module
                                    
                                    real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: ndchar
                                        real(8), intent (in) :: ec
                                        real(8), intent (in) :: vef
                                        real(8), intent (in) :: edonor
                                        real(8), intent (in) :: mu
                                        real(8), intent (in) :: kbt
                                        real(8), intent (in) :: nachar
                                        real(8), intent (in) :: ev
                                        real(8), intent (in) :: eaccept
                                        real(8) :: 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 <= (-2d-102)) .or. (.not. (t_0 <= 5d-214))) then
                                            tmp = 0.5d0 * (nachar + ndchar)
                                        else
                                            tmp = nachar / (2.0d0 + ((eaccept + (ev + vef)) / kbt))
                                        end if
                                        code = tmp
                                    end function
                                    
                                    public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                    	double 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 <= -2e-102) || !(t_0 <= 5e-214)) {
                                    		tmp = 0.5 * (NaChar + NdChar);
                                    	} else {
                                    		tmp = NaChar / (2.0 + ((EAccept + (Ev + Vef)) / 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 <= -2e-102) or not (t_0 <= 5e-214):
                                    		tmp = 0.5 * (NaChar + NdChar)
                                    	else:
                                    		tmp = NaChar / (2.0 + ((EAccept + (Ev + Vef)) / KbT))
                                    	return tmp
                                    
                                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                    	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)))))
                                    	tmp = 0.0
                                    	if ((t_0 <= -2e-102) || !(t_0 <= 5e-214))
                                    		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                                    	else
                                    		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(EAccept + Float64(Ev + Vef)) / 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 <= -2e-102) || ~((t_0 <= 5e-214)))
                                    		tmp = 0.5 * (NaChar + NdChar);
                                    	else
                                    		tmp = NaChar / (2.0 + ((EAccept + (Ev + Vef)) / 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, -2e-102], N[Not[LessEqual[t$95$0, 5e-214]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $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 -2 \cdot 10^{-102} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-214}\right):\\
                                    \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;\frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}}\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.99999999999999987e-102 or 4.9999999999999998e-214 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                                      1. Initial program 100.0%

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

                                        \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                      4. Step-by-step derivation
                                        1. 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-+.f6441.0

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

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

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

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

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

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

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

                                          \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites42.6%

                                            \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                                        4. Recombined 2 regimes into one program.
                                        5. Final simplification41.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 -2 \cdot 10^{-102} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}}\\ \end{array} \]
                                        6. Add Preprocessing

                                        Alternative 13: 35.8% accurate, 0.5× speedup?

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

                                          1. Initial program 100.0%

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

                                            \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                          4. Step-by-step derivation
                                            1. 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-+.f6441.0

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

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

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

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

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

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

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

                                              \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites42.6%

                                                \[\leadsto \frac{NaChar}{2 + \frac{EAccept + \left(Ev + Vef\right)}{KbT}} \]
                                              2. Taylor expanded in Ev around 0

                                                \[\leadsto \frac{NaChar}{2 + \frac{EAccept + Vef}{KbT}} \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites42.3%

                                                  \[\leadsto \frac{NaChar}{2 + \frac{EAccept + Vef}{KbT}} \]
                                              4. Recombined 2 regimes into one program.
                                              5. Final simplification41.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^{-102} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-214}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{EAccept + Vef}{KbT}}\\ \end{array} \]
                                              6. Add Preprocessing

                                              Alternative 14: 33.9% accurate, 0.5× speedup?

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

                                                1. Initial program 100.0%

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

                                                  \[\leadsto \color{blue}{\frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot NdChar} \]
                                                4. Step-by-step derivation
                                                  1. 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-+.f6439.3

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

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

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

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

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

                                                  \[\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 rewrites49.0%

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

                                                    \[\leadsto \frac{NaChar}{\frac{Vef}{KbT}} \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites36.5%

                                                      \[\leadsto \frac{NaChar}{\frac{Vef}{KbT}} \]
                                                  4. Recombined 2 regimes into one program.
                                                  5. Final simplification38.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^{-230} \lor \neg \left(\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq 5 \cdot 10^{-290}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{\frac{Vef}{KbT}}\\ \end{array} \]
                                                  6. Add Preprocessing

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

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

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

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

                                                    if -3.99999999999999991e-256 < (+.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-224

                                                    1. Initial program 100.0%

                                                      \[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in 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-+.f6487.7

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

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

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

                                                        \[\leadsto \frac{NaChar}{\frac{EAccept}{KbT}} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites25.2%

                                                          \[\leadsto \frac{NaChar}{\frac{EAccept}{KbT}} \]
                                                      4. Recombined 2 regimes into one program.
                                                      5. Final simplification36.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 -4 \cdot 10^{-256} \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^{-224}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{\frac{EAccept}{KbT}}\\ \end{array} \]
                                                      6. Add Preprocessing

                                                      Alternative 16: 65.6% accurate, 1.2× speedup?

                                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45} \lor \neg \left(KbT \leq 2 \cdot 10^{+105}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \mathsf{fma}\left(Vef, \frac{\frac{1}{KbT} + \frac{\frac{Ev - mu}{KbT}}{Vef}}{EAccept}, \frac{1}{KbT}\right) \cdot EAccept}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \end{array} \end{array} \]
                                                      (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                       :precision binary64
                                                       (if (or (<= KbT -1.18e+45) (not (<= KbT 2e+105)))
                                                         (+
                                                          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                                                          (/
                                                           NaChar
                                                           (+
                                                            2.0
                                                            (*
                                                             (fma
                                                              Vef
                                                              (/ (+ (/ 1.0 KbT) (/ (/ (- Ev mu) KbT) Vef)) EAccept)
                                                              (/ 1.0 KbT))
                                                             EAccept))))
                                                         (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))))
                                                      double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                      	double tmp;
                                                      	if ((KbT <= -1.18e+45) || !(KbT <= 2e+105)) {
                                                      		tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + (fma(Vef, (((1.0 / KbT) + (((Ev - mu) / KbT) / Vef)) / EAccept), (1.0 / KbT)) * EAccept)));
                                                      	} else {
                                                      		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                      	}
                                                      	return tmp;
                                                      }
                                                      
                                                      function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                      	tmp = 0.0
                                                      	if ((KbT <= -1.18e+45) || !(KbT <= 2e+105))
                                                      		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(2.0 + Float64(fma(Vef, Float64(Float64(Float64(1.0 / KbT) + Float64(Float64(Float64(Ev - mu) / KbT) / Vef)) / EAccept), Float64(1.0 / KbT)) * EAccept))));
                                                      	else
                                                      		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0));
                                                      	end
                                                      	return tmp
                                                      end
                                                      
                                                      code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[KbT, -1.18e+45], N[Not[LessEqual[KbT, 2e+105]], $MachinePrecision]], 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[(2.0 + N[(N[(Vef * N[(N[(N[(1.0 / KbT), $MachinePrecision] + N[(N[(N[(Ev - mu), $MachinePrecision] / KbT), $MachinePrecision] / Vef), $MachinePrecision]), $MachinePrecision] / EAccept), $MachinePrecision] + N[(1.0 / KbT), $MachinePrecision]), $MachinePrecision] * EAccept), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                                                      
                                                      \begin{array}{l}
                                                      
                                                      \\
                                                      \begin{array}{l}
                                                      \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45} \lor \neg \left(KbT \leq 2 \cdot 10^{+105}\right):\\
                                                      \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \mathsf{fma}\left(Vef, \frac{\frac{1}{KbT} + \frac{\frac{Ev - mu}{KbT}}{Vef}}{EAccept}, \frac{1}{KbT}\right) \cdot EAccept}\\
                                                      
                                                      \mathbf{else}:\\
                                                      \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
                                                      
                                                      
                                                      \end{array}
                                                      \end{array}
                                                      
                                                      Derivation
                                                      1. Split input into 2 regimes
                                                      2. if KbT < -1.17999999999999993e45 or 1.9999999999999999e105 < 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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                        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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                          3. div-addN/A

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

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

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

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

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

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

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

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

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

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

                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                          2. 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}{2 + EAccept \cdot \left(\frac{1}{KbT} + \color{blue}{\frac{Vef \cdot \left(\left(\frac{1}{KbT} + \frac{Ev}{KbT \cdot Vef}\right) - \frac{mu}{KbT \cdot Vef}\right)}{EAccept}}\right)} \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites82.4%

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

                                                            if -1.17999999999999993e45 < KbT < 1.9999999999999999e105

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

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

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

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

                                                          Alternative 17: 65.1% accurate, 1.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}}}\\ \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + EAccept \cdot \left(\frac{\frac{\left(Ev + Vef\right) - mu}{KbT}}{EAccept} - \frac{-1}{KbT}\right)}\\ \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\ \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))))))
                                                             (if (<= KbT -1.18e+45)
                                                               (+
                                                                t_0
                                                                (/
                                                                 NaChar
                                                                 (+
                                                                  2.0
                                                                  (* EAccept (- (/ (/ (- (+ Ev Vef) mu) KbT) EAccept) (/ -1.0 KbT))))))
                                                               (if (<= KbT 4.4e+96)
                                                                 (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))
                                                                 (+ t_0 (/ NaChar (+ 2.0 (* (/ (/ EAccept KbT) Vef) Vef))))))))
                                                          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 tmp;
                                                          	if (KbT <= -1.18e+45) {
                                                          		tmp = t_0 + (NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / KbT)))));
                                                          	} else if (KbT <= 4.4e+96) {
                                                          		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                          	} else {
                                                          		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                          	}
                                                          	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)))
                                                              if (kbt <= (-1.18d+45)) then
                                                                  tmp = t_0 + (nachar / (2.0d0 + (eaccept * (((((ev + vef) - mu) / kbt) / eaccept) - ((-1.0d0) / kbt)))))
                                                              else if (kbt <= 4.4d+96) then
                                                                  tmp = nachar / (exp(((((ev + vef) + eaccept) - mu) / kbt)) + 1.0d0)
                                                              else
                                                                  tmp = t_0 + (nachar / (2.0d0 + (((eaccept / kbt) / vef) * vef)))
                                                              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 tmp;
                                                          	if (KbT <= -1.18e+45) {
                                                          		tmp = t_0 + (NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / KbT)))));
                                                          	} else if (KbT <= 4.4e+96) {
                                                          		tmp = NaChar / (Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                          	} else {
                                                          		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                          	}
                                                          	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)))
                                                          	tmp = 0
                                                          	if KbT <= -1.18e+45:
                                                          		tmp = t_0 + (NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / KbT)))))
                                                          	elif KbT <= 4.4e+96:
                                                          		tmp = NaChar / (math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0)
                                                          	else:
                                                          		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)))
                                                          	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))))
                                                          	tmp = 0.0
                                                          	if (KbT <= -1.18e+45)
                                                          		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(EAccept * Float64(Float64(Float64(Float64(Float64(Ev + Vef) - mu) / KbT) / EAccept) - Float64(-1.0 / KbT))))));
                                                          	elseif (KbT <= 4.4e+96)
                                                          		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0));
                                                          	else
                                                          		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(EAccept / KbT) / Vef) * Vef))));
                                                          	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)));
                                                          	tmp = 0.0;
                                                          	if (KbT <= -1.18e+45)
                                                          		tmp = t_0 + (NaChar / (2.0 + (EAccept * (((((Ev + Vef) - mu) / KbT) / EAccept) - (-1.0 / KbT)))));
                                                          	elseif (KbT <= 4.4e+96)
                                                          		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                          	else
                                                          		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                          	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]}, If[LessEqual[KbT, -1.18e+45], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(EAccept * N[(N[(N[(N[(N[(Ev + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision] / EAccept), $MachinePrecision] - N[(-1.0 / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 4.4e+96], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(EAccept / KbT), $MachinePrecision] / Vef), $MachinePrecision] * Vef), $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}}}\\
                                                          \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45}:\\
                                                          \;\;\;\;t\_0 + \frac{NaChar}{2 + EAccept \cdot \left(\frac{\frac{\left(Ev + Vef\right) - mu}{KbT}}{EAccept} - \frac{-1}{KbT}\right)}\\
                                                          
                                                          \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\
                                                          \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\
                                                          
                                                          
                                                          \end{array}
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 3 regimes
                                                          2. if KbT < -1.17999999999999993e45

                                                            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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                            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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                              3. div-addN/A

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

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

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

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

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

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

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

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

                                                              \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{\color{blue}{2 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \]
                                                            6. 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}{2 + -1 \cdot \color{blue}{\left(EAccept \cdot \left(-1 \cdot \frac{\left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right) - \frac{mu}{KbT}}{EAccept} - \frac{1}{KbT}\right)\right)}} \]
                                                            7. Step-by-step derivation
                                                              1. Applied rewrites82.6%

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

                                                              if -1.17999999999999993e45 < KbT < 4.3999999999999998e96

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

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

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

                                                              if 4.3999999999999998e96 < KbT

                                                              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                                2. 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}{2 + \frac{EAccept}{KbT \cdot Vef} \cdot Vef} \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites76.0%

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

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

                                                                Alternative 18: 65.1% accurate, 1.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}}}\\ \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot Vef}\\ \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\ \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))))))
                                                                   (if (<= KbT -1.18e+45)
                                                                     (+
                                                                      t_0
                                                                      (/
                                                                       NaChar
                                                                       (+ 2.0 (* (+ (/ 1.0 KbT) (/ (/ (- (+ EAccept Ev) mu) KbT) Vef)) Vef))))
                                                                     (if (<= KbT 4.4e+96)
                                                                       (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))
                                                                       (+ t_0 (/ NaChar (+ 2.0 (* (/ (/ EAccept KbT) Vef) Vef))))))))
                                                                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 tmp;
                                                                	if (KbT <= -1.18e+45) {
                                                                		tmp = t_0 + (NaChar / (2.0 + (((1.0 / KbT) + ((((EAccept + Ev) - mu) / KbT) / Vef)) * Vef)));
                                                                	} else if (KbT <= 4.4e+96) {
                                                                		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                	} else {
                                                                		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                	}
                                                                	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)))
                                                                    if (kbt <= (-1.18d+45)) then
                                                                        tmp = t_0 + (nachar / (2.0d0 + (((1.0d0 / kbt) + ((((eaccept + ev) - mu) / kbt) / vef)) * vef)))
                                                                    else if (kbt <= 4.4d+96) then
                                                                        tmp = nachar / (exp(((((ev + vef) + eaccept) - mu) / kbt)) + 1.0d0)
                                                                    else
                                                                        tmp = t_0 + (nachar / (2.0d0 + (((eaccept / kbt) / vef) * vef)))
                                                                    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 tmp;
                                                                	if (KbT <= -1.18e+45) {
                                                                		tmp = t_0 + (NaChar / (2.0 + (((1.0 / KbT) + ((((EAccept + Ev) - mu) / KbT) / Vef)) * Vef)));
                                                                	} else if (KbT <= 4.4e+96) {
                                                                		tmp = NaChar / (Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                	} else {
                                                                		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                	}
                                                                	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)))
                                                                	tmp = 0
                                                                	if KbT <= -1.18e+45:
                                                                		tmp = t_0 + (NaChar / (2.0 + (((1.0 / KbT) + ((((EAccept + Ev) - mu) / KbT) / Vef)) * Vef)))
                                                                	elif KbT <= 4.4e+96:
                                                                		tmp = NaChar / (math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0)
                                                                	else:
                                                                		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)))
                                                                	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))))
                                                                	tmp = 0.0
                                                                	if (KbT <= -1.18e+45)
                                                                		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(1.0 / KbT) + Float64(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT) / Vef)) * Vef))));
                                                                	elseif (KbT <= 4.4e+96)
                                                                		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0));
                                                                	else
                                                                		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(EAccept / KbT) / Vef) * Vef))));
                                                                	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)));
                                                                	tmp = 0.0;
                                                                	if (KbT <= -1.18e+45)
                                                                		tmp = t_0 + (NaChar / (2.0 + (((1.0 / KbT) + ((((EAccept + Ev) - mu) / KbT) / Vef)) * Vef)));
                                                                	elseif (KbT <= 4.4e+96)
                                                                		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                	else
                                                                		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                	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]}, If[LessEqual[KbT, -1.18e+45], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(1.0 / KbT), $MachinePrecision] + N[(N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision] / Vef), $MachinePrecision]), $MachinePrecision] * Vef), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 4.4e+96], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(EAccept / KbT), $MachinePrecision] / Vef), $MachinePrecision] * Vef), $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}}}\\
                                                                \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45}:\\
                                                                \;\;\;\;t\_0 + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot Vef}\\
                                                                
                                                                \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\
                                                                \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\
                                                                
                                                                
                                                                \end{array}
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 3 regimes
                                                                2. if KbT < -1.17999999999999993e45

                                                                  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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                  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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                    3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

                                                                    if -1.17999999999999993e45 < KbT < 4.3999999999999998e96

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

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

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

                                                                    if 4.3999999999999998e96 < KbT

                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                                      2. 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}{2 + \frac{EAccept}{KbT \cdot Vef} \cdot Vef} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites76.0%

                                                                          \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef} \]
                                                                      4. Recombined 3 regimes into one program.
                                                                      5. Final simplification76.9%

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

                                                                      Alternative 19: 65.5% accurate, 1.4× speedup?

                                                                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\ t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ \mathbf{if}\;KbT \leq -9.5 \cdot 10^{+189}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + t\_1}\\ \mathbf{elif}\;KbT \leq -1.18 \cdot 10^{+45}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{1 + \frac{\left(EAccept + Ev\right) - mu}{Vef}}{KbT} \cdot Vef}\\ \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{NaChar}{t\_1 + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\ \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))))
                                                                         (if (<= KbT -9.5e+189)
                                                                           (+ (* 0.5 NdChar) (/ NaChar (+ 1.0 t_1)))
                                                                           (if (<= KbT -1.18e+45)
                                                                             (+
                                                                              t_0
                                                                              (/
                                                                               NaChar
                                                                               (+ 2.0 (* (/ (+ 1.0 (/ (- (+ EAccept Ev) mu) Vef)) KbT) Vef))))
                                                                             (if (<= KbT 4.4e+96)
                                                                               (/ NaChar (+ t_1 1.0))
                                                                               (+ t_0 (/ NaChar (+ 2.0 (* (/ (/ EAccept KbT) Vef) Vef)))))))))
                                                                      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 tmp;
                                                                      	if (KbT <= -9.5e+189) {
                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_1));
                                                                      	} else if (KbT <= -1.18e+45) {
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((1.0 + (((EAccept + Ev) - mu) / Vef)) / KbT) * Vef)));
                                                                      	} else if (KbT <= 4.4e+96) {
                                                                      		tmp = NaChar / (t_1 + 1.0);
                                                                      	} else {
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                      	}
                                                                      	return tmp;
                                                                      }
                                                                      
                                                                      module fmin_fmax_functions
                                                                          implicit none
                                                                          private
                                                                          public fmax
                                                                          public fmin
                                                                      
                                                                          interface fmax
                                                                              module procedure fmax88
                                                                              module procedure fmax44
                                                                              module procedure fmax84
                                                                              module procedure fmax48
                                                                          end interface
                                                                          interface fmin
                                                                              module procedure fmin88
                                                                              module procedure fmin44
                                                                              module procedure fmin84
                                                                              module procedure fmin48
                                                                          end interface
                                                                      contains
                                                                          real(8) function fmax88(x, y) result (res)
                                                                              real(8), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(4) function fmax44(x, y) result (res)
                                                                              real(4), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmax84(x, y) result(res)
                                                                              real(8), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmax48(x, y) result(res)
                                                                              real(4), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmin88(x, y) result (res)
                                                                              real(8), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(4) function fmin44(x, y) result (res)
                                                                              real(4), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmin84(x, y) result(res)
                                                                              real(8), intent (in) :: x
                                                                              real(4), intent (in) :: y
                                                                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                          end function
                                                                          real(8) function fmin48(x, y) result(res)
                                                                              real(4), intent (in) :: x
                                                                              real(8), intent (in) :: y
                                                                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                          end function
                                                                      end module
                                                                      
                                                                      real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
                                                                      use fmin_fmax_functions
                                                                          real(8), intent (in) :: ndchar
                                                                          real(8), intent (in) :: ec
                                                                          real(8), intent (in) :: vef
                                                                          real(8), intent (in) :: edonor
                                                                          real(8), intent (in) :: mu
                                                                          real(8), intent (in) :: kbt
                                                                          real(8), intent (in) :: nachar
                                                                          real(8), intent (in) :: ev
                                                                          real(8), intent (in) :: eaccept
                                                                          real(8) :: t_0
                                                                          real(8) :: t_1
                                                                          real(8) :: tmp
                                                                          t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
                                                                          t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
                                                                          if (kbt <= (-9.5d+189)) then
                                                                              tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + t_1))
                                                                          else if (kbt <= (-1.18d+45)) then
                                                                              tmp = t_0 + (nachar / (2.0d0 + (((1.0d0 + (((eaccept + ev) - mu) / vef)) / kbt) * vef)))
                                                                          else if (kbt <= 4.4d+96) then
                                                                              tmp = nachar / (t_1 + 1.0d0)
                                                                          else
                                                                              tmp = t_0 + (nachar / (2.0d0 + (((eaccept / kbt) / vef) * vef)))
                                                                          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 tmp;
                                                                      	if (KbT <= -9.5e+189) {
                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_1));
                                                                      	} else if (KbT <= -1.18e+45) {
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((1.0 + (((EAccept + Ev) - mu) / Vef)) / KbT) * Vef)));
                                                                      	} else if (KbT <= 4.4e+96) {
                                                                      		tmp = NaChar / (t_1 + 1.0);
                                                                      	} else {
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                      	}
                                                                      	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))
                                                                      	tmp = 0
                                                                      	if KbT <= -9.5e+189:
                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_1))
                                                                      	elif KbT <= -1.18e+45:
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((1.0 + (((EAccept + Ev) - mu) / Vef)) / KbT) * Vef)))
                                                                      	elif KbT <= 4.4e+96:
                                                                      		tmp = NaChar / (t_1 + 1.0)
                                                                      	else:
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)))
                                                                      	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))
                                                                      	tmp = 0.0
                                                                      	if (KbT <= -9.5e+189)
                                                                      		tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + t_1)));
                                                                      	elseif (KbT <= -1.18e+45)
                                                                      		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(1.0 + Float64(Float64(Float64(EAccept + Ev) - mu) / Vef)) / KbT) * Vef))));
                                                                      	elseif (KbT <= 4.4e+96)
                                                                      		tmp = Float64(NaChar / Float64(t_1 + 1.0));
                                                                      	else
                                                                      		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(EAccept / KbT) / Vef) * Vef))));
                                                                      	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));
                                                                      	tmp = 0.0;
                                                                      	if (KbT <= -9.5e+189)
                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_1));
                                                                      	elseif (KbT <= -1.18e+45)
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((1.0 + (((EAccept + Ev) - mu) / Vef)) / KbT) * Vef)));
                                                                      	elseif (KbT <= 4.4e+96)
                                                                      		tmp = NaChar / (t_1 + 1.0);
                                                                      	else
                                                                      		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                      	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]}, If[LessEqual[KbT, -9.5e+189], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, -1.18e+45], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(1.0 + N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision] * Vef), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 4.4e+96], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(EAccept / KbT), $MachinePrecision] / Vef), $MachinePrecision] * Vef), $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}}\\
                                                                      \mathbf{if}\;KbT \leq -9.5 \cdot 10^{+189}:\\
                                                                      \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + t\_1}\\
                                                                      
                                                                      \mathbf{elif}\;KbT \leq -1.18 \cdot 10^{+45}:\\
                                                                      \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{1 + \frac{\left(EAccept + Ev\right) - mu}{Vef}}{KbT} \cdot Vef}\\
                                                                      
                                                                      \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\
                                                                      \;\;\;\;\frac{NaChar}{t\_1 + 1}\\
                                                                      
                                                                      \mathbf{else}:\\
                                                                      \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\
                                                                      
                                                                      
                                                                      \end{array}
                                                                      \end{array}
                                                                      
                                                                      Derivation
                                                                      1. Split input into 4 regimes
                                                                      2. if KbT < -9.49999999999999911e189

                                                                        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-*.f6495.7

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

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

                                                                        if -9.49999999999999911e189 < KbT < -1.17999999999999993e45

                                                                        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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                        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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                          3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

                                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{\left(1 + \left(\frac{EAccept}{Vef} + \frac{Ev}{Vef}\right)\right) - \frac{mu}{Vef}}{KbT} \cdot Vef} \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites83.3%

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

                                                                            if -1.17999999999999993e45 < KbT < 4.3999999999999998e96

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

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

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

                                                                            if 4.3999999999999998e96 < KbT

                                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                                              2. 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}{2 + \frac{EAccept}{KbT \cdot Vef} \cdot Vef} \]
                                                                              3. Step-by-step derivation
                                                                                1. Applied rewrites76.0%

                                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef} \]
                                                                              4. Recombined 4 regimes into one program.
                                                                              5. Final simplification78.1%

                                                                                \[\leadsto \begin{array}{l} \mathbf{if}\;KbT \leq -9.5 \cdot 10^{+189}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{elif}\;KbT \leq -1.18 \cdot 10^{+45}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{1 + \frac{\left(EAccept + Ev\right) - mu}{Vef}}{KbT} \cdot Vef}\\ \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\ \end{array} \]
                                                                              6. Add Preprocessing

                                                                              Alternative 20: 64.6% accurate, 1.4× speedup?

                                                                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\ \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{Ev}{KbT}}{Vef} \cdot Vef}\\ \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\ \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))))))
                                                                                 (if (<= KbT -1.18e+45)
                                                                                   (+ t_0 (/ NaChar (+ 2.0 (* (/ (/ Ev KbT) Vef) Vef))))
                                                                                   (if (<= KbT 4.4e+96)
                                                                                     (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))
                                                                                     (+ t_0 (/ NaChar (+ 2.0 (* (/ (/ EAccept KbT) Vef) Vef))))))))
                                                                              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 tmp;
                                                                              	if (KbT <= -1.18e+45) {
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((Ev / KbT) / Vef) * Vef)));
                                                                              	} else if (KbT <= 4.4e+96) {
                                                                              		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                              	} else {
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                              	}
                                                                              	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)))
                                                                                  if (kbt <= (-1.18d+45)) then
                                                                                      tmp = t_0 + (nachar / (2.0d0 + (((ev / kbt) / vef) * vef)))
                                                                                  else if (kbt <= 4.4d+96) then
                                                                                      tmp = nachar / (exp(((((ev + vef) + eaccept) - mu) / kbt)) + 1.0d0)
                                                                                  else
                                                                                      tmp = t_0 + (nachar / (2.0d0 + (((eaccept / kbt) / vef) * vef)))
                                                                                  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 tmp;
                                                                              	if (KbT <= -1.18e+45) {
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((Ev / KbT) / Vef) * Vef)));
                                                                              	} else if (KbT <= 4.4e+96) {
                                                                              		tmp = NaChar / (Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                              	} else {
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                              	}
                                                                              	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)))
                                                                              	tmp = 0
                                                                              	if KbT <= -1.18e+45:
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((Ev / KbT) / Vef) * Vef)))
                                                                              	elif KbT <= 4.4e+96:
                                                                              		tmp = NaChar / (math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0)
                                                                              	else:
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)))
                                                                              	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))))
                                                                              	tmp = 0.0
                                                                              	if (KbT <= -1.18e+45)
                                                                              		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Ev / KbT) / Vef) * Vef))));
                                                                              	elseif (KbT <= 4.4e+96)
                                                                              		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0));
                                                                              	else
                                                                              		tmp = Float64(t_0 + Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(EAccept / KbT) / Vef) * Vef))));
                                                                              	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)));
                                                                              	tmp = 0.0;
                                                                              	if (KbT <= -1.18e+45)
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((Ev / KbT) / Vef) * Vef)));
                                                                              	elseif (KbT <= 4.4e+96)
                                                                              		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                              	else
                                                                              		tmp = t_0 + (NaChar / (2.0 + (((EAccept / KbT) / Vef) * Vef)));
                                                                              	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]}, If[LessEqual[KbT, -1.18e+45], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(Ev / KbT), $MachinePrecision] / Vef), $MachinePrecision] * Vef), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 4.4e+96], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(NaChar / N[(2.0 + N[(N[(N[(EAccept / KbT), $MachinePrecision] / Vef), $MachinePrecision] * Vef), $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}}}\\
                                                                              \mathbf{if}\;KbT \leq -1.18 \cdot 10^{+45}:\\
                                                                              \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{Ev}{KbT}}{Vef} \cdot Vef}\\
                                                                              
                                                                              \mathbf{elif}\;KbT \leq 4.4 \cdot 10^{+96}:\\
                                                                              \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
                                                                              
                                                                              \mathbf{else}:\\
                                                                              \;\;\;\;t\_0 + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef}\\
                                                                              
                                                                              
                                                                              \end{array}
                                                                              \end{array}
                                                                              
                                                                              Derivation
                                                                              1. Split input into 3 regimes
                                                                              2. if KbT < -1.17999999999999993e45

                                                                                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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                  3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                    if -1.17999999999999993e45 < KbT < 4.3999999999999998e96

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

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

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

                                                                                    if 4.3999999999999998e96 < KbT

                                                                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                        \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                                                      2. 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}{2 + \frac{EAccept}{KbT \cdot Vef} \cdot Vef} \]
                                                                                      3. Step-by-step derivation
                                                                                        1. Applied rewrites76.0%

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

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

                                                                                      Alternative 21: 64.8% accurate, 1.4× speedup?

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

                                                                                        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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                        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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                          3. div-addN/A

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

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

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

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

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

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

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

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

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

                                                                                        if -1.4e45 < KbT < 4.3999999999999998e96

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

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

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

                                                                                        if 4.3999999999999998e96 < KbT

                                                                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                            \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                                                          2. 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}{2 + \frac{EAccept}{KbT \cdot Vef} \cdot Vef} \]
                                                                                          3. Step-by-step derivation
                                                                                            1. Applied rewrites76.0%

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

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

                                                                                          Alternative 22: 64.8% accurate, 1.5× speedup?

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

                                                                                            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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                            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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                              3. div-addN/A

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

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

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

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

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

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

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

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

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

                                                                                            if -1.4e45 < KbT < 4.3999999999999998e96

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

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

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

                                                                                            if 4.3999999999999998e96 < KbT

                                                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \left(\frac{1}{KbT} + \frac{\frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot \color{blue}{Vef}} \]
                                                                                              2. 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}{2 + \frac{EAccept}{KbT \cdot Vef} \cdot Vef} \]
                                                                                              3. Step-by-step derivation
                                                                                                1. Applied rewrites76.0%

                                                                                                  \[\leadsto \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{\frac{EAccept}{KbT}}{Vef} \cdot Vef} \]
                                                                                                2. Step-by-step derivation
                                                                                                  1. Applied rewrites76.0%

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

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

                                                                                                Alternative 23: 65.1% accurate, 1.5× speedup?

                                                                                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}\\ \mathbf{if}\;KbT \leq -1.4 \cdot 10^{+45} \lor \neg \left(KbT \leq 3.2 \cdot 10^{+119}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{e^{t\_0} + 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 (or (<= KbT -1.4e+45) (not (<= KbT 3.2e+119)))
                                                                                                     (+
                                                                                                      (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                                                                                                      (/ NaChar (+ 2.0 t_0)))
                                                                                                     (/ NaChar (+ (exp 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 = (((Ev + Vef) + EAccept) - mu) / KbT;
                                                                                                	double tmp;
                                                                                                	if ((KbT <= -1.4e+45) || !(KbT <= 3.2e+119)) {
                                                                                                		tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + t_0));
                                                                                                	} else {
                                                                                                		tmp = NaChar / (exp(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) :: tmp
                                                                                                    t_0 = (((ev + vef) + eaccept) - mu) / kbt
                                                                                                    if ((kbt <= (-1.4d+45)) .or. (.not. (kbt <= 3.2d+119))) then
                                                                                                        tmp = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (2.0d0 + t_0))
                                                                                                    else
                                                                                                        tmp = nachar / (exp(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 = (((Ev + Vef) + EAccept) - mu) / KbT;
                                                                                                	double tmp;
                                                                                                	if ((KbT <= -1.4e+45) || !(KbT <= 3.2e+119)) {
                                                                                                		tmp = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + t_0));
                                                                                                	} else {
                                                                                                		tmp = NaChar / (Math.exp(t_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 <= -1.4e+45) or not (KbT <= 3.2e+119):
                                                                                                		tmp = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + t_0))
                                                                                                	else:
                                                                                                		tmp = NaChar / (math.exp(t_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 <= -1.4e+45) || !(KbT <= 3.2e+119))
                                                                                                		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(2.0 + t_0)));
                                                                                                	else
                                                                                                		tmp = Float64(NaChar / Float64(exp(t_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 <= -1.4e+45) || ~((KbT <= 3.2e+119)))
                                                                                                		tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + t_0));
                                                                                                	else
                                                                                                		tmp = NaChar / (exp(t_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[Or[LessEqual[KbT, -1.4e+45], N[Not[LessEqual[KbT, 3.2e+119]], $MachinePrecision]], 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[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[t$95$0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
                                                                                                
                                                                                                \begin{array}{l}
                                                                                                
                                                                                                \\
                                                                                                \begin{array}{l}
                                                                                                t_0 := \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}\\
                                                                                                \mathbf{if}\;KbT \leq -1.4 \cdot 10^{+45} \lor \neg \left(KbT \leq 3.2 \cdot 10^{+119}\right):\\
                                                                                                \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + t\_0}\\
                                                                                                
                                                                                                \mathbf{else}:\\
                                                                                                \;\;\;\;\frac{NaChar}{e^{t\_0} + 1}\\
                                                                                                
                                                                                                
                                                                                                \end{array}
                                                                                                \end{array}
                                                                                                
                                                                                                Derivation
                                                                                                1. Split input into 2 regimes
                                                                                                2. if KbT < -1.4e45 or 3.19999999999999989e119 < 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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                                  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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                                    3. div-addN/A

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

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

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

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

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

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

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

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

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

                                                                                                  if -1.4e45 < KbT < 3.19999999999999989e119

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

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

                                                                                                    \[\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 simplification76.1%

                                                                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;KbT \leq -1.4 \cdot 10^{+45} \lor \neg \left(KbT \leq 3.2 \cdot 10^{+119}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \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 24: 64.6% accurate, 1.6× speedup?

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

                                                                                                  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}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                                  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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                                    3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

                                                                                                    if -1.8e44 < KbT < 3.19999999999999989e119

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

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

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

                                                                                                    if 3.19999999999999989e119 < 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 Vef around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                    Alternative 25: 64.9% accurate, 1.6× speedup?

                                                                                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;KbT \leq -1.8 \cdot 10^{+44} \lor \neg \left(KbT \leq 7.8 \cdot 10^{+121}\right):\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{Vef}{KbT}}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\ \end{array} \end{array} \]
                                                                                                    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                                                                                                     :precision binary64
                                                                                                     (if (or (<= KbT -1.8e+44) (not (<= KbT 7.8e+121)))
                                                                                                       (+
                                                                                                        (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                                                                                                        (/ NaChar (+ 2.0 (/ Vef KbT))))
                                                                                                       (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))))
                                                                                                    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
                                                                                                    	double tmp;
                                                                                                    	if ((KbT <= -1.8e+44) || !(KbT <= 7.8e+121)) {
                                                                                                    		tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + (Vef / KbT)));
                                                                                                    	} else {
                                                                                                    		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 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) :: tmp
                                                                                                        if ((kbt <= (-1.8d+44)) .or. (.not. (kbt <= 7.8d+121))) then
                                                                                                            tmp = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (2.0d0 + (vef / kbt)))
                                                                                                        else
                                                                                                            tmp = nachar / (exp(((((ev + vef) + eaccept) - mu) / kbt)) + 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 tmp;
                                                                                                    	if ((KbT <= -1.8e+44) || !(KbT <= 7.8e+121)) {
                                                                                                    		tmp = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + (Vef / KbT)));
                                                                                                    	} else {
                                                                                                    		tmp = NaChar / (Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                                                    	}
                                                                                                    	return tmp;
                                                                                                    }
                                                                                                    
                                                                                                    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                                                                                                    	tmp = 0
                                                                                                    	if (KbT <= -1.8e+44) or not (KbT <= 7.8e+121):
                                                                                                    		tmp = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + (Vef / KbT)))
                                                                                                    	else:
                                                                                                    		tmp = NaChar / (math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0)
                                                                                                    	return tmp
                                                                                                    
                                                                                                    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                                                    	tmp = 0.0
                                                                                                    	if ((KbT <= -1.8e+44) || !(KbT <= 7.8e+121))
                                                                                                    		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(2.0 + Float64(Vef / KbT))));
                                                                                                    	else
                                                                                                    		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0));
                                                                                                    	end
                                                                                                    	return tmp
                                                                                                    end
                                                                                                    
                                                                                                    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                                                                                                    	tmp = 0.0;
                                                                                                    	if ((KbT <= -1.8e+44) || ~((KbT <= 7.8e+121)))
                                                                                                    		tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (2.0 + (Vef / KbT)));
                                                                                                    	else
                                                                                                    		tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
                                                                                                    	end
                                                                                                    	tmp_2 = tmp;
                                                                                                    end
                                                                                                    
                                                                                                    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[KbT, -1.8e+44], N[Not[LessEqual[KbT, 7.8e+121]], $MachinePrecision]], 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[(2.0 + N[(Vef / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
                                                                                                    
                                                                                                    \begin{array}{l}
                                                                                                    
                                                                                                    \\
                                                                                                    \begin{array}{l}
                                                                                                    \mathbf{if}\;KbT \leq -1.8 \cdot 10^{+44} \lor \neg \left(KbT \leq 7.8 \cdot 10^{+121}\right):\\
                                                                                                    \;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{2 + \frac{Vef}{KbT}}\\
                                                                                                    
                                                                                                    \mathbf{else}:\\
                                                                                                    \;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
                                                                                                    
                                                                                                    
                                                                                                    \end{array}
                                                                                                    \end{array}
                                                                                                    
                                                                                                    Derivation
                                                                                                    1. Split input into 2 regimes
                                                                                                    2. if KbT < -1.8e44 or 7.79999999999999967e121 < 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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                                      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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                                        3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

                                                                                                        if -1.8e44 < KbT < 7.79999999999999967e121

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

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

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

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

                                                                                                      Alternative 26: 64.2% accurate, 1.8× speedup?

                                                                                                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ \mathbf{if}\;KbT \leq -1.5 \cdot 10^{+45} \lor \neg \left(KbT \leq 3.8 \cdot 10^{+53}\right):\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + t\_0}\\ \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))))
                                                                                                         (if (or (<= KbT -1.5e+45) (not (<= KbT 3.8e+53)))
                                                                                                           (+ (* 0.5 NdChar) (/ NaChar (+ 1.0 t_0)))
                                                                                                           (/ 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 tmp;
                                                                                                      	if ((KbT <= -1.5e+45) || !(KbT <= 3.8e+53)) {
                                                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_0));
                                                                                                      	} 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) :: tmp
                                                                                                          t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
                                                                                                          if ((kbt <= (-1.5d+45)) .or. (.not. (kbt <= 3.8d+53))) then
                                                                                                              tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + t_0))
                                                                                                          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 tmp;
                                                                                                      	if ((KbT <= -1.5e+45) || !(KbT <= 3.8e+53)) {
                                                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_0));
                                                                                                      	} 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))
                                                                                                      	tmp = 0
                                                                                                      	if (KbT <= -1.5e+45) or not (KbT <= 3.8e+53):
                                                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_0))
                                                                                                      	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))
                                                                                                      	tmp = 0.0
                                                                                                      	if ((KbT <= -1.5e+45) || !(KbT <= 3.8e+53))
                                                                                                      		tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + t_0)));
                                                                                                      	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));
                                                                                                      	tmp = 0.0;
                                                                                                      	if ((KbT <= -1.5e+45) || ~((KbT <= 3.8e+53)))
                                                                                                      		tmp = (0.5 * NdChar) + (NaChar / (1.0 + t_0));
                                                                                                      	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]}, If[Or[LessEqual[KbT, -1.5e+45], N[Not[LessEqual[KbT, 3.8e+53]], $MachinePrecision]], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $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}}\\
                                                                                                      \mathbf{if}\;KbT \leq -1.5 \cdot 10^{+45} \lor \neg \left(KbT \leq 3.8 \cdot 10^{+53}\right):\\
                                                                                                      \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + t\_0}\\
                                                                                                      
                                                                                                      \mathbf{else}:\\
                                                                                                      \;\;\;\;\frac{NaChar}{t\_0 + 1}\\
                                                                                                      
                                                                                                      
                                                                                                      \end{array}
                                                                                                      \end{array}
                                                                                                      
                                                                                                      Derivation
                                                                                                      1. Split input into 2 regimes
                                                                                                      2. if KbT < -1.50000000000000005e45 or 3.79999999999999997e53 < 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 -1.50000000000000005e45 < KbT < 3.79999999999999997e53

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

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

                                                                                                        \[\leadsto \begin{array}{l} \mathbf{if}\;KbT \leq -1.5 \cdot 10^{+45} \lor \neg \left(KbT \leq 3.8 \cdot 10^{+53}\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 27: 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 -9 \cdot 10^{+181}:\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{elif}\;KbT \leq 4.2 \cdot 10^{+133}:\\ \;\;\;\;\frac{NaChar}{e^{t\_0} + 1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.25, NdChar \cdot \frac{\left(\left(mu + Vef\right) + EDonor\right) - Ec}{KbT}, 0.5 \cdot NdChar\right) + \frac{NaChar}{2 + t\_0}\\ \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 -9e+181)
                                                                                                           (* 0.5 (+ NaChar NdChar))
                                                                                                           (if (<= KbT 4.2e+133)
                                                                                                             (/ NaChar (+ (exp t_0) 1.0))
                                                                                                             (+
                                                                                                              (fma
                                                                                                               -0.25
                                                                                                               (* NdChar (/ (- (+ (+ mu Vef) EDonor) Ec) KbT))
                                                                                                               (* 0.5 NdChar))
                                                                                                              (/ NaChar (+ 2.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 (KbT <= -9e+181) {
                                                                                                      		tmp = 0.5 * (NaChar + NdChar);
                                                                                                      	} else if (KbT <= 4.2e+133) {
                                                                                                      		tmp = NaChar / (exp(t_0) + 1.0);
                                                                                                      	} else {
                                                                                                      		tmp = fma(-0.25, (NdChar * ((((mu + Vef) + EDonor) - Ec) / KbT)), (0.5 * NdChar)) + (NaChar / (2.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 (KbT <= -9e+181)
                                                                                                      		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                                                                                                      	elseif (KbT <= 4.2e+133)
                                                                                                      		tmp = Float64(NaChar / Float64(exp(t_0) + 1.0));
                                                                                                      	else
                                                                                                      		tmp = Float64(fma(-0.25, Float64(NdChar * Float64(Float64(Float64(Float64(mu + Vef) + EDonor) - Ec) / KbT)), Float64(0.5 * NdChar)) + Float64(NaChar / Float64(2.0 + t_0)));
                                                                                                      	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, -9e+181], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 4.2e+133], N[(NaChar / N[(N[Exp[t$95$0], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.25 * N[(NdChar * N[(N[(N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NdChar), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(2.0 + t$95$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 -9 \cdot 10^{+181}:\\
                                                                                                      \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                                                                                                      
                                                                                                      \mathbf{elif}\;KbT \leq 4.2 \cdot 10^{+133}:\\
                                                                                                      \;\;\;\;\frac{NaChar}{e^{t\_0} + 1}\\
                                                                                                      
                                                                                                      \mathbf{else}:\\
                                                                                                      \;\;\;\;\mathsf{fma}\left(-0.25, NdChar \cdot \frac{\left(\left(mu + Vef\right) + EDonor\right) - Ec}{KbT}, 0.5 \cdot NdChar\right) + \frac{NaChar}{2 + t\_0}\\
                                                                                                      
                                                                                                      
                                                                                                      \end{array}
                                                                                                      \end{array}
                                                                                                      
                                                                                                      Derivation
                                                                                                      1. Split input into 3 regimes
                                                                                                      2. if KbT < -9e181

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

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

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

                                                                                                        if -9e181 < KbT < 4.2e133

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

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

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

                                                                                                        if 4.2e133 < 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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                                        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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                                          3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                            \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, NdChar \cdot \frac{\left(\color{blue}{\left(mu + Vef\right)} + EDonor\right) - Ec}{KbT}, \frac{1}{2} \cdot NdChar\right) + \frac{NaChar}{2 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} \]
                                                                                                          10. lower-*.f6466.9

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

                                                                                                          \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, NdChar \cdot \frac{\left(\left(mu + Vef\right) + EDonor\right) - Ec}{KbT}, 0.5 \cdot NdChar\right)} + \frac{NaChar}{2 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} \]
                                                                                                      3. Recombined 3 regimes into one program.
                                                                                                      4. Final simplification69.6%

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

                                                                                                      Alternative 28: 55.1% accurate, 1.9× speedup?

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

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

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

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

                                                                                                        if -1.9000000000000001e181 < KbT < 4.2e133

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

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

                                                                                                          \[\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}{e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}} + 1} \]
                                                                                                        7. Step-by-step derivation
                                                                                                          1. Applied rewrites60.9%

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

                                                                                                          if 4.2e133 < 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 \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{\color{blue}{\left(2 + \left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right)\right) - \frac{mu}{KbT}}} \]
                                                                                                          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}{\color{blue}{2 + \left(\left(\frac{EAccept}{KbT} + \left(\frac{Ev}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}\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}{2 + \left(\left(\frac{EAccept}{KbT} + \color{blue}{\frac{Ev + Vef}{KbT}}\right) - \frac{mu}{KbT}\right)} \]
                                                                                                            3. div-addN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, NdChar \cdot \frac{\left(\color{blue}{\left(mu + Vef\right)} + EDonor\right) - Ec}{KbT}, \frac{1}{2} \cdot NdChar\right) + \frac{NaChar}{2 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} \]
                                                                                                            10. lower-*.f6466.9

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

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

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

                                                                                                        Alternative 29: 41.8% accurate, 2.0× speedup?

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

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

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

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

                                                                                                          if -3.9e11 < KbT < 3.69999999999999985e105

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

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

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

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

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

                                                                                                            if 3.69999999999999985e105 < KbT

                                                                                                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, NdChar \cdot \frac{\left(\left(mu + Vef\right) + EDonor\right) - Ec}{KbT}, 0.5 \cdot NdChar\right)} + \frac{NaChar}{2 + \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} \]
                                                                                                          8. Recombined 3 regimes into one program.
                                                                                                          9. Final simplification49.6%

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

                                                                                                          Alternative 30: 22.3% accurate, 15.3× speedup?

                                                                                                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NaChar \leq -7.8 \cdot 10^{-162} \lor \neg \left(NaChar \leq 2.3 \cdot 10^{+68}\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 -7.8e-162) (not (<= NaChar 2.3e+68)))
                                                                                                             (* 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 <= -7.8e-162) || !(NaChar <= 2.3e+68)) {
                                                                                                          		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 <= (-7.8d-162)) .or. (.not. (nachar <= 2.3d+68))) 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 <= -7.8e-162) || !(NaChar <= 2.3e+68)) {
                                                                                                          		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 <= -7.8e-162) or not (NaChar <= 2.3e+68):
                                                                                                          		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 <= -7.8e-162) || !(NaChar <= 2.3e+68))
                                                                                                          		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 <= -7.8e-162) || ~((NaChar <= 2.3e+68)))
                                                                                                          		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, -7.8e-162], N[Not[LessEqual[NaChar, 2.3e+68]], $MachinePrecision]], N[(0.5 * NaChar), $MachinePrecision], N[(0.5 * NdChar), $MachinePrecision]]
                                                                                                          
                                                                                                          \begin{array}{l}
                                                                                                          
                                                                                                          \\
                                                                                                          \begin{array}{l}
                                                                                                          \mathbf{if}\;NaChar \leq -7.8 \cdot 10^{-162} \lor \neg \left(NaChar \leq 2.3 \cdot 10^{+68}\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 < -7.7999999999999999e-162 or 2.3e68 < 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-+.f6427.4

                                                                                                                \[\leadsto 0.5 \cdot \color{blue}{\left(NaChar + NdChar\right)} \]
                                                                                                            5. Applied rewrites27.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 rewrites24.9%

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

                                                                                                              if -7.7999999999999999e-162 < NaChar < 2.3e68

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

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

                                                                                                                \[\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 rewrites32.1%

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

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

                                                                                                              Alternative 31: 27.7% 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 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-+.f6430.9

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

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

                                                                                                              Alternative 32: 18.1% 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 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-+.f6430.9

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

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

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

                                                                                                                Reproduce

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