Bulmash initializePoisson

Percentage Accurate: 100.0% → 100.0%
Time: 8.3s
Alternatives: 22
Speedup: N/A×

Specification

?
\[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
(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]
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 22 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

\[\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \]
(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]
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\mathsf{fma}\left(\frac{1}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}, NaChar, \frac{NdChar}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}\right) \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (fma
  (/ 1.0 (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
  NaChar
  (/ NdChar (- (exp (/ (- mu (- (- Ec Vef) EDonor)) 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 / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0)), NaChar, (NdChar / (exp(((mu - ((Ec - Vef) - EDonor)) / KbT)) - -1.0)));
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	return fma(Float64(1.0 / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)), NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - Float64(Float64(Ec - Vef) - EDonor)) / KbT)) - -1.0)))
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(1.0 / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}, NaChar, \frac{NdChar}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}\right)
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. +-commutativeN/A

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

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

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

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

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

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

Alternative 2: 100.0% accurate, 1.0× speedup?

\[\mathsf{fma}\left(\frac{1}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}, NdChar, \frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\right) \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (fma
  (/ 1.0 (- (exp (/ (- mu (- (- Ec Vef) EDonor)) KbT)) -1.0))
  NdChar
  (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) 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 / (exp(((mu - ((Ec - Vef) - EDonor)) / KbT)) - -1.0)), NdChar, (NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0)));
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	return fma(Float64(1.0 / Float64(exp(Float64(Float64(mu - Float64(Float64(Ec - Vef) - EDonor)) / KbT)) - -1.0)), NdChar, Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)))
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(1.0 / N[(N[Exp[N[(N[(mu - N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * NdChar + N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}, NdChar, \frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\right)
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}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}, NdChar, \frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\right)} \]
  4. Add Preprocessing

Alternative 3: 81.2% accurate, 0.2× speedup?

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

\mathbf{elif}\;t\_4 \leq -2 \cdot 10^{-89}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-221}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT}}}\\

\mathbf{elif}\;t\_4 \leq 10^{-296}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\

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


\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))))) < -1.9999999999999999e162

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

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

      \[\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}}}} \]
    5. Taylor expanded in Vef around 0

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

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

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

    if -1.9999999999999999e162 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.00000000000000008e-89 or 1e-296 < (+.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.4

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

      \[\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 -2.00000000000000008e-89 < (+.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.99999999999999996e-221

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
      11. metadata-evalN/A

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

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

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

Alternative 4: 79.4% accurate, 0.3× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} + t\_1\\


\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.99999999999999988e-277

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

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

      \[\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}}}} \]

    if -3.99999999999999988e-277 < (+.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.00000000000000013e-301

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
      11. metadata-evalN/A

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

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

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

    if 5.00000000000000013e-301 < (+.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 EDonor around inf

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

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

      \[\leadsto \frac{NdChar}{1 + e^{\color{blue}{\frac{EDonor}{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 5: 78.6% accurate, 0.3× speedup?

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

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

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = fmin(ev, eaccept) + vef
    t_1 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
    t_2 = t_1 + (nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt))))
    if (t_2 <= (-4d-277)) then
        tmp = t_1 + (nachar / (1.0d0 + exp((fmin(ev, eaccept) / kbt))))
    else if (t_2 <= 5d-106) then
        tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
    else
        tmp = t_1 + (nachar / (1.0d0 + exp((fmax(ev, eaccept) / kbt))))
    end if
    code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = fmin(Ev, EAccept) + Vef;
	double t_1 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	double t_2 = t_1 + (NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
	double tmp;
	if (t_2 <= -4e-277) {
		tmp = t_1 + (NaChar / (1.0 + Math.exp((fmin(Ev, EAccept) / KbT))));
	} else if (t_2 <= 5e-106) {
		tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
	} else {
		tmp = t_1 + (NaChar / (1.0 + Math.exp((fmax(Ev, EAccept) / KbT))));
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = fmin(Ev, EAccept) + Vef
	t_1 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))
	t_2 = t_1 + (NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))))
	tmp = 0
	if t_2 <= -4e-277:
		tmp = t_1 + (NaChar / (1.0 + math.exp((fmin(Ev, EAccept) / KbT))))
	elif t_2 <= 5e-106:
		tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)
	else:
		tmp = t_1 + (NaChar / (1.0 + math.exp((fmax(Ev, EAccept) / KbT))))
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(fmin(Ev, EAccept) + Vef)
	t_1 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT))))
	t_2 = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT)))))
	tmp = 0.0
	if (t_2 <= -4e-277)
		tmp = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(fmin(Ev, EAccept) / KbT)))));
	elseif (t_2 <= 5e-106)
		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0));
	else
		tmp = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(fmax(Ev, EAccept) / KbT)))));
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = min(Ev, EAccept) + Vef;
	t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
	t_2 = t_1 + (NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT))));
	tmp = 0.0;
	if (t_2 <= -4e-277)
		tmp = t_1 + (NaChar / (1.0 + exp((min(Ev, EAccept) / KbT))));
	elseif (t_2 <= 5e-106)
		tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
	else
		tmp = t_1 + (NaChar / (1.0 + exp((max(Ev, EAccept) / KbT))));
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-277], N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[Min[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_2 := t\_1 + \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{min}\left(Ev, EAccept\right)}{KbT}}}\\

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

\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT}}}\\


\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.99999999999999988e-277

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

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

      \[\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}}}} \]

    if -3.99999999999999988e-277 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
      11. metadata-evalN/A

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

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

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

    if 4.99999999999999983e-106 < (+.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 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-/.f6469.2

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

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

Alternative 6: 78.3% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\

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


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

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

      \[\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 -4.99999999999999996e-221 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
      11. metadata-evalN/A

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

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

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

Alternative 7: 74.2% accurate, 0.3× speedup?

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

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

real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
    real(8), intent (in) :: ndchar
    real(8), intent (in) :: ec
    real(8), intent (in) :: vef
    real(8), intent (in) :: edonor
    real(8), intent (in) :: mu
    real(8), intent (in) :: kbt
    real(8), intent (in) :: nachar
    real(8), intent (in) :: ev
    real(8), intent (in) :: eaccept
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = fmin(ev, eaccept) + vef
    t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt))))
    if (t_1 <= (-4d-277)) then
        tmp = (ndchar / (1.0d0 + exp((-((ec - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((fmin(ev, eaccept) / kbt))))
    else if (t_1 <= 5d-106) then
        tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
    else
        tmp = (ndchar / (1.0d0 + exp((vef / kbt)))) + (nachar / (1.0d0 + exp(((t_0 - mu) / kbt))))
    end if
    code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = fmin(Ev, EAccept) + Vef;
	double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
	double tmp;
	if (t_1 <= -4e-277) {
		tmp = (NdChar / (1.0 + Math.exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((fmin(Ev, EAccept) / KbT))));
	} else if (t_1 <= 5e-106) {
		tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
	} else {
		tmp = (NdChar / (1.0 + Math.exp((Vef / KbT)))) + (NaChar / (1.0 + Math.exp(((t_0 - mu) / KbT))));
	}
	return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
	t_0 = fmin(Ev, EAccept) + Vef
	t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))))
	tmp = 0
	if t_1 <= -4e-277:
		tmp = (NdChar / (1.0 + math.exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((fmin(Ev, EAccept) / KbT))))
	elif t_1 <= 5e-106:
		tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)
	else:
		tmp = (NdChar / (1.0 + math.exp((Vef / KbT)))) + (NaChar / (1.0 + math.exp(((t_0 - mu) / KbT))))
	return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = Float64(fmin(Ev, EAccept) + Vef)
	t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT)))))
	tmp = 0.0
	if (t_1 <= -4e-277)
		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Ec - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(fmin(Ev, EAccept) / KbT)))));
	elseif (t_1 <= 5e-106)
		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0));
	else
		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(t_0 - mu) / KbT)))));
	end
	return tmp
end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
	t_0 = min(Ev, EAccept) + Vef;
	t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT))));
	tmp = 0.0;
	if (t_1 <= -4e-277)
		tmp = (NdChar / (1.0 + exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((min(Ev, EAccept) / KbT))));
	elseif (t_1 <= 5e-106)
		tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
	else
		tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp(((t_0 - mu) / KbT))));
	end
	tmp_2 = tmp;
end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-277], N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(Ec - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[Min[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(t$95$0 - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(Ec - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\mathsf{min}\left(Ev, EAccept\right)}{KbT}}}\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\

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


\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.99999999999999988e-277

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

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

      \[\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}}}} \]
    5. Taylor expanded in Vef around 0

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

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

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

    if -3.99999999999999988e-277 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
      11. metadata-evalN/A

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

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

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

    if 4.99999999999999983e-106 < (+.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.4

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

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

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

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

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

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

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

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

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

Alternative 8: 70.1% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{KbT}}}\\ \mathbf{if}\;mu \leq -2.5 \cdot 10^{+123}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;mu \leq -7.5 \cdot 10^{+56}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\ \mathbf{elif}\;mu \leq 6.5 \cdot 10^{+111}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(Ev + Vef\right) - mu}{KbT}}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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 (* -1.0 (/ mu KbT))))))))
   (if (<= mu -2.5e+123)
     t_0
     (if (<= mu -7.5e+56)
       (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
       (if (<= mu 6.5e+111)
         (+
          (/ NdChar (+ 1.0 (exp (/ Vef KbT))))
          (/ 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 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((-1.0 * (mu / KbT)))));
	double tmp;
	if (mu <= -2.5e+123) {
		tmp = t_0;
	} else if (mu <= -7.5e+56) {
		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
	} else if (mu <= 6.5e+111) {
		tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (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 = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp(((-1.0d0) * (mu / kbt)))))
    if (mu <= (-2.5d+123)) then
        tmp = t_0
    else if (mu <= (-7.5d+56)) then
        tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
    else if (mu <= 6.5d+111) then
        tmp = (ndchar / (1.0d0 + exp((vef / kbt)))) + (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 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp((-1.0 * (mu / KbT)))));
	double tmp;
	if (mu <= -2.5e+123) {
		tmp = t_0;
	} else if (mu <= -7.5e+56) {
		tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
	} else if (mu <= 6.5e+111) {
		tmp = (NdChar / (1.0 + Math.exp((Vef / KbT)))) + (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 = (NdChar / (1.0 + math.exp((mu / KbT)))) + (NaChar / (1.0 + math.exp((-1.0 * (mu / KbT)))))
	tmp = 0
	if mu <= -2.5e+123:
		tmp = t_0
	elif mu <= -7.5e+56:
		tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0)
	elif mu <= 6.5e+111:
		tmp = (NdChar / (1.0 + math.exp((Vef / KbT)))) + (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(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(-1.0 * Float64(mu / KbT))))))
	tmp = 0.0
	if (mu <= -2.5e+123)
		tmp = t_0;
	elseif (mu <= -7.5e+56)
		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0));
	elseif (mu <= 6.5e+111)
		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT)))) + 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 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((-1.0 * (mu / KbT)))));
	tmp = 0.0;
	if (mu <= -2.5e+123)
		tmp = t_0;
	elseif (mu <= -7.5e+56)
		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
	elseif (mu <= 6.5e+111)
		tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (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[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(-1.0 * N[(mu / KbT), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[mu, -2.5e+123], t$95$0, If[LessEqual[mu, -7.5e+56], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[mu, 6.5e+111], N[(N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(Ev + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{KbT}}}\\
\mathbf{if}\;mu \leq -2.5 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;mu \leq 6.5 \cdot 10^{+111}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(Ev + Vef\right) - mu}{KbT}}}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if mu < -2.49999999999999987e123 or 6.5000000000000002e111 < 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.4

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

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

      \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\color{blue}{-1 \cdot \frac{mu}{KbT}}}} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \color{blue}{\frac{mu}{KbT}}}} \]
      2. lower-/.f6452.7

        \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{\color{blue}{KbT}}}} \]
    7. Applied rewrites52.7%

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

    if -2.49999999999999987e123 < mu < -7.4999999999999999e56

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
      11. metadata-evalN/A

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

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

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

    if -7.4999999999999999e56 < mu < 6.5000000000000002e111

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

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

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

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

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

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

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

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

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

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

Alternative 9: 69.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \left(Ec - Vef\right) - EDonor\\ t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + t\_1\\ \mathbf{if}\;t\_2 \leq -2 \cdot 10^{+162}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\ \mathbf{elif}\;t\_2 \leq -4 \cdot 10^{-277}:\\ \;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{KbT}}}\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-106}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + t\_1\\ \end{array} \]
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
 :precision binary64
 (let* ((t_0 (- (- Ec Vef) EDonor))
        (t_1
         (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))
        (t_2 (+ (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT)))) t_1)))
   (if (<= t_2 -2e+162)
     (fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_0) KbT)) -1.0)))
     (if (<= t_2 -4e-277)
       (+
        (/ NdChar (+ 1.0 (exp (/ mu KbT))))
        (/ NaChar (+ 1.0 (exp (* -1.0 (/ mu KbT))))))
       (if (<= t_2 5e-106)
         (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
         (+ (* 0.5 NdChar) t_1))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
	double t_0 = (Ec - Vef) - EDonor;
	double t_1 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)));
	double t_2 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + t_1;
	double tmp;
	if (t_2 <= -2e+162) {
		tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_0) / KbT)) - -1.0)));
	} else if (t_2 <= -4e-277) {
		tmp = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((-1.0 * (mu / KbT)))));
	} else if (t_2 <= 5e-106) {
		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
	} else {
		tmp = (0.5 * 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(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))
	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_0 - mu)) / KbT)))) + t_1)
	tmp = 0.0
	if (t_2 <= -2e+162)
		tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_0) / KbT)) - -1.0)));
	elseif (t_2 <= -4e-277)
		tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(-1.0 * Float64(mu / KbT))))));
	elseif (t_2 <= 5e-106)
		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0));
	else
		tmp = Float64(Float64(0.5 * NdChar) + 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[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$0 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+162], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -4e-277], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(-1.0 * N[(mu / KbT), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \left(Ec - Vef\right) - EDonor\\
t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + t\_1\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+162}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\

\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{KbT}}}\\

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

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


\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))))) < -1.9999999999999999e162

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

      if -1.9999999999999999e162 < (+.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.99999999999999988e-277

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

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

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

        \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\color{blue}{-1 \cdot \frac{mu}{KbT}}}} \]
      6. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \color{blue}{\frac{mu}{KbT}}}} \]
        2. lower-/.f6452.7

          \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{\color{blue}{KbT}}}} \]
      7. Applied rewrites52.7%

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

      if -3.99999999999999988e-277 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
        11. metadata-evalN/A

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

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

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

      if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

    Alternative 10: 67.9% accurate, 0.2× speedup?

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

      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. +-commutativeN/A

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

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

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

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

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

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

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

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

        if -1.9999999999999999e162 < (+.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))))) < -4e17

        1. Initial program 100.0%

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

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

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

          \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\color{blue}{\frac{EAccept}{KbT}}}} \]
        6. Step-by-step derivation
          1. lower-/.f6449.1

            \[\leadsto \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{\color{blue}{KbT}}}} \]
        7. Applied rewrites49.1%

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

        if -4e17 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
          11. metadata-evalN/A

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

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

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

        if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

      Alternative 11: 67.7% accurate, 0.4× speedup?

      \[\begin{array}{l} t_0 := \left(Ec - Vef\right) - EDonor\\ t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + t\_1\\ \mathbf{if}\;t\_2 \leq -4 \cdot 10^{+17}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-106}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + t\_1\\ \end{array} \]
      (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
       :precision binary64
       (let* ((t_0 (- (- Ec Vef) EDonor))
              (t_1
               (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))
              (t_2 (+ (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT)))) t_1)))
         (if (<= t_2 -4e+17)
           (fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_0) KbT)) -1.0)))
           (if (<= t_2 5e-106)
             (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
             (+ (* 0.5 NdChar) t_1)))))
      double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
      	double t_0 = (Ec - Vef) - EDonor;
      	double t_1 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)));
      	double t_2 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + t_1;
      	double tmp;
      	if (t_2 <= -4e+17) {
      		tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_0) / KbT)) - -1.0)));
      	} else if (t_2 <= 5e-106) {
      		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
      	} else {
      		tmp = (0.5 * 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(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))
      	t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_0 - mu)) / KbT)))) + t_1)
      	tmp = 0.0
      	if (t_2 <= -4e+17)
      		tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_0) / KbT)) - -1.0)));
      	elseif (t_2 <= 5e-106)
      		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0));
      	else
      		tmp = Float64(Float64(0.5 * NdChar) + 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[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$0 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+17], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]
      
      \begin{array}{l}
      t_0 := \left(Ec - Vef\right) - EDonor\\
      t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
      t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + t\_1\\
      \mathbf{if}\;t\_2 \leq -4 \cdot 10^{+17}:\\
      \;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\
      
      \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-106}:\\
      \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
      
      \mathbf{else}:\\
      \;\;\;\;0.5 \cdot NdChar + t\_1\\
      
      
      \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))))) < -4e17

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

          if -4e17 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
            11. metadata-evalN/A

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

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

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

          if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

        Alternative 12: 66.4% accurate, 0.4× speedup?

        \[\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}}}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\ \;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}}\\ \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)))))))
           (if (<= t_1 -4e+17)
             (fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_0) KbT)) -1.0)))
             (if (<= t_1 5e-106)
               (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
               (+
                (* 0.5 NdChar)
                (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Vef) mu) KbT)))))))))
        double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
        	double t_0 = (Ec - Vef) - EDonor;
        	double t_1 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
        	double tmp;
        	if (t_1 <= -4e+17) {
        		tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_0) / KbT)) - -1.0)));
        	} else if (t_1 <= 5e-106) {
        		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
        	} else {
        		tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Vef) - mu) / KbT))));
        	}
        	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)))))
        	tmp = 0.0
        	if (t_1 <= -4e+17)
        		tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_0) / KbT)) - -1.0)));
        	elseif (t_1 <= 5e-106)
        		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0));
        	else
        		tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Vef) - mu) / KbT)))));
        	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[(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$1, -4e+17], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
        
        \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}}}\\
        \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\
        \;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\
        
        \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
        \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
        
        \mathbf{else}:\\
        \;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}}\\
        
        
        \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))))) < -4e17

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

            if -4e17 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
              11. metadata-evalN/A

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

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

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

            if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
              6. lower-+.f6442.9

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

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

          Alternative 13: 65.1% accurate, 0.4× speedup?

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

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}} \]
            7. Applied rewrites43.1%

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

            if -4e17 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
              11. metadata-evalN/A

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

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

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

            if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
              6. lower-+.f6442.9

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

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

          Alternative 14: 65.1% accurate, 0.4× speedup?

          \[\begin{array}{l} t_0 := 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}\\ t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\ \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
          (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
           :precision binary64
           (let* ((t_0
                   (+
                    (* 0.5 NdChar)
                    (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Ev) mu) KbT))))))
                  (t_1
                   (+
                    (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                    (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
             (if (<= t_1 -4e+17)
               t_0
               (if (<= t_1 5e-106)
                 (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
                 t_0))))
          double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
          	double t_0 = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT))));
          	double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
          	double tmp;
          	if (t_1 <= -4e+17) {
          		tmp = t_0;
          	} else if (t_1 <= 5e-106) {
          		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
          	} 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 = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp((((eaccept + ev) - mu) / kbt))))
              t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
              if (t_1 <= (-4d+17)) then
                  tmp = t_0
              else if (t_1 <= 5d-106) then
                  tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
              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 = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp((((EAccept + Ev) - mu) / KbT))));
          	double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
          	double tmp;
          	if (t_1 <= -4e+17) {
          		tmp = t_0;
          	} else if (t_1 <= 5e-106) {
          		tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
          	t_0 = (0.5 * NdChar) + (NaChar / (1.0 + math.exp((((EAccept + Ev) - mu) / KbT))))
          	t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
          	tmp = 0
          	if t_1 <= -4e+17:
          		tmp = t_0
          	elif t_1 <= 5e-106:
          		tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0)
          	else:
          		tmp = t_0
          	return tmp
          
          function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT)))))
          	t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))))
          	tmp = 0.0
          	if (t_1 <= -4e+17)
          		tmp = t_0;
          	elseif (t_1 <= 5e-106)
          		tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
          	t_0 = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT))));
          	t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
          	tmp = 0.0;
          	if (t_1 <= -4e+17)
          		tmp = t_0;
          	elseif (t_1 <= 5e-106)
          		tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
          	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[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+17], t$95$0, If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
          
          \begin{array}{l}
          t_0 := 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}\\
          t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
          \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
          \;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4e17 or 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

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

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

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

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

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

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

                \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}} \]
            7. Applied rewrites43.1%

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

            if -4e17 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
              11. metadata-evalN/A

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

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

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

          Alternative 15: 62.4% accurate, 0.3× speedup?

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

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
              6. lower-+.f6442.9

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

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

              \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{EAccept - mu}{KbT}}} \]
            9. Step-by-step derivation
              1. Applied rewrites39.5%

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

              if -4e17 < (+.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.99999999999999983e-106

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
                11. metadata-evalN/A

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

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

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

              if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
                6. lower-+.f6442.9

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

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

                \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
              9. Step-by-step derivation
                1. lower--.f6439.0

                  \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
              10. Applied rewrites39.0%

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

            Alternative 16: 61.9% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
                11. metadata-evalN/A

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

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

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

              if 4.99999999999999983e-106 < (+.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 KbT around inf

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
                6. lower-+.f6442.9

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

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

                \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
              9. Step-by-step derivation
                1. lower--.f6439.0

                  \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}} \]
              10. Applied rewrites39.0%

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

            Alternative 17: 60.9% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}} \]
                11. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
                6. lower-+.f6442.9

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

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

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

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

                  \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
                3. lower-+.f64N/A

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

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

                  \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
                6. lower-/.f6425.7

                  \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
              10. Applied rewrites25.7%

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

            Alternative 18: 53.3% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}} \]
                  6. lower-+.f6442.9

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

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

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

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

                    \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
                  3. lower-+.f64N/A

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

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

                    \[\leadsto \frac{1}{2} \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
                  6. lower-/.f6425.7

                    \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}} \]
                10. Applied rewrites25.7%

                  \[\leadsto 0.5 \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{EAccept}{KbT} + \frac{Vef}{KbT}\right)\right) - \color{blue}{\frac{mu}{KbT}}} \]
              7. Recombined 2 regimes into one program.
              8. Add Preprocessing

              Alternative 19: 53.2% accurate, 2.0× speedup?

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

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

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

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

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

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

                  if 6.39999999999999993e205 < 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.6

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

                    \[\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. +-commutativeN/A

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

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

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

                Alternative 20: 32.2% accurate, 0.4× speedup?

                \[\begin{array}{l} t_0 := \left(NdChar + NaChar\right) \cdot 0.5\\ t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-264}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-228}:\\ \;\;\;\;\frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                (FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
                 :precision binary64
                 (let* ((t_0 (* (+ NdChar NaChar) 0.5))
                        (t_1
                         (+
                          (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
                          (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
                   (if (<= t_1 -5e-264)
                     t_0
                     (if (<= t_1 5e-228)
                       (/ 1.0 (/ (+ 2.0 (* -2.0 (/ NaChar NdChar))) NdChar))
                       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 + NaChar) * 0.5;
                	double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
                	double tmp;
                	if (t_1 <= -5e-264) {
                		tmp = t_0;
                	} else if (t_1 <= 5e-228) {
                		tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar);
                	} 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 = (ndchar + nachar) * 0.5d0
                    t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
                    if (t_1 <= (-5d-264)) then
                        tmp = t_0
                    else if (t_1 <= 5d-228) then
                        tmp = 1.0d0 / ((2.0d0 + ((-2.0d0) * (nachar / ndchar))) / ndchar)
                    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 + NaChar) * 0.5;
                	double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
                	double tmp;
                	if (t_1 <= -5e-264) {
                		tmp = t_0;
                	} else if (t_1 <= 5e-228) {
                		tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept):
                	t_0 = (NdChar + NaChar) * 0.5
                	t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
                	tmp = 0
                	if t_1 <= -5e-264:
                		tmp = t_0
                	elif t_1 <= 5e-228:
                		tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar)
                	else:
                		tmp = t_0
                	return tmp
                
                function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                	t_0 = Float64(Float64(NdChar + NaChar) * 0.5)
                	t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))))
                	tmp = 0.0
                	if (t_1 <= -5e-264)
                		tmp = t_0;
                	elseif (t_1 <= 5e-228)
                		tmp = Float64(1.0 / Float64(Float64(2.0 + Float64(-2.0 * Float64(NaChar / NdChar))) / NdChar));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept)
                	t_0 = (NdChar + NaChar) * 0.5;
                	t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
                	tmp = 0.0;
                	if (t_1 <= -5e-264)
                		tmp = t_0;
                	elseif (t_1 <= 5e-228)
                		tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar);
                	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 + NaChar), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-264], t$95$0, If[LessEqual[t$95$1, 5e-228], N[(1.0 / N[(N[(2.0 + N[(-2.0 * N[(NaChar / NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / NdChar), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
                
                \begin{array}{l}
                t_0 := \left(NdChar + NaChar\right) \cdot 0.5\\
                t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
                \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-264}:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-228}:\\
                \;\;\;\;\frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -5.0000000000000001e-264 or 4.99999999999999972e-228 < (+.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 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.6

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

                    \[\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. +-commutativeN/A

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

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

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

                  if -5.0000000000000001e-264 < (+.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.99999999999999972e-228

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

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

                    \[\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. +-commutativeN/A

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

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

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

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

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

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

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

                      \[\leadsto \frac{\left(\frac{1}{2} \cdot NdChar\right) \cdot \left(\frac{1}{2} \cdot NdChar\right) - \left(\frac{1}{2} \cdot NaChar\right) \cdot \left(\frac{1}{2} \cdot NaChar\right)}{\frac{1}{2} \cdot NdChar - \frac{1}{2} \cdot NaChar} \]
                    10. lower-unsound--.f64N/A

                      \[\leadsto \frac{\left(\frac{1}{2} \cdot NdChar\right) \cdot \left(\frac{1}{2} \cdot NdChar\right) - \left(\frac{1}{2} \cdot NaChar\right) \cdot \left(\frac{1}{2} \cdot NaChar\right)}{\frac{1}{2} \cdot NdChar - \color{blue}{\frac{1}{2} \cdot NaChar}} \]
                    11. lower-*.f6417.2

                      \[\leadsto \frac{\left(0.5 \cdot NdChar\right) \cdot \left(0.5 \cdot NdChar\right) - \left(0.5 \cdot NaChar\right) \cdot \left(0.5 \cdot NaChar\right)}{0.5 \cdot NdChar - 0.5 \cdot \color{blue}{NaChar}} \]
                  6. Applied rewrites17.2%

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

                      \[\leadsto \frac{\left(\frac{1}{2} \cdot NdChar\right) \cdot \left(\frac{1}{2} \cdot NdChar\right) - \left(\frac{1}{2} \cdot NaChar\right) \cdot \left(\frac{1}{2} \cdot NaChar\right)}{\color{blue}{\frac{1}{2} \cdot NdChar - \frac{1}{2} \cdot NaChar}} \]
                    2. div-flipN/A

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

                      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{1}{2} \cdot NdChar - \frac{1}{2} \cdot NaChar}{\left(\frac{1}{2} \cdot NdChar\right) \cdot \left(\frac{1}{2} \cdot NdChar\right) - \left(\frac{1}{2} \cdot NaChar\right) \cdot \left(\frac{1}{2} \cdot NaChar\right)}}} \]
                    4. lower-unsound-/.f6417.2

                      \[\leadsto \frac{1}{\frac{0.5 \cdot NdChar - 0.5 \cdot NaChar}{\color{blue}{\left(0.5 \cdot NdChar\right) \cdot \left(0.5 \cdot NdChar\right) - \left(0.5 \cdot NaChar\right) \cdot \left(0.5 \cdot NaChar\right)}}} \]
                    5. lift--.f64N/A

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

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

                      \[\leadsto \frac{1}{\frac{\frac{1}{2} \cdot NdChar - \frac{1}{2} \cdot NaChar}{\left(\frac{1}{2} \cdot NdChar\right) \cdot \color{blue}{\left(\frac{1}{2} \cdot NdChar\right)} - \left(\frac{1}{2} \cdot NaChar\right) \cdot \left(\frac{1}{2} \cdot NaChar\right)}} \]
                    8. distribute-lft-out--N/A

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

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

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

                      \[\leadsto \frac{1}{\frac{\left(NdChar - NaChar\right) \cdot 0.5}{\color{blue}{\left(0.5 \cdot NdChar\right)} \cdot \left(0.5 \cdot NdChar\right) - \left(0.5 \cdot NaChar\right) \cdot \left(0.5 \cdot NaChar\right)}} \]
                    12. lift--.f64N/A

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

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

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

                      \[\leadsto \frac{1}{\frac{\left(NdChar - NaChar\right) \cdot \frac{1}{2}}{\left(\frac{1}{2} \cdot NdChar\right) \cdot \left(\frac{1}{2} \cdot NdChar\right) - \left(\frac{1}{2} \cdot \color{blue}{NaChar}\right) \cdot \left(\frac{1}{2} \cdot NaChar\right)}} \]
                    16. swap-sqrN/A

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

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

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

                      \[\leadsto \frac{1}{\frac{\left(NdChar - NaChar\right) \cdot \frac{1}{2}}{\left(\frac{1}{2} \cdot \frac{1}{2}\right) \cdot \left(NdChar \cdot NdChar\right) - \left(\frac{1}{2} \cdot NaChar\right) \cdot \left(\frac{1}{2} \cdot \color{blue}{NaChar}\right)}} \]
                    20. swap-sqrN/A

                      \[\leadsto \frac{1}{\frac{\left(NdChar - NaChar\right) \cdot \frac{1}{2}}{\left(\frac{1}{2} \cdot \frac{1}{2}\right) \cdot \left(NdChar \cdot NdChar\right) - \left(\frac{1}{2} \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(NaChar \cdot NaChar\right)}}} \]
                    21. distribute-lft-out--N/A

                      \[\leadsto \frac{1}{\frac{\left(NdChar - NaChar\right) \cdot \frac{1}{2}}{\left(\frac{1}{2} \cdot \frac{1}{2}\right) \cdot \color{blue}{\left(NdChar \cdot NdChar - NaChar \cdot NaChar\right)}}} \]
                  8. Applied rewrites17.2%

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

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

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

                      \[\leadsto \frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}} \]
                    3. lower-*.f64N/A

                      \[\leadsto \frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}} \]
                    4. lower-/.f6420.1

                      \[\leadsto \frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}} \]
                  11. Applied rewrites20.1%

                    \[\leadsto \frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{\color{blue}{NdChar}}} \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 21: 27.6% accurate, 9.1× speedup?

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

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

                  \[\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. +-commutativeN/A

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

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

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

                Alternative 22: 18.1% accurate, 15.4× speedup?

                \[0.5 \cdot NaChar \]
                (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]
                
                0.5 \cdot NaChar
                
                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.6

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

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

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

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

                Reproduce

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