
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 31 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (+ (+ (+ Ev Vef) EAccept) (- mu)) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) + -mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) + -mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) + Float64(-mu)) / KbT))))) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) + -mu) / KbT)))); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] + (-mu)), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) + \left(-mu\right)}{KbT}}}
\end{array}
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (+ (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))) (/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))))
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)))); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ mu KbT))))
(/ NaChar (+ 1.0 (exp (/ (- mu) KbT))))))
(t_1 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_2 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_3 (/ NaChar (+ 1.0 t_2)))
(t_4 (+ t_1 t_3)))
(if (<= t_4 -5e+112)
(+
(/ NdChar (+ 1.0 (exp (/ Vef KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ EAccept Vef) mu) KbT)))))
(if (<= t_4 -5e-198)
t_0
(if (<= t_4 2e-219)
(/ NaChar (+ t_2 1.0))
(if (<= t_4 5e-77)
t_0
(if (<= t_4 1e+182)
(+ (* 0.5 NdChar) t_3)
(+ t_1 (* 0.5 NaChar)))))))))
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((-mu / KbT))));
double t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_3 = NaChar / (1.0 + t_2);
double t_4 = t_1 + t_3;
double tmp;
if (t_4 <= -5e+112) {
tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp((((EAccept + Vef) - mu) / KbT))));
} else if (t_4 <= -5e-198) {
tmp = t_0;
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_2 + 1.0);
} else if (t_4 <= 5e-77) {
tmp = t_0;
} else if (t_4 <= 1e+182) {
tmp = (0.5 * NdChar) + t_3;
} else {
tmp = t_1 + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp((-mu / kbt))))
t_1 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_2 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_3 = nachar / (1.0d0 + t_2)
t_4 = t_1 + t_3
if (t_4 <= (-5d+112)) then
tmp = (ndchar / (1.0d0 + exp((vef / kbt)))) + (nachar / (1.0d0 + exp((((eaccept + vef) - mu) / kbt))))
else if (t_4 <= (-5d-198)) then
tmp = t_0
else if (t_4 <= 2d-219) then
tmp = nachar / (t_2 + 1.0d0)
else if (t_4 <= 5d-77) then
tmp = t_0
else if (t_4 <= 1d+182) then
tmp = (0.5d0 * ndchar) + t_3
else
tmp = t_1 + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp((-mu / KbT))));
double t_1 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_3 = NaChar / (1.0 + t_2);
double t_4 = t_1 + t_3;
double tmp;
if (t_4 <= -5e+112) {
tmp = (NdChar / (1.0 + Math.exp((Vef / KbT)))) + (NaChar / (1.0 + Math.exp((((EAccept + Vef) - mu) / KbT))));
} else if (t_4 <= -5e-198) {
tmp = t_0;
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_2 + 1.0);
} else if (t_4 <= 5e-77) {
tmp = t_0;
} else if (t_4 <= 1e+182) {
tmp = (0.5 * NdChar) + t_3;
} else {
tmp = t_1 + (0.5 * NaChar);
}
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((-mu / KbT)))) t_1 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_2 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_3 = NaChar / (1.0 + t_2) t_4 = t_1 + t_3 tmp = 0 if t_4 <= -5e+112: tmp = (NdChar / (1.0 + math.exp((Vef / KbT)))) + (NaChar / (1.0 + math.exp((((EAccept + Vef) - mu) / KbT)))) elif t_4 <= -5e-198: tmp = t_0 elif t_4 <= 2e-219: tmp = NaChar / (t_2 + 1.0) elif t_4 <= 5e-77: tmp = t_0 elif t_4 <= 1e+182: tmp = (0.5 * NdChar) + t_3 else: tmp = t_1 + (0.5 * NaChar) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(-mu) / KbT))))) t_1 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) t_2 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_3 = Float64(NaChar / Float64(1.0 + t_2)) t_4 = Float64(t_1 + t_3) tmp = 0.0 if (t_4 <= -5e+112) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Vef / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(EAccept + Vef) - mu) / KbT))))); elseif (t_4 <= -5e-198) tmp = t_0; elseif (t_4 <= 2e-219) tmp = Float64(NaChar / Float64(t_2 + 1.0)); elseif (t_4 <= 5e-77) tmp = t_0; elseif (t_4 <= 1e+182) tmp = Float64(Float64(0.5 * NdChar) + t_3); else tmp = Float64(t_1 + Float64(0.5 * NaChar)); 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((-mu / KbT)))); t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_2 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_3 = NaChar / (1.0 + t_2); t_4 = t_1 + t_3; tmp = 0.0; if (t_4 <= -5e+112) tmp = (NdChar / (1.0 + exp((Vef / KbT)))) + (NaChar / (1.0 + exp((((EAccept + Vef) - mu) / KbT)))); elseif (t_4 <= -5e-198) tmp = t_0; elseif (t_4 <= 2e-219) tmp = NaChar / (t_2 + 1.0); elseif (t_4 <= 5e-77) tmp = t_0; elseif (t_4 <= 1e+182) tmp = (0.5 * NdChar) + t_3; else tmp = t_1 + (0.5 * NaChar); 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[((-mu) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(NaChar / N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + t$95$3), $MachinePrecision]}, If[LessEqual[t$95$4, -5e+112], 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[(EAccept + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, -5e-198], t$95$0, If[LessEqual[t$95$4, 2e-219], N[(NaChar / N[(t$95$2 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5e-77], t$95$0, If[LessEqual[t$95$4, 1e+182], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$3), $MachinePrecision], N[(t$95$1 + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{-mu}{KbT}}}\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_2 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_3 := \frac{NaChar}{1 + t\_2}\\
t_4 := t\_1 + t\_3\\
\mathbf{if}\;t\_4 \leq -5 \cdot 10^{+112}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{Vef}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}}}\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-198}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_4 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\frac{NaChar}{t\_2 + 1}\\
\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_4 \leq 10^{+182}:\\
\;\;\;\;0.5 \cdot NdChar + t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1 + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -5e112Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6488.3
Applied rewrites88.3%
Taylor expanded in Vef around inf
lower-/.f6483.7
Applied rewrites83.7%
Taylor expanded in Ev around 0
lower-/.f64N/A
lower--.f64N/A
lower-+.f6476.8
Applied rewrites76.8%
if -5e112 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.9999999999999999e-198 or 2.0000000000000001e-219 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999963e-77Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6479.7
Applied rewrites79.7%
Taylor expanded in mu around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6468.3
Applied rewrites68.3%
if -4.9999999999999999e-198 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 2.0000000000000001e-219Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6484.6
Applied rewrites84.6%
if 4.99999999999999963e-77 < (+.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.0000000000000001e182Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6480.3
Applied rewrites80.3%
if 1.0000000000000001e182 < (+.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-*.f6487.2
Applied rewrites87.2%
Final simplification77.9%
(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 (/ (- mu) KbT))))))
(t_1 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_2 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_3 (/ NaChar (+ 1.0 t_2)))
(t_4 (+ t_1 t_3)))
(if (<= t_4 -5e-198)
t_0
(if (<= t_4 2e-219)
(/ NaChar (+ t_2 1.0))
(if (<= t_4 5e-77)
t_0
(if (<= t_4 1e+182)
(+ (* 0.5 NdChar) t_3)
(+ t_1 (* 0.5 NaChar))))))))
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((-mu / KbT))));
double t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_3 = NaChar / (1.0 + t_2);
double t_4 = t_1 + t_3;
double tmp;
if (t_4 <= -5e-198) {
tmp = t_0;
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_2 + 1.0);
} else if (t_4 <= 5e-77) {
tmp = t_0;
} else if (t_4 <= 1e+182) {
tmp = (0.5 * NdChar) + t_3;
} else {
tmp = t_1 + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp((-mu / kbt))))
t_1 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_2 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_3 = nachar / (1.0d0 + t_2)
t_4 = t_1 + t_3
if (t_4 <= (-5d-198)) then
tmp = t_0
else if (t_4 <= 2d-219) then
tmp = nachar / (t_2 + 1.0d0)
else if (t_4 <= 5d-77) then
tmp = t_0
else if (t_4 <= 1d+182) then
tmp = (0.5d0 * ndchar) + t_3
else
tmp = t_1 + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp((-mu / KbT))));
double t_1 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_2 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_3 = NaChar / (1.0 + t_2);
double t_4 = t_1 + t_3;
double tmp;
if (t_4 <= -5e-198) {
tmp = t_0;
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_2 + 1.0);
} else if (t_4 <= 5e-77) {
tmp = t_0;
} else if (t_4 <= 1e+182) {
tmp = (0.5 * NdChar) + t_3;
} else {
tmp = t_1 + (0.5 * NaChar);
}
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((-mu / KbT)))) t_1 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_2 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_3 = NaChar / (1.0 + t_2) t_4 = t_1 + t_3 tmp = 0 if t_4 <= -5e-198: tmp = t_0 elif t_4 <= 2e-219: tmp = NaChar / (t_2 + 1.0) elif t_4 <= 5e-77: tmp = t_0 elif t_4 <= 1e+182: tmp = (0.5 * NdChar) + t_3 else: tmp = t_1 + (0.5 * NaChar) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(-mu) / KbT))))) t_1 = Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) t_2 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_3 = Float64(NaChar / Float64(1.0 + t_2)) t_4 = Float64(t_1 + t_3) tmp = 0.0 if (t_4 <= -5e-198) tmp = t_0; elseif (t_4 <= 2e-219) tmp = Float64(NaChar / Float64(t_2 + 1.0)); elseif (t_4 <= 5e-77) tmp = t_0; elseif (t_4 <= 1e+182) tmp = Float64(Float64(0.5 * NdChar) + t_3); else tmp = Float64(t_1 + Float64(0.5 * NaChar)); 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((-mu / KbT)))); t_1 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_2 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_3 = NaChar / (1.0 + t_2); t_4 = t_1 + t_3; tmp = 0.0; if (t_4 <= -5e-198) tmp = t_0; elseif (t_4 <= 2e-219) tmp = NaChar / (t_2 + 1.0); elseif (t_4 <= 5e-77) tmp = t_0; elseif (t_4 <= 1e+182) tmp = (0.5 * NdChar) + t_3; else tmp = t_1 + (0.5 * NaChar); 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[((-mu) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(NaChar / N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + t$95$3), $MachinePrecision]}, If[LessEqual[t$95$4, -5e-198], t$95$0, If[LessEqual[t$95$4, 2e-219], N[(NaChar / N[(t$95$2 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5e-77], t$95$0, If[LessEqual[t$95$4, 1e+182], N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$3), $MachinePrecision], N[(t$95$1 + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{-mu}{KbT}}}\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_2 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_3 := \frac{NaChar}{1 + t\_2}\\
t_4 := t\_1 + t\_3\\
\mathbf{if}\;t\_4 \leq -5 \cdot 10^{-198}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_4 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\frac{NaChar}{t\_2 + 1}\\
\mathbf{elif}\;t\_4 \leq 5 \cdot 10^{-77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_4 \leq 10^{+182}:\\
\;\;\;\;0.5 \cdot NdChar + t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1 + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.9999999999999999e-198 or 2.0000000000000001e-219 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999963e-77Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6483.5
Applied rewrites83.5%
Taylor expanded in mu around inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6469.0
Applied rewrites69.0%
if -4.9999999999999999e-198 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 2.0000000000000001e-219Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6484.6
Applied rewrites84.6%
if 4.99999999999999963e-77 < (+.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.0000000000000001e182Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6480.3
Applied rewrites80.3%
if 1.0000000000000001e182 < (+.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-*.f6487.2
Applied rewrites87.2%
Final simplification76.3%
(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 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_2 (/ NaChar (+ 1.0 t_1)))
(t_3 (+ (* 0.5 NdChar) t_2))
(t_4 (+ t_0 t_2)))
(if (<= t_4 -1e+121)
t_3
(if (<= t_4 -1e-37)
(+
(/ NdChar (+ 1.0 (exp (/ mu KbT))))
(/ NaChar (+ 1.0 (exp (/ Ev KbT)))))
(if (<= t_4 2e-219)
(/ NaChar (+ t_1 1.0))
(if (<= t_4 1e+182) t_3 (+ t_0 (* 0.5 NaChar))))))))
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 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = (0.5 * NdChar) + t_2;
double t_4 = t_0 + t_2;
double tmp;
if (t_4 <= -1e+121) {
tmp = t_3;
} else if (t_4 <= -1e-37) {
tmp = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((Ev / KbT))));
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_4 <= 1e+182) {
tmp = t_3;
} else {
tmp = t_0 + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_2 = nachar / (1.0d0 + t_1)
t_3 = (0.5d0 * ndchar) + t_2
t_4 = t_0 + t_2
if (t_4 <= (-1d+121)) then
tmp = t_3
else if (t_4 <= (-1d-37)) then
tmp = (ndchar / (1.0d0 + exp((mu / kbt)))) + (nachar / (1.0d0 + exp((ev / kbt))))
else if (t_4 <= 2d-219) then
tmp = nachar / (t_1 + 1.0d0)
else if (t_4 <= 1d+182) then
tmp = t_3
else
tmp = t_0 + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = (0.5 * NdChar) + t_2;
double t_4 = t_0 + t_2;
double tmp;
if (t_4 <= -1e+121) {
tmp = t_3;
} else if (t_4 <= -1e-37) {
tmp = (NdChar / (1.0 + Math.exp((mu / KbT)))) + (NaChar / (1.0 + Math.exp((Ev / KbT))));
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_4 <= 1e+182) {
tmp = t_3;
} else {
tmp = t_0 + (0.5 * NaChar);
}
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 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_2 = NaChar / (1.0 + t_1) t_3 = (0.5 * NdChar) + t_2 t_4 = t_0 + t_2 tmp = 0 if t_4 <= -1e+121: tmp = t_3 elif t_4 <= -1e-37: tmp = (NdChar / (1.0 + math.exp((mu / KbT)))) + (NaChar / (1.0 + math.exp((Ev / KbT)))) elif t_4 <= 2e-219: tmp = NaChar / (t_1 + 1.0) elif t_4 <= 1e+182: tmp = t_3 else: tmp = t_0 + (0.5 * NaChar) 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 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_2 = Float64(NaChar / Float64(1.0 + t_1)) t_3 = Float64(Float64(0.5 * NdChar) + t_2) t_4 = Float64(t_0 + t_2) tmp = 0.0 if (t_4 <= -1e+121) tmp = t_3; elseif (t_4 <= -1e-37) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))))); elseif (t_4 <= 2e-219) tmp = Float64(NaChar / Float64(t_1 + 1.0)); elseif (t_4 <= 1e+182) tmp = t_3; else tmp = Float64(t_0 + Float64(0.5 * NaChar)); 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 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_2 = NaChar / (1.0 + t_1); t_3 = (0.5 * NdChar) + t_2; t_4 = t_0 + t_2; tmp = 0.0; if (t_4 <= -1e+121) tmp = t_3; elseif (t_4 <= -1e-37) tmp = (NdChar / (1.0 + exp((mu / KbT)))) + (NaChar / (1.0 + exp((Ev / KbT)))); elseif (t_4 <= 2e-219) tmp = NaChar / (t_1 + 1.0); elseif (t_4 <= 1e+182) tmp = t_3; else tmp = t_0 + (0.5 * NaChar); 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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, -1e+121], t$95$3, If[LessEqual[t$95$4, -1e-37], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2e-219], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e+182], t$95$3, N[(t$95$0 + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NaChar}{1 + t\_1}\\
t_3 := 0.5 \cdot NdChar + t\_2\\
t_4 := t\_0 + t\_2\\
\mathbf{if}\;t\_4 \leq -1 \cdot 10^{+121}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq -1 \cdot 10^{-37}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
\mathbf{elif}\;t\_4 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\
\mathbf{elif}\;t\_4 \leq 10^{+182}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_0 + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000004e121 or 2.0000000000000001e-219 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1.0000000000000001e182Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6471.2
Applied rewrites71.2%
if -1.00000000000000004e121 < (+.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.00000000000000007e-37Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6481.8
Applied rewrites81.8%
Taylor expanded in Ev around inf
lower-/.f6467.6
Applied rewrites67.6%
if -1.00000000000000007e-37 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 2.0000000000000001e-219Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6476.2
Applied rewrites76.2%
if 1.0000000000000001e182 < (+.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-*.f6487.2
Applied rewrites87.2%
Final simplification73.8%
(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 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_2 (/ NaChar (+ 1.0 t_1)))
(t_3 (+ (/ NdChar (+ 1.0 (exp (/ mu KbT)))) t_2))
(t_4 (+ t_0 t_2)))
(if (<= t_4 -5e-299)
t_3
(if (<= t_4 0.0)
(/ NaChar (+ t_1 1.0))
(if (<= t_4 1e+182)
t_3
(+ t_0 (/ NaChar (+ 1.0 (exp (/ EAccept KbT))))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = (NdChar / (1.0 + exp((mu / KbT)))) + t_2;
double t_4 = t_0 + t_2;
double tmp;
if (t_4 <= -5e-299) {
tmp = t_3;
} else if (t_4 <= 0.0) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_4 <= 1e+182) {
tmp = t_3;
} else {
tmp = t_0 + (NaChar / (1.0 + exp((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) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_2 = nachar / (1.0d0 + t_1)
t_3 = (ndchar / (1.0d0 + exp((mu / kbt)))) + t_2
t_4 = t_0 + t_2
if (t_4 <= (-5d-299)) then
tmp = t_3
else if (t_4 <= 0.0d0) then
tmp = nachar / (t_1 + 1.0d0)
else if (t_4 <= 1d+182) then
tmp = t_3
else
tmp = t_0 + (nachar / (1.0d0 + exp((eaccept / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = (NdChar / (1.0 + Math.exp((mu / KbT)))) + t_2;
double t_4 = t_0 + t_2;
double tmp;
if (t_4 <= -5e-299) {
tmp = t_3;
} else if (t_4 <= 0.0) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_4 <= 1e+182) {
tmp = t_3;
} else {
tmp = t_0 + (NaChar / (1.0 + Math.exp((EAccept / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_1 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_2 = NaChar / (1.0 + t_1) t_3 = (NdChar / (1.0 + math.exp((mu / KbT)))) + t_2 t_4 = t_0 + t_2 tmp = 0 if t_4 <= -5e-299: tmp = t_3 elif t_4 <= 0.0: tmp = NaChar / (t_1 + 1.0) elif t_4 <= 1e+182: tmp = t_3 else: tmp = t_0 + (NaChar / (1.0 + math.exp((EAccept / KbT)))) 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 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_2 = Float64(NaChar / Float64(1.0 + t_1)) t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + t_2) t_4 = Float64(t_0 + t_2) tmp = 0.0 if (t_4 <= -5e-299) tmp = t_3; elseif (t_4 <= 0.0) tmp = Float64(NaChar / Float64(t_1 + 1.0)); elseif (t_4 <= 1e+182) tmp = t_3; else tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(EAccept / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_2 = NaChar / (1.0 + t_1); t_3 = (NdChar / (1.0 + exp((mu / KbT)))) + t_2; t_4 = t_0 + t_2; tmp = 0.0; if (t_4 <= -5e-299) tmp = t_3; elseif (t_4 <= 0.0) tmp = NaChar / (t_1 + 1.0); elseif (t_4 <= 1e+182) tmp = t_3; else tmp = t_0 + (NaChar / (1.0 + exp((EAccept / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + t$95$1), $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$0 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, -5e-299], t$95$3, If[LessEqual[t$95$4, 0.0], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e+182], t$95$3, N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(EAccept / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NaChar}{1 + t\_1}\\
t_3 := \frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_2\\
t_4 := t\_0 + t\_2\\
\mathbf{if}\;t\_4 \leq -5 \cdot 10^{-299}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\
\mathbf{elif}\;t\_4 \leq 10^{+182}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{EAccept}{KbT}}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.99999999999999956e-299 or 0.0 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1.0000000000000001e182Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6481.7
Applied rewrites81.7%
if -4.99999999999999956e-299 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 0.0Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f64100.0
Applied rewrites100.0%
if 1.0000000000000001e182 < (+.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-/.f6495.7
Applied rewrites95.7%
Final simplification85.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_1 (/ NaChar (+ 1.0 t_0)))
(t_2 (+ (/ NdChar (+ 1.0 (exp (/ EDonor KbT)))) t_1))
(t_3
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
t_1)))
(if (<= t_3 -4e-288)
t_2
(if (<= t_3 2e-219)
(/ NaChar (+ t_0 1.0))
(if (<= t_3 4e+248)
t_2
(+
(/ NdChar (+ 1.0 (exp (/ (- (+ mu Vef) Ec) KbT))))
(* 0.5 NaChar)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = NaChar / (1.0 + t_0);
double t_2 = (NdChar / (1.0 + exp((EDonor / KbT)))) + t_1;
double t_3 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
double tmp;
if (t_3 <= -4e-288) {
tmp = t_2;
} else if (t_3 <= 2e-219) {
tmp = NaChar / (t_0 + 1.0);
} else if (t_3 <= 4e+248) {
tmp = t_2;
} else {
tmp = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_1 = nachar / (1.0d0 + t_0)
t_2 = (ndchar / (1.0d0 + exp((edonor / kbt)))) + t_1
t_3 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
if (t_3 <= (-4d-288)) then
tmp = t_2
else if (t_3 <= 2d-219) then
tmp = nachar / (t_0 + 1.0d0)
else if (t_3 <= 4d+248) then
tmp = t_2
else
tmp = (ndchar / (1.0d0 + exp((((mu + vef) - ec) / kbt)))) + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = NaChar / (1.0 + t_0);
double t_2 = (NdChar / (1.0 + Math.exp((EDonor / KbT)))) + t_1;
double t_3 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
double tmp;
if (t_3 <= -4e-288) {
tmp = t_2;
} else if (t_3 <= 2e-219) {
tmp = NaChar / (t_0 + 1.0);
} else if (t_3 <= 4e+248) {
tmp = t_2;
} else {
tmp = (NdChar / (1.0 + Math.exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_1 = NaChar / (1.0 + t_0) t_2 = (NdChar / (1.0 + math.exp((EDonor / KbT)))) + t_1 t_3 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1 tmp = 0 if t_3 <= -4e-288: tmp = t_2 elif t_3 <= 2e-219: tmp = NaChar / (t_0 + 1.0) elif t_3 <= 4e+248: tmp = t_2 else: tmp = (NdChar / (1.0 + math.exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_1 = Float64(NaChar / Float64(1.0 + t_0)) t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(EDonor / KbT)))) + t_1) t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1) tmp = 0.0 if (t_3 <= -4e-288) tmp = t_2; elseif (t_3 <= 2e-219) tmp = Float64(NaChar / Float64(t_0 + 1.0)); elseif (t_3 <= 4e+248) tmp = t_2; else tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(mu + Vef) - Ec) / KbT)))) + Float64(0.5 * NaChar)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_1 = NaChar / (1.0 + t_0); t_2 = (NdChar / (1.0 + exp((EDonor / KbT)))) + t_1; t_3 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1; tmp = 0.0; if (t_3 <= -4e-288) tmp = t_2; elseif (t_3 <= 2e-219) tmp = NaChar / (t_0 + 1.0); elseif (t_3 <= 4e+248) tmp = t_2; else tmp = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[(EDonor / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -4e-288], t$95$2, If[LessEqual[t$95$3, 2e-219], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4e+248], t$95$2, N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(mu + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_1 := \frac{NaChar}{1 + t\_0}\\
t_2 := \frac{NdChar}{1 + e^{\frac{EDonor}{KbT}}} + t\_1\\
t_3 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\
\mathbf{if}\;t\_3 \leq -4 \cdot 10^{-288}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\frac{NaChar}{t\_0 + 1}\\
\mathbf{elif}\;t\_3 \leq 4 \cdot 10^{+248}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.00000000000000023e-288 or 2.0000000000000001e-219 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.00000000000000018e248Initial program 100.0%
Taylor expanded in EDonor around inf
lower-/.f6478.3
Applied rewrites78.3%
if -4.00000000000000023e-288 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 2.0000000000000001e-219Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6489.7
Applied rewrites89.7%
if 4.00000000000000018e248 < (+.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-*.f6493.2
Applied rewrites93.2%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6493.2
Applied rewrites93.2%
Final simplification81.3%
(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 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_2 (/ NaChar (+ 1.0 t_1)))
(t_3 (+ (* 0.5 NdChar) t_2))
(t_4 (+ t_0 t_2)))
(if (<= t_4 -2e+131)
t_3
(if (<= t_4 2e-219)
(/ NaChar (+ t_1 1.0))
(if (<= t_4 1e+182) t_3 (+ t_0 (* 0.5 NaChar)))))))
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 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = (0.5 * NdChar) + t_2;
double t_4 = t_0 + t_2;
double tmp;
if (t_4 <= -2e+131) {
tmp = t_3;
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_4 <= 1e+182) {
tmp = t_3;
} else {
tmp = t_0 + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_2 = nachar / (1.0d0 + t_1)
t_3 = (0.5d0 * ndchar) + t_2
t_4 = t_0 + t_2
if (t_4 <= (-2d+131)) then
tmp = t_3
else if (t_4 <= 2d-219) then
tmp = nachar / (t_1 + 1.0d0)
else if (t_4 <= 1d+182) then
tmp = t_3
else
tmp = t_0 + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = (0.5 * NdChar) + t_2;
double t_4 = t_0 + t_2;
double tmp;
if (t_4 <= -2e+131) {
tmp = t_3;
} else if (t_4 <= 2e-219) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_4 <= 1e+182) {
tmp = t_3;
} else {
tmp = t_0 + (0.5 * NaChar);
}
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 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_2 = NaChar / (1.0 + t_1) t_3 = (0.5 * NdChar) + t_2 t_4 = t_0 + t_2 tmp = 0 if t_4 <= -2e+131: tmp = t_3 elif t_4 <= 2e-219: tmp = NaChar / (t_1 + 1.0) elif t_4 <= 1e+182: tmp = t_3 else: tmp = t_0 + (0.5 * NaChar) 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 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_2 = Float64(NaChar / Float64(1.0 + t_1)) t_3 = Float64(Float64(0.5 * NdChar) + t_2) t_4 = Float64(t_0 + t_2) tmp = 0.0 if (t_4 <= -2e+131) tmp = t_3; elseif (t_4 <= 2e-219) tmp = Float64(NaChar / Float64(t_1 + 1.0)); elseif (t_4 <= 1e+182) tmp = t_3; else tmp = Float64(t_0 + Float64(0.5 * NaChar)); 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 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_2 = NaChar / (1.0 + t_1); t_3 = (0.5 * NdChar) + t_2; t_4 = t_0 + t_2; tmp = 0.0; if (t_4 <= -2e+131) tmp = t_3; elseif (t_4 <= 2e-219) tmp = NaChar / (t_1 + 1.0); elseif (t_4 <= 1e+182) tmp = t_3; else tmp = t_0 + (0.5 * NaChar); 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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, -2e+131], t$95$3, If[LessEqual[t$95$4, 2e-219], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1e+182], t$95$3, N[(t$95$0 + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NaChar}{1 + t\_1}\\
t_3 := 0.5 \cdot NdChar + t\_2\\
t_4 := t\_0 + t\_2\\
\mathbf{if}\;t\_4 \leq -2 \cdot 10^{+131}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\
\mathbf{elif}\;t\_4 \leq 10^{+182}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_0 + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.9999999999999998e131 or 2.0000000000000001e-219 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1.0000000000000001e182Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6471.3
Applied rewrites71.3%
if -1.9999999999999998e131 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 2.0000000000000001e-219Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6470.6
Applied rewrites70.6%
if 1.0000000000000001e182 < (+.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-*.f6487.2
Applied rewrites87.2%
Final simplification72.1%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_1 (/ NaChar (+ 1.0 t_0)))
(t_2 (+ (* 0.5 NdChar) t_1))
(t_3
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
t_1)))
(if (<= t_3 -2e+131)
t_2
(if (<= t_3 2e-219)
(/ NaChar (+ t_0 1.0))
(if (<= t_3 2e+224)
t_2
(+
(/ NdChar (+ 1.0 (exp (/ (- (+ mu Vef) Ec) KbT))))
(* 0.5 NaChar)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = NaChar / (1.0 + t_0);
double t_2 = (0.5 * NdChar) + t_1;
double t_3 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
double tmp;
if (t_3 <= -2e+131) {
tmp = t_2;
} else if (t_3 <= 2e-219) {
tmp = NaChar / (t_0 + 1.0);
} else if (t_3 <= 2e+224) {
tmp = t_2;
} else {
tmp = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_1 = nachar / (1.0d0 + t_0)
t_2 = (0.5d0 * ndchar) + t_1
t_3 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
if (t_3 <= (-2d+131)) then
tmp = t_2
else if (t_3 <= 2d-219) then
tmp = nachar / (t_0 + 1.0d0)
else if (t_3 <= 2d+224) then
tmp = t_2
else
tmp = (ndchar / (1.0d0 + exp((((mu + vef) - ec) / kbt)))) + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = NaChar / (1.0 + t_0);
double t_2 = (0.5 * NdChar) + t_1;
double t_3 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
double tmp;
if (t_3 <= -2e+131) {
tmp = t_2;
} else if (t_3 <= 2e-219) {
tmp = NaChar / (t_0 + 1.0);
} else if (t_3 <= 2e+224) {
tmp = t_2;
} else {
tmp = (NdChar / (1.0 + Math.exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_1 = NaChar / (1.0 + t_0) t_2 = (0.5 * NdChar) + t_1 t_3 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1 tmp = 0 if t_3 <= -2e+131: tmp = t_2 elif t_3 <= 2e-219: tmp = NaChar / (t_0 + 1.0) elif t_3 <= 2e+224: tmp = t_2 else: tmp = (NdChar / (1.0 + math.exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_1 = Float64(NaChar / Float64(1.0 + t_0)) t_2 = Float64(Float64(0.5 * NdChar) + t_1) t_3 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1) tmp = 0.0 if (t_3 <= -2e+131) tmp = t_2; elseif (t_3 <= 2e-219) tmp = Float64(NaChar / Float64(t_0 + 1.0)); elseif (t_3 <= 2e+224) tmp = t_2; else tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(Float64(mu + Vef) - Ec) / KbT)))) + Float64(0.5 * NaChar)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_1 = NaChar / (1.0 + t_0); t_2 = (0.5 * NdChar) + t_1; t_3 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1; tmp = 0.0; if (t_3 <= -2e+131) tmp = t_2; elseif (t_3 <= 2e-219) tmp = NaChar / (t_0 + 1.0); elseif (t_3 <= 2e+224) tmp = t_2; else tmp = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 * NdChar), $MachinePrecision] + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -2e+131], t$95$2, If[LessEqual[t$95$3, 2e-219], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+224], t$95$2, N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(mu + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_1 := \frac{NaChar}{1 + t\_0}\\
t_2 := 0.5 \cdot NdChar + t\_1\\
t_3 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\
\mathbf{if}\;t\_3 \leq -2 \cdot 10^{+131}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-219}:\\
\;\;\;\;\frac{NaChar}{t\_0 + 1}\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{+224}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.9999999999999998e131 or 2.0000000000000001e-219 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 1.99999999999999994e224Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6470.7
Applied rewrites70.7%
if -1.9999999999999998e131 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 2.0000000000000001e-219Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6470.6
Applied rewrites70.6%
if 1.99999999999999994e224 < (+.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-*.f6494.6
Applied rewrites94.6%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.2
Applied rewrites88.2%
Final simplification71.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+ (/ NdChar (+ 1.0 (exp (/ (- (+ mu Vef) Ec) KbT)))) (* 0.5 NaChar)))
(t_1 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_2
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 t_1)))))
(if (<= t_2 -2e+161)
t_0
(if (<= t_2 4e-76)
(/ NaChar (+ t_1 1.0))
(if (<= t_2 2e+224)
(+ (* 0.5 NdChar) (/ NaChar (+ 1.0 (exp (/ (- (+ Vef Ev) mu) KbT)))))
t_0)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar);
double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
double tmp;
if (t_2 <= -2e+161) {
tmp = t_0;
} else if (t_2 <= 4e-76) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_2 <= 2e+224) {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((Vef + Ev) - mu) / KbT))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((((mu + vef) - ec) / kbt)))) + (0.5d0 * nachar)
t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_1))
if (t_2 <= (-2d+161)) then
tmp = t_0
else if (t_2 <= 4d-76) then
tmp = nachar / (t_1 + 1.0d0)
else if (t_2 <= 2d+224) then
tmp = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp((((vef + ev) - mu) / kbt))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar);
double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
double tmp;
if (t_2 <= -2e+161) {
tmp = t_0;
} else if (t_2 <= 4e-76) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_2 <= 2e+224) {
tmp = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp((((Vef + Ev) - 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 + Vef) - Ec) / KbT)))) + (0.5 * NaChar) t_1 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1)) tmp = 0 if t_2 <= -2e+161: tmp = t_0 elif t_2 <= 4e-76: tmp = NaChar / (t_1 + 1.0) elif t_2 <= 2e+224: tmp = (0.5 * NdChar) + (NaChar / (1.0 + math.exp((((Vef + Ev) - 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(Float64(Float64(mu + Vef) - Ec) / KbT)))) + Float64(0.5 * NaChar)) t_1 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_1))) tmp = 0.0 if (t_2 <= -2e+161) tmp = t_0; elseif (t_2 <= 4e-76) tmp = Float64(NaChar / Float64(t_1 + 1.0)); elseif (t_2 <= 2e+224) tmp = Float64(Float64(0.5 * NdChar) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Vef + Ev) - mu) / KbT))))); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((((mu + Vef) - Ec) / KbT)))) + (0.5 * NaChar); t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1)); tmp = 0.0; if (t_2 <= -2e+161) tmp = t_0; elseif (t_2 <= 4e-76) tmp = NaChar / (t_1 + 1.0); elseif (t_2 <= 2e+224) tmp = (0.5 * NdChar) + (NaChar / (1.0 + exp((((Vef + Ev) - mu) / KbT)))); else tmp = t_0; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(N[(mu + Vef), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+161], t$95$0, If[LessEqual[t$95$2, 4e-76], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+224], N[(N[(0.5 * NdChar), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(Vef + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{\left(mu + Vef\right) - Ec}{KbT}}} + 0.5 \cdot NaChar\\
t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_1}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-76}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+224}:\\
\;\;\;\;0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(Vef + Ev\right) - mu}{KbT}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.0000000000000001e161 or 1.99999999999999994e224 < (+.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-*.f6477.7
Applied rewrites77.7%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6476.1
Applied rewrites76.1%
if -2.0000000000000001e161 < (+.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.99999999999999971e-76Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6465.6
Applied rewrites65.6%
if 3.99999999999999971e-76 < (+.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.99999999999999994e224Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6479.0
Applied rewrites79.0%
Taylor expanded in EAccept around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6474.6
Applied rewrites74.6%
Final simplification69.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+ (* 0.5 NdChar) (/ NaChar (+ 1.0 (exp (/ (- (+ Vef Ev) mu) KbT))))))
(t_1 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_2
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 t_1)))))
(if (<= t_2 -5e+199)
t_0
(if (<= t_2 4e-76)
(/ NaChar (+ t_1 1.0))
(if (<= t_2 1e+182)
t_0
(+ (/ NdChar (+ 1.0 (exp (/ (- mu Ec) KbT)))) (* 0.5 NaChar)))))))
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((((Vef + Ev) - mu) / KbT))));
double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
double tmp;
if (t_2 <= -5e+199) {
tmp = t_0;
} else if (t_2 <= 4e-76) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_2 <= 1e+182) {
tmp = t_0;
} else {
tmp = (NdChar / (1.0 + exp(((mu - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (0.5d0 * ndchar) + (nachar / (1.0d0 + exp((((vef + ev) - mu) / kbt))))
t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_1))
if (t_2 <= (-5d+199)) then
tmp = t_0
else if (t_2 <= 4d-76) then
tmp = nachar / (t_1 + 1.0d0)
else if (t_2 <= 1d+182) then
tmp = t_0
else
tmp = (ndchar / (1.0d0 + exp(((mu - ec) / kbt)))) + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (0.5 * NdChar) + (NaChar / (1.0 + Math.exp((((Vef + Ev) - mu) / KbT))));
double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1));
double tmp;
if (t_2 <= -5e+199) {
tmp = t_0;
} else if (t_2 <= 4e-76) {
tmp = NaChar / (t_1 + 1.0);
} else if (t_2 <= 1e+182) {
tmp = t_0;
} else {
tmp = (NdChar / (1.0 + Math.exp(((mu - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (0.5 * NdChar) + (NaChar / (1.0 + math.exp((((Vef + Ev) - mu) / KbT)))) t_1 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1)) tmp = 0 if t_2 <= -5e+199: tmp = t_0 elif t_2 <= 4e-76: tmp = NaChar / (t_1 + 1.0) elif t_2 <= 1e+182: tmp = t_0 else: tmp = (NdChar / (1.0 + math.exp(((mu - Ec) / KbT)))) + (0.5 * NaChar) 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(Vef + Ev) - mu) / KbT))))) t_1 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_1))) tmp = 0.0 if (t_2 <= -5e+199) tmp = t_0; elseif (t_2 <= 4e-76) tmp = Float64(NaChar / Float64(t_1 + 1.0)); elseif (t_2 <= 1e+182) tmp = t_0; else tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(mu - Ec) / KbT)))) + Float64(0.5 * NaChar)); 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((((Vef + Ev) - mu) / KbT)))); t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_1)); tmp = 0.0; if (t_2 <= -5e+199) tmp = t_0; elseif (t_2 <= 4e-76) tmp = NaChar / (t_1 + 1.0); elseif (t_2 <= 1e+182) tmp = t_0; else tmp = (NdChar / (1.0 + exp(((mu - Ec) / KbT)))) + (0.5 * NaChar); 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[(Vef + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+199], t$95$0, If[LessEqual[t$95$2, 4e-76], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+182], t$95$0, N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(mu - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot NdChar + \frac{NaChar}{1 + e^{\frac{\left(Vef + Ev\right) - mu}{KbT}}}\\
t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_1}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+199}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-76}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\
\mathbf{elif}\;t\_2 \leq 10^{+182}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}} + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.9999999999999998e199 or 3.99999999999999971e-76 < (+.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.0000000000000001e182Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6481.4
Applied rewrites81.4%
Taylor expanded in EAccept around 0
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6475.7
Applied rewrites75.7%
if -4.9999999999999998e199 < (+.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.99999999999999971e-76Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6465.1
Applied rewrites65.1%
if 1.0000000000000001e182 < (+.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-*.f6487.2
Applied rewrites87.2%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6476.9
Applied rewrites76.9%
Taylor expanded in Vef around 0
Applied rewrites77.8%
Final simplification69.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT)))))
(t_1 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_2 (/ NaChar (+ 1.0 t_1)))
(t_3 (+ t_0 t_2)))
(if (<= t_3 -5e-299)
(+ (/ NdChar (+ 1.0 (exp (/ mu KbT)))) t_2)
(if (<= t_3 5e-240)
(/ NaChar (+ t_1 1.0))
(+ t_0 (/ NaChar (+ 1.0 (exp (/ Ev KbT)))))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = t_0 + t_2;
double tmp;
if (t_3 <= -5e-299) {
tmp = (NdChar / (1.0 + exp((mu / KbT)))) + t_2;
} else if (t_3 <= 5e-240) {
tmp = NaChar / (t_1 + 1.0);
} else {
tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))
t_1 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_2 = nachar / (1.0d0 + t_1)
t_3 = t_0 + t_2
if (t_3 <= (-5d-299)) then
tmp = (ndchar / (1.0d0 + exp((mu / kbt)))) + t_2
else if (t_3 <= 5d-240) then
tmp = nachar / (t_1 + 1.0d0)
else
tmp = t_0 + (nachar / (1.0d0 + exp((ev / kbt))))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)));
double t_1 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_2 = NaChar / (1.0 + t_1);
double t_3 = t_0 + t_2;
double tmp;
if (t_3 <= -5e-299) {
tmp = (NdChar / (1.0 + Math.exp((mu / KbT)))) + t_2;
} else if (t_3 <= 5e-240) {
tmp = NaChar / (t_1 + 1.0);
} else {
tmp = t_0 + (NaChar / (1.0 + Math.exp((Ev / KbT))));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT))) t_1 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_2 = NaChar / (1.0 + t_1) t_3 = t_0 + t_2 tmp = 0 if t_3 <= -5e-299: tmp = (NdChar / (1.0 + math.exp((mu / KbT)))) + t_2 elif t_3 <= 5e-240: tmp = NaChar / (t_1 + 1.0) else: tmp = t_0 + (NaChar / (1.0 + math.exp((Ev / KbT)))) 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 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_2 = Float64(NaChar / Float64(1.0 + t_1)) t_3 = Float64(t_0 + t_2) tmp = 0.0 if (t_3 <= -5e-299) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + t_2); elseif (t_3 <= 5e-240) tmp = Float64(NaChar / Float64(t_1 + 1.0)); else tmp = Float64(t_0 + Float64(NaChar / Float64(1.0 + exp(Float64(Ev / KbT))))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT))); t_1 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_2 = NaChar / (1.0 + t_1); t_3 = t_0 + t_2; tmp = 0.0; if (t_3 <= -5e-299) tmp = (NdChar / (1.0 + exp((mu / KbT)))) + t_2; elseif (t_3 <= 5e-240) tmp = NaChar / (t_1 + 1.0); else tmp = t_0 + (NaChar / (1.0 + exp((Ev / KbT)))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(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[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(NaChar / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-299], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision], If[LessEqual[t$95$3, 5e-240], N[(NaChar / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(NaChar / N[(1.0 + N[Exp[N[(Ev / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}}\\
t_1 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_2 := \frac{NaChar}{1 + t\_1}\\
t_3 := t\_0 + t\_2\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{-299}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_2\\
\mathbf{elif}\;t\_3 \leq 5 \cdot 10^{-240}:\\
\;\;\;\;\frac{NaChar}{t\_1 + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{NaChar}{1 + e^{\frac{Ev}{KbT}}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.99999999999999956e-299Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6483.7
Applied rewrites83.7%
if -4.99999999999999956e-299 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 5.0000000000000004e-240Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6492.4
Applied rewrites92.4%
if 5.0000000000000004e-240 < (+.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 Ev around inf
lower-/.f6477.0
Applied rewrites77.0%
Final simplification83.1%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_1 (/ NaChar (+ 1.0 t_0)))
(t_2
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
t_1)))
(if (or (<= t_2 -5e-299) (not (<= t_2 0.0)))
(+ (/ NdChar (+ 1.0 (exp (/ mu KbT)))) t_1)
(/ NaChar (+ t_0 1.0)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = NaChar / (1.0 + t_0);
double t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
double tmp;
if ((t_2 <= -5e-299) || !(t_2 <= 0.0)) {
tmp = (NdChar / (1.0 + exp((mu / KbT)))) + t_1;
} else {
tmp = NaChar / (t_0 + 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_1 = nachar / (1.0d0 + t_0)
t_2 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + t_1
if ((t_2 <= (-5d-299)) .or. (.not. (t_2 <= 0.0d0))) then
tmp = (ndchar / (1.0d0 + exp((mu / kbt)))) + t_1
else
tmp = nachar / (t_0 + 1.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = NaChar / (1.0 + t_0);
double t_2 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1;
double tmp;
if ((t_2 <= -5e-299) || !(t_2 <= 0.0)) {
tmp = (NdChar / (1.0 + Math.exp((mu / KbT)))) + t_1;
} else {
tmp = NaChar / (t_0 + 1.0);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_1 = NaChar / (1.0 + t_0) t_2 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1 tmp = 0 if (t_2 <= -5e-299) or not (t_2 <= 0.0): tmp = (NdChar / (1.0 + math.exp((mu / KbT)))) + t_1 else: tmp = NaChar / (t_0 + 1.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_1 = Float64(NaChar / Float64(1.0 + t_0)) t_2 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + t_1) tmp = 0.0 if ((t_2 <= -5e-299) || !(t_2 <= 0.0)) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(mu / KbT)))) + t_1); else tmp = Float64(NaChar / Float64(t_0 + 1.0)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_1 = NaChar / (1.0 + t_0); t_2 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + t_1; tmp = 0.0; if ((t_2 <= -5e-299) || ~((t_2 <= 0.0))) tmp = (NdChar / (1.0 + exp((mu / KbT)))) + t_1; else tmp = NaChar / (t_0 + 1.0); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -5e-299], N[Not[LessEqual[t$95$2, 0.0]], $MachinePrecision]], N[(N[(NdChar / N[(1.0 + N[Exp[N[(mu / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_1 := \frac{NaChar}{1 + t\_0}\\
t_2 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-299} \lor \neg \left(t\_2 \leq 0\right):\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu}{KbT}}} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{t\_0 + 1}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.99999999999999956e-299 or 0.0 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in mu around inf
lower-/.f6480.7
Applied rewrites80.7%
if -4.99999999999999956e-299 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 0.0Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f64100.0
Applied rewrites100.0%
Final simplification83.8%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))
(t_1
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 t_0)))))
(if (<= t_1 -2e+161)
(+ (/ NdChar (+ 1.0 (exp (/ (+ mu Vef) KbT)))) (* 0.5 NaChar))
(if (<= t_1 5e+119)
(/ NaChar (+ t_0 1.0))
(+ (/ NdChar (+ 1.0 (exp (/ (- mu Ec) KbT)))) (* 0.5 NaChar))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
double tmp;
if (t_1 <= -2e+161) {
tmp = (NdChar / (1.0 + exp(((mu + Vef) / KbT)))) + (0.5 * NaChar);
} else if (t_1 <= 5e+119) {
tmp = NaChar / (t_0 + 1.0);
} else {
tmp = (NdChar / (1.0 + exp(((mu - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(((((ev + vef) + eaccept) - mu) / kbt))
t_1 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + t_0))
if (t_1 <= (-2d+161)) then
tmp = (ndchar / (1.0d0 + exp(((mu + vef) / kbt)))) + (0.5d0 * nachar)
else if (t_1 <= 5d+119) then
tmp = nachar / (t_0 + 1.0d0)
else
tmp = (ndchar / (1.0d0 + exp(((mu - ec) / kbt)))) + (0.5d0 * nachar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT));
double t_1 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0));
double tmp;
if (t_1 <= -2e+161) {
tmp = (NdChar / (1.0 + Math.exp(((mu + Vef) / KbT)))) + (0.5 * NaChar);
} else if (t_1 <= 5e+119) {
tmp = NaChar / (t_0 + 1.0);
} else {
tmp = (NdChar / (1.0 + Math.exp(((mu - Ec) / KbT)))) + (0.5 * NaChar);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) t_1 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0)) tmp = 0 if t_1 <= -2e+161: tmp = (NdChar / (1.0 + math.exp(((mu + Vef) / KbT)))) + (0.5 * NaChar) elif t_1 <= 5e+119: tmp = NaChar / (t_0 + 1.0) else: tmp = (NdChar / (1.0 + math.exp(((mu - Ec) / KbT)))) + (0.5 * NaChar) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) t_1 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + t_0))) tmp = 0.0 if (t_1 <= -2e+161) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(mu + Vef) / KbT)))) + Float64(0.5 * NaChar)); elseif (t_1 <= 5e+119) tmp = Float64(NaChar / Float64(t_0 + 1.0)); else tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(mu - Ec) / KbT)))) + Float64(0.5 * NaChar)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = exp(((((Ev + Vef) + EAccept) - mu) / KbT)); t_1 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + t_0)); tmp = 0.0; if (t_1 <= -2e+161) tmp = (NdChar / (1.0 + exp(((mu + Vef) / KbT)))) + (0.5 * NaChar); elseif (t_1 <= 5e+119) tmp = NaChar / (t_0 + 1.0); else tmp = (NdChar / (1.0 + exp(((mu - Ec) / KbT)))) + (0.5 * NaChar); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+161], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(mu + Vef), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+119], N[(NaChar / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(mu - Ec), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}\\
t_1 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + t\_0}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+161}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu + Vef}{KbT}}} + 0.5 \cdot NaChar\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+119}:\\
\;\;\;\;\frac{NaChar}{t\_0 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu - Ec}{KbT}}} + 0.5 \cdot NaChar\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -2.0000000000000001e161Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6472.1
Applied rewrites72.1%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6472.1
Applied rewrites72.1%
Taylor expanded in Ec around 0
Applied rewrites68.1%
if -2.0000000000000001e161 < (+.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.9999999999999999e119Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6466.1
Applied rewrites66.1%
if 4.9999999999999999e119 < (+.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-*.f6478.5
Applied rewrites78.5%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6473.2
Applied rewrites73.2%
Taylor expanded in Vef around 0
Applied rewrites71.0%
Final simplification67.2%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -1e-263) (not (<= t_0 1e-254)))
(* 0.5 (+ NaChar NdChar))
(/
NaChar
(* (+ (/ 1.0 KbT) (/ (+ 2.0 (/ (- (+ EAccept Ev) mu) KbT)) Vef)) Vef)))))
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 <= -1e-263) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (((1.0 / KbT) + ((2.0 + (((EAccept + Ev) - mu) / KbT)) / Vef)) * Vef);
}
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 <= (-1d-263)) .or. (.not. (t_0 <= 1d-254))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (((1.0d0 / kbt) + ((2.0d0 + (((eaccept + ev) - mu) / kbt)) / vef)) * vef)
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 <= -1e-263) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (((1.0 / KbT) + ((2.0 + (((EAccept + Ev) - mu) / KbT)) / Vef)) * Vef);
}
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 <= -1e-263) or not (t_0 <= 1e-254): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (((1.0 / KbT) + ((2.0 + (((EAccept + Ev) - mu) / KbT)) / Vef)) * Vef) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -1e-263) || !(t_0 <= 1e-254)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(Float64(Float64(1.0 / KbT) + Float64(Float64(2.0 + Float64(Float64(Float64(EAccept + Ev) - mu) / KbT)) / Vef)) * Vef)); 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 <= -1e-263) || ~((t_0 <= 1e-254))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (((1.0 / KbT) + ((2.0 + (((EAccept + Ev) - mu) / KbT)) / Vef)) * Vef); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e-263], N[Not[LessEqual[t$95$0, 1e-254]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[(N[(1.0 / KbT), $MachinePrecision] + N[(N[(2.0 + N[(N[(N[(EAccept + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision] / Vef), $MachinePrecision]), $MachinePrecision] * Vef), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-263} \lor \neg \left(t\_0 \leq 10^{-254}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{\left(\frac{1}{KbT} + \frac{2 + \frac{\left(EAccept + Ev\right) - mu}{KbT}}{Vef}\right) \cdot Vef}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1e-263 or 9.9999999999999991e-255 < (+.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
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.9
Applied rewrites37.9%
if -1e-263 < (+.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))))) < 9.9999999999999991e-255Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in KbT around inf
Applied rewrites50.6%
Taylor expanded in Vef around inf
Applied rewrites59.1%
Final simplification42.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -2e-280) (not (<= t_0 1e-254)))
(* 0.5 (+ NaChar NdChar))
(/
NaChar
(* (/ (- (+ (/ (+ Ev Vef) EAccept) 1.0) (/ mu EAccept)) KbT) EAccept)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / ((((((Ev + Vef) / EAccept) + 1.0) - (mu / EAccept)) / KbT) * EAccept);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
if ((t_0 <= (-2d-280)) .or. (.not. (t_0 <= 1d-254))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / ((((((ev + vef) / eaccept) + 1.0d0) - (mu / eaccept)) / kbt) * eaccept)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / ((((((Ev + Vef) / EAccept) + 1.0) - (mu / EAccept)) / KbT) * EAccept);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)))) tmp = 0 if (t_0 <= -2e-280) or not (t_0 <= 1e-254): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / ((((((Ev + Vef) / EAccept) + 1.0) - (mu / EAccept)) / KbT) * EAccept) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(Float64(Float64(Float64(Float64(Float64(Ev + Vef) / EAccept) + 1.0) - Float64(mu / EAccept)) / KbT) * EAccept)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)))); tmp = 0.0; if ((t_0 <= -2e-280) || ~((t_0 <= 1e-254))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / ((((((Ev + Vef) / EAccept) + 1.0) - (mu / EAccept)) / KbT) * EAccept); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-280], N[Not[LessEqual[t$95$0, 1e-254]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[(N[(N[(N[(N[(Ev + Vef), $MachinePrecision] / EAccept), $MachinePrecision] + 1.0), $MachinePrecision] - N[(mu / EAccept), $MachinePrecision]), $MachinePrecision] / KbT), $MachinePrecision] * EAccept), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-280} \lor \neg \left(t\_0 \leq 10^{-254}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{\frac{\left(\frac{Ev + Vef}{EAccept} + 1\right) - \frac{mu}{EAccept}}{KbT} \cdot EAccept}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.9999999999999999e-280 or 9.9999999999999991e-255 < (+.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
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if -1.9999999999999999e-280 < (+.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))))) < 9.9999999999999991e-255Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in KbT around inf
Applied rewrites53.9%
Taylor expanded in EAccept around inf
Applied rewrites55.5%
Taylor expanded in KbT around 0
Applied rewrites61.3%
Final simplification42.2%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -2e-280) (not (<= t_0 1e-254)))
(* 0.5 (+ NaChar NdChar))
(/
NaChar
(+ 2.0 (/ (- (* (+ (+ EAccept Ev) Vef) KbT) (* KbT mu)) (* KbT KbT)))))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (2.0 + (((((EAccept + Ev) + Vef) * KbT) - (KbT * mu)) / (KbT * KbT)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
if ((t_0 <= (-2d-280)) .or. (.not. (t_0 <= 1d-254))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (2.0d0 + (((((eaccept + ev) + vef) * kbt) - (kbt * mu)) / (kbt * kbt)))
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (2.0 + (((((EAccept + Ev) + Vef) * KbT) - (KbT * mu)) / (KbT * KbT)));
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)))) tmp = 0 if (t_0 <= -2e-280) or not (t_0 <= 1e-254): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (2.0 + (((((EAccept + Ev) + Vef) * KbT) - (KbT * mu)) / (KbT * KbT))) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Float64(EAccept + Ev) + Vef) * KbT) - Float64(KbT * mu)) / Float64(KbT * KbT)))); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)))); tmp = 0.0; if ((t_0 <= -2e-280) || ~((t_0 <= 1e-254))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (2.0 + (((((EAccept + Ev) + Vef) * KbT) - (KbT * mu)) / (KbT * KbT))); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-280], N[Not[LessEqual[t$95$0, 1e-254]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(N[(EAccept + Ev), $MachinePrecision] + Vef), $MachinePrecision] * KbT), $MachinePrecision] - N[(KbT * mu), $MachinePrecision]), $MachinePrecision] / N[(KbT * KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-280} \lor \neg \left(t\_0 \leq 10^{-254}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{2 + \frac{\left(\left(EAccept + Ev\right) + Vef\right) \cdot KbT - KbT \cdot mu}{KbT \cdot KbT}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.9999999999999999e-280 or 9.9999999999999991e-255 < (+.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
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if -1.9999999999999999e-280 < (+.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))))) < 9.9999999999999991e-255Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in KbT around inf
Applied rewrites53.9%
Applied rewrites59.1%
Final simplification41.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -1e-263) (not (<= t_0 1e-254)))
(* 0.5 (+ NaChar NdChar))
(/ NaChar (+ 2.0 (/ (- (+ (+ Vef Ev) EAccept) 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 <= -1e-263) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - 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 <= (-1d-263)) .or. (.not. (t_0 <= 1d-254))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (2.0d0 + ((((vef + ev) + eaccept) - 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 <= -1e-263) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - 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 <= -1e-263) or not (t_0 <= 1e-254): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - mu) / KbT)) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -1e-263) || !(t_0 <= 1e-254)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(2.0 + Float64(Float64(Float64(Float64(Vef + Ev) + EAccept) - 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 <= -1e-263) || ~((t_0 <= 1e-254))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (2.0 + ((((Vef + Ev) + EAccept) - mu) / KbT)); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e-263], N[Not[LessEqual[t$95$0, 1e-254]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(2.0 + N[(N[(N[(N[(Vef + Ev), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-263} \lor \neg \left(t\_0 \leq 10^{-254}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{2 + \frac{\left(\left(Vef + Ev\right) + EAccept\right) - mu}{KbT}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1e-263 or 9.9999999999999991e-255 < (+.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
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.9
Applied rewrites37.9%
if -1e-263 < (+.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))))) < 9.9999999999999991e-255Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in KbT around inf
Applied rewrites50.6%
Final simplification40.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -1e-263) (not (<= t_0 1e-254)))
(* 0.5 (+ NaChar NdChar))
(/ NaChar (+ (/ (+ (+ Vef Ev) EAccept) KbT) 2.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((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -1e-263) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / ((((Vef + Ev) + EAccept) / KbT) + 2.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((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
if ((t_0 <= (-1d-263)) .or. (.not. (t_0 <= 1d-254))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / ((((vef + ev) + eaccept) / kbt) + 2.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (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 <= -1e-263) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / ((((Vef + Ev) + EAccept) / KbT) + 2.0);
}
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 <= -1e-263) or not (t_0 <= 1e-254): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / ((((Vef + Ev) + EAccept) / KbT) + 2.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -1e-263) || !(t_0 <= 1e-254)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(Float64(Float64(Float64(Vef + Ev) + EAccept) / KbT) + 2.0)); 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 <= -1e-263) || ~((t_0 <= 1e-254))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / ((((Vef + Ev) + EAccept) / KbT) + 2.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[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e-263], N[Not[LessEqual[t$95$0, 1e-254]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[(N[(N[(Vef + Ev), $MachinePrecision] + EAccept), $MachinePrecision] / KbT), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-263} \lor \neg \left(t\_0 \leq 10^{-254}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{\frac{\left(Vef + Ev\right) + EAccept}{KbT} + 2}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1e-263 or 9.9999999999999991e-255 < (+.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
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.9
Applied rewrites37.9%
if -1e-263 < (+.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))))) < 9.9999999999999991e-255Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in KbT around inf
Applied rewrites50.6%
Taylor expanded in mu around 0
Applied rewrites50.6%
Final simplification40.7%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -2e-280) (not (<= t_0 1e-254)))
(* 0.5 (+ NaChar NdChar))
(/ NaChar (/ Vef KbT)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (Vef / KbT);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
if ((t_0 <= (-2d-280)) .or. (.not. (t_0 <= 1d-254))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (vef / kbt)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (Vef / KbT);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)))) tmp = 0 if (t_0 <= -2e-280) or not (t_0 <= 1e-254): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (Vef / KbT) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -2e-280) || !(t_0 <= 1e-254)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(Vef / KbT)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)))); tmp = 0.0; if ((t_0 <= -2e-280) || ~((t_0 <= 1e-254))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (Vef / KbT); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-280], N[Not[LessEqual[t$95$0, 1e-254]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(Vef / KbT), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-280} \lor \neg \left(t\_0 \leq 10^{-254}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{\frac{Vef}{KbT}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.9999999999999999e-280 or 9.9999999999999991e-255 < (+.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
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.4
Applied rewrites37.4%
if -1.9999999999999999e-280 < (+.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))))) < 9.9999999999999991e-255Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6489.3
Applied rewrites89.3%
Taylor expanded in KbT around inf
Applied rewrites53.9%
Taylor expanded in Vef around inf
Applied rewrites40.4%
Final simplification38.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0
(+
(/ NdChar (+ 1.0 (exp (/ (- (- (- (- Ec Vef) EDonor) mu)) KbT))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -1e-306) (not (<= t_0 5e-259)))
(* 0.5 (+ NaChar NdChar))
(/ NaChar (/ Ev KbT)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -1e-306) || !(t_0 <= 5e-259)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (Ev / KbT);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
if ((t_0 <= (-1d-306)) .or. (.not. (t_0 <= 5d-259))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (ev / kbt)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -1e-306) || !(t_0 <= 5e-259)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (Ev / KbT);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)))) tmp = 0 if (t_0 <= -1e-306) or not (t_0 <= 5e-259): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (Ev / KbT) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -1e-306) || !(t_0 <= 5e-259)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(Ev / KbT)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)))); tmp = 0.0; if ((t_0 <= -1e-306) || ~((t_0 <= 5e-259))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (Ev / KbT); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -1e-306], N[Not[LessEqual[t$95$0, 5e-259]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(Ev / KbT), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-306} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-259}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{\frac{Ev}{KbT}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -1.00000000000000003e-306 or 4.99999999999999977e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6436.5
Applied rewrites36.5%
if -1.00000000000000003e-306 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-259Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6493.9
Applied rewrites93.9%
Taylor expanded in KbT around inf
Applied rewrites60.1%
Taylor expanded in Ev around inf
Applied rewrites18.7%
Final simplification33.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))))
(/ NaChar (+ 1.0 (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)))))))
(if (or (<= t_0 -4e-288) (not (<= t_0 5e-259)))
(* 0.5 (+ NaChar NdChar))
(/ NaChar (/ EAccept KbT)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -4e-288) || !(t_0 <= 5e-259)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (EAccept / KbT);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: t_0
real(8) :: tmp
t_0 = (ndchar / (1.0d0 + exp((-(((ec - vef) - edonor) - mu) / kbt)))) + (nachar / (1.0d0 + exp(((((ev + vef) + eaccept) - mu) / kbt))))
if ((t_0 <= (-4d-288)) .or. (.not. (t_0 <= 5d-259))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (eaccept / kbt)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double t_0 = (NdChar / (1.0 + Math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT))));
double tmp;
if ((t_0 <= -4e-288) || !(t_0 <= 5e-259)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (EAccept / KbT);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = (NdChar / (1.0 + math.exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)))) tmp = 0 if (t_0 <= -4e-288) or not (t_0 <= 5e-259): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (EAccept / KbT) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(-Float64(Float64(Float64(Ec - Vef) - EDonor) - mu)) / KbT)))) + Float64(NaChar / Float64(1.0 + exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT))))) tmp = 0.0 if ((t_0 <= -4e-288) || !(t_0 <= 5e-259)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(EAccept / KbT)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = (NdChar / (1.0 + exp((-(((Ec - Vef) - EDonor) - mu) / KbT)))) + (NaChar / (1.0 + exp(((((Ev + Vef) + EAccept) - mu) / KbT)))); tmp = 0.0; if ((t_0 <= -4e-288) || ~((t_0 <= 5e-259))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (EAccept / KbT); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := Block[{t$95$0 = N[(N[(NdChar / N[(1.0 + N[Exp[N[((-N[(N[(N[(Ec - Vef), $MachinePrecision] - EDonor), $MachinePrecision] - mu), $MachinePrecision]) / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(NaChar / N[(1.0 + N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-288], N[Not[LessEqual[t$95$0, 5e-259]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(EAccept / KbT), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NdChar}{1 + e^{\frac{-\left(\left(\left(Ec - Vef\right) - EDonor\right) - mu\right)}{KbT}}} + \frac{NaChar}{1 + e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}}}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-288} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-259}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{\frac{EAccept}{KbT}}\\
\end{array}
\end{array}
if (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < -4.00000000000000023e-288 or 4.99999999999999977e-259 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6437.1
Applied rewrites37.1%
if -4.00000000000000023e-288 < (+.f64 (/.f64 NdChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (neg.f64 (-.f64 (-.f64 (-.f64 Ec Vef) EDonor) mu)) KbT)))) (/.f64 NaChar (+.f64 #s(literal 1 binary64) (exp.f64 (/.f64 (+.f64 (+.f64 (+.f64 Ev Vef) EAccept) (neg.f64 mu)) KbT))))) < 4.99999999999999977e-259Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6492.6
Applied rewrites92.6%
Taylor expanded in KbT around inf
Applied rewrites55.9%
Taylor expanded in EAccept around inf
Applied rewrites27.9%
Final simplification35.3%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(let* ((t_0 (/ NaChar (+ (exp (/ (- Ev mu) KbT)) 1.0))))
(if (<= mu -2.05e+159)
t_0
(if (<= mu 6.5e+15)
(/ NaChar (+ (exp (/ (+ Vef Ev) KbT)) 1.0))
(if (<= mu 1.85e+179) (* 0.5 (+ NaChar 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 = NaChar / (exp(((Ev - mu) / KbT)) + 1.0);
double tmp;
if (mu <= -2.05e+159) {
tmp = t_0;
} else if (mu <= 6.5e+15) {
tmp = NaChar / (exp(((Vef + Ev) / KbT)) + 1.0);
} else if (mu <= 1.85e+179) {
tmp = 0.5 * (NaChar + 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) :: tmp
t_0 = nachar / (exp(((ev - mu) / kbt)) + 1.0d0)
if (mu <= (-2.05d+159)) then
tmp = t_0
else if (mu <= 6.5d+15) then
tmp = nachar / (exp(((vef + ev) / kbt)) + 1.0d0)
else if (mu <= 1.85d+179) then
tmp = 0.5d0 * (nachar + 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 = NaChar / (Math.exp(((Ev - mu) / KbT)) + 1.0);
double tmp;
if (mu <= -2.05e+159) {
tmp = t_0;
} else if (mu <= 6.5e+15) {
tmp = NaChar / (Math.exp(((Vef + Ev) / KbT)) + 1.0);
} else if (mu <= 1.85e+179) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = t_0;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): t_0 = NaChar / (math.exp(((Ev - mu) / KbT)) + 1.0) tmp = 0 if mu <= -2.05e+159: tmp = t_0 elif mu <= 6.5e+15: tmp = NaChar / (math.exp(((Vef + Ev) / KbT)) + 1.0) elif mu <= 1.85e+179: tmp = 0.5 * (NaChar + NdChar) else: tmp = t_0 return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = Float64(NaChar / Float64(exp(Float64(Float64(Ev - mu) / KbT)) + 1.0)) tmp = 0.0 if (mu <= -2.05e+159) tmp = t_0; elseif (mu <= 6.5e+15) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Vef + Ev) / KbT)) + 1.0)); elseif (mu <= 1.85e+179) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = t_0; end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) t_0 = NaChar / (exp(((Ev - mu) / KbT)) + 1.0); tmp = 0.0; if (mu <= -2.05e+159) tmp = t_0; elseif (mu <= 6.5e+15) tmp = NaChar / (exp(((Vef + Ev) / KbT)) + 1.0); elseif (mu <= 1.85e+179) tmp = 0.5 * (NaChar + 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[(NaChar / N[(N[Exp[N[(N[(Ev - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[mu, -2.05e+159], t$95$0, If[LessEqual[mu, 6.5e+15], N[(NaChar / N[(N[Exp[N[(N[(Vef + Ev), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[mu, 1.85e+179], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{NaChar}{e^{\frac{Ev - mu}{KbT}} + 1}\\
\mathbf{if}\;mu \leq -2.05 \cdot 10^{+159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;mu \leq 6.5 \cdot 10^{+15}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{Vef + Ev}{KbT}} + 1}\\
\mathbf{elif}\;mu \leq 1.85 \cdot 10^{+179}:\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if mu < -2.05000000000000007e159 or 1.85e179 < mu Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6464.0
Applied rewrites64.0%
Taylor expanded in EAccept around 0
Applied rewrites58.6%
Taylor expanded in Vef around 0
Applied rewrites55.8%
if -2.05000000000000007e159 < mu < 6.5e15Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6464.6
Applied rewrites64.6%
Taylor expanded in EAccept around 0
Applied rewrites56.0%
Taylor expanded in mu around 0
Applied rewrites56.0%
if 6.5e15 < mu < 1.85e179Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6446.4
Applied rewrites46.4%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (or (<= KbT -9.4e+157) (not (<= KbT 3e+214))) (* 0.5 (+ NaChar NdChar)) (/ NaChar (+ (exp (/ (+ (+ Vef Ev) EAccept) KbT)) 1.0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if ((KbT <= -9.4e+157) || !(KbT <= 3e+214)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (exp((((Vef + Ev) + EAccept) / KbT)) + 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if ((kbt <= (-9.4d+157)) .or. (.not. (kbt <= 3d+214))) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (exp((((vef + ev) + eaccept) / kbt)) + 1.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if ((KbT <= -9.4e+157) || !(KbT <= 3e+214)) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (Math.exp((((Vef + Ev) + EAccept) / KbT)) + 1.0);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if (KbT <= -9.4e+157) or not (KbT <= 3e+214): tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (math.exp((((Vef + Ev) + EAccept) / KbT)) + 1.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if ((KbT <= -9.4e+157) || !(KbT <= 3e+214)) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Vef + Ev) + EAccept) / KbT)) + 1.0)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if ((KbT <= -9.4e+157) || ~((KbT <= 3e+214))) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (exp((((Vef + Ev) + EAccept) / KbT)) + 1.0); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[KbT, -9.4e+157], N[Not[LessEqual[KbT, 3e+214]], $MachinePrecision]], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(Vef + Ev), $MachinePrecision] + EAccept), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;KbT \leq -9.4 \cdot 10^{+157} \lor \neg \left(KbT \leq 3 \cdot 10^{+214}\right):\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(Vef + Ev\right) + EAccept}{KbT}} + 1}\\
\end{array}
\end{array}
if KbT < -9.40000000000000061e157 or 3.0000000000000001e214 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6471.2
Applied rewrites71.2%
if -9.40000000000000061e157 < KbT < 3.0000000000000001e214Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6462.2
Applied rewrites62.2%
Taylor expanded in mu around 0
Applied rewrites55.0%
Final simplification59.0%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (<= NdChar -1.9e+114) (+ (/ NdChar (+ 1.0 (exp (/ (+ mu Vef) KbT)))) (* 0.5 NaChar)) (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (NdChar <= -1.9e+114) {
tmp = (NdChar / (1.0 + exp(((mu + Vef) / KbT)))) + (0.5 * NaChar);
} else {
tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (ndchar <= (-1.9d+114)) then
tmp = (ndchar / (1.0d0 + exp(((mu + vef) / kbt)))) + (0.5d0 * nachar)
else
tmp = nachar / (exp(((((ev + vef) + eaccept) - mu) / kbt)) + 1.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (NdChar <= -1.9e+114) {
tmp = (NdChar / (1.0 + Math.exp(((mu + Vef) / KbT)))) + (0.5 * NaChar);
} else {
tmp = NaChar / (Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if NdChar <= -1.9e+114: tmp = (NdChar / (1.0 + math.exp(((mu + Vef) / KbT)))) + (0.5 * NaChar) else: tmp = NaChar / (math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (NdChar <= -1.9e+114) tmp = Float64(Float64(NdChar / Float64(1.0 + exp(Float64(Float64(mu + Vef) / KbT)))) + Float64(0.5 * NaChar)); else tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (NdChar <= -1.9e+114) tmp = (NdChar / (1.0 + exp(((mu + Vef) / KbT)))) + (0.5 * NaChar); else tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[NdChar, -1.9e+114], N[(N[(NdChar / N[(1.0 + N[Exp[N[(N[(mu + Vef), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;NdChar \leq -1.9 \cdot 10^{+114}:\\
\;\;\;\;\frac{NdChar}{1 + e^{\frac{mu + Vef}{KbT}}} + 0.5 \cdot NaChar\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
\end{array}
\end{array}
if NdChar < -1.9e114Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6470.7
Applied rewrites70.7%
Taylor expanded in EDonor around 0
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6469.6
Applied rewrites69.6%
Taylor expanded in Ec around 0
Applied rewrites64.3%
if -1.9e114 < NdChar Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6464.6
Applied rewrites64.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept)
:precision binary64
(if (<= KbT -3.45e+75)
(+
(/ NdChar (+ 1.0 (+ 1.0 (/ (- (+ (+ mu Vef) EDonor) Ec) KbT))))
(* 0.5 NaChar))
(if (<= KbT 3e+214)
(/ NaChar (+ (exp (/ (+ Vef Ev) KbT)) 1.0))
(* 0.5 (+ NaChar NdChar)))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= -3.45e+75) {
tmp = (NdChar / (1.0 + (1.0 + ((((mu + Vef) + EDonor) - Ec) / KbT)))) + (0.5 * NaChar);
} else if (KbT <= 3e+214) {
tmp = NaChar / (exp(((Vef + Ev) / KbT)) + 1.0);
} else {
tmp = 0.5 * (NaChar + NdChar);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (kbt <= (-3.45d+75)) then
tmp = (ndchar / (1.0d0 + (1.0d0 + ((((mu + vef) + edonor) - ec) / kbt)))) + (0.5d0 * nachar)
else if (kbt <= 3d+214) then
tmp = nachar / (exp(((vef + ev) / kbt)) + 1.0d0)
else
tmp = 0.5d0 * (nachar + ndchar)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= -3.45e+75) {
tmp = (NdChar / (1.0 + (1.0 + ((((mu + Vef) + EDonor) - Ec) / KbT)))) + (0.5 * NaChar);
} else if (KbT <= 3e+214) {
tmp = NaChar / (Math.exp(((Vef + Ev) / KbT)) + 1.0);
} else {
tmp = 0.5 * (NaChar + NdChar);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if KbT <= -3.45e+75: tmp = (NdChar / (1.0 + (1.0 + ((((mu + Vef) + EDonor) - Ec) / KbT)))) + (0.5 * NaChar) elif KbT <= 3e+214: tmp = NaChar / (math.exp(((Vef + Ev) / KbT)) + 1.0) else: tmp = 0.5 * (NaChar + NdChar) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (KbT <= -3.45e+75) tmp = Float64(Float64(NdChar / Float64(1.0 + Float64(1.0 + Float64(Float64(Float64(Float64(mu + Vef) + EDonor) - Ec) / KbT)))) + Float64(0.5 * NaChar)); elseif (KbT <= 3e+214) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Vef + Ev) / KbT)) + 1.0)); else tmp = Float64(0.5 * Float64(NaChar + NdChar)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (KbT <= -3.45e+75) tmp = (NdChar / (1.0 + (1.0 + ((((mu + Vef) + EDonor) - Ec) / KbT)))) + (0.5 * NaChar); elseif (KbT <= 3e+214) tmp = NaChar / (exp(((Vef + Ev) / KbT)) + 1.0); else tmp = 0.5 * (NaChar + NdChar); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, -3.45e+75], N[(N[(NdChar / N[(1.0 + N[(1.0 + N[(N[(N[(N[(mu + Vef), $MachinePrecision] + EDonor), $MachinePrecision] - Ec), $MachinePrecision] / KbT), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * NaChar), $MachinePrecision]), $MachinePrecision], If[LessEqual[KbT, 3e+214], N[(NaChar / N[(N[Exp[N[(N[(Vef + Ev), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;KbT \leq -3.45 \cdot 10^{+75}:\\
\;\;\;\;\frac{NdChar}{1 + \left(1 + \frac{\left(\left(mu + Vef\right) + EDonor\right) - Ec}{KbT}\right)} + 0.5 \cdot NaChar\\
\mathbf{elif}\;KbT \leq 3 \cdot 10^{+214}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{Vef + Ev}{KbT}} + 1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\end{array}
\end{array}
if KbT < -3.4500000000000002e75Initial program 100.0%
Taylor expanded in KbT around inf
lower-*.f6471.6
Applied rewrites71.6%
Taylor expanded in KbT around inf
associate--l+N/A
div-add-revN/A
div-addN/A
div-subN/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6465.8
Applied rewrites65.8%
if -3.4500000000000002e75 < KbT < 3.0000000000000001e214Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6461.3
Applied rewrites61.3%
Taylor expanded in EAccept around 0
Applied rewrites54.0%
Taylor expanded in mu around 0
Applied rewrites48.1%
if 3.0000000000000001e214 < KbT Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6467.6
Applied rewrites67.6%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (<= KbT -9.4e+157) (* 0.5 (+ NaChar NdChar)) (/ NaChar (+ (exp (/ (- (+ (+ Ev Vef) EAccept) mu) KbT)) 1.0))))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= -9.4e+157) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (kbt <= (-9.4d+157)) then
tmp = 0.5d0 * (nachar + ndchar)
else
tmp = nachar / (exp(((((ev + vef) + eaccept) - mu) / kbt)) + 1.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (KbT <= -9.4e+157) {
tmp = 0.5 * (NaChar + NdChar);
} else {
tmp = NaChar / (Math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if KbT <= -9.4e+157: tmp = 0.5 * (NaChar + NdChar) else: tmp = NaChar / (math.exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (KbT <= -9.4e+157) tmp = Float64(0.5 * Float64(NaChar + NdChar)); else tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Float64(Ev + Vef) + EAccept) - mu) / KbT)) + 1.0)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (KbT <= -9.4e+157) tmp = 0.5 * (NaChar + NdChar); else tmp = NaChar / (exp(((((Ev + Vef) + EAccept) - mu) / KbT)) + 1.0); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[KbT, -9.4e+157], N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(N[(Ev + Vef), $MachinePrecision] + EAccept), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;KbT \leq -9.4 \cdot 10^{+157}:\\
\;\;\;\;0.5 \cdot \left(NaChar + NdChar\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(\left(Ev + Vef\right) + EAccept\right) - mu}{KbT}} + 1}\\
\end{array}
\end{array}
if KbT < -9.40000000000000061e157Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6473.3
Applied rewrites73.3%
if -9.40000000000000061e157 < KbT Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6461.5
Applied rewrites61.5%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (<= EAccept 1.5e+75) (/ NaChar (+ (exp (/ (- (+ Vef Ev) mu) KbT)) 1.0)) (/ NaChar (+ (exp (/ (- (+ EAccept 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) {
double tmp;
if (EAccept <= 1.5e+75) {
tmp = NaChar / (exp((((Vef + Ev) - mu) / KbT)) + 1.0);
} else {
tmp = NaChar / (exp((((EAccept + Vef) - mu) / KbT)) + 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (eaccept <= 1.5d+75) then
tmp = nachar / (exp((((vef + ev) - mu) / kbt)) + 1.0d0)
else
tmp = nachar / (exp((((eaccept + vef) - mu) / kbt)) + 1.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (EAccept <= 1.5e+75) {
tmp = NaChar / (Math.exp((((Vef + Ev) - mu) / KbT)) + 1.0);
} else {
tmp = NaChar / (Math.exp((((EAccept + Vef) - mu) / KbT)) + 1.0);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if EAccept <= 1.5e+75: tmp = NaChar / (math.exp((((Vef + Ev) - mu) / KbT)) + 1.0) else: tmp = NaChar / (math.exp((((EAccept + Vef) - mu) / KbT)) + 1.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (EAccept <= 1.5e+75) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Vef + Ev) - mu) / KbT)) + 1.0)); else tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Vef) - mu) / KbT)) + 1.0)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (EAccept <= 1.5e+75) tmp = NaChar / (exp((((Vef + Ev) - mu) / KbT)) + 1.0); else tmp = NaChar / (exp((((EAccept + Vef) - mu) / KbT)) + 1.0); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[EAccept, 1.5e+75], N[(NaChar / N[(N[Exp[N[(N[(N[(Vef + Ev), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;EAccept \leq 1.5 \cdot 10^{+75}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(Vef + Ev\right) - mu}{KbT}} + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}} + 1}\\
\end{array}
\end{array}
if EAccept < 1.5e75Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6458.5
Applied rewrites58.5%
Taylor expanded in EAccept around 0
Applied rewrites53.6%
if 1.5e75 < EAccept Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6467.7
Applied rewrites67.7%
Taylor expanded in KbT around inf
Applied rewrites24.6%
Taylor expanded in Ev around 0
Applied rewrites65.8%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (<= Ev -2.2e+53) (/ NaChar (+ (exp (/ (+ (+ Vef Ev) EAccept) KbT)) 1.0)) (/ NaChar (+ (exp (/ (- (+ EAccept 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) {
double tmp;
if (Ev <= -2.2e+53) {
tmp = NaChar / (exp((((Vef + Ev) + EAccept) / KbT)) + 1.0);
} else {
tmp = NaChar / (exp((((EAccept + Vef) - mu) / KbT)) + 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if (ev <= (-2.2d+53)) then
tmp = nachar / (exp((((vef + ev) + eaccept) / kbt)) + 1.0d0)
else
tmp = nachar / (exp((((eaccept + vef) - mu) / kbt)) + 1.0d0)
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if (Ev <= -2.2e+53) {
tmp = NaChar / (Math.exp((((Vef + Ev) + EAccept) / KbT)) + 1.0);
} else {
tmp = NaChar / (Math.exp((((EAccept + Vef) - mu) / KbT)) + 1.0);
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if Ev <= -2.2e+53: tmp = NaChar / (math.exp((((Vef + Ev) + EAccept) / KbT)) + 1.0) else: tmp = NaChar / (math.exp((((EAccept + Vef) - mu) / KbT)) + 1.0) return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if (Ev <= -2.2e+53) tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(Vef + Ev) + EAccept) / KbT)) + 1.0)); else tmp = Float64(NaChar / Float64(exp(Float64(Float64(Float64(EAccept + Vef) - mu) / KbT)) + 1.0)); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if (Ev <= -2.2e+53) tmp = NaChar / (exp((((Vef + Ev) + EAccept) / KbT)) + 1.0); else tmp = NaChar / (exp((((EAccept + Vef) - mu) / KbT)) + 1.0); end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[LessEqual[Ev, -2.2e+53], N[(NaChar / N[(N[Exp[N[(N[(N[(Vef + Ev), $MachinePrecision] + EAccept), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(NaChar / N[(N[Exp[N[(N[(N[(EAccept + Vef), $MachinePrecision] - mu), $MachinePrecision] / KbT), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;Ev \leq -2.2 \cdot 10^{+53}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(Vef + Ev\right) + EAccept}{KbT}} + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{NaChar}{e^{\frac{\left(EAccept + Vef\right) - mu}{KbT}} + 1}\\
\end{array}
\end{array}
if Ev < -2.19999999999999999e53Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6459.8
Applied rewrites59.8%
Taylor expanded in mu around 0
Applied rewrites55.6%
if -2.19999999999999999e53 < Ev Initial program 100.0%
Taylor expanded in NdChar around 0
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-+.f6460.6
Applied rewrites60.6%
Taylor expanded in KbT around inf
Applied rewrites26.0%
Taylor expanded in Ev around 0
Applied rewrites56.1%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (if (or (<= NdChar -1.12e+42) (not (<= NdChar 6e-185))) (* 0.5 NdChar) (* 0.5 NaChar)))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if ((NdChar <= -1.12e+42) || !(NdChar <= 6e-185)) {
tmp = 0.5 * NdChar;
} else {
tmp = 0.5 * NaChar;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
real(8) :: tmp
if ((ndchar <= (-1.12d+42)) .or. (.not. (ndchar <= 6d-185))) then
tmp = 0.5d0 * ndchar
else
tmp = 0.5d0 * nachar
end if
code = tmp
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
double tmp;
if ((NdChar <= -1.12e+42) || !(NdChar <= 6e-185)) {
tmp = 0.5 * NdChar;
} else {
tmp = 0.5 * NaChar;
}
return tmp;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): tmp = 0 if (NdChar <= -1.12e+42) or not (NdChar <= 6e-185): tmp = 0.5 * NdChar else: tmp = 0.5 * NaChar return tmp
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0 if ((NdChar <= -1.12e+42) || !(NdChar <= 6e-185)) tmp = Float64(0.5 * NdChar); else tmp = Float64(0.5 * NaChar); end return tmp end
function tmp_2 = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.0; if ((NdChar <= -1.12e+42) || ~((NdChar <= 6e-185))) tmp = 0.5 * NdChar; else tmp = 0.5 * NaChar; end tmp_2 = tmp; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := If[Or[LessEqual[NdChar, -1.12e+42], N[Not[LessEqual[NdChar, 6e-185]], $MachinePrecision]], N[(0.5 * NdChar), $MachinePrecision], N[(0.5 * NaChar), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;NdChar \leq -1.12 \cdot 10^{+42} \lor \neg \left(NdChar \leq 6 \cdot 10^{-185}\right):\\
\;\;\;\;0.5 \cdot NdChar\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot NaChar\\
\end{array}
\end{array}
if NdChar < -1.12e42 or 6.00000000000000061e-185 < NdChar Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6427.5
Applied rewrites27.5%
Taylor expanded in NdChar around inf
Applied rewrites22.8%
if -1.12e42 < NdChar < 6.00000000000000061e-185Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6434.3
Applied rewrites34.3%
Taylor expanded in NdChar around 0
Applied rewrites30.3%
Final simplification26.1%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (* 0.5 (+ NaChar NdChar)))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * (NaChar + NdChar);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = 0.5d0 * (nachar + ndchar)
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * (NaChar + NdChar);
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return 0.5 * (NaChar + NdChar)
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(0.5 * Float64(NaChar + NdChar)) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.5 * (NaChar + NdChar); end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * N[(NaChar + NdChar), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(NaChar + NdChar\right)
\end{array}
Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6430.5
Applied rewrites30.5%
(FPCore (NdChar Ec Vef EDonor mu KbT NaChar Ev EAccept) :precision binary64 (* 0.5 NaChar))
double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * NaChar;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(ndchar, ec, vef, edonor, mu, kbt, nachar, ev, eaccept)
use fmin_fmax_functions
real(8), intent (in) :: ndchar
real(8), intent (in) :: ec
real(8), intent (in) :: vef
real(8), intent (in) :: edonor
real(8), intent (in) :: mu
real(8), intent (in) :: kbt
real(8), intent (in) :: nachar
real(8), intent (in) :: ev
real(8), intent (in) :: eaccept
code = 0.5d0 * nachar
end function
public static double code(double NdChar, double Ec, double Vef, double EDonor, double mu, double KbT, double NaChar, double Ev, double EAccept) {
return 0.5 * NaChar;
}
def code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept): return 0.5 * NaChar
function code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) return Float64(0.5 * NaChar) end
function tmp = code(NdChar, Ec, Vef, EDonor, mu, KbT, NaChar, Ev, EAccept) tmp = 0.5 * NaChar; end
code[NdChar_, Ec_, Vef_, EDonor_, mu_, KbT_, NaChar_, Ev_, EAccept_] := N[(0.5 * NaChar), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot NaChar
\end{array}
Initial program 100.0%
Taylor expanded in KbT around inf
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6430.5
Applied rewrites30.5%
Taylor expanded in NdChar around 0
Applied rewrites19.7%
herbie shell --seed 2024366
(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))))))