
(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 10 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))))
(if (<= h 2.65e-300)
(*
(* (sqrt (/ (/ 1.0 l) h)) d_m)
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))
(*
(* (/ (sqrt (/ 1.0 l)) (sqrt h)) d_m)
(- 1.0 (* (* (/ 1.0 2.0) (* t_0 t_0)) (/ h 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 (h <= 2.65e-300) {
tmp = (sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
} else {
tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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) / (d_m + d_m)
if (h <= 2.65d-300) then
tmp = (sqrt(((1.0d0 / l) / h)) * d_m) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
else
tmp = ((sqrt((1.0d0 / l)) / sqrt(h)) * d_m) * (1.0d0 - (((1.0d0 / 2.0d0) * (t_0 * t_0)) * (h / 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) / (d_m + d_m);
double tmp;
if (h <= 2.65e-300) {
tmp = (Math.sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
} else {
tmp = ((Math.sqrt((1.0 / l)) / Math.sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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 h <= 2.65e-300: tmp = (math.sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))) else: tmp = ((math.sqrt((1.0 / l)) / math.sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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 (h <= 2.65e-300) tmp = Float64(Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / l)) / sqrt(h)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_0 * t_0)) * Float64(h / 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 (h <= 2.65e-300) tmp = (sqrt(((1.0 / l) / h)) * d_m) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l))); else tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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[h, 2.65e-300], N[(N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d$95$m), $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], N[(N[(N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $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]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\mathbf{if}\;h \leq 2.65 \cdot 10^{-300}:\\
\;\;\;\;\left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\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)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}} \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)\\
\end{array}
\end{array}
if h < 2.65e-300Initial program 6.5%
Taylor expanded in d around 0
Applied rewrites70.5%
Applied rewrites70.9%
if 2.65e-300 < h Initial program 65.6%
Taylor expanded in d around 0
Applied rewrites69.5%
Applied rewrites69.5%
Applied rewrites79.5%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (* M D) (+ d_m d_m))))
(if (<= h 2e-307)
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(- 1.0 (* (* (* (/ 1.0 2.0) t_0) t_0) (/ h l))))
(*
(* (/ (sqrt (/ 1.0 l)) (sqrt h)) d_m)
(- 1.0 (* (* (/ 1.0 2.0) (* t_0 t_0)) (/ h 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 (h <= 2e-307) {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / l)));
} else {
tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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) / (d_m + d_m)
if (h <= 2d-307) then
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - ((((1.0d0 / 2.0d0) * t_0) * t_0) * (h / l)))
else
tmp = ((sqrt((1.0d0 / l)) / sqrt(h)) * d_m) * (1.0d0 - (((1.0d0 / 2.0d0) * (t_0 * t_0)) * (h / 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) / (d_m + d_m);
double tmp;
if (h <= 2e-307) {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / l)));
} else {
tmp = ((Math.sqrt((1.0 / l)) / Math.sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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 h <= 2e-307: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / l))) else: tmp = ((math.sqrt((1.0 / l)) / math.sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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 (h <= 2e-307) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(1.0 / 2.0) * t_0) * t_0) * Float64(h / l)))); else tmp = Float64(Float64(Float64(sqrt(Float64(1.0 / l)) / sqrt(h)) * d_m) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_0 * t_0)) * Float64(h / 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 (h <= 2e-307) tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / l))); else tmp = ((sqrt((1.0 / l)) / sqrt(h)) * d_m) * (1.0 - (((1.0 / 2.0) * (t_0 * t_0)) * (h / 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[h, 2e-307], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(1.0 / 2.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[N[(1.0 / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $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]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := \frac{M \cdot D}{d\_m + d\_m}\\
\mathbf{if}\;h \leq 2 \cdot 10^{-307}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \left(\left(\frac{1}{2} \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{\frac{1}{\ell}}}{\sqrt{h}} \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)\\
\end{array}
\end{array}
if h < 1.99999999999999982e-307Initial program 5.7%
Taylor expanded in d around 0
Applied rewrites70.6%
Applied rewrites70.6%
Applied rewrites70.6%
if 1.99999999999999982e-307 < h Initial program 65.6%
Taylor expanded in d around 0
Applied rewrites69.5%
Applied rewrites69.5%
Applied rewrites79.5%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(let* ((t_0 (/ (* M D) (+ d_m d_m))))
(if (<= (* M D) 1e-238)
(* (sqrt (/ (/ 1.0 l) h)) d_m)
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(- 1.0 (* (* (* (/ 1.0 2.0) t_0) t_0) (/ h 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 ((M * D) <= 1e-238) {
tmp = sqrt(((1.0 / l) / h)) * d_m;
} else {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / 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) / (d_m + d_m)
if ((m * d) <= 1d-238) then
tmp = sqrt(((1.0d0 / l) / h)) * d_m
else
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - ((((1.0d0 / 2.0d0) * t_0) * t_0) * (h / 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) / (d_m + d_m);
double tmp;
if ((M * D) <= 1e-238) {
tmp = Math.sqrt(((1.0 / l) / h)) * d_m;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / 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 (M * D) <= 1e-238: tmp = math.sqrt(((1.0 / l) / h)) * d_m else: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / 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(M * D) <= 1e-238) tmp = Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d_m); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(1.0 / 2.0) * t_0) * t_0) * Float64(h / 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 ((M * D) <= 1e-238) tmp = sqrt(((1.0 / l) / h)) * d_m; else tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((1.0 / 2.0) * t_0) * t_0) * (h / 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[(M * D), $MachinePrecision], 1e-238], N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(1.0 / 2.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $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}\;M \cdot D \leq 10^{-238}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \left(\left(\frac{1}{2} \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 9.9999999999999999e-239Initial program 36.3%
Taylor expanded in d around inf
Applied rewrites48.8%
Applied rewrites49.0%
if 9.9999999999999999e-239 < (*.f64 M D) Initial program 35.1%
Taylor expanded in d around 0
Applied rewrites69.4%
Applied rewrites69.4%
Applied rewrites69.4%
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)))
(t_1
(*
(* t_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))))))
(if (<= t_1 -5e-91)
(* (/ (* (* (* M D) (* M D)) -0.125) d_m) (sqrt (/ h (* (* l l) l))))
(if (<= t_1 2e-213)
(* (sqrt (/ (/ 1.0 h) l)) d_m)
(if (<= t_1 5e+267)
(* (* t_0 (sqrt (/ d_m l))) 1.0)
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(-
1.0
(/
(*
(*
(* M (/ (* D (* M D)) (* (+ d_m d_m) (+ d_m d_m))))
(/ 1.0 2.0))
h)
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));
double t_1 = (t_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 tmp;
if (t_1 <= -5e-91) {
tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
} else if (t_1 <= 2e-213) {
tmp = sqrt(((1.0 / h) / l)) * d_m;
} else if (t_1 <= 5e+267) {
tmp = (t_0 * sqrt((d_m / l))) * 1.0;
} else {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * ((D * (M * D)) / ((d_m + d_m) * (d_m + d_m)))) * (1.0 / 2.0)) * h) / 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)
t_1 = (t_0 * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
if (t_1 <= (-5d-91)) then
tmp = ((((m * d) * (m * d)) * (-0.125d0)) / d_m) * sqrt((h / ((l * l) * l)))
else if (t_1 <= 2d-213) then
tmp = sqrt(((1.0d0 / h) / l)) * d_m
else if (t_1 <= 5d+267) then
tmp = (t_0 * sqrt((d_m / l))) * 1.0d0
else
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - ((((m * ((d * (m * d)) / ((d_m + d_m) * (d_m + d_m)))) * (1.0d0 / 2.0d0)) * h) / 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));
double t_1 = (t_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 tmp;
if (t_1 <= -5e-91) {
tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * Math.sqrt((h / ((l * l) * l)));
} else if (t_1 <= 2e-213) {
tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
} else if (t_1 <= 5e+267) {
tmp = (t_0 * Math.sqrt((d_m / l))) * 1.0;
} else {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * ((D * (M * D)) / ((d_m + d_m) * (d_m + d_m)))) * (1.0 / 2.0)) * h) / 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)) t_1 = (t_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))) tmp = 0 if t_1 <= -5e-91: tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * math.sqrt((h / ((l * l) * l))) elif t_1 <= 2e-213: tmp = math.sqrt(((1.0 / h) / l)) * d_m elif t_1 <= 5e+267: tmp = (t_0 * math.sqrt((d_m / l))) * 1.0 else: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * ((D * (M * D)) / ((d_m + d_m) * (d_m + d_m)))) * (1.0 / 2.0)) * h) / l)) return tmp
d_m = abs(d) function code(d_m, h, l, M, D) t_0 = Float64(d_m / h) ^ Float64(1.0 / 2.0) t_1 = Float64(Float64(t_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)))) tmp = 0.0 if (t_1 <= -5e-91) tmp = Float64(Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); elseif (t_1 <= 2e-213) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m); elseif (t_1 <= 5e+267) tmp = Float64(Float64(t_0 * sqrt(Float64(d_m / l))) * 1.0); else tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(Float64(M * Float64(Float64(D * Float64(M * D)) / Float64(Float64(d_m + d_m) * Float64(d_m + d_m)))) * Float64(1.0 / 2.0)) * h) / 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); t_1 = (t_0 * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l))); tmp = 0.0; if (t_1 <= -5e-91) tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * sqrt((h / ((l * l) * l))); elseif (t_1 <= 2e-213) tmp = sqrt(((1.0 / h) / l)) * d_m; elseif (t_1 <= 5e+267) tmp = (t_0 * sqrt((d_m / l))) * 1.0; else tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - ((((M * ((D * (M * D)) / ((d_m + d_m) * (d_m + d_m)))) * (1.0 / 2.0)) * h) / 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[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * 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]}, If[LessEqual[t$95$1, -5e-91], 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], If[LessEqual[t$95$1, 2e-213], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[t$95$1, 5e+267], N[(N[(t$95$0 * N[Sqrt[N[(d$95$m / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M * N[(N[(D * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m + d$95$m), $MachinePrecision] * N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
\begin{array}{l}
t_0 := {\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)}\\
t_1 := \left(t\_0 \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)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-91}:\\
\;\;\;\;\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}}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-213}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+267}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d\_m}{\ell}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{\left(\left(M \cdot \frac{D \cdot \left(M \cdot D\right)}{\left(d\_m + d\_m\right) \cdot \left(d\_m + d\_m\right)}\right) \cdot \frac{1}{2}\right) \cdot h}{\ell}\right)\\
\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.99999999999999997e-91Initial program 86.0%
Taylor expanded in d around 0
Applied rewrites71.7%
if -4.99999999999999997e-91 < (*.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.9999999999999999e-213Initial program 52.2%
Taylor expanded in d around inf
Applied rewrites63.1%
Applied rewrites63.4%
if 1.9999999999999999e-213 < (*.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.9999999999999999e267Initial program 98.8%
Taylor expanded in d around 0
Applied rewrites98.8%
Taylor expanded in d around inf
Applied rewrites98.1%
if 4.9999999999999999e267 < (*.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 8.7%
Taylor expanded in d around 0
Applied rewrites66.0%
Applied rewrites62.8%
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
:precision binary64
(if (<= M 6.5e-135)
(* (sqrt (/ (/ 1.0 h) l)) d_m)
(if (<= M 1.82e+93)
(*
(* (sqrt (/ 1.0 (* l h))) d_m)
(- 1.0 (* (/ (* 0.125 (* (* D D) (* M M))) (* d_m d_m)) (/ h l))))
(* (/ (* (* (* 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 <= 6.5e-135) {
tmp = sqrt(((1.0 / h) / l)) * d_m;
} else if (M <= 1.82e+93) {
tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - (((0.125 * ((D * D) * (M * M))) / (d_m * d_m)) * (h / l)));
} 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 <= 6.5d-135) then
tmp = sqrt(((1.0d0 / h) / l)) * d_m
else if (m <= 1.82d+93) then
tmp = (sqrt((1.0d0 / (l * h))) * d_m) * (1.0d0 - (((0.125d0 * ((d * d) * (m * m))) / (d_m * d_m)) * (h / l)))
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 <= 6.5e-135) {
tmp = Math.sqrt(((1.0 / h) / l)) * d_m;
} else if (M <= 1.82e+93) {
tmp = (Math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - (((0.125 * ((D * D) * (M * M))) / (d_m * d_m)) * (h / l)));
} 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 <= 6.5e-135: tmp = math.sqrt(((1.0 / h) / l)) * d_m elif M <= 1.82e+93: tmp = (math.sqrt((1.0 / (l * h))) * d_m) * (1.0 - (((0.125 * ((D * D) * (M * M))) / (d_m * d_m)) * (h / l))) 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 (M <= 6.5e-135) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * d_m); elseif (M <= 1.82e+93) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d_m) * Float64(1.0 - Float64(Float64(Float64(0.125 * Float64(Float64(D * D) * Float64(M * M))) / Float64(d_m * d_m)) * Float64(h / l)))); 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 <= 6.5e-135) tmp = sqrt(((1.0 / h) / l)) * d_m; elseif (M <= 1.82e+93) tmp = (sqrt((1.0 / (l * h))) * d_m) * (1.0 - (((0.125 * ((D * D) * (M * M))) / (d_m * d_m)) * (h / l))); 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[M, 6.5e-135], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision], If[LessEqual[M, 1.82e+93], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(1.0 - N[(N[(N[(0.125 * N[(N[(D * D), $MachinePrecision] * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 \leq 6.5 \cdot 10^{-135}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot d\_m\\
\mathbf{elif}\;M \leq 1.82 \cdot 10^{+93}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\_m\right) \cdot \left(1 - \frac{0.125 \cdot \left(\left(D \cdot D\right) \cdot \left(M \cdot M\right)\right)}{d\_m \cdot d\_m} \cdot \frac{h}{\ell}\right)\\
\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 M < 6.50000000000000056e-135Initial program 36.0%
Taylor expanded in d around inf
Applied rewrites48.1%
Applied rewrites48.4%
if 6.50000000000000056e-135 < M < 1.82000000000000009e93Initial program 35.7%
Taylor expanded in d around 0
Applied rewrites71.1%
Taylor expanded in d around 0
Applied rewrites56.0%
if 1.82000000000000009e93 < M Initial program 35.2%
Taylor expanded in d around 0
Applied rewrites48.6%
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))))))
(if (<= t_0 -5e+80)
(* (/ (* (* (* M D) (* M D)) -0.125) d_m) (sqrt (/ h (* (* l l) l))))
(if (<= t_0 INFINITY)
(* (/ (sqrt 1.0) (sqrt (* l h))) d_m)
(*
(* (sqrt (/ (/ 1.0 l) h)) d_m)
(fma (/ (* (* (* M M) h) (* D D)) (* (* d_m d_m) l)) -0.125 1.0))))))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 tmp;
if (t_0 <= -5e+80) {
tmp = ((((M * D) * (M * D)) * -0.125) / d_m) * sqrt((h / ((l * l) * l)));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt(1.0) / sqrt((l * h))) * d_m;
} else {
tmp = (sqrt(((1.0 / l) / h)) * d_m) * fma(((((M * M) * h) * (D * D)) / ((d_m * d_m) * l)), -0.125, 1.0);
}
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)))) tmp = 0.0 if (t_0 <= -5e+80) tmp = Float64(Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * -0.125) / d_m) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * d_m); else tmp = Float64(Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d_m) * fma(Float64(Float64(Float64(Float64(M * M) * h) * Float64(D * D)) / Float64(Float64(d_m * d_m) * l)), -0.125, 1.0)); end return 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]}, If[LessEqual[t$95$0, -5e+80], 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], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $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)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+80}:\\
\;\;\;\;\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}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \cdot d\_m\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\_m\right) \cdot \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell}, -0.125, 1\right)\\
\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.99999999999999961e80Initial program 85.1%
Taylor expanded in d around 0
Applied rewrites73.4%
if -4.99999999999999961e80 < (*.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 80.4%
Taylor expanded in d around inf
Applied rewrites78.6%
Applied rewrites78.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 rewrites60.9%
Applied rewrites61.3%
Taylor expanded in d around inf
Applied rewrites47.8%
d_m = (fabs.f64 d) (FPCore (d_m h l M D) :precision binary64 (if (<= (* M D) 4e-14) (* (/ (sqrt 1.0) (sqrt (* l h))) 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-14) {
tmp = (sqrt(1.0) / sqrt((l * h))) * 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-14) then
tmp = (sqrt(1.0d0) / sqrt((l * h))) * 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-14) {
tmp = (Math.sqrt(1.0) / Math.sqrt((l * h))) * 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-14: tmp = (math.sqrt(1.0) / math.sqrt((l * h))) * 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-14) tmp = Float64(Float64(sqrt(1.0) / sqrt(Float64(l * h))) * 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-14) tmp = (sqrt(1.0) / sqrt((l * h))) * 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-14], N[(N[(N[Sqrt[1.0], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $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^{-14}:\\
\;\;\;\;\frac{\sqrt{1}}{\sqrt{\ell \cdot h}} \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) < 4e-14Initial program 36.1%
Taylor expanded in d around inf
Applied rewrites50.6%
Applied rewrites50.9%
if 4e-14 < (*.f64 M D) Initial program 35.0%
Taylor expanded in d around 0
Applied rewrites48.4%
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-91)
(* (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-91) {
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-91)) 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-91) {
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-91: 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-91) 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-91) 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-91], 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^{-91}:\\
\;\;\;\;\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)))) < -4.99999999999999997e-91Initial program 86.0%
Taylor expanded in l around -inf
Applied rewrites24.4%
if -4.99999999999999997e-91 < (*.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 25.7%
Taylor expanded in d around inf
Applied rewrites51.7%
Applied rewrites52.0%
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 35.8%
Taylor expanded in d around inf
Applied rewrites43.3%
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 35.8%
Taylor expanded in d around inf
Applied rewrites43.3%
herbie shell --seed 2025121
(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)))))