
(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}
Sampling outcomes in binary64 precision:
Herbie found 16 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)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l))))
(if (<= l -5e-310)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) t_0)
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M_m d)) 2.0) (* 0.5 h)) l)))
(if (<= l 1.55e+131)
(*
(/
(*
(fma (* (/ h l) -0.5) (pow (* (/ (/ D_m d) 2.0) M_m) 2.0) 1.0)
(sqrt d))
(sqrt h))
t_0)
(/ d (* (sqrt l) (sqrt h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double tmp;
if (l <= -5e-310) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * (1.0 - ((pow(((D_m / 2.0) * (M_m / d)), 2.0) * (0.5 * h)) / l));
} else if (l <= 1.55e+131) {
tmp = ((fma(((h / l) * -0.5), pow((((D_m / d) / 2.0) * M_m), 2.0), 1.0) * sqrt(d)) / sqrt(h)) * t_0;
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0) * Float64(0.5 * h)) / l))); elseif (l <= 1.55e+131) tmp = Float64(Float64(Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(Float64(D_m / d) / 2.0) * M_m) ^ 2.0), 1.0) * sqrt(d)) / sqrt(h)) * t_0); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.55e+131], N[(N[(N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+131}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right)}^{2}, 1\right) \cdot \sqrt{d}}{\sqrt{h}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 64.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6466.6
lift-/.f64N/A
metadata-eval66.6
Applied rewrites66.6%
lift-/.f64N/A
metadata-eval66.6
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6466.6
Applied rewrites66.6%
lift-/.f64N/A
metadata-eval66.6
lift-pow.f64N/A
pow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6478.4
Applied rewrites78.4%
if -4.999999999999985e-310 < l < 1.55000000000000008e131Initial program 73.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites73.8%
Applied rewrites84.1%
if 1.55000000000000008e131 < l Initial program 37.6%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (/ d h)) (sqrt (/ d l)))))
(if (<= t_0 -1e-25)
(* t_1 (* (* -0.125 (/ (/ (* D_m D_m) d) d)) (/ (* (* M_m M_m) h) l)))
(if (<= t_0 0.0)
(/ d (sqrt (* l h)))
(if (<= t_0 2e+307) t_1 (* (- d) (sqrt (/ (/ 1.0 h) l))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / h)) * sqrt((d / l));
double tmp;
if (t_0 <= -1e-25) {
tmp = t_1 * ((-0.125 * (((D_m * D_m) / d) / d)) * (((M_m * M_m) * h) / l));
} else if (t_0 <= 0.0) {
tmp = d / sqrt((l * h));
} else if (t_0 <= 2e+307) {
tmp = t_1;
} else {
tmp = -d * sqrt(((1.0 / h) / l));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
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_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = sqrt((d / h)) * sqrt((d / l))
if (t_0 <= (-1d-25)) then
tmp = t_1 * (((-0.125d0) * (((d_m * d_m) / d) / d)) * (((m_m * m_m) * h) / l))
else if (t_0 <= 0.0d0) then
tmp = d / sqrt((l * h))
else if (t_0 <= 2d+307) then
tmp = t_1
else
tmp = -d * sqrt(((1.0d0 / h) / l))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (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_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((d / h)) * Math.sqrt((d / l));
double tmp;
if (t_0 <= -1e-25) {
tmp = t_1 * ((-0.125 * (((D_m * D_m) / d) / d)) * (((M_m * M_m) * h) / l));
} else if (t_0 <= 0.0) {
tmp = d / Math.sqrt((l * h));
} else if (t_0 <= 2e+307) {
tmp = t_1;
} else {
tmp = -d * Math.sqrt(((1.0 / h) / l));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (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_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((d / h)) * math.sqrt((d / l)) tmp = 0 if t_0 <= -1e-25: tmp = t_1 * ((-0.125 * (((D_m * D_m) / d) / d)) * (((M_m * M_m) * h) / l)) elif t_0 <= 0.0: tmp = d / math.sqrt((l * h)) elif t_0 <= 2e+307: tmp = t_1 else: tmp = -d * math.sqrt(((1.0 / h) / l)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = 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_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) tmp = 0.0 if (t_0 <= -1e-25) tmp = Float64(t_1 * Float64(Float64(-0.125 * Float64(Float64(Float64(D_m * D_m) / d) / d)) * Float64(Float64(Float64(M_m * M_m) * h) / l))); elseif (t_0 <= 0.0) tmp = Float64(d / sqrt(Float64(l * h))); elseif (t_0 <= 2e+307) tmp = t_1; else tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((d / h)) * sqrt((d / l));
tmp = 0.0;
if (t_0 <= -1e-25)
tmp = t_1 * ((-0.125 * (((D_m * D_m) / d) / d)) * (((M_m * M_m) * h) / l));
elseif (t_0 <= 0.0)
tmp = d / sqrt((l * h));
elseif (t_0 <= 2e+307)
tmp = t_1;
else
tmp = -d * sqrt(((1.0 / h) / l));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = 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$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-25], N[(t$95$1 * N[(N[(-0.125 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+307], t$95$1, N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \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\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-25}:\\
\;\;\;\;t\_1 \cdot \left(\left(-0.125 \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right) \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\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)))) < -1.00000000000000004e-25Initial program 84.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6485.3
lift-/.f64N/A
metadata-eval85.3
Applied rewrites85.3%
lift-/.f64N/A
metadata-eval85.3
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6485.3
Applied rewrites85.3%
lift-/.f64N/A
metadata-eval85.3
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6485.3
Applied rewrites85.3%
Taylor expanded in d around 0
Applied rewrites60.6%
if -1.00000000000000004e-25 < (*.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)))) < -0.0Initial program 59.6%
Taylor expanded in d around inf
Applied rewrites59.4%
Applied rewrites59.5%
Applied rewrites59.5%
if -0.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)))) < 1.99999999999999997e307Initial program 98.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in d around inf
Applied rewrites98.9%
if 1.99999999999999997e307 < (*.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 20.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6420.6
Applied rewrites20.6%
Taylor expanded in d around -inf
Applied rewrites31.6%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -4e-66)
(*
(fma (* (* -0.125 (* D_m D_m)) (/ (* M_m (/ M_m d)) d)) (/ h l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(if (<= t_0 0.0)
(/ d (sqrt (* l h)))
(if (<= t_0 2e+307)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(* (- d) (sqrt (/ (/ 1.0 h) l))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -4e-66) {
tmp = fma(((-0.125 * (D_m * D_m)) * ((M_m * (M_m / d)) / d)), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else if (t_0 <= 0.0) {
tmp = d / sqrt((l * h));
} else if (t_0 <= 2e+307) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else {
tmp = -d * sqrt(((1.0 / h) / l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = 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_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -4e-66) tmp = Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(M_m * Float64(M_m / d)) / d)), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_0 <= 0.0) tmp = Float64(d / sqrt(Float64(l * h))); elseif (t_0 <= 2e+307) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); else tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = 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$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-66], N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+307], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \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\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-66}:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{M\_m \cdot \frac{M\_m}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\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)))) < -3.9999999999999999e-66Initial program 84.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites62.4%
Taylor expanded in d around 0
Applied rewrites47.7%
if -3.9999999999999999e-66 < (*.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)))) < -0.0Initial program 53.1%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites68.5%
if -0.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)))) < 1.99999999999999997e307Initial program 98.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in d around inf
Applied rewrites98.9%
if 1.99999999999999997e307 < (*.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 20.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6420.6
Applied rewrites20.6%
Taylor expanded in d around -inf
Applied rewrites31.6%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -5e-310)
(*
(* (- d) (sqrt (/ (/ 1.0 h) l)))
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M_m d)) 2.0) (* 0.5 h)) l)))
(if (<= l 1.55e+131)
(*
(/
(*
(fma (* (/ h l) -0.5) (pow (* (/ (/ D_m d) 2.0) M_m) 2.0) 1.0)
(sqrt d))
(sqrt h))
(sqrt (/ d l)))
(/ d (* (sqrt l) (sqrt h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -5e-310) {
tmp = (-d * sqrt(((1.0 / h) / l))) * (1.0 - ((pow(((D_m / 2.0) * (M_m / d)), 2.0) * (0.5 * h)) / l));
} else if (l <= 1.55e+131) {
tmp = ((fma(((h / l) * -0.5), pow((((D_m / d) / 2.0) * M_m), 2.0), 1.0) * sqrt(d)) / sqrt(h)) * sqrt((d / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0) * Float64(0.5 * h)) / l))); elseif (l <= 1.55e+131) tmp = Float64(Float64(Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(Float64(D_m / d) / 2.0) * M_m) ^ 2.0), 1.0) * sqrt(d)) / sqrt(h)) * sqrt(Float64(d / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -5e-310], N[(N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.55e+131], N[(N[(N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\right) \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.55 \cdot 10^{+131}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right)}^{2}, 1\right) \cdot \sqrt{d}}{\sqrt{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 64.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6466.6
lift-/.f64N/A
metadata-eval66.6
Applied rewrites66.6%
lift-/.f64N/A
metadata-eval66.6
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6466.6
Applied rewrites66.6%
lift-/.f64N/A
metadata-eval66.6
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6466.6
Applied rewrites66.6%
Taylor expanded in h around -inf
Applied rewrites76.4%
if -4.999999999999985e-310 < l < 1.55000000000000008e131Initial program 73.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites73.8%
Applied rewrites84.1%
if 1.55000000000000008e131 < l Initial program 37.6%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ (/ 1.0 h) l))) (t_1 (* (/ M_m 2.0) (/ D_m d))))
(if (<= d -3e+189)
(* (- d) t_0)
(if (<= d -1.5e-105)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (/ (* (* t_1 t_1) (* 0.5 h)) l)))
(if (<= d -1e-310)
(fma
(* (* (* (/ M_m d) M_m) (* 0.125 D_m)) D_m)
(sqrt (/ h (pow l 3.0)))
(* (- d) (sqrt (/ 1.0 (* l h)))))
(*
(* t_0 d)
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M_m d)) 2.0) (* 0.5 h)) l))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(((1.0 / h) / l));
double t_1 = (M_m / 2.0) * (D_m / d);
double tmp;
if (d <= -3e+189) {
tmp = -d * t_0;
} else if (d <= -1.5e-105) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (((t_1 * t_1) * (0.5 * h)) / l));
} else if (d <= -1e-310) {
tmp = fma(((((M_m / d) * M_m) * (0.125 * D_m)) * D_m), sqrt((h / pow(l, 3.0))), (-d * sqrt((1.0 / (l * h)))));
} else {
tmp = (t_0 * d) * (1.0 - ((pow(((D_m / 2.0) * (M_m / d)), 2.0) * (0.5 * h)) / l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(Float64(1.0 / h) / l)) t_1 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) tmp = 0.0 if (d <= -3e+189) tmp = Float64(Float64(-d) * t_0); elseif (d <= -1.5e-105) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(t_1 * t_1) * Float64(0.5 * h)) / l))); elseif (d <= -1e-310) tmp = fma(Float64(Float64(Float64(Float64(M_m / d) * M_m) * Float64(0.125 * D_m)) * D_m), sqrt(Float64(h / (l ^ 3.0))), Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h))))); else tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0) * Float64(0.5 * h)) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3e+189], N[((-d) * t$95$0), $MachinePrecision], If[LessEqual[d, -1.5e-105], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e-310], N[(N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(0.125 * D$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\
t_1 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
\mathbf{if}\;d \leq -3 \cdot 10^{+189}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-105}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(t\_1 \cdot t\_1\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\frac{M\_m}{d} \cdot M\_m\right) \cdot \left(0.125 \cdot D\_m\right)\right) \cdot D\_m, \sqrt{\frac{h}{{\ell}^{3}}}, \left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -2.9999999999999998e189Initial program 67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.9%
Taylor expanded in d around -inf
Applied rewrites90.0%
if -2.9999999999999998e189 < d < -1.5e-105Initial program 80.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.8
lift-/.f64N/A
metadata-eval80.8
Applied rewrites80.8%
lift-/.f64N/A
metadata-eval80.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6480.8
Applied rewrites80.8%
lift-/.f64N/A
metadata-eval80.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6480.8
Applied rewrites80.8%
lift-pow.f64N/A
unpow2N/A
lower-*.f6480.8
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6480.8
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6482.7
Applied rewrites82.7%
if -1.5e-105 < d < -9.999999999999969e-311Initial program 44.1%
Taylor expanded in l around -inf
Applied rewrites49.1%
Applied rewrites58.5%
if -9.999999999999969e-311 < d Initial program 61.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6463.4
lift-/.f64N/A
metadata-eval63.4
Applied rewrites63.4%
lift-/.f64N/A
metadata-eval63.4
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
metadata-eval63.4
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6463.4
Applied rewrites63.4%
Taylor expanded in d around 0
Applied rewrites73.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M_m d)) 2.0) (* 0.5 h)) l)))
(t_1 (sqrt (/ (/ 1.0 h) l))))
(if (<= h -1e-298)
(* (* (- d) t_1) t_0)
(if (<= h 1.26e+251)
(* (* t_1 d) t_0)
(/
(fma
(* (* -0.125 (* D_m D_m)) (* (/ M_m d) M_m))
(sqrt (* l h))
(* (sqrt (/ (pow l 3.0) h)) d))
(* l l))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = 1.0 - ((pow(((D_m / 2.0) * (M_m / d)), 2.0) * (0.5 * h)) / l);
double t_1 = sqrt(((1.0 / h) / l));
double tmp;
if (h <= -1e-298) {
tmp = (-d * t_1) * t_0;
} else if (h <= 1.26e+251) {
tmp = (t_1 * d) * t_0;
} else {
tmp = fma(((-0.125 * (D_m * D_m)) * ((M_m / d) * M_m)), sqrt((l * h)), (sqrt((pow(l, 3.0) / h)) * d)) / (l * l);
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0) * Float64(0.5 * h)) / l)) t_1 = sqrt(Float64(Float64(1.0 / h) / l)) tmp = 0.0 if (h <= -1e-298) tmp = Float64(Float64(Float64(-d) * t_1) * t_0); elseif (h <= 1.26e+251) tmp = Float64(Float64(t_1 * d) * t_0); else tmp = Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(M_m / d) * M_m)), sqrt(Float64(l * h)), Float64(sqrt(Float64((l ^ 3.0) / h)) * d)) / Float64(l * l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -1e-298], N[(N[((-d) * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, 1.26e+251], N[(N[(t$95$1 * d), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] + N[(N[Sqrt[N[(N[Power[l, 3.0], $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\\
t_1 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{if}\;h \leq -1 \cdot 10^{-298}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_1\right) \cdot t\_0\\
\mathbf{elif}\;h \leq 1.26 \cdot 10^{+251}:\\
\;\;\;\;\left(t\_1 \cdot d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(\frac{M\_m}{d} \cdot M\_m\right), \sqrt{\ell \cdot h}, \sqrt{\frac{{\ell}^{3}}{h}} \cdot d\right)}{\ell \cdot \ell}\\
\end{array}
\end{array}
if h < -9.99999999999999912e-299Initial program 65.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6467.1
lift-/.f64N/A
metadata-eval67.1
Applied rewrites67.1%
lift-/.f64N/A
metadata-eval67.1
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.1
Applied rewrites67.1%
lift-/.f64N/A
metadata-eval67.1
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.1
Applied rewrites67.1%
Taylor expanded in h around -inf
Applied rewrites77.0%
if -9.99999999999999912e-299 < h < 1.25999999999999996e251Initial program 64.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6466.2
lift-/.f64N/A
metadata-eval66.2
Applied rewrites66.2%
lift-/.f64N/A
metadata-eval66.2
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6466.2
Applied rewrites66.2%
lift-/.f64N/A
metadata-eval66.2
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6466.2
Applied rewrites66.2%
Taylor expanded in d around 0
Applied rewrites76.3%
if 1.25999999999999996e251 < h Initial program 36.3%
Taylor expanded in d around inf
Applied rewrites8.4%
Taylor expanded in l around 0
Applied rewrites56.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ M_m 2.0) (/ D_m d))))
(if (<= l -2.3e+25)
(fma
(* (* (* (/ M_m d) M_m) (* 0.125 D_m)) D_m)
(sqrt (/ h (pow l 3.0)))
(* (- d) (sqrt (/ 1.0 (* l h)))))
(if (<= l 1.25e+131)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (/ (* (* t_0 t_0) (* 0.5 h)) l)))
(/ d (* (sqrt l) (sqrt h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (l <= -2.3e+25) {
tmp = fma(((((M_m / d) * M_m) * (0.125 * D_m)) * D_m), sqrt((h / pow(l, 3.0))), (-d * sqrt((1.0 / (l * h)))));
} else if (l <= 1.25e+131) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) tmp = 0.0 if (l <= -2.3e+25) tmp = fma(Float64(Float64(Float64(Float64(M_m / d) * M_m) * Float64(0.125 * D_m)) * D_m), sqrt(Float64(h / (l ^ 3.0))), Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h))))); elseif (l <= 1.25e+131) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * Float64(0.5 * h)) / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.3e+25], N[(N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(0.125 * D$95$m), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.25e+131], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\frac{M\_m}{d} \cdot M\_m\right) \cdot \left(0.125 \cdot D\_m\right)\right) \cdot D\_m, \sqrt{\frac{h}{{\ell}^{3}}}, \left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right)\\
\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{+131}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -2.2999999999999998e25Initial program 54.8%
Taylor expanded in l around -inf
Applied rewrites41.6%
Applied rewrites55.0%
if -2.2999999999999998e25 < l < 1.24999999999999999e131Initial program 72.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6475.5
lift-/.f64N/A
metadata-eval75.5
Applied rewrites75.5%
lift-/.f64N/A
metadata-eval75.5
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6475.5
Applied rewrites75.5%
lift-/.f64N/A
metadata-eval75.5
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6475.5
Applied rewrites75.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6475.5
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6474.9
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
if 1.24999999999999999e131 < l Initial program 37.6%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ M_m 2.0) (/ D_m d))))
(if (<= l 1.25e+131)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (/ (* (* t_0 t_0) (* 0.5 h)) l)))
(/ d (* (sqrt l) (sqrt h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (l <= 1.25e+131) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
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_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (m_m / 2.0d0) * (d_m / d)
if (l <= 1.25d+131) then
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - (((t_0 * t_0) * (0.5d0 * h)) / l))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (M_m / 2.0) * (D_m / d);
double tmp;
if (l <= 1.25e+131) {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (M_m / 2.0) * (D_m / d) tmp = 0 if l <= 1.25e+131: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(M_m / 2.0) * Float64(D_m / d)) tmp = 0.0 if (l <= 1.25e+131) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * Float64(0.5 * h)) / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (M_m / 2.0) * (D_m / d);
tmp = 0.0;
if (l <= 1.25e+131)
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (((t_0 * t_0) * (0.5 * h)) / l));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 1.25e+131], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M\_m}{2} \cdot \frac{D\_m}{d}\\
\mathbf{if}\;\ell \leq 1.25 \cdot 10^{+131}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(t\_0 \cdot t\_0\right) \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 1.24999999999999999e131Initial program 68.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6469.9
lift-/.f64N/A
metadata-eval69.9
Applied rewrites69.9%
lift-/.f64N/A
metadata-eval69.9
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6469.9
Applied rewrites69.9%
lift-/.f64N/A
metadata-eval69.9
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6469.9
Applied rewrites69.9%
lift-pow.f64N/A
unpow2N/A
lower-*.f6469.9
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6469.5
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6470.4
Applied rewrites70.4%
if 1.24999999999999999e131 < l Initial program 37.6%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l 1.3e+131)
(*
(*
(fma
(* (/ (* M_m D_m) (* d 2.0)) (* (* (/ (/ D_m d) 2.0) M_m) -0.5))
(/ h l)
1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(/ d (* (sqrt l) (sqrt h)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.3e+131) {
tmp = (fma((((M_m * D_m) / (d * 2.0)) * ((((D_m / d) / 2.0) * M_m) * -0.5)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 1.3e+131) tmp = Float64(Float64(fma(Float64(Float64(Float64(M_m * D_m) / Float64(d * 2.0)) * Float64(Float64(Float64(Float64(D_m / d) / 2.0) * M_m) * -0.5)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.3e+131], N[(N[(N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.3 \cdot 10^{+131}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{M\_m \cdot D\_m}{d \cdot 2} \cdot \left(\left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right) \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 1.3e131Initial program 68.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites67.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f6467.9
Applied rewrites67.9%
if 1.3e131 < l Initial program 37.6%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l 1.3e+131)
(*
(*
(fma
(* (* (/ (/ D_m d) 2.0) M_m) (* (* (/ D_m d) M_m) -0.25))
(/ h l)
1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(/ d (* (sqrt l) (sqrt h)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.3e+131) {
tmp = (fma(((((D_m / d) / 2.0) * M_m) * (((D_m / d) * M_m) * -0.25)), (h / l), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 1.3e+131) tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(D_m / d) / 2.0) * M_m) * Float64(Float64(Float64(D_m / d) * M_m) * -0.25)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.3e+131], N[(N[(N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(N[(D$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.3 \cdot 10^{+131}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right) \cdot \left(\left(\frac{D\_m}{d} \cdot M\_m\right) \cdot -0.25\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 1.3e131Initial program 68.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites67.9%
Taylor expanded in d around 0
Applied rewrites67.9%
if 1.3e131 < l Initial program 37.6%
Taylor expanded in d around inf
Applied rewrites68.3%
Applied rewrites68.3%
Applied rewrites68.4%
Applied rewrites70.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (pow (* l h) -0.5)))
(if (<= d -1.7e+100)
(* (- d) t_0)
(if (<= d 1.86e+115)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(fma (* h -0.125) (* (/ (* D_m D_m) l) (/ (* M_m (/ M_m d)) d)) 1.0))
(* t_0 d)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = pow((l * h), -0.5);
double tmp;
if (d <= -1.7e+100) {
tmp = -d * t_0;
} else if (d <= 1.86e+115) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * fma((h * -0.125), (((D_m * D_m) / l) * ((M_m * (M_m / d)) / d)), 1.0);
} else {
tmp = t_0 * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(l * h) ^ -0.5 tmp = 0.0 if (d <= -1.7e+100) tmp = Float64(Float64(-d) * t_0); elseif (d <= 1.86e+115) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * fma(Float64(h * -0.125), Float64(Float64(Float64(D_m * D_m) / l) * Float64(Float64(M_m * Float64(M_m / d)) / d)), 1.0)); else tmp = Float64(t_0 * d); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, -1.7e+100], N[((-d) * t$95$0), $MachinePrecision], If[LessEqual[d, 1.86e+115], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(h * -0.125), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * d), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq -1.7 \cdot 10^{+100}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{elif}\;d \leq 1.86 \cdot 10^{+115}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(h \cdot -0.125, \frac{D\_m \cdot D\_m}{\ell} \cdot \frac{M\_m \cdot \frac{M\_m}{d}}{d}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot d\\
\end{array}
\end{array}
if d < -1.69999999999999997e100Initial program 73.5%
Taylor expanded in d around inf
Applied rewrites1.0%
Applied rewrites1.0%
Taylor expanded in h around -inf
Applied rewrites83.7%
if -1.69999999999999997e100 < d < 1.86e115Initial program 62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6463.4
lift-/.f64N/A
metadata-eval63.4
Applied rewrites63.4%
lift-/.f64N/A
metadata-eval63.4
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
metadata-eval63.4
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6463.4
Applied rewrites63.4%
Taylor expanded in d around 0
Applied rewrites53.5%
if 1.86e115 < d Initial program 53.9%
Taylor expanded in d around inf
Applied rewrites75.8%
Applied rewrites75.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d -1.7e+100)
(* (- d) (sqrt (/ (/ 1.0 h) l)))
(if (<= d 1.86e+115)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(fma (* h -0.125) (* (/ (* D_m D_m) l) (/ (* M_m (/ M_m d)) d)) 1.0))
(* (pow (* l h) -0.5) d))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.7e+100) {
tmp = -d * sqrt(((1.0 / h) / l));
} else if (d <= 1.86e+115) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * fma((h * -0.125), (((D_m * D_m) / l) * ((M_m * (M_m / d)) / d)), 1.0);
} else {
tmp = pow((l * h), -0.5) * d;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -1.7e+100) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); elseif (d <= 1.86e+115) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * fma(Float64(h * -0.125), Float64(Float64(Float64(D_m * D_m) / l) * Float64(Float64(M_m * Float64(M_m / d)) / d)), 1.0)); else tmp = Float64((Float64(l * h) ^ -0.5) * d); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -1.7e+100], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.86e+115], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(h * -0.125), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.7 \cdot 10^{+100}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{elif}\;d \leq 1.86 \cdot 10^{+115}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \mathsf{fma}\left(h \cdot -0.125, \frac{D\_m \cdot D\_m}{\ell} \cdot \frac{M\_m \cdot \frac{M\_m}{d}}{d}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\ell \cdot h\right)}^{-0.5} \cdot d\\
\end{array}
\end{array}
if d < -1.69999999999999997e100Initial program 73.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.5
Applied rewrites67.1%
Taylor expanded in d around -inf
Applied rewrites82.0%
if -1.69999999999999997e100 < d < 1.86e115Initial program 62.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6463.4
lift-/.f64N/A
metadata-eval63.4
Applied rewrites63.4%
lift-/.f64N/A
metadata-eval63.4
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6463.4
Applied rewrites63.4%
lift-/.f64N/A
metadata-eval63.4
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6463.4
Applied rewrites63.4%
Taylor expanded in d around 0
Applied rewrites53.5%
if 1.86e115 < d Initial program 53.9%
Taylor expanded in d around inf
Applied rewrites75.8%
Applied rewrites75.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l 1.5e-260) (* (- d) (sqrt (/ (/ 1.0 h) l))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.5e-260) {
tmp = -d * sqrt(((1.0 / h) / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
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_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 1.5d-260) then
tmp = -d * sqrt(((1.0d0 / h) / l))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.5e-260) {
tmp = -d * Math.sqrt(((1.0 / h) / l));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= 1.5e-260: tmp = -d * math.sqrt(((1.0 / h) / l)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 1.5e-260) tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= 1.5e-260)
tmp = -d * sqrt(((1.0 / h) / l));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.5e-260], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.5 \cdot 10^{-260}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 1.5e-260Initial program 64.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6464.8
Applied rewrites50.2%
Taylor expanded in d around -inf
Applied rewrites48.1%
if 1.5e-260 < l Initial program 61.8%
Taylor expanded in d around inf
Applied rewrites47.6%
Applied rewrites47.5%
Applied rewrites47.6%
Applied rewrites50.4%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l 1.5e-260) (* (- d) (sqrt (/ 1.0 (* l h)))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.5e-260) {
tmp = -d * sqrt((1.0 / (l * h)));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
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_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 1.5d-260) then
tmp = -d * sqrt((1.0d0 / (l * h)))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= 1.5e-260) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= 1.5e-260: tmp = -d * math.sqrt((1.0 / (l * h))) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= 1.5e-260) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= 1.5e-260)
tmp = -d * sqrt((1.0 / (l * h)));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, 1.5e-260], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.5 \cdot 10^{-260}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < 1.5e-260Initial program 64.8%
Taylor expanded in l around -inf
Applied rewrites47.4%
if 1.5e-260 < l Initial program 61.8%
Taylor expanded in d around inf
Applied rewrites47.6%
Applied rewrites47.5%
Applied rewrites47.6%
Applied rewrites50.4%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= d -1.5e-180) (* (- d) (sqrt (/ 1.0 (* l h)))) (/ d (sqrt (* l h)))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.5e-180) {
tmp = -d * sqrt((1.0 / (l * h)));
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
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_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= (-1.5d-180)) then
tmp = -d * sqrt((1.0d0 / (l * h)))
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.5e-180) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= -1.5e-180: tmp = -d * math.sqrt((1.0 / (l * h))) else: tmp = d / math.sqrt((l * h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -1.5e-180) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= -1.5e-180)
tmp = -d * sqrt((1.0 / (l * h)));
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -1.5e-180], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{-180}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -1.5e-180Initial program 72.2%
Taylor expanded in l around -inf
Applied rewrites60.3%
if -1.5e-180 < d Initial program 57.9%
Taylor expanded in d around inf
Applied rewrites39.8%
Applied rewrites39.7%
Applied rewrites39.8%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* l h))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return d / sqrt((l * h));
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
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_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = d / sqrt((l * h))
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return d / Math.sqrt((l * h));
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return d / math.sqrt((l * h))
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(d / sqrt(Float64(l * h))) end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = d / sqrt((l * h));
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 63.3%
Taylor expanded in d around inf
Applied rewrites26.7%
Applied rewrites26.6%
Applied rewrites26.7%
herbie shell --seed 2025019
(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)))))