
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
\end{array}
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
\end{array}
(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]
\begin{array}{l}
\\
\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)
\end{array}
Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ mu KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= mu -1.6e+173)
t_0
(if (<= mu 8e+128)
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept (+ Ev Vef)) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT)))))
t_0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (mu <= -1.6e+173) {
tmp = t_0;
} else if (mu <= 8e+128) {
tmp = (NaChar / (1.0 + exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
if (mu <= (-1.6d+173)) then
tmp = t_0
else if (mu <= 8d+128) then
tmp = (nachar / (1.0d0 + exp(((eaccept + (ev + vef)) / kbt)))) + (ndchar / (1.0d0 + exp((((edonor + vef) - ec) / kbt))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (mu <= -1.6e+173) {
tmp = t_0;
} else if (mu <= 8e+128) {
tmp = (NaChar / (1.0 + Math.exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + Math.exp((((EDonor + Vef) - Ec) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((mu / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))) tmp = 0 if mu <= -1.6e+173: tmp = t_0 elif mu <= 8e+128: tmp = (NaChar / (1.0 + math.exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT)))) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) tmp = 0.0 if (mu <= -1.6e+173) tmp = t_0; elseif (mu <= 8e+128) tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT))))); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); tmp = 0.0; if (mu <= -1.6e+173) tmp = t_0; elseif (mu <= 8e+128) tmp = (NaChar / (1.0 + exp(((EAccept + (Ev + Vef)) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[mu, -1.6e+173], t$95$0, If[LessEqual[mu, 8e+128], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;mu \leq -1.6 \cdot 10^{+173}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;mu \leq 8 \cdot 10^{+128}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}} + \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if mu < -1.6000000000000001e173 or 8.0000000000000006e128 < mu Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.5
Applied rewrites69.5%
if -1.6000000000000001e173 < mu < 8.0000000000000006e128Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(if (<= Ev -9.2e+120)
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ Ev KbT)))))
(if (<= Ev -3.7e+40)
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept Vef) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (Ev <= -9.2e+120) {
tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((Ev / KbT))));
} else if (Ev <= -3.7e+40) {
tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
} else {
tmp = (NaChar / (1.0 + exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / 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 (ev <= (-9.2d+120)) then
tmp = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((ev / kbt))))
else if (ev <= (-3.7d+40)) then
tmp = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
else
tmp = (nachar / (1.0d0 + exp(((eaccept + vef) / kbt)))) + (ndchar / (1.0d0 + exp((((edonor + vef) - ec) / 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 (Ev <= -9.2e+120) {
tmp = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((Ev / KbT))));
} else if (Ev <= -3.7e+40) {
tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
} else {
tmp = (NaChar / (1.0 + Math.exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + Math.exp((((EDonor + Vef) - Ec) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if Ev <= -9.2e+120: tmp = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((Ev / KbT)))) elif Ev <= -3.7e+40: tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT))) else: tmp = (NaChar / (1.0 + math.exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (Ev <= -9.2e+120) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))))); elseif (Ev <= -3.7e+40) tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)))); else tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Vef) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (Ev <= -9.2e+120) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((Ev / KbT)))); elseif (Ev <= -3.7e+40) tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT))); else tmp = (NaChar / (1.0 + exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[Ev, -9.2e+120], 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[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[Ev, -3.7e+40], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + Vef), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Ev \leq -9.2 \cdot 10^{+120}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
\mathbf{elif}\;Ev \leq -3.7 \cdot 10^{+40}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + Vef}{KbT}}} + \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\
\end{array}
\end{array}
if Ev < -9.1999999999999997e120Initial program 100.0%
Taylor expanded in Ev around inf
lower-/.f6468.9
Applied rewrites68.9%
if -9.1999999999999997e120 < Ev < -3.7e40Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if -3.7e40 < Ev Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in Ev around 0
lower-+.f6475.7
Applied rewrites75.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(if (<= Ev -1.3e+215)
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept Ev) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- EDonor Ec) KbT)))))
(if (<= Ev -5.8e+143)
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
(if (<= Ev -3.7e+40)
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT))))
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept Vef) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT)))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (Ev <= -1.3e+215) {
tmp = (NaChar / (1.0 + exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + exp(((EDonor - Ec) / KbT))));
} else if (Ev <= -5.8e+143) {
tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT))));
} else if (Ev <= -3.7e+40) {
tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
} else {
tmp = (NaChar / (1.0 + exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / 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 (ev <= (-1.3d+215)) then
tmp = (nachar / (1.0d0 + exp(((eaccept + ev) / kbt)))) + (ndchar / (1.0d0 + exp(((edonor - ec) / kbt))))
else if (ev <= (-5.8d+143)) then
tmp = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((eaccept / kbt))))
else if (ev <= (-3.7d+40)) then
tmp = nachar / (1.0d0 + exp((((eaccept + (ev + vef)) - mu) / kbt)))
else
tmp = (nachar / (1.0d0 + exp(((eaccept + vef) / kbt)))) + (ndchar / (1.0d0 + exp((((edonor + vef) - ec) / 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 (Ev <= -1.3e+215) {
tmp = (NaChar / (1.0 + Math.exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + Math.exp(((EDonor - Ec) / KbT))));
} else if (Ev <= -5.8e+143) {
tmp = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((EAccept / KbT))));
} else if (Ev <= -3.7e+40) {
tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
} else {
tmp = (NaChar / (1.0 + Math.exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + Math.exp((((EDonor + Vef) - Ec) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if Ev <= -1.3e+215: tmp = (NaChar / (1.0 + math.exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + math.exp(((EDonor - Ec) / KbT)))) elif Ev <= -5.8e+143: tmp = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((EAccept / KbT)))) elif Ev <= -3.7e+40: tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT))) else: tmp = (NaChar / (1.0 + math.exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (Ev <= -1.3e+215) tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Ev) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(EDonor - Ec) / KbT))))); elseif (Ev <= -5.8e+143) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); elseif (Ev <= -3.7e+40) tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)))); else tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Vef) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (Ev <= -1.3e+215) tmp = (NaChar / (1.0 + exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + exp(((EDonor - Ec) / KbT)))); elseif (Ev <= -5.8e+143) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT)))); elseif (Ev <= -3.7e+40) tmp = NaChar / (1.0 + exp((((EAccept + (Ev + Vef)) - mu) / KbT))); else tmp = (NaChar / (1.0 + exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[Ev, -1.3e+215], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + Ev), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(EDonor - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[Ev, -5.8e+143], 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[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[Ev, -3.7e+40], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + Vef), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Ev \leq -1.3 \cdot 10^{+215}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + Ev}{KbT}}} + \frac{NdChar}{1 + e^{\frac{EDonor - Ec}{KbT}}}\\
\mathbf{elif}\;Ev \leq -5.8 \cdot 10^{+143}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\mathbf{elif}\;Ev \leq -3.7 \cdot 10^{+40}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + Vef}{KbT}}} + \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\
\end{array}
\end{array}
if Ev < -1.3e215Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in Vef around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f6468.8
Applied rewrites68.8%
if -1.3e215 < Ev < -5.7999999999999996e143Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6468.8
Applied rewrites68.8%
if -5.7999999999999996e143 < Ev < -3.7e40Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if -3.7e40 < Ev Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in Ev around 0
lower-+.f6475.7
Applied rewrites75.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept Vef) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT)))))))
(if (<= Vef -128.0)
t_0
(if (<= Vef 1.65e-66)
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept Ev) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- EDonor Ec) KbT)))))
t_0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NaChar / (1.0 + exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT))));
double tmp;
if (Vef <= -128.0) {
tmp = t_0;
} else if (Vef <= 1.65e-66) {
tmp = (NaChar / (1.0 + exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + exp(((EDonor - Ec) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (nachar / (1.0d0 + exp(((eaccept + vef) / kbt)))) + (ndchar / (1.0d0 + exp((((edonor + vef) - ec) / kbt))))
if (vef <= (-128.0d0)) then
tmp = t_0
else if (vef <= 1.65d-66) then
tmp = (nachar / (1.0d0 + exp(((eaccept + ev) / kbt)))) + (ndchar / (1.0d0 + exp(((edonor - ec) / kbt))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NaChar / (1.0 + Math.exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + Math.exp((((EDonor + Vef) - Ec) / KbT))));
double tmp;
if (Vef <= -128.0) {
tmp = t_0;
} else if (Vef <= 1.65e-66) {
tmp = (NaChar / (1.0 + Math.exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + Math.exp(((EDonor - Ec) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NaChar / (1.0 + math.exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + math.exp((((EDonor + Vef) - Ec) / KbT)))) tmp = 0 if Vef <= -128.0: tmp = t_0 elif Vef <= 1.65e-66: tmp = (NaChar / (1.0 + math.exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + math.exp(((EDonor - Ec) / KbT)))) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Vef) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT))))) tmp = 0.0 if (Vef <= -128.0) tmp = t_0; elseif (Vef <= 1.65e-66) tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Ev) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(EDonor - Ec) / KbT))))); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NaChar / (1.0 + exp(((EAccept + Vef) / KbT)))) + (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))); tmp = 0.0; if (Vef <= -128.0) tmp = t_0; elseif (Vef <= 1.65e-66) tmp = (NaChar / (1.0 + exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + exp(((EDonor - Ec) / KbT)))); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + Vef), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[Vef, -128.0], t$95$0, If[LessEqual[Vef, 1.65e-66], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + Ev), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(EDonor - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NaChar}{1 + e^{\frac{EAccept + Vef}{KbT}}} + \frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}}\\
\mathbf{if}\;Vef \leq -128:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;Vef \leq 1.65 \cdot 10^{-66}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + Ev}{KbT}}} + \frac{NdChar}{1 + e^{\frac{EDonor - Ec}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if Vef < -128 or 1.6499999999999999e-66 < Vef Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in Ev around 0
lower-+.f6475.7
Applied rewrites75.7%
if -128 < Vef < 1.6499999999999999e-66Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in Vef around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f6468.8
Applied rewrites68.8%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ EAccept (+ Ev Vef)) 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 -2e-309)
(+
(/ NdChar (+ 1.0 (exp (/ (- (+ Vef mu) Ec) KbT))))
(/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
(if (<= t_1 5e-284)
(/ NaChar (+ 1.0 t_0))
(if (<= t_1 1e-97)
(+
(/ NaChar (+ 1.0 (exp (/ (+ EAccept Ev) KbT))))
(/ NdChar (+ 1.0 (exp (/ (- EDonor Ec) KbT)))))
(fma 0.5 NdChar (/ NaChar (- t_0 -1.0))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp((((EAccept + (Ev + Vef)) - 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 <= -2e-309) {
tmp = (NdChar / (1.0 + exp((((Vef + mu) - Ec) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT))));
} else if (t_1 <= 5e-284) {
tmp = NaChar / (1.0 + t_0);
} else if (t_1 <= 1e-97) {
tmp = (NaChar / (1.0 + exp(((EAccept + Ev) / KbT)))) + (NdChar / (1.0 + exp(((EDonor - Ec) / KbT))));
} else {
tmp = fma(0.5, NdChar, (NaChar / (t_0 - -1.0)));
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - 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 <= -2e-309) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(Vef + mu) - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); elseif (t_1 <= 5e-284) tmp = Float64(NaChar / Float64(1.0 + t_0)); elseif (t_1 <= 1e-97) tmp = Float64(Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Ev) / KbT)))) + Float64(NdChar / Float64(1.0 + exp(Float64(Float64(EDonor - Ec) / KbT))))); else tmp = fma(0.5, NdChar, Float64(NaChar / Float64(t_0 - -1.0))); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-309], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(Vef + mu), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-284], N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-97], N[(N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + Ev), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NdChar / N[(1.0 + N[Exp[N[(N[(EDonor - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * NdChar + N[(NaChar / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\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 -2 \cdot 10^{-309}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-284}:\\
\;\;\;\;\frac{NaChar}{1 + t\_0}\\
\mathbf{elif}\;t\_1 \leq 10^{-97}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + Ev}{KbT}}} + \frac{NdChar}{1 + e^{\frac{EDonor - Ec}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_0 - -1}\right)\\
\end{array}
\end{array}
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.9999999999999988e-309Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6468.8
Applied rewrites68.8%
Taylor expanded in mu around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6463.8
Applied rewrites63.8%
Taylor expanded in EDonor around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6462.9
Applied rewrites62.9%
if -1.9999999999999988e-309 < (+.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.99999999999999973e-284Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if 4.99999999999999973e-284 < (+.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.00000000000000004e-97Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in Vef around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f6468.8
Applied rewrites68.8%
if 1.00000000000000004e-97 < (+.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))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ EAccept (+ Ev Vef)) 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 -2e-309)
(+
(/ NdChar (+ 1.0 (exp (/ (- (+ Vef mu) Ec) KbT))))
(/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
(if (<= t_1 5e-7)
(/ NaChar (+ 1.0 t_0))
(fma 0.5 NdChar (/ NaChar (- t_0 -1.0)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp((((EAccept + (Ev + Vef)) - 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 <= -2e-309) {
tmp = (NdChar / (1.0 + exp((((Vef + mu) - Ec) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT))));
} else if (t_1 <= 5e-7) {
tmp = NaChar / (1.0 + t_0);
} else {
tmp = fma(0.5, NdChar, (NaChar / (t_0 - -1.0)));
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - 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 <= -2e-309) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(Vef + mu) - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); elseif (t_1 <= 5e-7) tmp = Float64(NaChar / Float64(1.0 + t_0)); else tmp = fma(0.5, NdChar, Float64(NaChar / Float64(t_0 - -1.0))); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-309], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(Vef + mu), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-7], N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * NdChar + N[(NaChar / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\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 -2 \cdot 10^{-309}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(Vef + mu\right) - Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_0 - -1}\right)\\
\end{array}
\end{array}
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.9999999999999988e-309Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6468.8
Applied rewrites68.8%
Taylor expanded in mu around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6463.8
Applied rewrites63.8%
Taylor expanded in EDonor around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6462.9
Applied rewrites62.9%
if -1.9999999999999988e-309 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-7Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if 4.99999999999999977e-7 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ EAccept (+ Ev Vef)) 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 -2e-309)
(+
(/ NdChar (+ 1.0 (exp (/ (- (+ EDonor mu) Ec) KbT))))
(/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
(if (<= t_1 5e-7)
(/ NaChar (+ 1.0 t_0))
(fma 0.5 NdChar (/ NaChar (- t_0 -1.0)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp((((EAccept + (Ev + Vef)) - 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 <= -2e-309) {
tmp = (NdChar / (1.0 + exp((((EDonor + mu) - Ec) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT))));
} else if (t_1 <= 5e-7) {
tmp = NaChar / (1.0 + t_0);
} else {
tmp = fma(0.5, NdChar, (NaChar / (t_0 - -1.0)));
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - 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 <= -2e-309) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + mu) - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); elseif (t_1 <= 5e-7) tmp = Float64(NaChar / Float64(1.0 + t_0)); else tmp = fma(0.5, NdChar, Float64(NaChar / Float64(t_0 - -1.0))); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-309], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + mu), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-7], N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * NdChar + N[(NaChar / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\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 -2 \cdot 10^{-309}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + mu\right) - Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_0 - -1}\right)\\
\end{array}
\end{array}
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.9999999999999988e-309Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6468.8
Applied rewrites68.8%
Taylor expanded in Vef around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6463.9
Applied rewrites63.9%
if -1.9999999999999988e-309 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-7Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if 4.99999999999999977e-7 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ EAccept (+ Ev Vef)) 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 -2e-309)
(+
(/ NdChar (+ 1.0 (exp (/ (- (+ EDonor Vef) Ec) KbT))))
(/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
(if (<= t_1 5e-7)
(/ NaChar (+ 1.0 t_0))
(fma 0.5 NdChar (/ NaChar (- t_0 -1.0)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp((((EAccept + (Ev + Vef)) - 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 <= -2e-309) {
tmp = (NdChar / (1.0 + exp((((EDonor + Vef) - Ec) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT))));
} else if (t_1 <= 5e-7) {
tmp = NaChar / (1.0 + t_0);
} else {
tmp = fma(0.5, NdChar, (NaChar / (t_0 - -1.0)));
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - 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 <= -2e-309) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(EDonor + Vef) - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); elseif (t_1 <= 5e-7) tmp = Float64(NaChar / Float64(1.0 + t_0)); else tmp = fma(0.5, NdChar, Float64(NaChar / Float64(t_0 - -1.0))); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-309], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(EDonor + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-7], N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * NdChar + N[(NaChar / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\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 -2 \cdot 10^{-309}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(EDonor + Vef\right) - Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_0 - -1}\right)\\
\end{array}
\end{array}
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.9999999999999988e-309Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6468.8
Applied rewrites68.8%
Taylor expanded in mu around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6463.8
Applied rewrites63.8%
if -1.9999999999999988e-309 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-7Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if 4.99999999999999977e-7 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ EAccept (+ Ev Vef)) 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 -5e-295)
(+
(/ NdChar (+ 1.0 (exp (/ (- Vef Ec) KbT))))
(/ NaChar (+ 1.0 (exp (/ EAccept KbT)))))
(if (<= t_1 5e-7)
(/ NaChar (+ 1.0 t_0))
(fma 0.5 NdChar (/ NaChar (- t_0 -1.0)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp((((EAccept + (Ev + Vef)) - 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 <= -5e-295) {
tmp = (NdChar / (1.0 + exp(((Vef - Ec) / KbT)))) + (NaChar / (1.0 + exp((EAccept / KbT))));
} else if (t_1 <= 5e-7) {
tmp = NaChar / (1.0 + t_0);
} else {
tmp = fma(0.5, NdChar, (NaChar / (t_0 - -1.0)));
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - 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 <= -5e-295) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Vef - Ec) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); elseif (t_1 <= 5e-7) tmp = Float64(NaChar / Float64(1.0 + t_0)); else tmp = fma(0.5, NdChar, Float64(NaChar / Float64(t_0 - -1.0))); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + 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-295], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(Vef - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-7], N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * NdChar + N[(NaChar / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\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 -5 \cdot 10^{-295}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef - Ec}{KbT}}} + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_0 - -1}\right)\\
\end{array}
\end{array}
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.00000000000000008e-295Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6468.8
Applied rewrites68.8%
Taylor expanded in mu around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6463.8
Applied rewrites63.8%
Taylor expanded in EDonor around 0
lower--.f6457.3
Applied rewrites57.3%
if -5.00000000000000008e-295 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-7Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
if 4.99999999999999977e-7 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
(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
(+
t_0
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
(t_2 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)))
(t_3 (fma 0.5 NdChar (/ NaChar (- t_2 -1.0)))))
(if (<= t_1 -2e+144)
t_3
(if (<= t_1 -1e-232)
(+ t_0 (* 0.5 NaChar))
(if (<= t_1 5e-7) (/ NaChar (+ 1.0 t_2)) 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 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = t_0 + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double t_2 = exp((((EAccept + (Ev + Vef)) - mu) / KbT));
double t_3 = fma(0.5, NdChar, (NaChar / (t_2 - -1.0)));
double tmp;
if (t_1 <= -2e+144) {
tmp = t_3;
} else if (t_1 <= -1e-232) {
tmp = t_0 + (0.5 * NaChar);
} else if (t_1 <= 5e-7) {
tmp = NaChar / (1.0 + t_2);
} else {
tmp = t_3;
}
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(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) t_2 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) t_3 = fma(0.5, NdChar, Float64(NaChar / Float64(t_2 - -1.0))) tmp = 0.0 if (t_1 <= -2e+144) tmp = t_3; elseif (t_1 <= -1e-232) tmp = Float64(t_0 + Float64(0.5 * NaChar)); elseif (t_1 <= 5e-7) tmp = Float64(NaChar / Float64(1.0 + t_2)); else tmp = t_3; end return 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[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * NdChar + N[(NaChar / N[(t$95$2 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+144], t$95$3, If[LessEqual[t$95$1, -1e-232], N[(t$95$0 + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-7], N[(NaChar / N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := t\_0 + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
t_2 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}\\
t_3 := \mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_2 - -1}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+144}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-232}:\\
\;\;\;\;t\_0 + 0.5 \cdot NaChar\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + t\_2}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.00000000000000005e144 or 4.99999999999999977e-7 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
if -2.00000000000000005e144 < (+.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.00000000000000002e-232Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.6
Applied rewrites46.6%
if -1.00000000000000002e-232 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-7Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
(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))))))
(t_1 (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)))
(t_2 (fma 0.5 NdChar (/ NaChar (- t_1 -1.0)))))
(if (<= t_0 -5e-216) t_2 (if (<= t_0 5e-7) (/ NaChar (+ 1.0 t_1)) t_2))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double t_1 = exp((((EAccept + (Ev + Vef)) - mu) / KbT));
double t_2 = fma(0.5, NdChar, (NaChar / (t_1 - -1.0)));
double tmp;
if (t_0 <= -5e-216) {
tmp = t_2;
} else if (t_0 <= 5e-7) {
tmp = NaChar / (1.0 + t_1);
} else {
tmp = t_2;
}
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))))) t_1 = exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) t_2 = fma(0.5, NdChar, Float64(NaChar / Float64(t_1 - -1.0))) tmp = 0.0 if (t_0 <= -5e-216) tmp = t_2; elseif (t_0 <= 5e-7) tmp = Float64(NaChar / Float64(1.0 + t_1)); else tmp = t_2; end return 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]}, Block[{t$95$1 = N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * NdChar + N[(NaChar / N[(t$95$1 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-216], t$95$2, If[LessEqual[t$95$0, 5e-7], N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
t_1 := e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}\\
t_2 := \mathsf{fma}\left(0.5, NdChar, \frac{NaChar}{t\_1 - -1}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-216}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{NaChar}{1 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
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.00000000000000021e-216 or 4.99999999999999977e-7 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
div-flipN/A
associate-/r/N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.0%
if -5.00000000000000021e-216 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-7Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (* 0.5 (+ NdChar NaChar))))
(if (<= KbT -1.5e+172)
t_0
(if (<= KbT 6.2e+211)
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept (+ 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 = 0.5 * (NdChar + NaChar);
double tmp;
if (KbT <= -1.5e+172) {
tmp = t_0;
} else if (KbT <= 6.2e+211) {
tmp = NaChar / (1.0 + exp((((EAccept + (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 = 0.5d0 * (ndchar + nachar)
if (kbt <= (-1.5d+172)) then
tmp = t_0
else if (kbt <= 6.2d+211) then
tmp = nachar / (1.0d0 + exp((((eaccept + (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 = 0.5 * (NdChar + NaChar);
double tmp;
if (KbT <= -1.5e+172) {
tmp = t_0;
} else if (KbT <= 6.2e+211) {
tmp = NaChar / (1.0 + Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)));
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = 0.5 * (NdChar + NaChar) tmp = 0 if KbT <= -1.5e+172: tmp = t_0 elif KbT <= 6.2e+211: tmp = NaChar / (1.0 + math.exp((((EAccept + (Ev + Vef)) - mu) / KbT))) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(0.5 * Float64(NdChar + NaChar)) tmp = 0.0 if (KbT <= -1.5e+172) tmp = t_0; elseif (KbT <= 6.2e+211) tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + 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 = 0.5 * (NdChar + NaChar); tmp = 0.0; if (KbT <= -1.5e+172) tmp = t_0; elseif (KbT <= 6.2e+211) tmp = NaChar / (1.0 + exp((((EAccept + (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[(0.5 * N[(NdChar + NaChar), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[KbT, -1.5e+172], t$95$0, If[LessEqual[KbT, 6.2e+211], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(NdChar + NaChar\right)\\
\mathbf{if}\;KbT \leq -1.5 \cdot 10^{+172}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;KbT \leq 6.2 \cdot 10^{+211}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if KbT < -1.5e172 or 6.2000000000000003e211 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6427.5
Applied rewrites27.5%
if -1.5e172 < KbT < 6.2000000000000003e211Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-+.f6461.6
Applied rewrites61.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (* 0.5 (+ NdChar NaChar))))
(if (<= KbT -1.25e+172)
t_0
(if (<= KbT 1.5e+201)
(/ NaChar (+ 1.0 (exp (/ (+ EAccept (+ Ev Vef)) 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 = 0.5 * (NdChar + NaChar);
double tmp;
if (KbT <= -1.25e+172) {
tmp = t_0;
} else if (KbT <= 1.5e+201) {
tmp = NaChar / (1.0 + exp(((EAccept + (Ev + Vef)) / 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 = 0.5d0 * (ndchar + nachar)
if (kbt <= (-1.25d+172)) then
tmp = t_0
else if (kbt <= 1.5d+201) then
tmp = nachar / (1.0d0 + exp(((eaccept + (ev + vef)) / 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 = 0.5 * (NdChar + NaChar);
double tmp;
if (KbT <= -1.25e+172) {
tmp = t_0;
} else if (KbT <= 1.5e+201) {
tmp = NaChar / (1.0 + Math.exp(((EAccept + (Ev + Vef)) / KbT)));
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = 0.5 * (NdChar + NaChar) tmp = 0 if KbT <= -1.25e+172: tmp = t_0 elif KbT <= 1.5e+201: tmp = NaChar / (1.0 + math.exp(((EAccept + (Ev + Vef)) / KbT))) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(0.5 * Float64(NdChar + NaChar)) tmp = 0.0 if (KbT <= -1.25e+172) tmp = t_0; elseif (KbT <= 1.5e+201) tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(EAccept + Float64(Ev + Vef)) / KbT)))); 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); tmp = 0.0; if (KbT <= -1.25e+172) tmp = t_0; elseif (KbT <= 1.5e+201) tmp = NaChar / (1.0 + exp(((EAccept + (Ev + Vef)) / 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[(0.5 * N[(NdChar + NaChar), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[KbT, -1.25e+172], t$95$0, If[LessEqual[KbT, 1.5e+201], N[(NaChar / N[(1.0 + N[Exp[N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(NdChar + NaChar\right)\\
\mathbf{if}\;KbT \leq -1.25 \cdot 10^{+172}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;KbT \leq 1.5 \cdot 10^{+201}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{EAccept + \left(Ev + Vef\right)}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if KbT < -1.25e172 or 1.50000000000000012e201 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6427.5
Applied rewrites27.5%
if -1.25e172 < KbT < 1.50000000000000012e201Initial program 100.0%
Taylor expanded in mu around 0
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
Applied rewrites84.6%
Taylor expanded in NdChar around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-+.f6454.9
Applied rewrites54.9%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (* 0.5 (+ NdChar NaChar)))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= t_1 -1e-232)
t_0
(if (<= t_1 1e-168)
(/ 1.0 (/ (+ 2.0 (* -2.0 (/ NdChar NaChar))) NaChar))
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);
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 <= -1e-232) {
tmp = t_0;
} else if (t_1 <= 1e-168) {
tmp = 1.0 / ((2.0 + (-2.0 * (NdChar / NaChar))) / NaChar);
} 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)
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
if (t_1 <= (-1d-232)) then
tmp = t_0
else if (t_1 <= 1d-168) then
tmp = 1.0d0 / ((2.0d0 + ((-2.0d0) * (ndchar / nachar))) / nachar)
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);
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 <= -1e-232) {
tmp = t_0;
} else if (t_1 <= 1e-168) {
tmp = 1.0 / ((2.0 + (-2.0 * (NdChar / NaChar))) / NaChar);
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = 0.5 * (NdChar + NaChar) 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 <= -1e-232: tmp = t_0 elif t_1 <= 1e-168: tmp = 1.0 / ((2.0 + (-2.0 * (NdChar / NaChar))) / NaChar) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(0.5 * Float64(NdChar + NaChar)) 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 <= -1e-232) tmp = t_0; elseif (t_1 <= 1e-168) tmp = Float64(1.0 / Float64(Float64(2.0 + Float64(-2.0 * Float64(NdChar / NaChar))) / NaChar)); 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); 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 <= -1e-232) tmp = t_0; elseif (t_1 <= 1e-168) tmp = 1.0 / ((2.0 + (-2.0 * (NdChar / NaChar))) / NaChar); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(0.5 * N[(NdChar + NaChar), $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, -1e-232], t$95$0, If[LessEqual[t$95$1, 1e-168], N[(1.0 / N[(N[(2.0 + N[(-2.0 * N[(NdChar / NaChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / NaChar), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(NdChar + NaChar\right)\\
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 -1 \cdot 10^{-232}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{-168}:\\
\;\;\;\;\frac{1}{\frac{2 + -2 \cdot \frac{NdChar}{NaChar}}{NaChar}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
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.00000000000000002e-232 or 1e-168 < (+.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))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6427.5
Applied rewrites27.5%
if -1.00000000000000002e-232 < (+.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-168Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
flip-+N/A
div-flipN/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
difference-of-squaresN/A
lift-fma.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f6417.4
Applied rewrites17.4%
Taylor expanded in NaChar around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f6419.9
Applied rewrites19.9%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (* 0.5 (+ NdChar NaChar)))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= t_1 -2e-219)
t_0
(if (<= t_1 4e-259)
(/ 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 = 0.5 * (NdChar + NaChar);
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 <= -2e-219) {
tmp = t_0;
} else if (t_1 <= 4e-259) {
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 = 0.5d0 * (ndchar + nachar)
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
if (t_1 <= (-2d-219)) then
tmp = t_0
else if (t_1 <= 4d-259) 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 = 0.5 * (NdChar + NaChar);
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 <= -2e-219) {
tmp = t_0;
} else if (t_1 <= 4e-259) {
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 = 0.5 * (NdChar + NaChar) 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 <= -2e-219: tmp = t_0 elif t_1 <= 4e-259: 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(0.5 * Float64(NdChar + NaChar)) 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 <= -2e-219) tmp = t_0; elseif (t_1 <= 4e-259) 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 = 0.5 * (NdChar + NaChar); 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 <= -2e-219) tmp = t_0; elseif (t_1 <= 4e-259) 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[(0.5 * N[(NdChar + NaChar), $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, -2e-219], t$95$0, If[LessEqual[t$95$1, 4e-259], 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}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(NdChar + NaChar\right)\\
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 -2 \cdot 10^{-219}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{-259}:\\
\;\;\;\;\frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.0000000000000001e-219 or 4.0000000000000003e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6427.5
Applied rewrites27.5%
if -2.0000000000000001e-219 < (+.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.0000000000000003e-259Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
flip-+N/A
div-flipN/A
lower-/.f64N/A
lower-/.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
difference-of-squaresN/A
lift-fma.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f6417.4
Applied rewrites17.4%
Taylor expanded in NdChar around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f6419.2
Applied rewrites19.2%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (* 0.5 (+ NdChar NaChar)))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * (NdChar + 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 * (ndchar + 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 * (NdChar + NaChar);
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return 0.5 * (NdChar + NaChar)
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(0.5 * Float64(NdChar + NaChar)) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.5 * (NdChar + NaChar); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * N[(NdChar + NaChar), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(NdChar + NaChar\right)
\end{array}
Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6427.5
Applied rewrites27.5%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (<= NaChar -7.5e-64) (* 0.5 NaChar) (if (<= NaChar 2.05e+129) (* 0.5 NdChar) (* 0.5 NaChar))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (NaChar <= -7.5e-64) {
tmp = 0.5 * NaChar;
} else if (NaChar <= 2.05e+129) {
tmp = 0.5 * NdChar;
} else {
tmp = 0.5 * NaChar;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (nachar <= (-7.5d-64)) then
tmp = 0.5d0 * nachar
else if (nachar <= 2.05d+129) then
tmp = 0.5d0 * ndchar
else
tmp = 0.5d0 * nachar
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (NaChar <= -7.5e-64) {
tmp = 0.5 * NaChar;
} else if (NaChar <= 2.05e+129) {
tmp = 0.5 * NdChar;
} else {
tmp = 0.5 * NaChar;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if NaChar <= -7.5e-64: tmp = 0.5 * NaChar elif NaChar <= 2.05e+129: tmp = 0.5 * NdChar else: tmp = 0.5 * NaChar return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (NaChar <= -7.5e-64) tmp = Float64(0.5 * NaChar); elseif (NaChar <= 2.05e+129) tmp = Float64(0.5 * NdChar); else tmp = Float64(0.5 * NaChar); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (NaChar <= -7.5e-64) tmp = 0.5 * NaChar; elseif (NaChar <= 2.05e+129) tmp = 0.5 * NdChar; else tmp = 0.5 * NaChar; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[NaChar, -7.5e-64], N[(0.5 * NaChar), $MachinePrecision], If[LessEqual[NaChar, 2.05e+129], N[(0.5 * NdChar), $MachinePrecision], N[(0.5 * NaChar), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;NaChar \leq -7.5 \cdot 10^{-64}:\\
\;\;\;\;0.5 \cdot NaChar\\
\mathbf{elif}\;NaChar \leq 2.05 \cdot 10^{+129}:\\
\;\;\;\;0.5 \cdot NdChar\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NaChar\\
\end{array}
\end{array}
if NaChar < -7.49999999999999949e-64 or 2.0500000000000001e129 < NaChar Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in NdChar around 0
lower-*.f6418.6
Applied rewrites18.6%
if -7.49999999999999949e-64 < NaChar < 2.0500000000000001e129Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in NdChar around 0
lower-*.f6418.6
Applied rewrites18.6%
Taylor expanded in NdChar around inf
lower-*.f6417.6
Applied rewrites17.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (* 0.5 NaChar))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * NaChar;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = 0.5d0 * nachar
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * NaChar;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return 0.5 * NaChar
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(0.5 * NaChar) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.5 * NaChar; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * NaChar), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot NaChar
\end{array}
Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.5
Applied rewrites27.5%
Taylor expanded in NdChar around 0
lower-*.f6418.6
Applied rewrites18.6%
herbie shell --seed 2025156
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:name "Bulmash initializePoisson"
:precision binary64
(+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))