
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (* M D) (+ d_m d_m)))
(t_1 (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0))))
(t_2
(*
t_1
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))))
(if (<= t_2 -5e-252)
(*
t_1
(- 1.0 (* (* (/ 1.0 2.0) (/ (* t_0 (* M D)) (+ d_m d_m))) (/ h l))))
(if (<= t_2 INFINITY)
(*
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(- 1.0 (* (* (/ 1.0 2.0) (* t_0 t_0)) (/ h l))))
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) l))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double t_1 = pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0));
double t_2 = t_1 * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= -5e-252) {
tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l)));
} else if (t_2 <= ((double) INFINITY)) {
tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
} else {
tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
}
return tmp;
}
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double t_1 = Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0));
double t_2 = t_1 * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= -5e-252) {
tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l)));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = ((Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (M * D) / (d_m + d_m) t_1 = math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0)) t_2 = t_1 * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))) tmp = 0 if t_2 <= -5e-252: tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l))) elif t_2 <= math.inf: tmp = ((math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l))) else: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) / Float64(d_m + d_m)) t_1 = Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) t_2 = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_2 <= -5e-252) tmp = Float64(t_1 * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(Float64(t_0 * Float64(M * D)) / Float64(d_m + d_m))) * Float64(h / l)))); elseif (t_2 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_0 * t_0)) * Float64(h / l)))); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / l)); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (M * D) / (d_m + d_m); t_1 = ((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0)); t_2 = t_1 * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l))); tmp = 0.0; if (t_2 <= -5e-252) tmp = t_1 * (1.0 - (((1.0 / 2.0) * ((t_0 * (M * D)) / (d_m + d_m))) * (h / l))); elseif (t_2 <= Inf) tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l))); else tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-252], N[(t$95$1 * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(N[(t$95$0 * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
t_1 := {\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\\
t_2 := t\_1 \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-252}:\\
\;\;\;\;t\_1 \cdot \left(1 - \left(\frac{1}{2} \cdot \frac{t\_0 \cdot \left(M \cdot D\right)}{d\_m + d\_m}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000008e-252Initial program 85.9%
Applied rewrites84.1%
if -5.00000000000000008e-252 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 79.1%
Taylor expanded in d around 0
Applied rewrites82.0%
Applied rewrites82.0%
Applied rewrites88.8%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in d around 0
Applied rewrites58.9%
Taylor expanded in l around 0
Applied rewrites58.1%
Applied rewrites65.7%
Applied rewrites67.9%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (* M D) (+ d_m d_m))))
(if (<=
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))
INFINITY)
(*
(* (/ (sqrt (/ 1.0 h)) (sqrt l)) d_m)
(- 1.0 (* (* (/ 1.0 2.0) (* t_0 t_0)) (/ h l))))
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) l)))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double tmp;
if (((pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
} else {
tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
}
return tmp;
}
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) / (d_m + d_m);
double tmp;
if (((Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))) <= Double.POSITIVE_INFINITY) {
tmp = ((Math.sqrt((1.0 / h)) / Math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l)));
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (M * D) / (d_m + d_m) tmp = 0 if ((math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))) <= math.inf: tmp = ((math.sqrt((1.0 / h)) / math.sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l))) else: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) / Float64(d_m + d_m)) tmp = 0.0 if (Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / h)) / sqrt(l)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_0 * t_0)) * Float64(h / l)))); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / l)); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (M * D) / (d_m + d_m); tmp = 0.0; if (((((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)))) <= Inf) tmp = ((sqrt((1.0 / h)) / sqrt(l)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / l))); else tmp = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\mathbf{if}\;\left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}} \cdot d\_m\right) \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 81.7%
Taylor expanded in d around 0
Applied rewrites80.1%
Applied rewrites80.1%
Applied rewrites86.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in d around 0
Applied rewrites58.9%
Taylor expanded in l around 0
Applied rewrites58.1%
Applied rewrites65.7%
Applied rewrites67.9%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (- l (* (/ 0.125 d_m) (/ (* (* (* M D) (* M D)) h) d_m))) l)))
(if (<= l 7.5e-280)
(* (* (sqrt (/ 1.0 (* l h))) d_m) t_0)
(* (* (/ (sqrt (/ 1.0 l)) (sqrt h)) d_m) t_0))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l;
double tmp;
if (l <= 7.5e-280) {
tmp = (sqrt((1.0 / (l * h))) * d_m) * t_0;
} else {
tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * t_0;
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (l - ((0.125d0 / d_m) * ((((m * d) * (m * d)) * h) / d_m))) / l
if (l <= 7.5d-280) then
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * t_0
else
tmp = ((sqrt((1.0d0 / l)) / sqrt(h)) * d_m) * t_0
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l;
double tmp;
if (l <= 7.5e-280) {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * t_0;
} else {
tmp = ((Math.sqrt((1.0 / l)) / Math.sqrt(h)) * d_m) * t_0;
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l tmp = 0 if l <= 7.5e-280: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * t_0 else: tmp = ((math.sqrt((1.0 / l)) / math.sqrt(h)) * d_m) * t_0 return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * h) / d_m))) / l) tmp = 0.0 if (l <= 7.5e-280) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * t_0); else tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / l)) / sqrt(h)) * d_m) * t_0); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l; tmp = 0.0; if (l <= 7.5e-280) tmp = (sqrt((1.0 / (l * h))) * d_m) * t_0; else tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * t_0; end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]}, If[LessEqual[l, 7.5e-280], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d\_m}}{\ell}\\
\mathbf{if}\;\ell \leq 7.5 \cdot 10^{-280}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}} \cdot d\_m\right) \cdot t\_0\\
\end{array}
\end{array}
if l < 7.4999999999999999e-280Initial program 8.7%
Taylor expanded in d around 0
Applied rewrites68.7%
Taylor expanded in l around 0
Applied rewrites61.2%
Applied rewrites70.6%
if 7.4999999999999999e-280 < l Initial program 65.6%
Taylor expanded in d around 0
Applied rewrites67.9%
Taylor expanded in l around 0
Applied rewrites60.0%
Applied rewrites69.0%
Applied rewrites78.3%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (/ 1.0 (* l h))) d_m)))
(if (<= t_0 5e-161)
(* t_1 (/ (- l (* (/ 0.125 d_m) (/ (* (* (* M D) (* M D)) h) d_m))) l))
(if (<= t_0 1e+130)
(* (pow (* (/ d_m l) (/ d_m h)) (/ 1.0 2.0)) 1.0)
(*
t_1
(/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) l))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = sqrt((1.0 / (l * h))) * d_m;
double tmp;
if (t_0 <= 5e-161) {
tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l);
} else if (t_0 <= 1e+130) {
tmp = pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
} else {
tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = sqrt((1.0d0 / (l * h))) * d_m
if (t_0 <= 5d-161) then
tmp = t_1 * ((l - ((0.125d0 / d_m) * ((((m * d) * (m * d)) * h) / d_m))) / l)
else if (t_0 <= 1d+130) then
tmp = (((d_m / l) * (d_m / h)) ** (1.0d0 / 2.0d0)) * 1.0d0
else
tmp = t_1 * ((l - ((0.125d0 / d_m) * (((m * d) * ((m * d) * h)) / d_m))) / l)
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((1.0 / (l * h))) * d_m;
double tmp;
if (t_0 <= 5e-161) {
tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l);
} else if (t_0 <= 1e+130) {
tmp = Math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
} else {
tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = math.sqrt((1.0 / (l * h))) * d_m tmp = 0 if t_0 <= 5e-161: tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l) elif t_0 <= 1e+130: tmp = math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0 else: tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) tmp = 0.0 if (t_0 <= 5e-161) tmp = Float64(t_1 * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * h) / d_m))) / l)); elseif (t_0 <= 1e+130) tmp = Float64((Float64(Float64(d_m / l) * Float64(d_m / h)) ^ Float64(1.0 / 2.0)) * 1.0); else tmp = Float64(t_1 * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / l)); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l))); t_1 = sqrt((1.0 / (l * h))) * d_m; tmp = 0.0; if (t_0 <= 5e-161) tmp = t_1 * ((l - ((0.125 / d_m) * ((((M * D) * (M * D)) * h) / d_m))) / l); elseif (t_0 <= 1e+130) tmp = (((d_m / l) * (d_m / h)) ^ (1.0 / 2.0)) * 1.0; else tmp = t_1 * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-161], N[(t$95$1 * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+130], N[(N[Power[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(t$95$1 * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\
\;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h}{d\_m}}{\ell}\\
\mathbf{elif}\;t\_0 \leq 10^{+130}:\\
\;\;\;\;{\left(\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.9999999999999999e-161Initial program 78.7%
Taylor expanded in d around 0
Applied rewrites76.0%
Taylor expanded in l around 0
Applied rewrites52.9%
Applied rewrites72.8%
if 4.9999999999999999e-161 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1.0000000000000001e130Initial program 99.0%
Applied rewrites57.6%
Applied rewrites87.4%
Taylor expanded in d around inf
Applied rewrites97.7%
if 1.0000000000000001e130 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 12.9%
Taylor expanded in d around 0
Applied rewrites65.1%
Taylor expanded in l around 0
Applied rewrites62.5%
Applied rewrites68.8%
Applied rewrites71.7%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
(t_1
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(/ (- l (* (/ 0.125 d_m) (/ (* (* M D) (* (* M D) h)) d_m))) l))))
(if (<= t_0 5e-161)
t_1
(if (<= t_0 1e+130)
(* (pow (* (/ d_m l) (/ d_m h)) (/ 1.0 2.0)) 1.0)
t_1))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
double tmp;
if (t_0 <= 5e-161) {
tmp = t_1;
} else if (t_0 <= 1e+130) {
tmp = pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
} else {
tmp = t_1;
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
t_1 = (sqrt((1.0d0 / (l * h))) * d_m) * ((l - ((0.125d0 / d_m) * (((m * d) * ((m * d) * h)) / d_m))) / l)
if (t_0 <= 5d-161) then
tmp = t_1
else if (t_0 <= 1d+130) then
tmp = (((d_m / l) * (d_m / h)) ** (1.0d0 / 2.0d0)) * 1.0d0
else
tmp = t_1
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
double t_1 = (Math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l);
double tmp;
if (t_0 <= 5e-161) {
tmp = t_1;
} else if (t_0 <= 1e+130) {
tmp = Math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0;
} else {
tmp = t_1;
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))) t_1 = (math.sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l) tmp = 0 if t_0 <= 5e-161: tmp = t_1 elif t_0 <= 1e+130: tmp = math.pow(((d_m / l) * (d_m / h)), (1.0 / 2.0)) * 1.0 else: tmp = t_1 return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(Float64(Float64(M * D) * Float64(Float64(M * D) * h)) / d_m))) / l)) tmp = 0.0 if (t_0 <= 5e-161) tmp = t_1; elseif (t_0 <= 1e+130) tmp = Float64((Float64(Float64(d_m / l) * Float64(d_m / h)) ^ Float64(1.0 / 2.0)) * 1.0); else tmp = t_1; end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l))); t_1 = (sqrt((1.0 / (l * h))) * d_m) * ((l - ((0.125 / d_m) * (((M * D) * ((M * D) * h)) / d_m))) / l); tmp = 0.0; if (t_0 <= 5e-161) tmp = t_1; elseif (t_0 <= 1e+130) tmp = (((d_m / l) * (d_m / h)) ^ (1.0 / 2.0)) * 1.0; else tmp = t_1; end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-161], t$95$1, If[LessEqual[t$95$0, 1e+130], N[(N[Power[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \frac{\left(M \cdot D\right) \cdot \left(\left(M \cdot D\right) \cdot h\right)}{d\_m}}{\ell}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-161}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+130}:\\
\;\;\;\;{\left(\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.9999999999999999e-161 or 1.0000000000000001e130 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 29.5%
Taylor expanded in d around 0
Applied rewrites67.8%
Taylor expanded in l around 0
Applied rewrites60.1%
Applied rewrites69.8%
Applied rewrites72.3%
if 4.9999999999999999e-161 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1.0000000000000001e130Initial program 99.0%
Applied rewrites57.6%
Applied rewrites87.4%
Taylor expanded in d around inf
Applied rewrites97.7%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (* (* M D) (* M D))) (t_1 (* (sqrt (/ 1.0 (* l h))) d_m)))
(if (<= (* M D) 5e-149)
(* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
(if (<= (* M D) 5e+143)
(* t_1 (/ (- l (* (/ 0.125 d_m) (* t_0 (/ h d_m)))) l))
(* t_1 (/ (* (/ -0.125 d_m) (/ (* t_0 h) d_m)) l))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) * (M * D);
double t_1 = sqrt((1.0 / (l * h))) * d_m;
double tmp;
if ((M * D) <= 5e-149) {
tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
} else if ((M * D) <= 5e+143) {
tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l);
} else {
tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l);
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m * d) * (m * d)
t_1 = sqrt((1.0d0 / (l * h))) * d_m
if ((m * d) <= 5d-149) then
tmp = (sqrt(1.0d0) / sqrt((l * h))) * d_m
else if ((m * d) <= 5d+143) then
tmp = t_1 * ((l - ((0.125d0 / d_m) * (t_0 * (h / d_m)))) / l)
else
tmp = t_1 * ((((-0.125d0) / d_m) * ((t_0 * h) / d_m)) / l)
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) * (M * D);
double t_1 = Math.sqrt((1.0 / (l * h))) * d_m;
double tmp;
if ((M * D) <= 5e-149) {
tmp = (Math.sqrt(1.0) / Math.sqrt((l * h))) * d_m;
} else if ((M * D) <= 5e+143) {
tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l);
} else {
tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l);
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (M * D) * (M * D) t_1 = math.sqrt((1.0 / (l * h))) * d_m tmp = 0 if (M * D) <= 5e-149: tmp = (math.sqrt(1.0) / math.sqrt((l * h))) * d_m elif (M * D) <= 5e+143: tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l) else: tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) * Float64(M * D)) t_1 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) tmp = 0.0 if (Float64(M * D) <= 5e-149) tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m); elseif (Float64(M * D) <= 5e+143) tmp = Float64(t_1 * Float64(Float64(l - Float64(Float64(0.125 / d_m) * Float64(t_0 * Float64(h / d_m)))) / l)); else tmp = Float64(t_1 * Float64(Float64(Float64(-0.125 / d_m) * Float64(Float64(t_0 * h) / d_m)) / l)); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (M * D) * (M * D); t_1 = sqrt((1.0 / (l * h))) * d_m; tmp = 0.0; if ((M * D) <= 5e-149) tmp = (sqrt(1.0) / sqrt((l * h))) * d_m; elseif ((M * D) <= 5e+143) tmp = t_1 * ((l - ((0.125 / d_m) * (t_0 * (h / d_m)))) / l); else tmp = t_1 * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 5e-149], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+143], N[(t$95$1 * N[(N[(l - N[(N[(0.125 / d$95$m), $MachinePrecision] * N[(t$95$0 * N[(h / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(N[(t$95$0 * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \left(M \cdot D\right) \cdot \left(M \cdot D\right)\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
\mathbf{if}\;M \cdot D \leq 5 \cdot 10^{-149}:\\
\;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+143}:\\
\;\;\;\;t\_1 \cdot \frac{\ell - \frac{0.125}{d\_m} \cdot \left(t\_0 \cdot \frac{h}{d\_m}\right)}{\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_0 \cdot h}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 4.99999999999999968e-149Initial program 37.3%
Taylor expanded in d around inf
Applied rewrites50.3%
Applied rewrites50.5%
if 4.99999999999999968e-149 < (*.f64 M D) < 5.00000000000000012e143Initial program 34.5%
Taylor expanded in d around 0
Applied rewrites67.4%
Taylor expanded in l around 0
Applied rewrites66.7%
Applied rewrites71.0%
Applied rewrites73.4%
if 5.00000000000000012e143 < (*.f64 M D) Initial program 35.6%
Taylor expanded in d around 0
Applied rewrites69.4%
Taylor expanded in l around 0
Applied rewrites52.0%
Taylor expanded in d around 0
Applied rewrites51.1%
Applied rewrites63.1%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (* (sqrt (/ 1.0 (* l h))) d_m)) (t_1 (* (* M D) (* M D))))
(if (<= (* M D) 2.5e-141)
(* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
(if (<= (* M D) 1e+35)
(* t_0 (fma (/ (* -0.125 t_1) (* (* d_m d_m) l)) h 1.0))
(if (<= (* M D) 5e+260)
(* (/ (* t_1 -0.125) d_m) (sqrt (/ h (* (* l l) l))))
(* t_0 (/ (* (/ -0.125 d_m) (/ (* t_1 h) d_m)) l)))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = sqrt((1.0 / (l * h))) * d_m;
double t_1 = (M * D) * (M * D);
double tmp;
if ((M * D) <= 2.5e-141) {
tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
} else if ((M * D) <= 1e+35) {
tmp = t_0 * fma(((-0.125 * t_1) / ((d_m * d_m) * l)), h, 1.0);
} else if ((M * D) <= 5e+260) {
tmp = ((t_1 * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
} else {
tmp = t_0 * (((-0.125 / d_m) * ((t_1 * h) / d_m)) / l);
}
return tmp;
}
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) t_1 = Float64(Float64(M * D) * Float64(M * D)) tmp = 0.0 if (Float64(M * D) <= 2.5e-141) tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m); elseif (Float64(M * D) <= 1e+35) tmp = Float64(t_0 * fma(Float64(Float64(-0.125 * t_1) / Float64(Float64(d_m * d_m) * l)), h, 1.0)); elseif (Float64(M * D) <= 5e+260) tmp = Float64(Float64(Float64(t_1 * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(t_0 * Float64(Float64(Float64(-0.125 / d_m) * Float64(Float64(t_1 * h) / d_m)) / l)); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.5e-141], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+35], N[(t$95$0 * N[(N[(N[(-0.125 * t$95$1), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+260], N[(N[(N[(t$95$1 * -0.125), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(N[(t$95$1 * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
t_1 := \left(M \cdot D\right) \cdot \left(M \cdot D\right)\\
\mathbf{if}\;M \cdot D \leq 2.5 \cdot 10^{-141}:\\
\;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\mathbf{elif}\;M \cdot D \leq 10^{+35}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(\frac{-0.125 \cdot t\_1}{\left(d\_m \cdot d\_m\right) \cdot \ell}, h, 1\right)\\
\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+260}:\\
\;\;\;\;\frac{t\_1 \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1 \cdot h}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 2.5e-141Initial program 37.3%
Taylor expanded in d around inf
Applied rewrites50.3%
Applied rewrites50.5%
if 2.5e-141 < (*.f64 M D) < 9.9999999999999997e34Initial program 33.3%
Taylor expanded in d around 0
Applied rewrites66.5%
Taylor expanded in h around inf
Applied rewrites66.5%
if 9.9999999999999997e34 < (*.f64 M D) < 4.9999999999999996e260Initial program 35.5%
Taylor expanded in d around 0
Applied rewrites45.0%
if 4.9999999999999996e260 < (*.f64 M D) Initial program 36.2%
Taylor expanded in d around 0
Applied rewrites69.1%
Taylor expanded in l around 0
Applied rewrites56.8%
Taylor expanded in d around 0
Applied rewrites56.8%
Applied rewrites73.0%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (* (sqrt (/ 1.0 (* l h))) d_m)) (t_1 (* (* (* M D) (* M D)) h)))
(if (<= (* M D) 2.5e-141)
(* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
(if (<= (* M D) 1e+100)
(* t_0 (/ (fma (/ t_1 (* d_m d_m)) -0.125 l) l))
(* t_0 (/ (* (/ -0.125 d_m) (/ t_1 d_m)) l))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = sqrt((1.0 / (l * h))) * d_m;
double t_1 = ((M * D) * (M * D)) * h;
double tmp;
if ((M * D) <= 2.5e-141) {
tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
} else if ((M * D) <= 1e+100) {
tmp = t_0 * (fma((t_1 / (d_m * d_m)), -0.125, l) / l);
} else {
tmp = t_0 * (((-0.125 / d_m) * (t_1 / d_m)) / l);
}
return tmp;
}
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) t_1 = Float64(Float64(Float64(M * D) * Float64(M * D)) * h) tmp = 0.0 if (Float64(M * D) <= 2.5e-141) tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m); elseif (Float64(M * D) <= 1e+100) tmp = Float64(t_0 * Float64(fma(Float64(t_1 / Float64(d_m * d_m)), -0.125, l) / l)); else tmp = Float64(t_0 * Float64(Float64(Float64(-0.125 / d_m) * Float64(t_1 / d_m)) / l)); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.5e-141], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+100], N[(t$95$0 * N[(N[(N[(t$95$1 / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125 + l), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(t$95$1 / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
t_1 := \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\\
\mathbf{if}\;M \cdot D \leq 2.5 \cdot 10^{-141}:\\
\;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\mathbf{elif}\;M \cdot D \leq 10^{+100}:\\
\;\;\;\;t\_0 \cdot \frac{\mathsf{fma}\left(\frac{t\_1}{d\_m \cdot d\_m}, -0.125, \ell\right)}{\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 2.5e-141Initial program 37.3%
Taylor expanded in d around inf
Applied rewrites50.3%
Applied rewrites50.5%
if 2.5e-141 < (*.f64 M D) < 1.00000000000000002e100Initial program 34.4%
Taylor expanded in d around 0
Applied rewrites66.9%
Taylor expanded in l around 0
Applied rewrites67.2%
Applied rewrites67.2%
if 1.00000000000000002e100 < (*.f64 M D) Initial program 35.4%
Taylor expanded in d around 0
Applied rewrites69.7%
Taylor expanded in l around 0
Applied rewrites53.8%
Taylor expanded in d around 0
Applied rewrites49.1%
Applied rewrites60.3%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (* (sqrt (/ 1.0 (* l h))) d_m)) (t_1 (* (* (* M D) (* M D)) h)))
(if (<= (* M D) 2.5e-141)
(* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
(if (<= (* M D) 1e+100)
(* t_0 (fma -0.125 (/ t_1 (* (* d_m d_m) l)) 1.0))
(* t_0 (/ (* (/ -0.125 d_m) (/ t_1 d_m)) l))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = sqrt((1.0 / (l * h))) * d_m;
double t_1 = ((M * D) * (M * D)) * h;
double tmp;
if ((M * D) <= 2.5e-141) {
tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
} else if ((M * D) <= 1e+100) {
tmp = t_0 * fma(-0.125, (t_1 / ((d_m * d_m) * l)), 1.0);
} else {
tmp = t_0 * (((-0.125 / d_m) * (t_1 / d_m)) / l);
}
return tmp;
}
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) t_1 = Float64(Float64(Float64(M * D) * Float64(M * D)) * h) tmp = 0.0 if (Float64(M * D) <= 2.5e-141) tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m); elseif (Float64(M * D) <= 1e+100) tmp = Float64(t_0 * fma(-0.125, Float64(t_1 / Float64(Float64(d_m * d_m) * l)), 1.0)); else tmp = Float64(t_0 * Float64(Float64(Float64(-0.125 / d_m) * Float64(t_1 / d_m)) / l)); end return tmp end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2.5e-141], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 1e+100], N[(t$95$0 * N[(-0.125 * N[(t$95$1 / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(t$95$1 / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\\
t_1 := \left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot h\\
\mathbf{if}\;M \cdot D \leq 2.5 \cdot 10^{-141}:\\
\;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\mathbf{elif}\;M \cdot D \leq 10^{+100}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(-0.125, \frac{t\_1}{\left(d\_m \cdot d\_m\right) \cdot \ell}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_1}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 2.5e-141Initial program 37.3%
Taylor expanded in d around inf
Applied rewrites50.3%
Applied rewrites50.5%
if 2.5e-141 < (*.f64 M D) < 1.00000000000000002e100Initial program 34.4%
Taylor expanded in d around 0
Applied rewrites66.9%
Taylor expanded in d around inf
Applied rewrites67.2%
if 1.00000000000000002e100 < (*.f64 M D) Initial program 35.4%
Taylor expanded in d around 0
Applied rewrites69.7%
Taylor expanded in l around 0
Applied rewrites53.8%
Taylor expanded in d around 0
Applied rewrites49.1%
Applied rewrites60.3%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (* (* M D) (* M D))))
(if (<= (* M D) 4e+30)
(* (sqrt (/ (/ 1.0 h) l)) d_m)
(if (<= (* M D) 5e+260)
(* (/ (* t_0 -0.125) d_m) (sqrt (/ h (* (* l l) l))))
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(/ (* (/ -0.125 d_m) (/ (* t_0 h) d_m)) l))))))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) * (M * D);
double tmp;
if ((M * D) <= 4e+30) {
tmp = sqrt(((1.0 / h) / l)) * d_m;
} else if ((M * D) <= 5e+260) {
tmp = ((t_0 * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
} else {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l);
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (m * d) * (m * d)
if ((m * d) <= 4d+30) then
tmp = sqrt(((1.0d0 / h) / l)) * d_m
else if ((m * d) <= 5d+260) then
tmp = ((t_0 * (-0.125d0)) / d_m) * sqrt((h / ((l * l) * l)))
else
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * ((((-0.125d0) / d_m) * ((t_0 * h) / d_m)) / l)
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double t_0 = (M * D) * (M * D);
double tmp;
if ((M * D) <= 4e+30) {
tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
} else if ((M * D) <= 5e+260) {
tmp = ((t_0 * -0.125) / d_m) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l);
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): t_0 = (M * D) * (M * D) tmp = 0 if (M * D) <= 4e+30: tmp = math.sqrt(((1.0 / h) / l)) * d_m elif (M * D) <= 5e+260: tmp = ((t_0 * -0.125) / d_m) * math.sqrt((h / ((l * l) * l))) else: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(Float64(M * D) * Float64(M * D)) tmp = 0.0 if (Float64(M * D) <= 4e+30) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m); elseif (Float64(M * D) <= 5e+260) tmp = Float64(Float64(Float64(t_0 * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(Float64(Float64(-0.125 / d_m) * Float64(Float64(t_0 * h) / d_m)) / l)); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) t_0 = (M * D) * (M * D); tmp = 0.0; if ((M * D) <= 4e+30) tmp = sqrt(((1.0 / h) / l)) * d_m; elseif ((M * D) <= 5e+260) tmp = ((t_0 * -0.125) / d_m) * sqrt((h / ((l * l) * l))); else tmp = (sqrt((1.0 / (l * h))) * d_m) * (((-0.125 / d_m) * ((t_0 * h) / d_m)) / l); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 4e+30], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 5e+260], N[(N[(N[(t$95$0 * -0.125), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(N[(-0.125 / d$95$m), $MachinePrecision] * N[(N[(t$95$0 * h), $MachinePrecision] / d$95$m), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \left(M \cdot D\right) \cdot \left(M \cdot D\right)\\
\mathbf{if}\;M \cdot D \leq 4 \cdot 10^{+30}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\
\mathbf{elif}\;M \cdot D \leq 5 \cdot 10^{+260}:\\
\;\;\;\;\frac{t\_0 \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \frac{\frac{-0.125}{d\_m} \cdot \frac{t\_0 \cdot h}{d\_m}}{\ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 4.0000000000000001e30Initial program 36.6%
Taylor expanded in d around inf
Applied rewrites50.5%
Applied rewrites50.9%
if 4.0000000000000001e30 < (*.f64 M D) < 4.9999999999999996e260Initial program 35.7%
Taylor expanded in d around 0
Applied rewrites44.9%
if 4.9999999999999996e260 < (*.f64 M D) Initial program 36.2%
Taylor expanded in d around 0
Applied rewrites69.1%
Taylor expanded in l around 0
Applied rewrites56.8%
Taylor expanded in d around 0
Applied rewrites56.8%
Applied rewrites73.0%
d_m = (fabs.f64 d) (FPCore (d_m h l M D) :precision binary64 (if (<= (* M D) 4e+30) (* (sqrt (/ (/ 1.0 h) l)) d_m) (* (/ (* (* (* M D) (* M D)) -0.125) d_m) (sqrt (/ h (* (* l l) l))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double tmp;
if ((M * D) <= 4e+30) {
tmp = sqrt(((1.0 / h) / l)) * d_m;
} else {
tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: tmp
if ((m * d) <= 4d+30) then
tmp = sqrt(((1.0d0 / h) / l)) * d_m
else
tmp = ((((m * d) * (m * d)) * (-0.125d0)) / d_m) * sqrt((h / ((l * l) * l)))
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double tmp;
if ((M * D) <= 4e+30) {
tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
} else {
tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * Math.sqrt((h / ((l * l) * l)));
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): tmp = 0 if (M * D) <= 4e+30: tmp = math.sqrt(((1.0 / h) / l)) * d_m else: tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * math.sqrt((h / ((l * l) * l))) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) tmp = 0.0 if (Float64(M * D) <= 4e+30) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m); else tmp = Float64(Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) tmp = 0.0; if ((M * D) <= 4e+30) tmp = sqrt(((1.0 / h) / l)) * d_m; else tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * sqrt((h / ((l * l) * l))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 4e+30], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / d$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;M \cdot D \leq 4 \cdot 10^{+30}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot -0.125}{d\_m} \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 M D) < 4.0000000000000001e30Initial program 36.6%
Taylor expanded in d around inf
Applied rewrites50.5%
Applied rewrites50.9%
if 4.0000000000000001e30 < (*.f64 M D) Initial program 35.9%
Taylor expanded in d around 0
Applied rewrites50.3%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(if (<=
(*
(* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))
-5e-252)
(* (sqrt (/ 1.0 (* l h))) (- d_m))
(* (sqrt (/ (/ 1.0 h) l)) d_m)))d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
double tmp;
if (((pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e-252) {
tmp = sqrt((1.0 / (l * h))) * -d_m;
} else {
tmp = sqrt(((1.0 / h) / l)) * d_m;
}
return tmp;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8) :: tmp
if (((((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))) <= (-5d-252)) then
tmp = sqrt((1.0d0 / (l * h))) * -d_m
else
tmp = sqrt(((1.0d0 / h) / l)) * d_m
end if
code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
double tmp;
if (((Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e-252) {
tmp = Math.sqrt((1.0 / (l * h))) * -d_m;
} else {
tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
}
return tmp;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): tmp = 0 if ((math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e-252: tmp = math.sqrt((1.0 / (l * h))) * -d_m else: tmp = math.sqrt(((1.0 / h) / l)) * d_m return tmp
d_m = abs(d) function code(d_m, h, l, M, D) tmp = 0.0 if (Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))) <= -5e-252) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d_m)); else tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m); end return tmp end
d_m = abs(d); function tmp_2 = code(d_m, h, l, M, D) tmp = 0.0; if (((((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)))) <= -5e-252) tmp = sqrt((1.0 / (l * h))) * -d_m; else tmp = sqrt(((1.0 / h) / l)) * d_m; end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-252], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d$95$m)), $MachinePrecision], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-252}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000008e-252Initial program 85.9%
Taylor expanded in l around -inf
Applied rewrites22.0%
if -5.00000000000000008e-252 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 26.1%
Taylor expanded in d around inf
Applied rewrites51.9%
Applied rewrites52.3%
d_m = (fabs.f64 d) (FPCore (d_m h l M D) :precision binary64 (* (sqrt (/ (/ 1.0 h) l)) d_m))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
return sqrt(((1.0 / h) / l)) * d_m;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
code = sqrt(((1.0d0 / h) / l)) * d_m
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
return Math.sqrt(((1.0 / h) / l)) * d_m;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): return math.sqrt(((1.0 / h) / l)) * d_m
d_m = abs(d) function code(d_m, h, l, M, D) return Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m) end
d_m = abs(d); function tmp = code(d_m, h, l, M, D) tmp = sqrt(((1.0 / h) / l)) * d_m; end
d_m = N[Abs[d], $MachinePrecision] code[d$95$m_, h_, l_, M_, D_] := N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m
\end{array}
Initial program 36.4%
Taylor expanded in d around inf
Applied rewrites43.2%
Applied rewrites43.5%
d_m = (fabs.f64 d) (FPCore (d_m h l M D) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d_m))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
return sqrt((1.0 / (l * h))) * d_m;
}
d_m = private
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(d_m, h, l, m, d)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d
code = sqrt((1.0d0 / (l * h))) * d_m
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
return Math.sqrt((1.0 / (l * h))) * d_m;
}
d_m = math.fabs(d) def code(d_m, h, l, M, D): return math.sqrt((1.0 / (l * h))) * d_m
d_m = abs(d) function code(d_m, h, l, M, D) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) end
d_m = abs(d); function tmp = code(d_m, h, l, M, D) tmp = sqrt((1.0 / (l * h))) * d_m; end
d_m = N[Abs[d], $MachinePrecision] code[d$95$m_, h_, l_, M_, D_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m
\end{array}
Initial program 36.4%
Taylor expanded in d around inf
Applied rewrites43.2%
herbie shell --seed 2025129
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))