
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
Herbie found 22 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]
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (fma (/ 1.0 (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0)) NaChar (/ NdChar (- (exp (/ (- mu (- (- Ec Vef) EDonor)) KbT)) -1.0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return fma((1.0 / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0)), NaChar, (NdChar / (exp(((mu - ((Ec - Vef) - EDonor)) / KbT)) - -1.0)));
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return fma(Float64(1.0 / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)), NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - Float64(Float64(Ec - Vef) - EDonor)) / KbT)) - -1.0))) end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(1.0 / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}, NaChar, \frac{NdChar}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}\right)
Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (fma (/ 1.0 (- (exp (/ (- mu (- (- Ec Vef) EDonor)) KbT)) -1.0)) NdChar (/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return fma((1.0 / (exp(((mu - ((Ec - Vef) - EDonor)) / KbT)) - -1.0)), NdChar, (NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0)));
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return fma(Float64(1.0 / Float64(exp(Float64(Float64(mu - Float64(Float64(Ec - Vef) - EDonor)) / KbT)) - -1.0)), NdChar, Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0))) end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(1.0 / N[(N[Exp[N[(N[(mu - N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * NdChar + N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{1}{e^{\frac{mu - \left(\left(Ec - Vef\right) - EDonor\right)}{KbT}} - -1}, NdChar, \frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\right)
Initial program 100.0%
lift-+.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (+ (fmin Ev EAccept) Vef))
(t_1 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_2
(/ NaChar (+ 1.0 (exp (/ (+ (+ t_0 (fmax Ev EAccept)) (- mu)) KbT)))))
(t_3 (+ (/ NdChar (+ 1.0 (exp (/ mu KbT)))) t_2))
(t_4 (+ t_1 t_2)))
(if (<= t_4 -2e+162)
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- Ec EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (fmin Ev EAccept) KbT)))))
(if (<= t_4 -2e-89)
t_3
(if (<= t_4 -5e-221)
(+ t_1 (/ NaChar (+ 1.0 (exp (/ (fmax Ev EAccept) KbT)))))
(if (<= t_4 1e-296)
(/ NaChar (- (exp (/ (- (+ (fmax Ev EAccept) t_0) mu) KbT)) -1.0))
t_3))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = NaChar / (1.0 + exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)));
double t_3 = (NdChar / (1.0 + exp((mu / KbT)))) + t_2;
double t_4 = t_1 + t_2;
double tmp;
if (t_4 <= -2e+162) {
tmp = (NdChar / (1.0 + exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((fmin(Ev, EAccept) / KbT))));
} else if (t_4 <= -2e-89) {
tmp = t_3;
} else if (t_4 <= -5e-221) {
tmp = t_1 + (NaChar / (1.0 + exp((fmax(Ev, EAccept) / KbT))));
} else if (t_4 <= 1e-296) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = fmin(ev, eaccept) + vef
t_1 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_2 = nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt)))
t_3 = (ndchar / (1.0d0 + exp((mu / kbt)))) + t_2
t_4 = t_1 + t_2
if (t_4 <= (-2d+162)) then
tmp = (ndchar / (1.0d0 + exp((-((ec - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((fmin(ev, eaccept) / kbt))))
else if (t_4 <= (-2d-89)) then
tmp = t_3
else if (t_4 <= (-5d-221)) then
tmp = t_1 + (nachar / (1.0d0 + exp((fmax(ev, eaccept) / kbt))))
else if (t_4 <= 1d-296) then
tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)));
double t_3 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + t_2;
double t_4 = t_1 + t_2;
double tmp;
if (t_4 <= -2e+162) {
tmp = (NdChar / (1.0 + Math.exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((fmin(Ev, EAccept) / KbT))));
} else if (t_4 <= -2e-89) {
tmp = t_3;
} else if (t_4 <= -5e-221) {
tmp = t_1 + (NaChar / (1.0 + Math.exp((fmax(Ev, EAccept) / KbT))));
} else if (t_4 <= 1e-296) {
tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = t_3;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = fmin(Ev, EAccept) + Vef t_1 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_2 = NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))) t_3 = (NdChar / (1.0 + math.exp((mu / KbT)))) + t_2 t_4 = t_1 + t_2 tmp = 0 if t_4 <= -2e+162: tmp = (NdChar / (1.0 + math.exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((fmin(Ev, EAccept) / KbT)))) elif t_4 <= -2e-89: tmp = t_3 elif t_4 <= -5e-221: tmp = t_1 + (NaChar / (1.0 + math.exp((fmax(Ev, EAccept) / KbT)))) elif t_4 <= 1e-296: tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0) else: tmp = t_3 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(fmin(Ev, EAccept) + Vef) t_1 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) t_2 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT)))) t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + t_2) t_4 = Float64(t_1 + t_2) tmp = 0.0 if (t_4 <= -2e+162) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Ec - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(fmin(Ev, EAccept) / KbT))))); elseif (t_4 <= -2e-89) tmp = t_3; elseif (t_4 <= -5e-221) tmp = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(fmax(Ev, EAccept) / KbT))))); elseif (t_4 <= 1e-296) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)); else tmp = t_3; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = min(Ev, EAccept) + Vef; t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_2 = NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT))); t_3 = (NdChar / (1.0 + exp((mu / KbT)))) + t_2; t_4 = t_1 + t_2; tmp = 0.0; if (t_4 <= -2e+162) tmp = (NdChar / (1.0 + exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((min(Ev, EAccept) / KbT)))); elseif (t_4 <= -2e-89) tmp = t_3; elseif (t_4 <= -5e-221) tmp = t_1 + (NaChar / (1.0 + exp((max(Ev, EAccept) / KbT)))); elseif (t_4 <= 1e-296) tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0); else tmp = t_3; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, -2e+162], N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(Ec - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[Min[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -2e-89], t$95$3, If[LessEqual[t$95$4, -5e-221], N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e-296], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_2 := \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
t_3 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_2\\
t_4 := t\_1 + t\_2\\
\mathbf{if}\;t\_4 \leq -2 \cdot 10^{+162}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(Ec - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\mathsf{min}\left(Ev, EAccept\right)}{KbT}}}\\
\mathbf{elif}\;t\_4 \leq -2 \cdot 10^{-89}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-221}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT}}}\\
\mathbf{elif}\;t\_4 \leq 10^{-296}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
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.9999999999999999e162Initial program 100.0%
Taylor expanded in Ev around inf
lower-/.f6469.1
Applied rewrites69.1%
Taylor expanded in Vef around 0
lower--.f6464.1
Applied rewrites64.1%
if -1.9999999999999999e162 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.00000000000000008e-89 or 1e-296 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.4
Applied rewrites69.4%
if -2.00000000000000008e-89 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.99999999999999996e-221Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6469.2
Applied rewrites69.2%
if -4.99999999999999996e-221 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1e-296Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_1
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))
(t_2 (+ t_0 t_1)))
(if (<= t_2 -4e-277)
(+ t_0 (/ NaChar (+ 1.0 (exp (/ Ev KbT)))))
(if (<= t_2 5e-301)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(+ (/ NdChar (+ 1.0 (exp (/ EDonor KbT)))) t_1)))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)));
double t_2 = t_0 + t_1;
double tmp;
if (t_2 <= -4e-277) {
tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT))));
} else if (t_2 <= 5e-301) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (NdChar / (1.0 + exp((EDonor / KbT)))) + t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_1 = nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt)))
t_2 = t_0 + t_1
if (t_2 <= (-4d-277)) then
tmp = t_0 + (nachar / (1.0d0 + exp((ev / kbt))))
else if (t_2 <= 5d-301) then
tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
else
tmp = (ndchar / (1.0d0 + exp((edonor / kbt)))) + t_1
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT)));
double t_2 = t_0 + t_1;
double tmp;
if (t_2 <= -4e-277) {
tmp = t_0 + (NaChar / (1.0 + Math.exp((Ev / KbT))));
} else if (t_2 <= 5e-301) {
tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (NdChar / (1.0 + Math.exp((EDonor / KbT)))) + t_1;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_1 = NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))) t_2 = t_0 + t_1 tmp = 0 if t_2 <= -4e-277: tmp = t_0 + (NaChar / (1.0 + math.exp((Ev / KbT)))) elif t_2 <= 5e-301: tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0) else: tmp = (NdChar / (1.0 + math.exp((EDonor / KbT)))) + t_1 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) t_1 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))) t_2 = Float64(t_0 + t_1) tmp = 0.0 if (t_2 <= -4e-277) tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))))); elseif (t_2 <= 5e-301) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT)))) + t_1); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_1 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))); t_2 = t_0 + t_1; tmp = 0.0; if (t_2 <= -4e-277) tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT)))); elseif (t_2 <= 5e-301) tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0); else tmp = (NdChar / (1.0 + exp((EDonor / KbT)))) + t_1; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-277], N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-301], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
t_2 := t\_0 + t\_1\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-301}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} + t\_1\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -3.99999999999999988e-277Initial program 100.0%
Taylor expanded in Ev around inf
lower-/.f6469.1
Applied rewrites69.1%
if -3.99999999999999988e-277 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 5.00000000000000013e-301Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 5.00000000000000013e-301 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in EDonor around inf
lower-/.f6468.1
Applied rewrites68.1%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (+ (fmin Ev EAccept) Vef))
(t_1 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_2
(+
t_1
(/
NaChar
(+ 1.0 (exp (/ (+ (+ t_0 (fmax Ev EAccept)) (- mu)) KbT)))))))
(if (<= t_2 -4e-277)
(+ t_1 (/ NaChar (+ 1.0 (exp (/ (fmin Ev EAccept) KbT)))))
(if (<= t_2 5e-106)
(/ NaChar (- (exp (/ (- (+ (fmax Ev EAccept) t_0) mu) KbT)) -1.0))
(+ t_1 (/ NaChar (+ 1.0 (exp (/ (fmax Ev EAccept) KbT)))))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = t_1 + (NaChar / (1.0 + exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_2 <= -4e-277) {
tmp = t_1 + (NaChar / (1.0 + exp((fmin(Ev, EAccept) / KbT))));
} else if (t_2 <= 5e-106) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = t_1 + (NaChar / (1.0 + exp((fmax(Ev, EAccept) / KbT))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmin(ev, eaccept) + vef
t_1 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_2 = t_1 + (nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt))))
if (t_2 <= (-4d-277)) then
tmp = t_1 + (nachar / (1.0d0 + exp((fmin(ev, eaccept) / kbt))))
else if (t_2 <= 5d-106) then
tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
else
tmp = t_1 + (nachar / (1.0d0 + exp((fmax(ev, eaccept) / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = t_1 + (NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_2 <= -4e-277) {
tmp = t_1 + (NaChar / (1.0 + Math.exp((fmin(Ev, EAccept) / KbT))));
} else if (t_2 <= 5e-106) {
tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = t_1 + (NaChar / (1.0 + Math.exp((fmax(Ev, EAccept) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = fmin(Ev, EAccept) + Vef t_1 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_2 = t_1 + (NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)))) tmp = 0 if t_2 <= -4e-277: tmp = t_1 + (NaChar / (1.0 + math.exp((fmin(Ev, EAccept) / KbT)))) elif t_2 <= 5e-106: tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0) else: tmp = t_1 + (NaChar / (1.0 + math.exp((fmax(Ev, EAccept) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(fmin(Ev, EAccept) + Vef) t_1 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) t_2 = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_2 <= -4e-277) tmp = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(fmin(Ev, EAccept) / KbT))))); elseif (t_2 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)); else tmp = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(fmax(Ev, EAccept) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = min(Ev, EAccept) + Vef; t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_2 = t_1 + (NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT)))); tmp = 0.0; if (t_2 <= -4e-277) tmp = t_1 + (NaChar / (1.0 + exp((min(Ev, EAccept) / KbT)))); elseif (t_2 <= 5e-106) tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0); else tmp = t_1 + (NaChar / (1.0 + exp((max(Ev, EAccept) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-277], N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[Min[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_2 := t\_1 + \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{min}\left(Ev, EAccept\right)}{KbT}}}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT}}}\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -3.99999999999999988e-277Initial program 100.0%
Taylor expanded in Ev around inf
lower-/.f6469.1
Applied rewrites69.1%
if -3.99999999999999988e-277 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6469.2
Applied rewrites69.2%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (+ (fmin Ev EAccept) Vef))
(t_1 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_2 (+ t_1 (/ NaChar (+ 1.0 (exp (/ (fmax Ev EAccept) KbT))))))
(t_3
(+
t_1
(/
NaChar
(+ 1.0 (exp (/ (+ (+ t_0 (fmax Ev EAccept)) (- mu)) KbT)))))))
(if (<= t_3 -5e-221)
t_2
(if (<= t_3 5e-106)
(/ NaChar (- (exp (/ (- (+ (fmax Ev EAccept) t_0) mu) KbT)) -1.0))
t_2))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = t_1 + (NaChar / (1.0 + exp((fmax(Ev, EAccept) / KbT))));
double t_3 = t_1 + (NaChar / (1.0 + exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_3 <= -5e-221) {
tmp = t_2;
} else if (t_3 <= 5e-106) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmin(ev, eaccept) + vef
t_1 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_2 = t_1 + (nachar / (1.0d0 + exp((fmax(ev, eaccept) / kbt))))
t_3 = t_1 + (nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt))))
if (t_3 <= (-5d-221)) then
tmp = t_2
else if (t_3 <= 5d-106) then
tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = t_1 + (NaChar / (1.0 + Math.exp((fmax(Ev, EAccept) / KbT))));
double t_3 = t_1 + (NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_3 <= -5e-221) {
tmp = t_2;
} else if (t_3 <= 5e-106) {
tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = t_2;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = fmin(Ev, EAccept) + Vef t_1 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_2 = t_1 + (NaChar / (1.0 + math.exp((fmax(Ev, EAccept) / KbT)))) t_3 = t_1 + (NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)))) tmp = 0 if t_3 <= -5e-221: tmp = t_2 elif t_3 <= 5e-106: tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0) else: tmp = t_2 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(fmin(Ev, EAccept) + Vef) t_1 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) t_2 = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(fmax(Ev, EAccept) / KbT))))) t_3 = Float64(t_1 + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_3 <= -5e-221) tmp = t_2; elseif (t_3 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)); else tmp = t_2; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = min(Ev, EAccept) + Vef; t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_2 = t_1 + (NaChar / (1.0 + exp((max(Ev, EAccept) / KbT)))); t_3 = t_1 + (NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT)))); tmp = 0.0; if (t_3 <= -5e-221) tmp = t_2; elseif (t_3 <= 5e-106) tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0); else tmp = t_2; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-221], t$95$2, If[LessEqual[t$95$3, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_2 := t\_1 + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT}}}\\
t_3 := t\_1 + \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{-221}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.99999999999999996e-221 or 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in EAccept around inf
lower-/.f6469.2
Applied rewrites69.2%
if -4.99999999999999996e-221 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (+ (fmin Ev EAccept) Vef))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/
NaChar
(+ 1.0 (exp (/ (+ (+ t_0 (fmax Ev EAccept)) (- mu)) KbT)))))))
(if (<= t_1 -4e-277)
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- Ec EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (fmin Ev EAccept) KbT)))))
(if (<= t_1 5e-106)
(/ NaChar (- (exp (/ (- (+ (fmax Ev EAccept) t_0) mu) KbT)) -1.0))
(+
(/ NdChar (+ 1.0 (exp (/ Vef KbT))))
(/ NaChar (+ 1.0 (exp (/ (- t_0 mu) KbT)))))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e-277) {
tmp = (NdChar / (1.0 + exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((fmin(Ev, EAccept) / KbT))));
} else if (t_1 <= 5e-106) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp(((t_0 - mu) / KbT))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmin(ev, eaccept) + vef
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt))))
if (t_1 <= (-4d-277)) then
tmp = (ndchar / (1.0d0 + exp((-((ec - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((fmin(ev, eaccept) / kbt))))
else if (t_1 <= 5d-106) then
tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
else
tmp = (ndchar / (1.0d0 + exp((vef / kbt)))) + (nachar / (1.0d0 + exp(((t_0 - mu) / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e-277) {
tmp = (NdChar / (1.0 + Math.exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((fmin(Ev, EAccept) / KbT))));
} else if (t_1 <= 5e-106) {
tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = (NdChar / (1.0 + Math.exp((Vef / KbT)))) + (NaChar / (1.0 + Math.exp(((t_0 - mu) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = fmin(Ev, EAccept) + Vef t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)))) tmp = 0 if t_1 <= -4e-277: tmp = (NdChar / (1.0 + math.exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((fmin(Ev, EAccept) / KbT)))) elif t_1 <= 5e-106: tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0) else: tmp = (NdChar / (1.0 + math.exp((Vef / KbT)))) + (NaChar / (1.0 + math.exp(((t_0 - mu) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(fmin(Ev, EAccept) + Vef) t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_1 <= -4e-277) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Ec - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(fmin(Ev, EAccept) / KbT))))); elseif (t_1 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(t_0 - mu) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = min(Ev, EAccept) + Vef; t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT)))); tmp = 0.0; if (t_1 <= -4e-277) tmp = (NdChar / (1.0 + exp((-((Ec - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((min(Ev, EAccept) / KbT)))); elseif (t_1 <= 5e-106) tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0); else tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp(((t_0 - mu) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-277], N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(Ec - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[Min[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(t$95$0 - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{-\left(\left(Ec - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\mathsf{min}\left(Ev, EAccept\right)}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} + \frac{NaChar}{1 + e^{\frac{t\_0 - mu}{KbT}}}\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -3.99999999999999988e-277Initial program 100.0%
Taylor expanded in Ev around inf
lower-/.f6469.1
Applied rewrites69.1%
Taylor expanded in Vef around 0
lower--.f6464.1
Applied rewrites64.1%
if -3.99999999999999988e-277 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.4
Applied rewrites69.4%
Taylor expanded in Vef around inf
lower-/.f6469.7
Applied rewrites69.7%
Taylor expanded in EAccept around 0
lower--.f64N/A
lower-+.f6464.8
Applied rewrites64.8%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ mu KbT))))
(/ NaChar (+ 1.0 (exp (* -1.0 (/ mu KbT))))))))
(if (<= mu -2.5e+123)
t_0
(if (<= mu -7.5e+56)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(if (<= mu 6.5e+111)
(+
(/ NdChar (+ 1.0 (exp (/ Vef KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ Ev Vef) mu) KbT)))))
t_0)))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((-1.0 * (mu / KbT)))));
double tmp;
if (mu <= -2.5e+123) {
tmp = t_0;
} else if (mu <= -7.5e+56) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else if (mu <= 6.5e+111) {
tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp((((Ev + Vef) - mu) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp(((-1.0d0) * (mu / kbt)))))
if (mu <= (-2.5d+123)) then
tmp = t_0
else if (mu <= (-7.5d+56)) then
tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
else if (mu <= 6.5d+111) then
tmp = (ndchar / (1.0d0 + exp((vef / kbt)))) + (nachar / (1.0d0 + exp((((ev + vef) - mu) / kbt))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp((-1.0 * (mu / KbT)))));
double tmp;
if (mu <= -2.5e+123) {
tmp = t_0;
} else if (mu <= -7.5e+56) {
tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else if (mu <= 6.5e+111) {
tmp = (NdChar / (1.0 + Math.exp((Vef / KbT)))) + (NaChar / (1.0 + Math.exp((((Ev + Vef) - mu) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((mu / KbT)))) + (NaChar / (1.0 + math.exp((-1.0 * (mu / KbT))))) tmp = 0 if mu <= -2.5e+123: tmp = t_0 elif mu <= -7.5e+56: tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0) elif mu <= 6.5e+111: tmp = (NdChar / (1.0 + math.exp((Vef / KbT)))) + (NaChar / (1.0 + math.exp((((Ev + Vef) - mu) / KbT)))) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(-1.0 * Float64(mu / KbT)))))) tmp = 0.0 if (mu <= -2.5e+123) tmp = t_0; elseif (mu <= -7.5e+56) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); elseif (mu <= 6.5e+111) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Ev + Vef) - mu) / KbT))))); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((-1.0 * (mu / KbT))))); tmp = 0.0; if (mu <= -2.5e+123) tmp = t_0; elseif (mu <= -7.5e+56) tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0); elseif (mu <= 6.5e+111) tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp((((Ev + Vef) - mu) / KbT)))); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(-1.0 * N[(mu / KbT), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[mu, -2.5e+123], t$95$0, If[LessEqual[mu, -7.5e+56], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[mu, 6.5e+111], N[(N[(NdChar / N[(1.0 + N[Exp[N[(Vef / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(Ev + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{KbT}}}\\
\mathbf{if}\;mu \leq -2.5 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;mu \leq -7.5 \cdot 10^{+56}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{elif}\;mu \leq 6.5 \cdot 10^{+111}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(Ev + Vef\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if mu < -2.49999999999999987e123 or 6.5000000000000002e111 < mu Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.4
Applied rewrites69.4%
Taylor expanded in mu around inf
lower-*.f64N/A
lower-/.f6452.7
Applied rewrites52.7%
if -2.49999999999999987e123 < mu < -7.4999999999999999e56Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if -7.4999999999999999e56 < mu < 6.5000000000000002e111Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.4
Applied rewrites69.4%
Taylor expanded in Vef around inf
lower-/.f6469.7
Applied rewrites69.7%
Taylor expanded in EAccept around 0
lower--.f64N/A
lower-+.f6464.8
Applied rewrites64.8%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (- (- Ec Vef) EDonor))
(t_1
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))
(t_2 (+ (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT)))) t_1)))
(if (<= t_2 -2e+162)
(fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_0) KbT)) -1.0)))
(if (<= t_2 -4e-277)
(+
(/ NdChar (+ 1.0 (exp (/ mu KbT))))
(/ NaChar (+ 1.0 (exp (* -1.0 (/ mu KbT))))))
(if (<= t_2 5e-106)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(+ (* 0.5 NdChar) t_1))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (Ec - Vef) - EDonor;
double t_1 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)));
double t_2 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + t_1;
double tmp;
if (t_2 <= -2e+162) {
tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_0) / KbT)) - -1.0)));
} else if (t_2 <= -4e-277) {
tmp = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((-1.0 * (mu / KbT)))));
} else if (t_2 <= 5e-106) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + t_1;
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(Ec - Vef) - EDonor) t_1 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))) t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_0 - mu)) / KbT)))) + t_1) tmp = 0.0 if (t_2 <= -2e+162) tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_0) / KbT)) - -1.0))); elseif (t_2 <= -4e-277) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(-1.0 * Float64(mu / KbT)))))); elseif (t_2 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + t_1); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$0 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+162], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -4e-277], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(-1.0 * N[(mu / KbT), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \left(Ec - Vef\right) - EDonor\\
t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + t\_1\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+162}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\
\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{-277}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{-1 \cdot \frac{mu}{KbT}}}\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + t\_1\\
\end{array}
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.9999999999999999e162Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.3%
if -1.9999999999999999e162 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -3.99999999999999988e-277Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.4
Applied rewrites69.4%
Taylor expanded in mu around inf
lower-*.f64N/A
lower-/.f6452.7
Applied rewrites52.7%
if -3.99999999999999988e-277 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (+ (fmin Ev EAccept) Vef))
(t_1 (- (- Ec Vef) EDonor))
(t_2
(/ NaChar (+ 1.0 (exp (/ (+ (+ t_0 (fmax Ev EAccept)) (- mu)) KbT)))))
(t_3 (+ (/ NdChar (+ 1.0 (exp (/ (- (- t_1 mu)) KbT)))) t_2)))
(if (<= t_3 -2e+162)
(fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_1) KbT)) -1.0)))
(if (<= t_3 -4e+17)
(+
(/ NdChar (+ 1.0 (exp (/ mu KbT))))
(/ NaChar (+ 1.0 (exp (/ (fmax Ev EAccept) KbT)))))
(if (<= t_3 5e-106)
(/ NaChar (- (exp (/ (- (+ (fmax Ev EAccept) t_0) mu) KbT)) -1.0))
(+ (* 0.5 NdChar) t_2))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = (Ec - Vef) - EDonor;
double t_2 = NaChar / (1.0 + exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)));
double t_3 = (NdChar / (1.0 + exp((-(t_1 - mu) / KbT)))) + t_2;
double tmp;
if (t_3 <= -2e+162) {
tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_1) / KbT)) - -1.0)));
} else if (t_3 <= -4e+17) {
tmp = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((fmax(Ev, EAccept) / KbT))));
} else if (t_3 <= 5e-106) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + t_2;
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(fmin(Ev, EAccept) + Vef) t_1 = Float64(Float64(Ec - Vef) - EDonor) t_2 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT)))) t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_1 - mu)) / KbT)))) + t_2) tmp = 0.0 if (t_3 <= -2e+162) tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_1) / KbT)) - -1.0))); elseif (t_3 <= -4e+17) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(fmax(Ev, EAccept) / KbT))))); elseif (t_3 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + t_2); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$1 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -2e+162], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$1), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -4e+17], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$2), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \left(Ec - Vef\right) - EDonor\\
t_2 := \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
t_3 := \frac{NdChar}{1 + e^{\frac{-\left(t\_1 - mu\right)}{KbT}}} + t\_2\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+162}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_1}{KbT}} - -1}\right)\\
\mathbf{elif}\;t\_3 \leq -4 \cdot 10^{+17}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT}}}\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + t\_2\\
\end{array}
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.9999999999999999e162Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.3%
if -1.9999999999999999e162 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4e17Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6469.4
Applied rewrites69.4%
Taylor expanded in EAccept around inf
lower-/.f6449.1
Applied rewrites49.1%
if -4e17 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (- (- Ec Vef) EDonor))
(t_1
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))
(t_2 (+ (/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT)))) t_1)))
(if (<= t_2 -4e+17)
(fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_0) KbT)) -1.0)))
(if (<= t_2 5e-106)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(+ (* 0.5 NdChar) t_1)))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (Ec - Vef) - EDonor;
double t_1 = NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)));
double t_2 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + t_1;
double tmp;
if (t_2 <= -4e+17) {
tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_0) / KbT)) - -1.0)));
} else if (t_2 <= 5e-106) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + t_1;
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(Ec - Vef) - EDonor) t_1 = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT)))) t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_0 - mu)) / KbT)))) + t_1) tmp = 0.0 if (t_2 <= -4e+17) tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_0) / KbT)) - -1.0))); elseif (t_2 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + t_1); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$0 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+17], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left(Ec - Vef\right) - EDonor\\
t_1 := \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
t_2 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + t\_1\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + t\_1\\
\end{array}
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))))) < -4e17Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.3%
if -4e17 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (- (- Ec Vef) EDonor))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- t_0 mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= t_1 -4e+17)
(fma 0.5 NaChar (/ NdChar (- (exp (/ (- mu t_0) KbT)) -1.0)))
(if (<= t_1 5e-106)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(+
(* 0.5 NdChar)
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Vef) mu) KbT)))))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (Ec - Vef) - EDonor;
double t_1 = (NdChar / (1.0 + exp((-(t_0 - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e+17) {
tmp = fma(0.5, NaChar, (NdChar / (exp(((mu - t_0) / KbT)) - -1.0)));
} else if (t_1 <= 5e-106) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Vef) - mu) / KbT))));
}
return tmp;
}
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(Ec - Vef) - EDonor) t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(t_0 - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_1 <= -4e+17) tmp = fma(0.5, NaChar, Float64(NdChar / Float64(exp(Float64(Float64(mu - t_0) / KbT)) - -1.0))); elseif (t_1 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Vef) - mu) / KbT))))); end return tmp end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(t$95$0 - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+17], N[(0.5 * NaChar + N[(NdChar / N[(N[Exp[N[(N[(mu - t$95$0), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left(Ec - Vef\right) - EDonor\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(t\_0 - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\
\;\;\;\;\mathsf{fma}\left(0.5, NaChar, \frac{NdChar}{e^{\frac{mu - t\_0}{KbT}} - -1}\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}}\\
\end{array}
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))))) < -4e17Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in KbT around inf
Applied rewrites47.3%
if -4e17 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= t_0 -4e+17)
(+ (* 0.5 NdChar) (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Ev) mu) KbT)))))
(if (<= t_0 5e-106)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(+
(* 0.5 NdChar)
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Vef) mu) KbT)))))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_0 <= -4e+17) {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT))));
} else if (t_0 <= 5e-106) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Vef) - mu) / KbT))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
if (t_0 <= (-4d+17)) then
tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp((((eaccept + ev) - mu) / kbt))))
else if (t_0 <= 5d-106) then
tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
else
tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp((((eaccept + vef) - mu) / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_0 <= -4e+17) {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp((((EAccept + Ev) - mu) / KbT))));
} else if (t_0 <= 5e-106) {
tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp((((EAccept + Vef) - mu) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))) tmp = 0 if t_0 <= -4e+17: tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp((((EAccept + Ev) - mu) / KbT)))) elif t_0 <= 5e-106: tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0) else: tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp((((EAccept + Vef) - mu) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_0 <= -4e+17) tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT))))); elseif (t_0 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Vef) - mu) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); tmp = 0.0; if (t_0 <= -4e+17) tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT)))); elseif (t_0 <= 5e-106) tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0); else tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Vef) - mu) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+17], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}}\\
\end{array}
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))))) < -4e17Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Vef around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6443.1
Applied rewrites43.1%
if -4e17 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(* 0.5 NdChar)
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Ev) mu) KbT))))))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= t_1 -4e+17)
t_0
(if (<= t_1 5e-106)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
t_0))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT))));
double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e+17) {
tmp = t_0;
} else if (t_1 <= 5e-106) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp((((eaccept + ev) - mu) / kbt))))
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
if (t_1 <= (-4d+17)) then
tmp = t_0
else if (t_1 <= 5d-106) then
tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp((((EAccept + Ev) - mu) / KbT))));
double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e+17) {
tmp = t_0;
} else if (t_1 <= 5e-106) {
tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (0.5 * NdChar) + (NaChar / (1.0 + math.exp((((EAccept + Ev) - mu) / KbT)))) t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))) tmp = 0 if t_1 <= -4e+17: tmp = t_0 elif t_1 <= 5e-106: tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT))))) t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_1 <= -4e+17) tmp = t_0; elseif (t_1 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (0.5 * NdChar) + (NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT)))); t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); tmp = 0.0; if (t_1 <= -4e+17) tmp = t_0; elseif (t_1 <= 5e-106) tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+17], t$95$0, If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4e17 or 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Vef around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6443.1
Applied rewrites43.1%
if -4e17 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (+ (fmin Ev EAccept) Vef))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/
NaChar
(+ 1.0 (exp (/ (+ (+ t_0 (fmax Ev EAccept)) (- mu)) KbT)))))))
(if (<= t_1 -4e+17)
(+
(* 0.5 NdChar)
(/ NaChar (+ 1.0 (exp (/ (- (fmax Ev EAccept) mu) KbT)))))
(if (<= t_1 5e-106)
(/ NaChar (- (exp (/ (- (+ (fmax Ev EAccept) t_0) mu) KbT)) -1.0))
(+ (* 0.5 NdChar) (/ NaChar (+ 1.0 (exp (/ (- Vef mu) KbT)))))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e+17) {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((fmax(Ev, EAccept) - mu) / KbT))));
} else if (t_1 <= 5e-106) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((Vef - mu) / KbT))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmin(ev, eaccept) + vef
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp((((t_0 + fmax(ev, eaccept)) + -mu) / kbt))))
if (t_1 <= (-4d+17)) then
tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp(((fmax(ev, eaccept) - mu) / kbt))))
else if (t_1 <= 5d-106) then
tmp = nachar / (exp((((fmax(ev, eaccept) + t_0) - mu) / kbt)) - (-1.0d0))
else
tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp(((vef - mu) / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = fmin(Ev, EAccept) + Vef;
double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT))));
double tmp;
if (t_1 <= -4e+17) {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp(((fmax(Ev, EAccept) - mu) / KbT))));
} else if (t_1 <= 5e-106) {
tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp(((Vef - mu) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = fmin(Ev, EAccept) + Vef t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp((((t_0 + fmax(Ev, EAccept)) + -mu) / KbT)))) tmp = 0 if t_1 <= -4e+17: tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp(((fmax(Ev, EAccept) - mu) / KbT)))) elif t_1 <= 5e-106: tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0) else: tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp(((Vef - mu) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(fmin(Ev, EAccept) + Vef) t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(t_0 + fmax(Ev, EAccept)) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_1 <= -4e+17) tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(fmax(Ev, EAccept) - mu) / KbT))))); elseif (t_1 <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Vef - mu) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = min(Ev, EAccept) + Vef; t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp((((t_0 + max(Ev, EAccept)) + -mu) / KbT)))); tmp = 0.0; if (t_1 <= -4e+17) tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((max(Ev, EAccept) - mu) / KbT)))); elseif (t_1 <= 5e-106) tmp = NaChar / (exp((((max(Ev, EAccept) + t_0) - mu) / KbT)) - -1.0); else tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((Vef - mu) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(t$95$0 + N[Max[Ev, EAccept], $MachinePrecision]), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+17], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[Max[Ev, EAccept], $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + t$95$0), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(Vef - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(Ev, EAccept\right) + Vef\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(t\_0 + \mathsf{max}\left(Ev, EAccept\right)\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+17}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\mathsf{max}\left(Ev, EAccept\right) - mu}{KbT}}}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + t\_0\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\
\end{array}
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))))) < -4e17Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
Taylor expanded in Vef around 0
Applied rewrites39.5%
if -4e17 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
Taylor expanded in EAccept around 0
lower--.f6439.0
Applied rewrites39.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(if (<=
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))
5e-106)
(/ NaChar (- (exp (/ (- (+ EAccept (+ Ev Vef)) mu) KbT)) -1.0))
(+ (* 0.5 NdChar) (/ NaChar (+ 1.0 (exp (/ (- Vef mu) KbT)))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (((NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))) <= 5e-106) {
tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((Vef - mu) / KbT))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (((ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))) <= 5d-106) then
tmp = nachar / (exp((((eaccept + (ev + vef)) - mu) / kbt)) - (-1.0d0))
else
tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp(((vef - mu) / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (((NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))) <= 5e-106) {
tmp = NaChar / (Math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp(((Vef - mu) / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if ((NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))) <= 5e-106: tmp = NaChar / (math.exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0) else: tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp(((Vef - mu) / KbT)))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) <= 5e-106) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Float64(Ev + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Vef - mu) / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (((NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))) <= 5e-106) tmp = NaChar / (exp((((EAccept + (Ev + Vef)) - mu) / KbT)) - -1.0); else tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp(((Vef - mu) / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e-106], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + N[(Ev + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(Vef - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}} \leq 5 \cdot 10^{-106}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + \left(Ev + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{Vef - mu}{KbT}}}\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999983e-106Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 4.99999999999999983e-106 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
Taylor expanded in EAccept around 0
lower--.f6439.0
Applied rewrites39.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(if (<= KbT 1.4e+206)
(/
NaChar
(-
(exp (/ (- (+ (fmax Ev EAccept) (+ (fmin Ev EAccept) Vef)) mu) KbT))
-1.0))
(+
(* 0.5 NdChar)
(/
NaChar
(- (+ 2.0 (+ (/ (fmax Ev EAccept) KbT) (/ Vef KbT))) (/ mu KbT))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= 1.4e+206) {
tmp = NaChar / (exp((((fmax(Ev, EAccept) + (fmin(Ev, EAccept) + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((fmax(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (kbt <= 1.4d+206) then
tmp = nachar / (exp((((fmax(ev, eaccept) + (fmin(ev, eaccept) + vef)) - mu) / kbt)) - (-1.0d0))
else
tmp = (0.5d0 * ndchar) + (nachar / ((2.0d0 + ((fmax(ev, eaccept) / kbt) + (vef / kbt))) - (mu / kbt)))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= 1.4e+206) {
tmp = NaChar / (Math.exp((((fmax(Ev, EAccept) + (fmin(Ev, EAccept) + Vef)) - mu) / KbT)) - -1.0);
} else {
tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((fmax(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT)));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if KbT <= 1.4e+206: tmp = NaChar / (math.exp((((fmax(Ev, EAccept) + (fmin(Ev, EAccept) + Vef)) - mu) / KbT)) - -1.0) else: tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((fmax(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (KbT <= 1.4e+206) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(fmax(Ev, EAccept) + Float64(fmin(Ev, EAccept) + Vef)) - mu) / KbT)) - -1.0)); else tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(Float64(2.0 + Float64(Float64(fmax(Ev, EAccept) / KbT) + Float64(Vef / KbT))) - Float64(mu / KbT)))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (KbT <= 1.4e+206) tmp = NaChar / (exp((((max(Ev, EAccept) + (min(Ev, EAccept) + Vef)) - mu) / KbT)) - -1.0); else tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((max(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, 1.4e+206], N[(NaChar / N[(N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + N[(N[Min[Ev, EAccept], $MachinePrecision] + Vef), $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(N[(2.0 + N[(N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision] + N[(Vef / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(mu / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;KbT \leq 1.4 \cdot 10^{+206}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + \left(\mathsf{min}\left(Ev, EAccept\right) + Vef\right)\right) - mu}{KbT}} - -1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}}\\
\end{array}
if KbT < 1.3999999999999999e206Initial 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-+.f6460.4
Applied rewrites60.4%
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
sub-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6460.4
Applied rewrites60.4%
if 1.3999999999999999e206 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
Taylor expanded in KbT around inf
lower--.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6425.7
Applied rewrites25.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(if (<= KbT 7.8e+205)
(/
NaChar
(+ 1.0 (exp (/ (- (+ (fmax Ev EAccept) (fmin Ev EAccept)) mu) KbT))))
(+
(* 0.5 NdChar)
(/
NaChar
(- (+ 2.0 (+ (/ (fmax Ev EAccept) KbT) (/ Vef KbT))) (/ mu KbT))))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= 7.8e+205) {
tmp = NaChar / (1.0 + exp((((fmax(Ev, EAccept) + fmin(Ev, EAccept)) - mu) / KbT)));
} else {
tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((fmax(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (kbt <= 7.8d+205) then
tmp = nachar / (1.0d0 + exp((((fmax(ev, eaccept) + fmin(ev, eaccept)) - mu) / kbt)))
else
tmp = (0.5d0 * ndchar) + (nachar / ((2.0d0 + ((fmax(ev, eaccept) / kbt) + (vef / kbt))) - (mu / kbt)))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= 7.8e+205) {
tmp = NaChar / (1.0 + Math.exp((((fmax(Ev, EAccept) + fmin(Ev, EAccept)) - mu) / KbT)));
} else {
tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((fmax(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT)));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if KbT <= 7.8e+205: tmp = NaChar / (1.0 + math.exp((((fmax(Ev, EAccept) + fmin(Ev, EAccept)) - mu) / KbT))) else: tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((fmax(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (KbT <= 7.8e+205) tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(fmax(Ev, EAccept) + fmin(Ev, EAccept)) - mu) / KbT)))); else tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(Float64(2.0 + Float64(Float64(fmax(Ev, EAccept) / KbT) + Float64(Vef / KbT))) - Float64(mu / KbT)))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (KbT <= 7.8e+205) tmp = NaChar / (1.0 + exp((((max(Ev, EAccept) + min(Ev, EAccept)) - mu) / KbT))); else tmp = (0.5 * NdChar) + (NaChar / ((2.0 + ((max(Ev, EAccept) / KbT) + (Vef / KbT))) - (mu / KbT))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, 7.8e+205], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[Max[Ev, EAccept], $MachinePrecision] + N[Min[Ev, EAccept], $MachinePrecision]), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(N[(2.0 + N[(N[(N[Max[Ev, EAccept], $MachinePrecision] / KbT), $MachinePrecision] + N[(Vef / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(mu / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;KbT \leq 7.8 \cdot 10^{+205}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(\mathsf{max}\left(Ev, EAccept\right) + \mathsf{min}\left(Ev, EAccept\right)\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{\left(2 + \left(\frac{\mathsf{max}\left(Ev, EAccept\right)}{KbT} + \frac{Vef}{KbT}\right)\right) - \frac{mu}{KbT}}\\
\end{array}
if KbT < 7.7999999999999997e205Initial 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-+.f6460.4
Applied rewrites60.4%
Taylor expanded in Vef around 0
Applied rewrites51.3%
if 7.7999999999999997e205 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-+.f6442.9
Applied rewrites42.9%
Taylor expanded in KbT around inf
lower--.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6425.7
Applied rewrites25.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (<= KbT 6.4e+205) (/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Ev) mu) KbT)))) (* (+ NdChar NaChar) 0.5)))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= 6.4e+205) {
tmp = NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT)));
} else {
tmp = (NdChar + NaChar) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (kbt <= 6.4d+205) then
tmp = nachar / (1.0d0 + exp((((eaccept + ev) - mu) / kbt)))
else
tmp = (ndchar + nachar) * 0.5d0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= 6.4e+205) {
tmp = NaChar / (1.0 + Math.exp((((EAccept + Ev) - mu) / KbT)));
} else {
tmp = (NdChar + NaChar) * 0.5;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if KbT <= 6.4e+205: tmp = NaChar / (1.0 + math.exp((((EAccept + Ev) - mu) / KbT))) else: tmp = (NdChar + NaChar) * 0.5 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (KbT <= 6.4e+205) tmp = Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Ev) - mu) / KbT)))); else tmp = Float64(Float64(NdChar + NaChar) * 0.5); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (KbT <= 6.4e+205) tmp = NaChar / (1.0 + exp((((EAccept + Ev) - mu) / KbT))); else tmp = (NdChar + NaChar) * 0.5; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, 6.4e+205], N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(NdChar + NaChar), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;KbT \leq 6.4 \cdot 10^{+205}:\\
\;\;\;\;\frac{NaChar}{1 + e^{\frac{\left(EAccept + Ev\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;\left(NdChar + NaChar\right) \cdot 0.5\\
\end{array}
if KbT < 6.39999999999999993e205Initial 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-+.f6460.4
Applied rewrites60.4%
Taylor expanded in Vef around 0
Applied rewrites51.3%
if 6.39999999999999993e205 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.6
Applied rewrites27.6%
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6427.6
Applied rewrites27.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (* (+ NdChar NaChar) 0.5))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT)))))))
(if (<= t_1 -5e-264)
t_0
(if (<= t_1 5e-228)
(/ 1.0 (/ (+ 2.0 (* -2.0 (/ NaChar NdChar))) NdChar))
t_0))))double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar + NaChar) * 0.5;
double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_1 <= -5e-264) {
tmp = t_0;
} else if (t_1 <= 5e-228) {
tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar);
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (ndchar + nachar) * 0.5d0
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
if (t_1 <= (-5d-264)) then
tmp = t_0
else if (t_1 <= 5d-228) then
tmp = 1.0d0 / ((2.0d0 + ((-2.0d0) * (nachar / ndchar))) / ndchar)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar + NaChar) * 0.5;
double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
double tmp;
if (t_1 <= -5e-264) {
tmp = t_0;
} else if (t_1 <= 5e-228) {
tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar);
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar + NaChar) * 0.5 t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))) tmp = 0 if t_1 <= -5e-264: tmp = t_0 elif t_1 <= 5e-228: tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar + NaChar) * 0.5) t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) tmp = 0.0 if (t_1 <= -5e-264) tmp = t_0; elseif (t_1 <= 5e-228) tmp = Float64(1.0 / Float64(Float64(2.0 + Float64(-2.0 * Float64(NaChar / NdChar))) / NdChar)); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar + NaChar) * 0.5; t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); tmp = 0.0; if (t_1 <= -5e-264) tmp = t_0; elseif (t_1 <= 5e-228) tmp = 1.0 / ((2.0 + (-2.0 * (NaChar / NdChar))) / NdChar); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar + NaChar), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-264], t$95$0, If[LessEqual[t$95$1, 5e-228], N[(1.0 / N[(N[(2.0 + N[(-2.0 * N[(NaChar / NdChar), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / NdChar), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \left(NdChar + NaChar\right) \cdot 0.5\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-264}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-228}:\\
\;\;\;\;\frac{1}{\frac{2 + -2 \cdot \frac{NaChar}{NdChar}}{NdChar}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -5.0000000000000001e-264 or 4.99999999999999972e-228 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.6
Applied rewrites27.6%
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6427.6
Applied rewrites27.6%
if -5.0000000000000001e-264 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999972e-228Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.6
Applied rewrites27.6%
lift-fma.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
lower-unsound-*.f64N/A
lower-unsound-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-unsound--.f64N/A
lower-*.f6417.2
Applied rewrites17.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6417.2
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6417.2
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
distribute-lft-out--N/A
Applied rewrites17.2%
Taylor expanded in NdChar around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f6420.1
Applied rewrites20.1%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (* (+ NdChar NaChar) 0.5))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar + NaChar) * 0.5;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar + nachar) * 0.5d0
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar + NaChar) * 0.5;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar + NaChar) * 0.5
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar + NaChar) * 0.5) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar + NaChar) * 0.5; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar + NaChar), $MachinePrecision] * 0.5), $MachinePrecision]
\left(NdChar + NaChar\right) \cdot 0.5
Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.6
Applied rewrites27.6%
lift-fma.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6427.6
Applied rewrites27.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]
0.5 \cdot NaChar
Initial program 100.0%
Taylor expanded in KbT around inf
lower-fma.f64N/A
lower-*.f6427.6
Applied rewrites27.6%
Taylor expanded in NdChar around 0
lower-*.f6418.1
Applied rewrites18.1%
herbie shell --seed 2025175
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:name "Bulmash initializePoisson"
:precision binary64
(+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))