Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 8.0s
Alternatives: 17
Speedup: N/A×

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}

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 17 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{-1}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}}, NdChar, \frac{NaChar}{e^{\frac{EAccept - \left(mu - \left(Ev + Vef\right)\right)}{KbT}} - -1}\right) \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (fma
  (/ -1.0 (- -1.0 (exp (/ (- mu (- (- Ec Vef) EDonor)) KbT))))
  NdChar
  (/ NaChar (- (exp (/ (- EAccept (- mu (+ Ev Vef))) KbT)) -1.0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	return fma((-1.0 / (-1.0 - exp(((mu - ((Ec - Vef) - EDonor)) / KbT)))), NdChar, (NaChar / (exp(((EAccept - (mu - (Ev + Vef))) / KbT)) - -1.0)));
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	return fma(Float64(-1.0 / Float64(-1.0 - exp(Float64(Float64(mu - Float64(Float64(Ec - Vef) - EDonor)) / KbT)))), NdChar, Float64(NaChar / Float64(exp(Float64(Float64(EAccept - Float64(mu - Float64(Ev + Vef))) / KbT)) - -1.0)))
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(-1.0 / N[(-1.0 - N[Exp[N[(N[(mu - N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * NdChar + N[(NaChar / N[(N[Exp[N[(N[(EAccept - N[(mu - N[(Ev + Vef), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

      \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - 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 \color{blue}{\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(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. mult-flipN/A

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

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

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

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

Alternative 2: 93.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ \mathbf{if}\;mu \leq -1.6 \cdot 10^{+173}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;mu \leq 8 \cdot 10^{+128}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}} + \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0
         (+
          (/ NdChar (+ 1.0 (exp (/ mu KbT))))
          (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
   (if (<= mu -1.6e+173)
     t_0
     (if (<= mu 8e+128)
       (+
        (/ NaChar (+ 1.0 (exp (/ (+ EAccept (+ Ev Vef)) KbT))))
        (/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT)))))
       t_0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
	double tmp;
	if (mu <= -1.6e+173) {
		tmp = t_0;
	} else if (mu <= 8e+128) {
		tmp = (NaChar / (1.0 + exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
    if (mu <= (-1.6d+173)) then
        tmp = t_0
    else if (mu <= 8d+128) then
        tmp = (nachar / (1.0d0 + exp(((eaccept + (ev + vef)) / kbt)))) + (ndchar / (1.0d0 + exp((((edonor + vef) - ec) / kbt))))
    else
        tmp = 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 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
	double tmp;
	if (mu <= -1.6e+173) {
		tmp = t_0;
	} else if (mu <= 8e+128) {
		tmp = (NaChar / (1.0 + Math.exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + Math.exp((((EDonor + Vef) - Ec) / KbT))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = (NdChar / (1.0 + math.exp((mu / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
	tmp = 0
	if mu <= -1.6e+173:
		tmp = t_0
	elif mu <= 8e+128:
		tmp = (NaChar / (1.0 + math.exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT))))
	else:
		tmp = t_0
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))))
	tmp = 0.0
	if (mu <= -1.6e+173)
		tmp = t_0;
	elseif (mu <= 8e+128)
		tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT)))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
	tmp = 0.0;
	if (mu <= -1.6e+173)
		tmp = t_0;
	elseif (mu <= 8e+128)
		tmp = (NaChar / (1.0 + exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT))));
	else
		tmp = t_0;
	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[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[mu, -1.6e+173], t$95$0, If[LessEqual[mu, 8e+128], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;mu \leq -1.6 \cdot 10^{+173}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;mu \leq 8 \cdot 10^{+128}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}} + \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if mu < -1.6000000000000001e173 or 8.0000000000000006e128 < mu

    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. Taylor expanded in mu around inf

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

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

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

    if -1.6000000000000001e173 < mu < 8.0000000000000006e128

    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. Taylor expanded in mu around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.4% accurate, 0.3× speedup?

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

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

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

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

\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-213}:\\
\;\;\;\;\frac{-NdChar}{-1 - e^{\frac{mu - t\_0}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_2\\


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

    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. Taylor expanded in EAccept around inf

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

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

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

    if -5.0000000000000002e-298 < (+.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.9999999999999999e-213

    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. Applied rewrites59.6%

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

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(NdChar\right)}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}} \]
      3. lower-neg.f6458.9

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

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

    if 1.9999999999999999e-213 < (+.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. Taylor expanded in mu around inf

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

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

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

Alternative 4: 79.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 10^{-306}:\\
\;\;\;\;\frac{-NdChar}{-1 - e^{\frac{mu - t\_0}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{Ev}{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))))) < -5.0000000000000002e-298

    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. Taylor expanded in EAccept around inf

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

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

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

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

    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. Applied rewrites59.6%

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

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(NdChar\right)}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}} \]
      3. lower-neg.f6458.9

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

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

    if 1.00000000000000003e-306 < (+.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. Taylor expanded in Ev around inf

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

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

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

Alternative 5: 74.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(Ec - Vef\right) - EDonor\\ t_1 := -1 - e^{\frac{mu - t\_0}{KbT}}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}}\\ t_3 := t\_2 + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ \mathbf{if}\;t\_3 \leq -5 \cdot 10^{-298}:\\ \;\;\;\;t\_2 + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\ \mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-213}:\\ \;\;\;\;\frac{-NdChar}{t\_1}\\ \mathbf{elif}\;t\_3 \leq 10000000000:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 \cdot NaChar - NdChar}{t\_1}\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (- (- Ec Vef) EDonor))
        (t_1 (- -1.0 (exp (/ (- mu t_0) KbT))))
        (t_2 (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT)))))
        (t_3
         (+
          t_2
          (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
   (if (<= t_3 -5e-298)
     (+ t_2 (/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
     (if (<= t_3 2e-213)
       (/ (- NdChar) t_1)
       (if (<= t_3 10000000000.0)
         (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))
         (/ (- (* -1.0 NaChar) NdChar) t_1))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = (Ec - Vef) - EDonor;
	double t_1 = -1.0 - exp(((mu - t_0) / KbT));
	double t_2 = NdChar / (1.0 + exp((-(t_0 - mu) / KbT)));
	double t_3 = t_2 + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
	double tmp;
	if (t_3 <= -5e-298) {
		tmp = t_2 + (NaChar / (1.0 + exp((EAccept / KbT))));
	} else if (t_3 <= 2e-213) {
		tmp = -NdChar / t_1;
	} else if (t_3 <= 10000000000.0) {
		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
	} else {
		tmp = ((-1.0 * NaChar) - NdChar) / t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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

\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-213}:\\
\;\;\;\;\frac{-NdChar}{t\_1}\\

\mathbf{elif}\;t\_3 \leq 10000000000:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot NaChar - NdChar}{t\_1}\\


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

    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. Taylor expanded in EAccept around inf

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

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

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

    if -5.0000000000000002e-298 < (+.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.9999999999999999e-213

    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. Applied rewrites59.6%

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

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(NdChar\right)}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}} \]
      3. lower-neg.f6458.9

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

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

    if 1.9999999999999999e-213 < (+.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))))) < 1e10

    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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

    if 1e10 < (+.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. Applied rewrites59.6%

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

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

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

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

Alternative 6: 69.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(Ec - Vef\right) - EDonor\\ t_1 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ t_2 := -1 - e^{\frac{mu - t\_0}{KbT}}\\ t_3 := \frac{-1 \cdot NaChar - NdChar}{t\_2}\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-73}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-213}:\\ \;\;\;\;\frac{-NdChar}{t\_2}\\ \mathbf{elif}\;t\_1 \leq 10000000000:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_3\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (- (- Ec Vef) EDonor))
        (t_1
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT))))
          (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
        (t_2 (- -1.0 (exp (/ (- mu t_0) KbT))))
        (t_3 (/ (- (* -1.0 NaChar) NdChar) t_2)))
   (if (<= t_1 -2e-73)
     t_3
     (if (<= t_1 2e-213)
       (/ (- NdChar) t_2)
       (if (<= t_1 10000000000.0)
         (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))
         t_3)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = (Ec - Vef) - EDonor;
	double t_1 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
	double t_2 = -1.0 - exp(((mu - t_0) / KbT));
	double t_3 = ((-1.0 * NaChar) - NdChar) / t_2;
	double tmp;
	if (t_1 <= -2e-73) {
		tmp = t_3;
	} else if (t_1 <= 2e-213) {
		tmp = -NdChar / t_2;
	} else if (t_1 <= 10000000000.0) {
		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
	} else {
		tmp = t_3;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-213}:\\
\;\;\;\;\frac{-NdChar}{t\_2}\\

\mathbf{elif}\;t\_1 \leq 10000000000:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;t\_3\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.99999999999999999e-73 or 1e10 < (+.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. Applied rewrites59.6%

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

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

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

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

    if -1.99999999999999999e-73 < (+.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.9999999999999999e-213

    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. Applied rewrites59.6%

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

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(NdChar\right)}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}} \]
      3. lower-neg.f6458.9

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

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

    if 1.9999999999999999e-213 < (+.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))))) < 1e10

    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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

Alternative 7: 68.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(Ec - Vef\right) - EDonor\\ t_1 := \mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{e^{\frac{EAccept - \left(mu - \left(Ev + Vef\right)\right)}{KbT}} - -1}\right)\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ \mathbf{if}\;t\_2 \leq -4 \cdot 10^{-24}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-213}:\\ \;\;\;\;\frac{-NdChar}{-1 - e^{\frac{mu - t\_0}{KbT}}}\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (- (- Ec Vef) EDonor))
        (t_1
         (fma
          0.5
          NdChar
          (/ NaChar (- (exp (/ (- EAccept (- mu (+ Ev Vef))) KbT)) -1.0))))
        (t_2
         (+
          (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT))))
          (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
   (if (<= t_2 -4e-24)
     t_1
     (if (<= t_2 2e-213)
       (/ (- NdChar) (- -1.0 (exp (/ (- mu t_0) KbT))))
       (if (<= t_2 5e-7)
         (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))
         t_1)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = (Ec - Vef) - EDonor;
	double t_1 = fma(0.5, NdChar, (NaChar / (exp(((EAccept - (mu - (Ev + Vef))) / KbT)) - -1.0)));
	double t_2 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
	double tmp;
	if (t_2 <= -4e-24) {
		tmp = t_1;
	} else if (t_2 <= 2e-213) {
		tmp = -NdChar / (-1.0 - exp(((mu - t_0) / KbT)));
	} else if (t_2 <= 5e-7) {
		tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(Float64(Ec - Vef) - EDonor)
	t_1 = fma(0.5, NdChar, Float64(NaChar / Float64(exp(Float64(Float64(EAccept - Float64(mu - Float64(Ev + Vef))) / KbT)) - -1.0)))
	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_0 - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))))
	tmp = 0.0
	if (t_2 <= -4e-24)
		tmp = t_1;
	elseif (t_2 <= 2e-213)
		tmp = Float64(Float64(-NdChar) / Float64(-1.0 - exp(Float64(Float64(mu - t_0) / KbT))));
	elseif (t_2 <= 5e-7)
		tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT))));
	else
		tmp = t_1;
	end
	return tmp
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * NdChar + N[(NaChar / N[(N[Exp[N[(N[(EAccept - N[(mu - N[(Ev + Vef), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$0 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-24], t$95$1, If[LessEqual[t$95$2, 2e-213], N[((-NdChar) / N[(-1.0 - N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-7], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-213}:\\
\;\;\;\;\frac{-NdChar}{-1 - e^{\frac{mu - t\_0}{KbT}}}\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -3.99999999999999969e-24 or 4.99999999999999977e-7 < (+.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. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - 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 \color{blue}{\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(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. mult-flipN/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{2}}, NdChar, \frac{NaChar}{e^{\frac{EAccept - \left(mu - \left(Ev + Vef\right)\right)}{KbT}} - -1}\right) \]
    5. Step-by-step derivation
      1. Applied rewrites47.0%

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

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

      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. Applied rewrites59.6%

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

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

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

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

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

          \[\leadsto \frac{\mathsf{neg}\left(NdChar\right)}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}} \]
        3. lower-neg.f6458.9

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

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

      if 1.9999999999999999e-213 < (+.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.99999999999999977e-7

      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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

    Alternative 8: 68.1% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ t_1 := \frac{-NdChar}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}}\\ \mathbf{if}\;NaChar \leq -1 \cdot 10^{-73}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;NaChar \leq 2.2 \cdot 10^{-107}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;NaChar \leq 1250000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;NaChar \leq 4.8 \cdot 10^{+122}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
     :precision binary64
     (let* ((t_0 (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)))))
            (t_1
             (/ (- NdChar) (- -1.0 (exp (/ (- mu (- (- Ec Vef) EDonor)) KbT))))))
       (if (<= NaChar -1e-73)
         t_0
         (if (<= NaChar 2.2e-107)
           t_1
           (if (<= NaChar 1250000000000.0)
             t_0
             (if (<= NaChar 4.8e+122) t_1 t_0))))))
    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
    	double t_0 = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
    	double t_1 = -NdChar / (-1.0 - exp(((mu - ((Ec - Vef) - EDonor)) / KbT)));
    	double tmp;
    	if (NaChar <= -1e-73) {
    		tmp = t_0;
    	} else if (NaChar <= 2.2e-107) {
    		tmp = t_1;
    	} else if (NaChar <= 1250000000000.0) {
    		tmp = t_0;
    	} else if (NaChar <= 4.8e+122) {
    		tmp = t_1;
    	} else {
    		tmp = 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 = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
        t_1 = -ndchar / ((-1.0d0) - exp(((mu - ((ec - vef) - edonor)) / kbt)))
        if (nachar <= (-1d-73)) then
            tmp = t_0
        else if (nachar <= 2.2d-107) then
            tmp = t_1
        else if (nachar <= 1250000000000.0d0) then
            tmp = t_0
        else if (nachar <= 4.8d+122) then
            tmp = t_1
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
    	double t_0 = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
    	double t_1 = -NdChar / (-1.0 - Math.exp(((mu - ((Ec - Vef) - EDonor)) / KbT)));
    	double tmp;
    	if (NaChar <= -1e-73) {
    		tmp = t_0;
    	} else if (NaChar <= 2.2e-107) {
    		tmp = t_1;
    	} else if (NaChar <= 1250000000000.0) {
    		tmp = t_0;
    	} else if (NaChar <= 4.8e+122) {
    		tmp = t_1;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
    	t_0 = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)))
    	t_1 = -NdChar / (-1.0 - math.exp(((mu - ((Ec - Vef) - EDonor)) / KbT)))
    	tmp = 0
    	if NaChar <= -1e-73:
    		tmp = t_0
    	elif NaChar <= 2.2e-107:
    		tmp = t_1
    	elif NaChar <= 1250000000000.0:
    		tmp = t_0
    	elif NaChar <= 4.8e+122:
    		tmp = t_1
    	else:
    		tmp = t_0
    	return tmp
    
    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
    	t_0 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT))))
    	t_1 = Float64(Float64(-NdChar) / Float64(-1.0 - exp(Float64(Float64(mu - Float64(Float64(Ec - Vef) - EDonor)) / KbT))))
    	tmp = 0.0
    	if (NaChar <= -1e-73)
    		tmp = t_0;
    	elseif (NaChar <= 2.2e-107)
    		tmp = t_1;
    	elseif (NaChar <= 1250000000000.0)
    		tmp = t_0;
    	elseif (NaChar <= 4.8e+122)
    		tmp = t_1;
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
    	t_0 = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
    	t_1 = -NdChar / (-1.0 - exp(((mu - ((Ec - Vef) - EDonor)) / KbT)));
    	tmp = 0.0;
    	if (NaChar <= -1e-73)
    		tmp = t_0;
    	elseif (NaChar <= 2.2e-107)
    		tmp = t_1;
    	elseif (NaChar <= 1250000000000.0)
    		tmp = t_0;
    	elseif (NaChar <= 4.8e+122)
    		tmp = t_1;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-NdChar) / N[(-1.0 - N[Exp[N[(N[(mu - N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[NaChar, -1e-73], t$95$0, If[LessEqual[NaChar, 2.2e-107], t$95$1, If[LessEqual[NaChar, 1250000000000.0], t$95$0, If[LessEqual[NaChar, 4.8e+122], t$95$1, t$95$0]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
    t_1 := \frac{-NdChar}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}}\\
    \mathbf{if}\;NaChar \leq -1 \cdot 10^{-73}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;NaChar \leq 2.2 \cdot 10^{-107}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;NaChar \leq 1250000000000:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;NaChar \leq 4.8 \cdot 10^{+122}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if NaChar < -9.99999999999999997e-74 or 2.20000000000000012e-107 < NaChar < 1.25e12 or 4.8000000000000004e122 < 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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

      if -9.99999999999999997e-74 < NaChar < 2.20000000000000012e-107 or 1.25e12 < NaChar < 4.8000000000000004e122

      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. Applied rewrites59.6%

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

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

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

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

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

          \[\leadsto \frac{\mathsf{neg}\left(NdChar\right)}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}} \]
        3. lower-neg.f6458.9

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

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

    Alternative 9: 63.5% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\ t_1 := \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \left(Ec - EDonor\right)}{KbT}}}\\ \mathbf{if}\;NaChar \leq -9.6 \cdot 10^{-74}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;NaChar \leq 1.35 \cdot 10^{-195}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;NaChar \leq 1250000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;NaChar \leq 4.8 \cdot 10^{+122}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
     :precision binary64
     (let* ((t_0 (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)))))
            (t_1 (/ (* -1.0 NdChar) (- -1.0 (exp (/ (- mu (- Ec EDonor)) KbT))))))
       (if (<= NaChar -9.6e-74)
         t_0
         (if (<= NaChar 1.35e-195)
           t_1
           (if (<= NaChar 1250000000000.0)
             t_0
             (if (<= NaChar 4.8e+122) t_1 t_0))))))
    double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
    	double t_0 = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
    	double t_1 = (-1.0 * NdChar) / (-1.0 - exp(((mu - (Ec - EDonor)) / KbT)));
    	double tmp;
    	if (NaChar <= -9.6e-74) {
    		tmp = t_0;
    	} else if (NaChar <= 1.35e-195) {
    		tmp = t_1;
    	} else if (NaChar <= 1250000000000.0) {
    		tmp = t_0;
    	} else if (NaChar <= 4.8e+122) {
    		tmp = t_1;
    	} else {
    		tmp = 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 = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
        t_1 = ((-1.0d0) * ndchar) / ((-1.0d0) - exp(((mu - (ec - edonor)) / kbt)))
        if (nachar <= (-9.6d-74)) then
            tmp = t_0
        else if (nachar <= 1.35d-195) then
            tmp = t_1
        else if (nachar <= 1250000000000.0d0) then
            tmp = t_0
        else if (nachar <= 4.8d+122) then
            tmp = t_1
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
    	double t_0 = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
    	double t_1 = (-1.0 * NdChar) / (-1.0 - Math.exp(((mu - (Ec - EDonor)) / KbT)));
    	double tmp;
    	if (NaChar <= -9.6e-74) {
    		tmp = t_0;
    	} else if (NaChar <= 1.35e-195) {
    		tmp = t_1;
    	} else if (NaChar <= 1250000000000.0) {
    		tmp = t_0;
    	} else if (NaChar <= 4.8e+122) {
    		tmp = t_1;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
    	t_0 = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)))
    	t_1 = (-1.0 * NdChar) / (-1.0 - math.exp(((mu - (Ec - EDonor)) / KbT)))
    	tmp = 0
    	if NaChar <= -9.6e-74:
    		tmp = t_0
    	elif NaChar <= 1.35e-195:
    		tmp = t_1
    	elif NaChar <= 1250000000000.0:
    		tmp = t_0
    	elif NaChar <= 4.8e+122:
    		tmp = t_1
    	else:
    		tmp = t_0
    	return tmp
    
    function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
    	t_0 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT))))
    	t_1 = Float64(Float64(-1.0 * NdChar) / Float64(-1.0 - exp(Float64(Float64(mu - Float64(Ec - EDonor)) / KbT))))
    	tmp = 0.0
    	if (NaChar <= -9.6e-74)
    		tmp = t_0;
    	elseif (NaChar <= 1.35e-195)
    		tmp = t_1;
    	elseif (NaChar <= 1250000000000.0)
    		tmp = t_0;
    	elseif (NaChar <= 4.8e+122)
    		tmp = t_1;
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
    	t_0 = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
    	t_1 = (-1.0 * NdChar) / (-1.0 - exp(((mu - (Ec - EDonor)) / KbT)));
    	tmp = 0.0;
    	if (NaChar <= -9.6e-74)
    		tmp = t_0;
    	elseif (NaChar <= 1.35e-195)
    		tmp = t_1;
    	elseif (NaChar <= 1250000000000.0)
    		tmp = t_0;
    	elseif (NaChar <= 4.8e+122)
    		tmp = t_1;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.0 * NdChar), $MachinePrecision] / N[(-1.0 - N[Exp[N[(N[(mu - N[(Ec - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[NaChar, -9.6e-74], t$95$0, If[LessEqual[NaChar, 1.35e-195], t$95$1, If[LessEqual[NaChar, 1250000000000.0], t$95$0, If[LessEqual[NaChar, 4.8e+122], t$95$1, t$95$0]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
    t_1 := \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \left(Ec - EDonor\right)}{KbT}}}\\
    \mathbf{if}\;NaChar \leq -9.6 \cdot 10^{-74}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;NaChar \leq 1.35 \cdot 10^{-195}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;NaChar \leq 1250000000000:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;NaChar \leq 4.8 \cdot 10^{+122}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if NaChar < -9.5999999999999996e-74 or 1.35e-195 < NaChar < 1.25e12 or 4.8000000000000004e122 < 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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

      if -9.5999999999999996e-74 < NaChar < 1.35e-195 or 1.25e12 < NaChar < 4.8000000000000004e122

      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. Applied rewrites59.6%

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

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

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

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

        \[\leadsto \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \color{blue}{\left(Ec - EDonor\right)}}{KbT}}} \]
      7. Step-by-step derivation
        1. lower--.f6450.9

          \[\leadsto \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \left(Ec - \color{blue}{EDonor}\right)}{KbT}}} \]
      8. Applied rewrites50.9%

        \[\leadsto \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \color{blue}{\left(Ec - EDonor\right)}}{KbT}}} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 10: 60.1% accurate, 1.4× speedup?

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

      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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
      6. Step-by-step derivation
        1. lower-+.f6454.7

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

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

      if -9.99999999999999997e-74 < NaChar < 2.1499999999999999e-107 or 1.25e12 < NaChar < 6.19999999999999998e122

      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. Applied rewrites59.6%

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

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

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

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

        \[\leadsto \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \color{blue}{\left(Ec - EDonor\right)}}{KbT}}} \]
      7. Step-by-step derivation
        1. lower--.f6450.9

          \[\leadsto \frac{-1 \cdot NdChar}{-1 - e^{\frac{mu - \left(Ec - \color{blue}{EDonor}\right)}{KbT}}} \]
      8. Applied rewrites50.9%

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

      if 2.1499999999999999e-107 < NaChar < 1.25e12 or 6.19999999999999998e122 < 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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(Ev + Vef\right) - mu}{KbT}}} \]
    3. Recombined 3 regimes into one program.
    4. Add Preprocessing

    Alternative 11: 57.8% accurate, 1.8× speedup?

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

      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. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - 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 \color{blue}{\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(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. mult-flipN/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{-1}{-1 - e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}}}, NdChar, \frac{NaChar}{\color{blue}{2}}\right) \]
      5. Step-by-step derivation
        1. Applied rewrites46.6%

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{0.5 + -0.25 \cdot \frac{\left(EDonor + \left(Vef + mu\right)\right) - Ec}{KbT}}, NdChar, \frac{NaChar}{2}\right) \]

        if -5.0000000000000001e172 < KbT < 6.0000000000000005e201

        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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 6.0000000000000005e201 < 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. Taylor expanded in KbT around inf

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
        5. Step-by-step derivation
          1. lift-fma.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \color{blue}{\frac{1}{2} \cdot NdChar} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot \color{blue}{NdChar} \]
          3. distribute-lft-outN/A

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

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

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

            \[\leadsto \left(NaChar + NdChar\right) \cdot 0.5 \]
        6. Applied rewrites27.5%

          \[\leadsto \color{blue}{\left(NaChar + NdChar\right) \cdot 0.5} \]
      6. Recombined 3 regimes into one program.
      7. Add Preprocessing

      Alternative 12: 57.8% accurate, 1.8× speedup?

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
        5. Step-by-step derivation
          1. lift-fma.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \color{blue}{\frac{1}{2} \cdot NdChar} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot \color{blue}{NdChar} \]
          3. distribute-lft-outN/A

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

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

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

            \[\leadsto \left(NaChar + NdChar\right) \cdot 0.5 \]
        6. Applied rewrites27.5%

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

        if -5.0000000000000001e172 < KbT < 6.0000000000000005e201

        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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{NaChar}{1 + e^{\frac{\left(Ev + Vef\right) - mu}{KbT}}} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 13: 51.2% accurate, 1.8× speedup?

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
        5. Step-by-step derivation
          1. lift-fma.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \color{blue}{\frac{1}{2} \cdot NdChar} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot \color{blue}{NdChar} \]
          3. distribute-lft-outN/A

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

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

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

            \[\leadsto \left(NaChar + NdChar\right) \cdot 0.5 \]
        6. Applied rewrites27.5%

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

        if -4.9000000000000001e172 < KbT < 1.75e-287

        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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
        9. Step-by-step derivation
          1. lower--.f6447.3

            \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
        10. Applied rewrites47.3%

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

        if 1.75e-287 < KbT < 1.39999999999999994e156

        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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{NaChar}{1 + e^{\frac{Ev - mu}{KbT}}} \]
        10. Recombined 3 regimes into one program.
        11. Add Preprocessing

        Alternative 14: 50.3% accurate, 2.0× speedup?

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
          5. Step-by-step derivation
            1. lift-fma.f64N/A

              \[\leadsto \frac{1}{2} \cdot NaChar + \color{blue}{\frac{1}{2} \cdot NdChar} \]
            2. lift-*.f64N/A

              \[\leadsto \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot \color{blue}{NdChar} \]
            3. distribute-lft-outN/A

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

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

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

              \[\leadsto \left(NaChar + NdChar\right) \cdot 0.5 \]
          6. Applied rewrites27.5%

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

          if -4.9000000000000001e172 < KbT < 1.74999999999999989e172

          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. Taylor expanded in NdChar around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
          9. Step-by-step derivation
            1. lower--.f6447.3

              \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
          10. Applied rewrites47.3%

            \[\leadsto \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 15: 27.5% accurate, 9.1× speedup?

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, NaChar, 0.5 \cdot NdChar\right)} \]
        5. Step-by-step derivation
          1. lift-fma.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \color{blue}{\frac{1}{2} \cdot NdChar} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot NaChar + \frac{1}{2} \cdot \color{blue}{NdChar} \]
          3. distribute-lft-outN/A

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

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

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

            \[\leadsto \left(NaChar + NdChar\right) \cdot 0.5 \]
        6. Applied rewrites27.5%

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

        Alternative 16: 22.1% accurate, 5.3× speedup?

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

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

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

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

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

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

              \[\leadsto 0.5 \cdot NaChar \]
          7. Applied rewrites18.6%

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

          if -5.39999999999999971e-64 < NaChar < 1.8000000000000001e129

          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. Taylor expanded in KbT around inf

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

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

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

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

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

              \[\leadsto 0.5 \cdot NaChar \]
          7. Applied rewrites18.6%

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

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

              \[\leadsto 0.5 \cdot NdChar \]
          10. Applied rewrites17.6%

            \[\leadsto 0.5 \cdot \color{blue}{NdChar} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 17: 18.6% accurate, 15.4× speedup?

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

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

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

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

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

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

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

            \[\leadsto 0.5 \cdot NaChar \]
        7. Applied rewrites18.6%

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

        Reproduce

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