Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 11.1s
Alternatives: 20
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 20 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, 0.7× speedup?

\[\begin{array}{l} \\ \frac{NdChar}{1 + {\left(e^{\frac{\left(\left(Ec - Vef\right) - EDonor\right) - mu}{KbT}}\right)}^{-1}} + \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 (pow (exp (/ (- (- (- Ec Vef) EDonor) mu) KbT)) -1.0)))
  (/ 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 + pow(exp(((((Ec - Vef) - EDonor) - mu) / KbT)), -1.0))) + (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)) ** (-1.0d0)))) + (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.pow(Math.exp(((((Ec - Vef) - EDonor) - mu) / KbT)), -1.0))) + (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.pow(math.exp(((((Ec - Vef) - EDonor) - mu) / KbT)), -1.0))) + (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(Ec - Vef) - EDonor) - mu) / KbT)) ^ -1.0))) + 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)) ^ -1.0))) + (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[Power[N[Exp[N[(N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision], -1.0], $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 + {\left(e^{\frac{\left(\left(Ec - Vef\right) - EDonor\right) - mu}{KbT}}\right)}^{-1}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}
\end{array}
Derivation
  1. Initial program 99.9%

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

      \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

      \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
    3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

Alternative 2: 87.2% accurate, 0.3× speedup?

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

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

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
    t_1 = nachar / (1.0d0 + t_0)
    t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
    if ((t_2 <= (-5d-292)) .or. (.not. (t_2 <= 5d-64))) then
        tmp = (ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))) + t_1
    else
        tmp = nachar / (t_0 + 1.0d0)
    end if
    code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_1 = NaChar / (1.0 + t_0);
	double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
	double tmp;
	if ((t_2 <= -5e-292) || !(t_2 <= 5e-64)) {
		tmp = (NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + t_1;
	} else {
		tmp = NaChar / (t_0 + 1.0);
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
	t_1 = NaChar / (1.0 + t_0)
	t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1
	tmp = 0
	if (t_2 <= -5e-292) or not (t_2 <= 5e-64):
		tmp = (NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + t_1
	else:
		tmp = NaChar / (t_0 + 1.0)
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
	t_1 = Float64(NaChar / Float64(1.0 + t_0))
	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1)
	tmp = 0.0
	if ((t_2 <= -5e-292) || !(t_2 <= 5e-64))
		tmp = Float64(Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + t_1);
	else
		tmp = Float64(NaChar / Float64(t_0 + 1.0));
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	t_1 = NaChar / (1.0 + t_0);
	t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
	tmp = 0.0;
	if ((t_2 <= -5e-292) || ~((t_2 <= 5e-64)))
		tmp = (NdChar / (1.0 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + t_1;
	else
		tmp = NaChar / (t_0 + 1.0);
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e-292], N[Not[LessEqual[t$95$2, 5e-64]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $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 -5 \cdot 10^{-292} \lor \neg \left(t\_2 \leq 5 \cdot 10^{-64}\right):\\
\;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + 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))))) < -4.99999999999999981e-292 or 5.00000000000000033e-64 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

    1. Initial program 99.9%

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

        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -5 \cdot 10^{-292} \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^{-64}\right):\\ \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \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 3: 74.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_1 := \frac{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^{-122} \lor \neg \left(t\_1 \leq 10^{-58}\right):\\ \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \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-122) (not (<= t_1 1e-58)))
     (+
      (/
       NdChar
       (+ 1.0 (pow (+ 1.0 (/ (- Ec (+ (+ mu Vef) EDonor)) KbT)) -1.0)))
      (/ NaChar (+ 1.0 (exp (/ Ev KbT)))))
     (/ 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-122) || !(t_1 <= 1e-58)) {
		tmp = (NdChar / (1.0 + pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + exp((Ev / KbT))));
	} 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-122)) .or. (.not. (t_1 <= 1d-58))) then
        tmp = (ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))) + (nachar / (1.0d0 + exp((ev / kbt))))
    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-122) || !(t_1 <= 1e-58)) {
		tmp = (NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + Math.exp((Ev / KbT))));
	} 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-122) or not (t_1 <= 1e-58):
		tmp = (NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + math.exp((Ev / KbT))))
	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-122) || !(t_1 <= 1e-58))
		tmp = Float64(Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT)))));
	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-122) || ~((t_1 <= 1e-58)))
		tmp = (NdChar / (1.0 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + (NaChar / (1.0 + exp((Ev / KbT))));
	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-122], N[Not[LessEqual[t$95$1, 1e-58]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $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^{-122} \lor \neg \left(t\_1 \leq 10^{-58}\right):\\
\;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\

\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))))) < -4.9999999999999999e-122 or 1e-58 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

    1. Initial program 99.9%

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

        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.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 -5 \cdot 10^{-183} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-64}\right):\\ \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \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-183) (not (<= t_1 5e-64)))
     (+
      (/
       NdChar
       (+ 1.0 (pow (+ 1.0 (/ (- Ec (+ (+ mu Vef) EDonor)) KbT)) -1.0)))
      (/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
     (/ 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-183) || !(t_1 <= 5e-64)) {
		tmp = (NdChar / (1.0 + pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + exp((EAccept / KbT))));
	} 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-183)) .or. (.not. (t_1 <= 5d-64))) then
        tmp = (ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))) + (nachar / (1.0d0 + exp((eaccept / kbt))))
    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-183) || !(t_1 <= 5e-64)) {
		tmp = (NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + Math.exp((EAccept / KbT))));
	} 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-183) or not (t_1 <= 5e-64):
		tmp = (NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + math.exp((EAccept / KbT))))
	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-183) || !(t_1 <= 5e-64))
		tmp = Float64(Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT)))));
	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-183) || ~((t_1 <= 5e-64)))
		tmp = (NdChar / (1.0 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + (NaChar / (1.0 + exp((EAccept / KbT))));
	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-183], N[Not[LessEqual[t$95$1, 5e-64]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $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^{-183} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-64}\right):\\
\;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\

\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.0000000000000002e-183 or 5.00000000000000033e-64 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

    1. Initial program 99.9%

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

        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 73.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}}\\ t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_1}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-122}:\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\ \mathbf{elif}\;t\_2 \leq 10^{-58}:\\ \;\;\;\;\frac{NaChar}{t\_1 + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\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 (pow (+ 1.0 (/ (- Ec (+ (+ mu Vef) EDonor)) KbT)) -1.0))))
        (t_1 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
        (t_2
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
          (/ NaChar (+ 1.0 t_1)))))
   (if (<= t_2 -5e-122)
     (+ t_0 (/ NaChar (+ 1.0 (exp (/ Ev KbT)))))
     (if (<= t_2 1e-58)
       (/ NaChar (+ t_1 1.0))
       (+ t_0 (/ NaChar (+ 1.0 (exp (/ Vef KbT)))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = NdChar / (1.0 + pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0));
	double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
	double tmp;
	if (t_2 <= -5e-122) {
		tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT))));
	} else if (t_2 <= 1e-58) {
		tmp = NaChar / (t_1 + 1.0);
	} else {
		tmp = t_0 + (NaChar / (1.0 + exp((Vef / KbT))));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))
    t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
    t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_1))
    if (t_2 <= (-5d-122)) then
        tmp = t_0 + (nachar / (1.0d0 + exp((ev / kbt))))
    else if (t_2 <= 1d-58) then
        tmp = nachar / (t_1 + 1.0d0)
    else
        tmp = t_0 + (nachar / (1.0d0 + exp((vef / kbt))))
    end if
    code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0));
	double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
	double tmp;
	if (t_2 <= -5e-122) {
		tmp = t_0 + (NaChar / (1.0 + Math.exp((Ev / KbT))));
	} else if (t_2 <= 1e-58) {
		tmp = NaChar / (t_1 + 1.0);
	} else {
		tmp = t_0 + (NaChar / (1.0 + Math.exp((Vef / KbT))));
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))
	t_1 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))
	t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1))
	tmp = 0
	if t_2 <= -5e-122:
		tmp = t_0 + (NaChar / (1.0 + math.exp((Ev / KbT))))
	elif t_2 <= 1e-58:
		tmp = NaChar / (t_1 + 1.0)
	else:
		tmp = t_0 + (NaChar / (1.0 + math.exp((Vef / KbT))))
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0)))
	t_1 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))
	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_1)))
	tmp = 0.0
	if (t_2 <= -5e-122)
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT)))));
	elseif (t_2 <= 1e-58)
		tmp = Float64(NaChar / Float64(t_1 + 1.0));
	else
		tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(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 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0));
	t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
	t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
	tmp = 0.0;
	if (t_2 <= -5e-122)
		tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT))));
	elseif (t_2 <= 1e-58)
		tmp = NaChar / (t_1 + 1.0);
	else
		tmp = t_0 + (NaChar / (1.0 + exp((Vef / KbT))));
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(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$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-122], N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-58], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_2 \leq 10^{-58}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\

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


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

    1. Initial program 99.8%

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

        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e-58 < (+.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. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 64.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(Ev + Vef\right) + EAccept\\ t_1 := \frac{t\_0 - mu}{KbT}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{t\_1}}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{-183} \lor \neg \left(t\_2 \leq 10^{-58}\right):\\ \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + \left(1 + t\_1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{t\_0}{KbT}} + 1}\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (+ (+ Ev Vef) EAccept))
        (t_1 (/ (- t_0 mu) KbT))
        (t_2
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
          (/ NaChar (+ 1.0 (exp t_1))))))
   (if (or (<= t_2 -5e-183) (not (<= t_2 1e-58)))
     (+
      (/
       NdChar
       (+ 1.0 (pow (+ 1.0 (/ (- Ec (+ (+ mu Vef) EDonor)) KbT)) -1.0)))
      (/ NaChar (+ 1.0 (+ 1.0 t_1))))
     (/ NaChar (+ (exp (/ t_0 KbT)) 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;
	double t_1 = (t_0 - mu) / KbT;
	double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(t_1)));
	double tmp;
	if ((t_2 <= -5e-183) || !(t_2 <= 1e-58)) {
		tmp = (NdChar / (1.0 + pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.0 + t_1)));
	} else {
		tmp = NaChar / (exp((t_0 / 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) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (ev + vef) + eaccept
    t_1 = (t_0 - mu) / kbt
    t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(t_1)))
    if ((t_2 <= (-5d-183)) .or. (.not. (t_2 <= 1d-58))) then
        tmp = (ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))) + (nachar / (1.0d0 + (1.0d0 + t_1)))
    else
        tmp = nachar / (exp((t_0 / 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 t_0 = (Ev + Vef) + EAccept;
	double t_1 = (t_0 - mu) / KbT;
	double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(t_1)));
	double tmp;
	if ((t_2 <= -5e-183) || !(t_2 <= 1e-58)) {
		tmp = (NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.0 + t_1)));
	} else {
		tmp = NaChar / (Math.exp((t_0 / KbT)) + 1.0);
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = (Ev + Vef) + EAccept
	t_1 = (t_0 - mu) / KbT
	t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(t_1)))
	tmp = 0
	if (t_2 <= -5e-183) or not (t_2 <= 1e-58):
		tmp = (NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.0 + t_1)))
	else:
		tmp = NaChar / (math.exp((t_0 / KbT)) + 1.0)
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(Float64(Ev + Vef) + EAccept)
	t_1 = Float64(Float64(t_0 - mu) / KbT)
	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(t_1))))
	tmp = 0.0
	if ((t_2 <= -5e-183) || !(t_2 <= 1e-58))
		tmp = Float64(Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + Float64(NaChar / Float64(1.0 + Float64(1.0 + t_1))));
	else
		tmp = Float64(NaChar / Float64(exp(Float64(t_0 / KbT)) + 1.0));
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = (Ev + Vef) + EAccept;
	t_1 = (t_0 - mu) / KbT;
	t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(t_1)));
	tmp = 0.0;
	if ((t_2 <= -5e-183) || ~((t_2 <= 1e-58)))
		tmp = (NdChar / (1.0 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + (NaChar / (1.0 + (1.0 + t_1)));
	else
		tmp = NaChar / (exp((t_0 / KbT)) + 1.0);
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - mu), $MachinePrecision] / KbT), $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] + N[(NaChar / N[(1.0 + N[Exp[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e-183], N[Not[LessEqual[t$95$2, 1e-58]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(t$95$0 / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{t\_0}{KbT}} + 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.0000000000000002e-183 or 1e-58 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

    1. Initial program 99.9%

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

        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 60.1% accurate, 0.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}}} + \frac{NaChar}{1 + e^{t\_0}}\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-299} \lor \neg \left(t\_1 \leq 2 \cdot 10^{-288}\right):\\ \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + \left(1 + t\_0\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - {KbT}^{-1}\right) \cdot mu}\\ \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))))
              (/ NaChar (+ 1.0 (exp t_0))))))
       (if (or (<= t_1 -2e-299) (not (<= t_1 2e-288)))
         (+
          (/
           NdChar
           (+ 1.0 (pow (+ 1.0 (/ (- Ec (+ (+ mu Vef) EDonor)) KbT)) -1.0)))
          (/ NaChar (+ 1.0 (+ 1.0 t_0))))
         (/
          NaChar
          (+
           2.0
           (* (- (/ (/ (+ EAccept (+ Ev Vef)) KbT) mu) (pow KbT -1.0)) mu))))))
    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)))) + (NaChar / (1.0 + exp(t_0)));
    	double tmp;
    	if ((t_1 <= -2e-299) || !(t_1 <= 2e-288)) {
    		tmp = (NdChar / (1.0 + pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.0 + t_0)));
    	} else {
    		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - pow(KbT, -1.0)) * 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) :: t_1
        real(8) :: tmp
        t_0 = (((ev + vef) + eaccept) - mu) / kbt
        t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(t_0)))
        if ((t_1 <= (-2d-299)) .or. (.not. (t_1 <= 2d-288))) then
            tmp = (ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))) + (nachar / (1.0d0 + (1.0d0 + t_0)))
        else
            tmp = nachar / (2.0d0 + (((((eaccept + (ev + vef)) / kbt) / mu) - (kbt ** (-1.0d0))) * 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 = (((Ev + Vef) + EAccept) - mu) / KbT;
    	double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(t_0)));
    	double tmp;
    	if ((t_1 <= -2e-299) || !(t_1 <= 2e-288)) {
    		tmp = (NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.0 + t_0)));
    	} else {
    		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - Math.pow(KbT, -1.0)) * mu));
    	}
    	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)))) + (NaChar / (1.0 + math.exp(t_0)))
    	tmp = 0
    	if (t_1 <= -2e-299) or not (t_1 <= 2e-288):
    		tmp = (NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.0 + t_0)))
    	else:
    		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - math.pow(KbT, -1.0)) * mu))
    	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(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(t_0))))
    	tmp = 0.0
    	if ((t_1 <= -2e-299) || !(t_1 <= 2e-288))
    		tmp = Float64(Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + Float64(NaChar / Float64(1.0 + Float64(1.0 + t_0))));
    	else
    		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT) / mu) - (KbT ^ -1.0)) * mu)));
    	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)))) + (NaChar / (1.0 + exp(t_0)));
    	tmp = 0.0;
    	if ((t_1 <= -2e-299) || ~((t_1 <= 2e-288)))
    		tmp = (NdChar / (1.0 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + (NaChar / (1.0 + (1.0 + t_0)));
    	else
    		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - (KbT ^ -1.0)) * mu));
    	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[(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[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-299], N[Not[LessEqual[t$95$1, 2e-288]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision] / mu), $MachinePrecision] - N[Power[KbT, -1.0], $MachinePrecision]), $MachinePrecision] * mu), $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}}} + \frac{NaChar}{1 + e^{t\_0}}\\
    \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-299} \lor \neg \left(t\_1 \leq 2 \cdot 10^{-288}\right):\\
    \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + \left(1 + t\_0\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - {KbT}^{-1}\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.99999999999999998e-299 or 2.00000000000000012e-288 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

      1. Initial program 99.9%

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

          \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

          \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
        3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1.99999999999999998e-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))))) < 2.00000000000000012e-288

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

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

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

          \[\leadsto \frac{NaChar}{2 + \color{blue}{\frac{\left(\left(Ev + Vef\right) + EAccept\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 rewrites84.4%

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

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

        Alternative 8: 39.8% 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^{-259} \lor \neg \left(t\_0 \leq 10^{-82}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - {KbT}^{-1}\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-259) (not (<= t_0 1e-82)))
             (* 0.5 (+ NaChar NdChar))
             (/
              NaChar
              (+
               2.0
               (* (- (/ (/ (+ EAccept (+ Ev Vef)) KbT) mu) (pow KbT -1.0)) 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-259) || !(t_0 <= 1e-82)) {
        		tmp = 0.5 * (NaChar + NdChar);
        	} else {
        		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - pow(KbT, -1.0)) * 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-259)) .or. (.not. (t_0 <= 1d-82))) then
                tmp = 0.5d0 * (nachar + ndchar)
            else
                tmp = nachar / (2.0d0 + (((((eaccept + (ev + vef)) / kbt) / mu) - (kbt ** (-1.0d0))) * 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-259) || !(t_0 <= 1e-82)) {
        		tmp = 0.5 * (NaChar + NdChar);
        	} else {
        		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - Math.pow(KbT, -1.0)) * 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-259) or not (t_0 <= 1e-82):
        		tmp = 0.5 * (NaChar + NdChar)
        	else:
        		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - math.pow(KbT, -1.0)) * 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-259) || !(t_0 <= 1e-82))
        		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) - (KbT ^ -1.0)) * 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-259) || ~((t_0 <= 1e-82)))
        		tmp = 0.5 * (NaChar + NdChar);
        	else
        		tmp = NaChar / (2.0 + (((((EAccept + (Ev + Vef)) / KbT) / mu) - (KbT ^ -1.0)) * 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-259], N[Not[LessEqual[t$95$0, 1e-82]], $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[Power[KbT, -1.0], $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^{-259} \lor \neg \left(t\_0 \leq 10^{-82}\right):\\
        \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - {KbT}^{-1}\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))))) < -2.0000000000000001e-259 or 1e-82 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

          1. Initial program 99.9%

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

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

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

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
            3. lower-+.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 -2.0000000000000001e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-82

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

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

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

              \[\leadsto \frac{NaChar}{2 + \color{blue}{\frac{\left(\left(Ev + Vef\right) + EAccept\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 rewrites63.5%

                \[\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 simplification47.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^{-259} \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 10^{-82}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \left(\frac{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}{mu} - {KbT}^{-1}\right) \cdot mu}\\ \end{array} \]
            6. Add Preprocessing

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

              1. Initial program 99.9%

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

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

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

                  \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                3. lower-+.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 -2.0000000000000001e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-82

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

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

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

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

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

              Alternative 10: 36.9% accurate, 0.5× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-259} \lor \neg \left(t\_0 \leq 10^{-82}\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-259) (not (<= t_0 1e-82)))
                   (* 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-259) || !(t_0 <= 1e-82)) {
              		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-259)) .or. (.not. (t_0 <= 1d-82))) 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-259) || !(t_0 <= 1e-82)) {
              		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-259) or not (t_0 <= 1e-82):
              		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-259) || !(t_0 <= 1e-82))
              		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-259) || ~((t_0 <= 1e-82)))
              		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-259], N[Not[LessEqual[t$95$0, 1e-82]], $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^{-259} \lor \neg \left(t\_0 \leq 10^{-82}\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))))) < -2.0000000000000001e-259 or 1e-82 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                1. Initial program 99.9%

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

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

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

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                  3. lower-+.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 -2.0000000000000001e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-82

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

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

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

                    \[\leadsto \frac{NaChar}{2 + \color{blue}{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{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 rewrites58.3%

                      \[\leadsto \frac{NaChar}{2 + \frac{\left(Ev + Vef\right) - mu}{KbT}} \]
                  4. Recombined 2 regimes into one program.
                  5. Final simplification45.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}} \leq -2 \cdot 10^{-259} \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 10^{-82}\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 11: 36.9% accurate, 0.5× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-259} \lor \neg \left(t\_0 \leq 10^{-82}\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{2 + \frac{\left(EAccept + 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-259) (not (<= t_0 1e-82)))
                       (* 0.5 (+ NaChar NdChar))
                       (/ NaChar (+ 2.0 (/ (- (+ EAccept 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-259) || !(t_0 <= 1e-82)) {
                  		tmp = 0.5 * (NaChar + NdChar);
                  	} else {
                  		tmp = NaChar / (2.0 + (((EAccept + 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-259)) .or. (.not. (t_0 <= 1d-82))) then
                          tmp = 0.5d0 * (nachar + ndchar)
                      else
                          tmp = nachar / (2.0d0 + (((eaccept + 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-259) || !(t_0 <= 1e-82)) {
                  		tmp = 0.5 * (NaChar + NdChar);
                  	} else {
                  		tmp = NaChar / (2.0 + (((EAccept + 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-259) or not (t_0 <= 1e-82):
                  		tmp = 0.5 * (NaChar + NdChar)
                  	else:
                  		tmp = NaChar / (2.0 + (((EAccept + 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-259) || !(t_0 <= 1e-82))
                  		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                  	else
                  		tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(EAccept + 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-259) || ~((t_0 <= 1e-82)))
                  		tmp = 0.5 * (NaChar + NdChar);
                  	else
                  		tmp = NaChar / (2.0 + (((EAccept + 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-259], N[Not[LessEqual[t$95$0, 1e-82]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(EAccept + 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^{-259} \lor \neg \left(t\_0 \leq 10^{-82}\right):\\
                  \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{NaChar}{2 + \frac{\left(EAccept + 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))))) < -2.0000000000000001e-259 or 1e-82 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                    1. Initial program 99.9%

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

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

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

                        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(NaChar + NdChar\right)} \]
                      3. lower-+.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 -2.0000000000000001e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-82

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

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

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

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

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

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

                      Alternative 12: 34.6% accurate, 0.5× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-292} \lor \neg \left(t\_0 \leq 0\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-292) (not (<= t_0 0.0)))
                           (* 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-292) || !(t_0 <= 0.0)) {
                      		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-292)) .or. (.not. (t_0 <= 0.0d0))) 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-292) || !(t_0 <= 0.0)) {
                      		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-292) or not (t_0 <= 0.0):
                      		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-292) || !(t_0 <= 0.0))
                      		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-292) || ~((t_0 <= 0.0)))
                      		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-292], N[Not[LessEqual[t$95$0, 0.0]], $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^{-292} \lor \neg \left(t\_0 \leq 0\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))))) < -4.99999999999999981e-292 or -0.0 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                        1. Initial program 99.9%

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

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

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

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

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

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

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

                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{NaChar}{\frac{Vef}{KbT}} \]
                          4. Recombined 2 regimes into one program.
                          5. Final simplification40.3%

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

                          Alternative 13: 32.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^{-259} \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{NaChar}{\frac{Ev}{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-259) (not (<= t_0 0.0)))
                               (* 0.5 (+ NaChar NdChar))
                               (/ NaChar (/ Ev 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-259) || !(t_0 <= 0.0)) {
                          		tmp = 0.5 * (NaChar + NdChar);
                          	} else {
                          		tmp = NaChar / (Ev / 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-259)) .or. (.not. (t_0 <= 0.0d0))) then
                                  tmp = 0.5d0 * (nachar + ndchar)
                              else
                                  tmp = nachar / (ev / 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-259) || !(t_0 <= 0.0)) {
                          		tmp = 0.5 * (NaChar + NdChar);
                          	} else {
                          		tmp = NaChar / (Ev / 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-259) or not (t_0 <= 0.0):
                          		tmp = 0.5 * (NaChar + NdChar)
                          	else:
                          		tmp = NaChar / (Ev / 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-259) || !(t_0 <= 0.0))
                          		tmp = Float64(0.5 * Float64(NaChar + NdChar));
                          	else
                          		tmp = Float64(NaChar / Float64(Ev / 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-259) || ~((t_0 <= 0.0)))
                          		tmp = 0.5 * (NaChar + NdChar);
                          	else
                          		tmp = NaChar / (Ev / 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-259], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(Ev / 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 -2 \cdot 10^{-259} \lor \neg \left(t\_0 \leq 0\right):\\
                          \;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\frac{NaChar}{\frac{Ev}{KbT}}\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.0000000000000001e-259 or -0.0 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                            1. Initial program 99.9%

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

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

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

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

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

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

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

                            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

                                \[\leadsto \frac{NaChar}{\frac{Ev}{KbT}} \]
                              3. Step-by-step derivation
                                1. Applied rewrites41.3%

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

                              Alternative 14: 32.9% accurate, 0.5× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-259} \lor \neg \left(t\_0 \leq 0\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 -2e-259) (not (<= t_0 0.0)))
                                   (* 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 <= -2e-259) || !(t_0 <= 0.0)) {
                              		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 <= (-2d-259)) .or. (.not. (t_0 <= 0.0d0))) 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 <= -2e-259) || !(t_0 <= 0.0)) {
                              		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 <= -2e-259) or not (t_0 <= 0.0):
                              		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 <= -2e-259) || !(t_0 <= 0.0))
                              		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 <= -2e-259) || ~((t_0 <= 0.0)))
                              		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, -2e-259], N[Not[LessEqual[t$95$0, 0.0]], $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 -2 \cdot 10^{-259} \lor \neg \left(t\_0 \leq 0\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))))) < -2.0000000000000001e-259 or -0.0 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT)))))

                                1. Initial program 99.9%

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

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

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

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

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

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

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

                                1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \frac{NaChar}{\frac{EAccept}{KbT}} \]
                                  4. Recombined 2 regimes into one program.
                                  5. Final simplification35.8%

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

                                  Alternative 15: 100.0% accurate, 1.0× speedup?

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

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

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

                                  Alternative 16: 64.6% accurate, 1.4× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}\\ \mathbf{if}\;KbT \leq -5.8 \cdot 10^{+135} \lor \neg \left(KbT \leq 1.8 \cdot 10^{+209}\right):\\ \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + \left(1 + t\_0\right)}\\ \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 -5.8e+135) (not (<= KbT 1.8e+209)))
                                       (+
                                        (/
                                         NdChar
                                         (+ 1.0 (pow (+ 1.0 (/ (- Ec (+ (+ mu Vef) EDonor)) KbT)) -1.0)))
                                        (/ NaChar (+ 1.0 (+ 1.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 <= -5.8e+135) || !(KbT <= 1.8e+209)) {
                                  		tmp = (NdChar / (1.0 + pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.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 <= (-5.8d+135)) .or. (.not. (kbt <= 1.8d+209))) then
                                          tmp = (ndchar / (1.0d0 + ((1.0d0 + ((ec - ((mu + vef) + edonor)) / kbt)) ** (-1.0d0)))) + (nachar / (1.0d0 + (1.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 <= -5.8e+135) || !(KbT <= 1.8e+209)) {
                                  		tmp = (NdChar / (1.0 + Math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.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 <= -5.8e+135) or not (KbT <= 1.8e+209):
                                  		tmp = (NdChar / (1.0 + math.pow((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)), -1.0))) + (NaChar / (1.0 + (1.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 <= -5.8e+135) || !(KbT <= 1.8e+209))
                                  		tmp = Float64(Float64(NdChar / Float64(1.0 + (Float64(1.0 + Float64(Float64(Ec - Float64(Float64(mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + Float64(NaChar / Float64(1.0 + Float64(1.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 <= -5.8e+135) || ~((KbT <= 1.8e+209)))
                                  		tmp = (NdChar / (1.0 + ((1.0 + ((Ec - ((mu + Vef) + EDonor)) / KbT)) ^ -1.0))) + (NaChar / (1.0 + (1.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, -5.8e+135], N[Not[LessEqual[KbT, 1.8e+209]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Power[N[(1.0 + N[(N[(Ec - N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[(1.0 + t$95$0), $MachinePrecision]), $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 -5.8 \cdot 10^{+135} \lor \neg \left(KbT \leq 1.8 \cdot 10^{+209}\right):\\
                                  \;\;\;\;\frac{NdChar}{1 + {\left(1 + \frac{Ec - \left(\left(mu + Vef\right) + EDonor\right)}{KbT}\right)}^{-1}} + \frac{NaChar}{1 + \left(1 + t\_0\right)}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;\frac{NaChar}{e^{t\_0} + 1}\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if KbT < -5.7999999999999997e135 or 1.80000000000000006e209 < 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. Step-by-step derivation
                                      1. lift-exp.f64N/A

                                        \[\leadsto \frac{NdChar}{1 + \color{blue}{e^{\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. lift-/.f64N/A

                                        \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\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}}} \]
                                      3. lift-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    if -5.7999999999999997e135 < KbT < 1.80000000000000006e209

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

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

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

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

                                  Alternative 17: 69.7% accurate, 1.9× speedup?

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

                                    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

                                    if -1.95e-83 < NaChar < 9.00000000000000031e-84

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

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

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

                                        \[\leadsto 0.5 \cdot \color{blue}{NdChar} \]
                                      2. Taylor expanded in NdChar around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 18: 23.1% accurate, 15.3× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;NaChar \leq -6 \cdot 10^{-83} \lor \neg \left(NaChar \leq 1.6 \cdot 10^{+93}\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 -6e-83) (not (<= NaChar 1.6e+93)))
                                       (* 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 <= -6e-83) || !(NaChar <= 1.6e+93)) {
                                    		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 <= (-6d-83)) .or. (.not. (nachar <= 1.6d+93))) 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 <= -6e-83) || !(NaChar <= 1.6e+93)) {
                                    		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 <= -6e-83) or not (NaChar <= 1.6e+93):
                                    		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 <= -6e-83) || !(NaChar <= 1.6e+93))
                                    		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 <= -6e-83) || ~((NaChar <= 1.6e+93)))
                                    		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, -6e-83], N[Not[LessEqual[NaChar, 1.6e+93]], $MachinePrecision]], N[(0.5 * NaChar), $MachinePrecision], N[(0.5 * NdChar), $MachinePrecision]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    \mathbf{if}\;NaChar \leq -6 \cdot 10^{-83} \lor \neg \left(NaChar \leq 1.6 \cdot 10^{+93}\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 < -6.00000000000000021e-83 or 1.6000000000000001e93 < 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-+.f6425.4

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

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

                                        if -6.00000000000000021e-83 < NaChar < 1.6000000000000001e93

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

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

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

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

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

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

                                        Alternative 19: 27.8% accurate, 30.7× speedup?

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

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

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

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

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

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

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

                                        Alternative 20: 18.4% accurate, 46.0× speedup?

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

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

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

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

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

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

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

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

                                          Reproduce

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