
(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 21 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)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0)) (t_1 (sqrt (- d))) (t_2 (* t_0 M)))
(if (<= l -4e-310)
(*
(* (/ t_1 (sqrt (- h))) (/ t_1 (sqrt (- l))))
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M d)) 2.0) (* 0.5 h)) l)))
(if (<= l 7.5e-134)
(*
(* (sqrt (/ d l)) (/ (sqrt d) (sqrt h)))
(- 1.0 (/ (* t_2 (* t_2 (* 0.5 h))) l)))
(/
(/
(*
(* (fma (* (pow (* M t_0) 2.0) -0.5) (/ h l) 1.0) (sqrt d))
(sqrt d))
(sqrt h))
(sqrt l))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = sqrt(-d);
double t_2 = t_0 * M;
double tmp;
if (l <= -4e-310) {
tmp = ((t_1 / sqrt(-h)) * (t_1 / sqrt(-l))) * (1.0 - ((pow(((D_m / 2.0) * (M / d)), 2.0) * (0.5 * h)) / l));
} else if (l <= 7.5e-134) {
tmp = (sqrt((d / l)) * (sqrt(d) / sqrt(h))) * (1.0 - ((t_2 * (t_2 * (0.5 * h))) / l));
} else {
tmp = (((fma((pow((M * t_0), 2.0) * -0.5), (h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) t_1 = sqrt(Float64(-d)) t_2 = Float64(t_0 * M) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(Float64(t_1 / sqrt(Float64(-h))) * Float64(t_1 / sqrt(Float64(-l)))) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M / d)) ^ 2.0) * Float64(0.5 * h)) / l))); elseif (l <= 7.5e-134) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(sqrt(d) / sqrt(h))) * Float64(1.0 - Float64(Float64(t_2 * Float64(t_2 * Float64(0.5 * h))) / l))); else tmp = Float64(Float64(Float64(Float64(fma(Float64((Float64(M * t_0) ^ 2.0) * -0.5), Float64(h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[(-d)], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * M), $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(N[(t$95$1 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.5e-134], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$2 * N[(t$95$2 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[Power[N[(M * t$95$0), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
t_1 := \sqrt{-d}\\
t_2 := t\_0 \cdot M\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{t\_1}{\sqrt{-h}} \cdot \frac{t\_1}{\sqrt{-\ell}}\right) \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-134}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot \left(1 - \frac{t\_2 \cdot \left(t\_2 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\mathsf{fma}\left({\left(M \cdot t\_0\right)}^{2} \cdot -0.5, \frac{h}{\ell}, 1\right) \cdot \sqrt{d}\right) \cdot \sqrt{d}}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 66.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-*.f6467.9
lift-/.f64N/A
metadata-eval67.9
Applied rewrites67.9%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lift-neg.f64N/A
sqrt-undivN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f6474.6
Applied rewrites74.6%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f6484.2
Applied rewrites84.2%
if -3.999999999999988e-310 < l < 7.50000000000000048e-134Initial program 70.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-*.f6475.0
lift-/.f64N/A
metadata-eval75.0
Applied rewrites75.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6475.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6475.4
Applied rewrites75.4%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if 7.50000000000000048e-134 < l Initial program 65.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-*.f6465.6
lift-/.f64N/A
metadata-eval65.6
Applied rewrites65.6%
Applied rewrites70.6%
Applied rewrites80.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M d) D_m)))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-152)
(*
(fma -0.5 (* (/ h l) (/ (* t_0 t_0) 4.0)) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / d) * D_m;
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-152) {
tmp = fma(-0.5, ((h / l) * ((t_0 * t_0) / 4.0)), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / d) * D_m) tmp = 0.0 if (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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-152) tmp = Float64(fma(-0.5, Float64(Float64(h / l) * Float64(Float64(t_0 * t_0) / 4.0)), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-152], N[(N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{d} \cdot D\_m\\
\mathbf{if}\;\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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-152}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot \frac{t\_0 \cdot t\_0}{4}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999997e-152Initial program 85.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites74.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval74.4
Applied rewrites74.4%
if -4.9999999999999997e-152 < (*.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 56.6%
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-*.f6459.2
lift-/.f64N/A
metadata-eval59.2
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites60.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6460.0
Applied rewrites60.0%
Taylor expanded in d around inf
Applied rewrites59.1%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-152)
(*
(fma -0.5 (* (/ h l) (* (/ (* M D_m) (* d 4.0)) (* (/ M d) D_m))) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-152) {
tmp = fma(-0.5, ((h / l) * (((M * D_m) / (d * 4.0)) * ((M / d) * D_m))), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-152) tmp = Float64(fma(-0.5, Float64(Float64(h / l) * Float64(Float64(Float64(M * D_m) / Float64(d * 4.0)) * Float64(Float64(M / d) * D_m))), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-152], N[(N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[(N[(N[(M * D$95$m), $MachinePrecision] / N[(d * 4.0), $MachinePrecision]), $MachinePrecision] * N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-152}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot \left(\frac{M \cdot D\_m}{d \cdot 4} \cdot \left(\frac{M}{d} \cdot D\_m\right)\right), 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999997e-152Initial program 85.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites74.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6474.9
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6457.4
Applied rewrites57.4%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6473.7
Applied rewrites73.7%
if -4.9999999999999997e-152 < (*.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 56.6%
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-*.f6459.2
lift-/.f64N/A
metadata-eval59.2
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites60.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6460.0
Applied rewrites60.0%
Taylor expanded in d around inf
Applied rewrites59.1%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-152)
(*
(fma -0.5 (* (/ h l) (* M (* D_m (* (/ M (* d 4.0)) (/ D_m d))))) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-152) {
tmp = fma(-0.5, ((h / l) * (M * (D_m * ((M / (d * 4.0)) * (D_m / d))))), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-152) tmp = Float64(fma(-0.5, Float64(Float64(h / l) * Float64(M * Float64(D_m * Float64(Float64(M / Float64(d * 4.0)) * Float64(D_m / d))))), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-152], N[(N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[(M * N[(D$95$m * N[(N[(M / N[(d * 4.0), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-152}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot \left(M \cdot \left(D\_m \cdot \left(\frac{M}{d \cdot 4} \cdot \frac{D\_m}{d}\right)\right)\right), 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999997e-152Initial program 85.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites74.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6474.9
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6457.4
Applied rewrites57.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lift-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
metadata-eval70.0
Applied rewrites70.0%
if -4.9999999999999997e-152 < (*.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 56.6%
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-*.f6459.2
lift-/.f64N/A
metadata-eval59.2
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites60.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6460.0
Applied rewrites60.0%
Taylor expanded in d around inf
Applied rewrites59.1%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(*
(fma -0.5 (* (/ h l) (* (/ M (* d 4.0)) (* (* (/ M d) D_m) D_m))) 1.0)
(sqrt (* d (/ d (* l h)))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = fma(-0.5, ((h / l) * ((M / (d * 4.0)) * (((M / d) * D_m) * D_m))), 1.0) * sqrt((d * (d / (l * h))));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(fma(-0.5, Float64(Float64(h / l) * Float64(Float64(M / Float64(d * 4.0)) * Float64(Float64(Float64(M / d) * D_m) * D_m))), 1.0) * sqrt(Float64(d * Float64(d / Float64(l * h))))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[(N[(M / N[(d * 4.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d * N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot \left(\frac{M}{d \cdot 4} \cdot \left(\left(\frac{M}{d} \cdot D\_m\right) \cdot D\_m\right)\right), 1\right) \cdot \sqrt{d \cdot \frac{d}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 78.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.8
Applied rewrites68.6%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6469.1
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6450.2
Applied rewrites50.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6449.6
Applied rewrites49.6%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
associate-*r/N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6463.8
Applied rewrites63.8%
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)))) Initial program 58.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-*.f6461.5
lift-/.f64N/A
metadata-eval61.5
Applied rewrites61.5%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites62.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6462.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6462.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6462.5
Applied rewrites62.5%
Taylor expanded in d around inf
Applied rewrites61.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-152)
(*
(fma -0.5 (* (/ h l) (/ (* (* M D_m) (* M D_m)) (* (* d d) 4.0))) 1.0)
(sqrt (* d (/ d (* l h)))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-152) {
tmp = fma(-0.5, ((h / l) * (((M * D_m) * (M * D_m)) / ((d * d) * 4.0))), 1.0) * sqrt((d * (d / (l * h))));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (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_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-152) tmp = Float64(fma(-0.5, Float64(Float64(h / l) * Float64(Float64(Float64(M * D_m) * Float64(M * D_m)) / Float64(Float64(d * d) * 4.0))), 1.0) * sqrt(Float64(d * Float64(d / Float64(l * h))))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[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$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-152], N[(N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(M * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d * N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\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\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-152}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot \frac{\left(M \cdot D\_m\right) \cdot \left(M \cdot D\_m\right)}{\left(d \cdot d\right) \cdot 4}, 1\right) \cdot \sqrt{d \cdot \frac{d}{\ell \cdot h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.9999999999999997e-152Initial program 85.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.7
Applied rewrites74.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6474.9
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-*.f6457.4
Applied rewrites57.4%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6455.5
Applied rewrites55.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6455.5
Applied rewrites55.5%
if -4.9999999999999997e-152 < (*.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 56.6%
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-*.f6459.2
lift-/.f64N/A
metadata-eval59.2
Applied rewrites59.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites60.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6460.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6460.0
Applied rewrites60.0%
Taylor expanded in d around inf
Applied rewrites59.1%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0))
(t_1 (* t_0 M))
(t_2 (- 1.0 (/ (* t_1 (* t_1 (* 0.5 h))) l)))
(t_3 (sqrt (/ d l))))
(if (<= l -4e-310)
(* (* t_3 (/ (sqrt (- d)) (sqrt (- h)))) t_2)
(if (<= l 7.5e-134)
(* (* t_3 (/ (sqrt d) (sqrt h))) t_2)
(/
(/
(*
(* (fma (* (pow (* M t_0) 2.0) -0.5) (/ h l) 1.0) (sqrt d))
(sqrt d))
(sqrt h))
(sqrt l))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = t_0 * M;
double t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l);
double t_3 = sqrt((d / l));
double tmp;
if (l <= -4e-310) {
tmp = (t_3 * (sqrt(-d) / sqrt(-h))) * t_2;
} else if (l <= 7.5e-134) {
tmp = (t_3 * (sqrt(d) / sqrt(h))) * t_2;
} else {
tmp = (((fma((pow((M * t_0), 2.0) * -0.5), (h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) t_1 = Float64(t_0 * M) t_2 = Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * Float64(0.5 * h))) / l)) t_3 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(t_3 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * t_2); elseif (l <= 7.5e-134) tmp = Float64(Float64(t_3 * Float64(sqrt(d) / sqrt(h))) * t_2); else tmp = Float64(Float64(Float64(Float64(fma(Float64((Float64(M * t_0) ^ 2.0) * -0.5), Float64(h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * M), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(t$95$3 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[l, 7.5e-134], N[(N[(t$95$3 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[Power[N[(M * t$95$0), $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
t_1 := t\_0 \cdot M\\
t_2 := 1 - \frac{t\_1 \cdot \left(t\_1 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_3 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_3 \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot t\_2\\
\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-134}:\\
\;\;\;\;\left(t\_3 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\mathsf{fma}\left({\left(M \cdot t\_0\right)}^{2} \cdot -0.5, \frac{h}{\ell}, 1\right) \cdot \sqrt{d}\right) \cdot \sqrt{d}}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 66.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-*.f6467.9
lift-/.f64N/A
metadata-eval67.9
Applied rewrites67.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.0
Applied rewrites69.0%
lift-sqrt.f64N/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.f6479.0
Applied rewrites79.0%
if -3.999999999999988e-310 < l < 7.50000000000000048e-134Initial program 70.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-*.f6475.0
lift-/.f64N/A
metadata-eval75.0
Applied rewrites75.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6475.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6475.4
Applied rewrites75.4%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-/.f6486.3
Applied rewrites86.3%
if 7.50000000000000048e-134 < l Initial program 65.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-*.f6465.6
lift-/.f64N/A
metadata-eval65.6
Applied rewrites65.6%
Applied rewrites70.6%
Applied rewrites80.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M)))
(if (<= l -4e-310)
(*
(* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h))))
(- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(*
(/ (* (sqrt d) (sqrt d)) (* (sqrt l) (sqrt h)))
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M d)) 2.0) (* 0.5 h)) l))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double tmp;
if (l <= -4e-310) {
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else {
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * (1.0 - ((pow(((D_m / 2.0) * (M / d)), 2.0) * (0.5 * h)) / l));
}
return tmp;
}
D_m = private
NOTE: d, h, l, 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, 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
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = ((d_m / d) / 2.0d0) * m
if (l <= (-4d-310)) then
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * (1.0d0 - ((t_0 * (t_0 * (0.5d0 * h))) / l))
else
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * (1.0d0 - (((((d_m / 2.0d0) * (m / d)) ** 2.0d0) * (0.5d0 * h)) / l))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double tmp;
if (l <= -4e-310) {
tmp = (Math.sqrt((d / l)) * (Math.sqrt(-d) / Math.sqrt(-h))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else {
tmp = ((Math.sqrt(d) * Math.sqrt(d)) / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 - ((Math.pow(((D_m / 2.0) * (M / d)), 2.0) * (0.5 * h)) / l));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = ((D_m / d) / 2.0) * M tmp = 0 if l <= -4e-310: tmp = (math.sqrt((d / l)) * (math.sqrt(-d) / math.sqrt(-h))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l)) else: tmp = ((math.sqrt(d) * math.sqrt(d)) / (math.sqrt(l) * math.sqrt(h))) * (1.0 - ((math.pow(((D_m / 2.0) * (M / d)), 2.0) * (0.5 * h)) / l)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l))); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(d)) / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M / d)) ^ 2.0) * Float64(0.5 * h)) / l))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = ((D_m / d) / 2.0) * M;
tmp = 0.0;
if (l <= -4e-310)
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
else
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * (1.0 - (((((D_m / 2.0) * (M / d)) ^ 2.0) * (0.5 * h)) / l));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(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|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 66.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-*.f6467.9
lift-/.f64N/A
metadata-eval67.9
Applied rewrites67.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.0
Applied rewrites69.0%
lift-sqrt.f64N/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.f6479.0
Applied rewrites79.0%
if -3.999999999999988e-310 < l Initial program 67.1%
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-*.f6468.2
lift-/.f64N/A
metadata-eval68.2
Applied rewrites68.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-*.f64N/A
sqrt-prodN/A
lift-/.f64N/A
sqrt-divN/A
lift-/.f64N/A
sqrt-divN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6484.4
Applied rewrites84.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (sqrt (/ d l))))
(if (<= l -4e-310)
(* (* t_2 (/ (sqrt (- d)) (sqrt (- h)))) t_1)
(if (<= l 1.65e+63)
(* (/ (* t_2 (sqrt d)) (sqrt h)) t_1)
(/
(/
(*
(*
(fma
(* (* M D_m) (* (/ (/ (* (/ M d) D_m) 4.0) d) -0.5))
(/ h l)
1.0)
(sqrt d))
(sqrt d))
(sqrt h))
(sqrt l))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = sqrt((d / l));
double tmp;
if (l <= -4e-310) {
tmp = (t_2 * (sqrt(-d) / sqrt(-h))) * t_1;
} else if (l <= 1.65e+63) {
tmp = ((t_2 * sqrt(d)) / sqrt(h)) * t_1;
} else {
tmp = (((fma(((M * D_m) * (((((M / d) * D_m) / 4.0) / d) * -0.5)), (h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(t_2 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * t_1); elseif (l <= 1.65e+63) tmp = Float64(Float64(Float64(t_2 * sqrt(d)) / sqrt(h)) * t_1); else tmp = Float64(Float64(Float64(Float64(fma(Float64(Float64(M * D_m) * Float64(Float64(Float64(Float64(Float64(M / d) * D_m) / 4.0) / d) * -0.5)), Float64(h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(t$95$2 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 1.65e+63], N[(N[(N[(t$95$2 * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision] / 4.0), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_2 \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+63}:\\
\;\;\;\;\frac{t\_2 \cdot \sqrt{d}}{\sqrt{h}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\mathsf{fma}\left(\left(M \cdot D\_m\right) \cdot \left(\frac{\frac{\frac{M}{d} \cdot D\_m}{4}}{d} \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{d}\right) \cdot \sqrt{d}}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 66.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-*.f6467.9
lift-/.f64N/A
metadata-eval67.9
Applied rewrites67.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.0
Applied rewrites69.0%
lift-sqrt.f64N/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.f6479.0
Applied rewrites79.0%
if -3.999999999999988e-310 < l < 1.6500000000000001e63Initial program 73.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-*.f6475.9
lift-/.f64N/A
metadata-eval75.9
Applied rewrites75.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites76.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6486.5
Applied rewrites86.5%
if 1.6500000000000001e63 < l Initial program 57.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-*.f6456.5
lift-/.f64N/A
metadata-eval56.5
Applied rewrites56.5%
Applied rewrites65.5%
Applied rewrites73.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites73.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (sqrt (/ d l))))
(if (<= l -4e-310)
(* (* t_2 (sqrt (/ d h))) t_1)
(if (<= l 1.65e+63)
(* (/ (* t_2 (sqrt d)) (sqrt h)) t_1)
(/
(/
(*
(*
(fma
(* (* M D_m) (* (/ (/ (* (/ M d) D_m) 4.0) d) -0.5))
(/ h l)
1.0)
(sqrt d))
(sqrt d))
(sqrt h))
(sqrt l))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = sqrt((d / l));
double tmp;
if (l <= -4e-310) {
tmp = (t_2 * sqrt((d / h))) * t_1;
} else if (l <= 1.65e+63) {
tmp = ((t_2 * sqrt(d)) / sqrt(h)) * t_1;
} else {
tmp = (((fma(((M * D_m) * (((((M / d) * D_m) / 4.0) / d) * -0.5)), (h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(t_2 * sqrt(Float64(d / h))) * t_1); elseif (l <= 1.65e+63) tmp = Float64(Float64(Float64(t_2 * sqrt(d)) / sqrt(h)) * t_1); else tmp = Float64(Float64(Float64(Float64(fma(Float64(Float64(M * D_m) * Float64(Float64(Float64(Float64(Float64(M / d) * D_m) / 4.0) / d) * -0.5)), Float64(h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 1.65e+63], N[(N[(N[(t$95$2 * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision] / 4.0), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_2 \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 1.65 \cdot 10^{+63}:\\
\;\;\;\;\frac{t\_2 \cdot \sqrt{d}}{\sqrt{h}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\mathsf{fma}\left(\left(M \cdot D\_m\right) \cdot \left(\frac{\frac{\frac{M}{d} \cdot D\_m}{4}}{d} \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{d}\right) \cdot \sqrt{d}}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 66.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-*.f6467.9
lift-/.f64N/A
metadata-eval67.9
Applied rewrites67.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.0
Applied rewrites69.0%
if -3.999999999999988e-310 < l < 1.6500000000000001e63Initial program 73.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-*.f6475.9
lift-/.f64N/A
metadata-eval75.9
Applied rewrites75.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites76.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f64N/A
lower-sqrt.f6486.5
Applied rewrites86.5%
if 1.6500000000000001e63 < l Initial program 57.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-*.f6456.5
lift-/.f64N/A
metadata-eval56.5
Applied rewrites56.5%
Applied rewrites65.5%
Applied rewrites73.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites73.0%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (sqrt (/ d l))))
(if (<= l -4e-310)
(* (* t_2 (sqrt (/ d h))) t_1)
(if (<= l 8.2e+19)
(* (* t_2 (/ (sqrt d) (sqrt h))) t_1)
(/
(/
(*
(*
(fma
(* (* M D_m) (* (/ (/ (* (/ M d) D_m) 4.0) d) -0.5))
(/ h l)
1.0)
(sqrt d))
(sqrt d))
(sqrt h))
(sqrt l))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = sqrt((d / l));
double tmp;
if (l <= -4e-310) {
tmp = (t_2 * sqrt((d / h))) * t_1;
} else if (l <= 8.2e+19) {
tmp = (t_2 * (sqrt(d) / sqrt(h))) * t_1;
} else {
tmp = (((fma(((M * D_m) * (((((M / d) * D_m) / 4.0) / d) * -0.5)), (h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(t_2 * sqrt(Float64(d / h))) * t_1); elseif (l <= 8.2e+19) tmp = Float64(Float64(t_2 * Float64(sqrt(d) / sqrt(h))) * t_1); else tmp = Float64(Float64(Float64(Float64(fma(Float64(Float64(M * D_m) * Float64(Float64(Float64(Float64(Float64(M / d) * D_m) / 4.0) / d) * -0.5)), Float64(h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 8.2e+19], N[(N[(t$95$2 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision] / 4.0), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_2 \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+19}:\\
\;\;\;\;\left(t\_2 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\mathsf{fma}\left(\left(M \cdot D\_m\right) \cdot \left(\frac{\frac{\frac{M}{d} \cdot D\_m}{4}}{d} \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{d}\right) \cdot \sqrt{d}}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 66.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-*.f6467.9
lift-/.f64N/A
metadata-eval67.9
Applied rewrites67.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.0
Applied rewrites69.0%
if -3.999999999999988e-310 < l < 8.2e19Initial program 73.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-*.f6476.4
lift-/.f64N/A
metadata-eval76.4
Applied rewrites76.4%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites77.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6477.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6477.0
Applied rewrites77.0%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
if 8.2e19 < l Initial program 60.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-*.f6458.9
lift-/.f64N/A
metadata-eval58.9
Applied rewrites58.9%
Applied rewrites66.7%
Applied rewrites75.8%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites74.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M)))
(if (<= l 1650000000000.0)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(/
(/
(*
(*
(fma (* (* M D_m) (* (/ (/ (* (/ M d) D_m) 4.0) d) -0.5)) (/ h l) 1.0)
(sqrt d))
(sqrt d))
(sqrt h))
(sqrt l)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double tmp;
if (l <= 1650000000000.0) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else {
tmp = (((fma(((M * D_m) * (((((M / d) * D_m) / 4.0) / d) * -0.5)), (h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M) tmp = 0.0 if (l <= 1650000000000.0) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l))); else tmp = Float64(Float64(Float64(Float64(fma(Float64(Float64(M * D_m) * Float64(Float64(Float64(Float64(Float64(M / d) * D_m) / 4.0) / d) * -0.5)), Float64(h / l), 1.0) * sqrt(d)) * sqrt(d)) / sqrt(h)) / sqrt(l)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, If[LessEqual[l, 1650000000000.0], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(N[(N[(N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision] / 4.0), $MachinePrecision] / d), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
\mathbf{if}\;\ell \leq 1650000000000:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\mathsf{fma}\left(\left(M \cdot D\_m\right) \cdot \left(\frac{\frac{\frac{M}{d} \cdot D\_m}{4}}{d} \cdot -0.5\right), \frac{h}{\ell}, 1\right) \cdot \sqrt{d}\right) \cdot \sqrt{d}}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 1.65e12Initial program 68.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-*.f6470.8
lift-/.f64N/A
metadata-eval70.8
Applied rewrites70.8%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites71.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.7
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6471.7
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6471.7
Applied rewrites71.7%
if 1.65e12 < l Initial program 60.6%
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-*.f6459.5
lift-/.f64N/A
metadata-eval59.5
Applied rewrites59.5%
Applied rewrites67.1%
Applied rewrites76.2%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
associate-/l*N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites75.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M d) D_m)) (t_1 (/ (/ D_m d) 2.0)) (t_2 (* t_1 M)))
(if (<= d -1.14e+216)
(* -1.0 (* d (sqrt (/ 1.0 (* h l)))))
(if (<= d -1.15e-80)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* t_1 (* M (* (* 0.5 (* M t_1)) (/ h l))))))
(if (<= d 5e-304)
(*
(fma -0.5 (/ (* (* h t_0) (/ t_0 4.0)) l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (/ d (sqrt (* h l))) (- 1.0 (/ (* t_2 (* t_2 (* 0.5 h))) l))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / d) * D_m;
double t_1 = (D_m / d) / 2.0;
double t_2 = t_1 * M;
double tmp;
if (d <= -1.14e+216) {
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
} else if (d <= -1.15e-80) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (t_1 * (M * ((0.5 * (M * t_1)) * (h / l)))));
} else if (d <= 5e-304) {
tmp = fma(-0.5, (((h * t_0) * (t_0 / 4.0)) / l), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = (d / sqrt((h * l))) * (1.0 - ((t_2 * (t_2 * (0.5 * h))) / l));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / d) * D_m) t_1 = Float64(Float64(D_m / d) / 2.0) t_2 = Float64(t_1 * M) tmp = 0.0 if (d <= -1.14e+216) tmp = Float64(-1.0 * Float64(d * sqrt(Float64(1.0 / Float64(h * l))))); elseif (d <= -1.15e-80) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(t_1 * Float64(M * Float64(Float64(0.5 * Float64(M * t_1)) * Float64(h / l)))))); elseif (d <= 5e-304) tmp = Float64(fma(-0.5, Float64(Float64(Float64(h * t_0) * Float64(t_0 / 4.0)) / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(t_2 * Float64(t_2 * Float64(0.5 * h))) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * M), $MachinePrecision]}, If[LessEqual[d, -1.14e+216], N[(-1.0 * N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.15e-80], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$1 * N[(M * N[(N[(0.5 * N[(M * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e-304], N[(N[(-0.5 * N[(N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 / 4.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$2 * N[(t$95$2 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{d} \cdot D\_m\\
t_1 := \frac{\frac{D\_m}{d}}{2}\\
t_2 := t\_1 \cdot M\\
\mathbf{if}\;d \leq -1.14 \cdot 10^{+216}:\\
\;\;\;\;-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-80}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - t\_1 \cdot \left(M \cdot \left(\left(0.5 \cdot \left(M \cdot t\_1\right)\right) \cdot \frac{h}{\ell}\right)\right)\right)\\
\mathbf{elif}\;d \leq 5 \cdot 10^{-304}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{\left(h \cdot t\_0\right) \cdot \frac{t\_0}{4}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 - \frac{t\_2 \cdot \left(t\_2 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -1.14e216Initial program 70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6
Applied rewrites60.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.8
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6464.4
Applied rewrites64.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6463.5
Applied rewrites63.5%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6472.8
Applied rewrites72.8%
if -1.14e216 < d < -1.1499999999999999e-80Initial program 78.1%
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-*.f6479.9
lift-/.f64N/A
metadata-eval79.9
Applied rewrites79.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites81.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6481.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6481.4
Applied rewrites81.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/l*N/A
lift-/.f64N/A
lower-*.f64N/A
Applied rewrites78.7%
if -1.1499999999999999e-80 < d < 4.99999999999999965e-304Initial program 48.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.6
Applied rewrites39.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.3
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6439.8
Applied rewrites39.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-commutativeN/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
Applied rewrites40.7%
if 4.99999999999999965e-304 < d Initial program 67.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-*.f6468.6
lift-/.f64N/A
metadata-eval68.6
Applied rewrites68.6%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.5
Applied rewrites69.5%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-sqrt.f6476.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.2
Applied rewrites76.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M d) D_m)) (t_1 (/ (/ D_m d) 2.0)) (t_2 (* t_1 M)))
(if (<= d -9.5e+215)
(* -1.0 (* d (sqrt (/ 1.0 (* h l)))))
(if (<= d -1.15e-80)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* M D_m) (* (* 0.5 (* M t_1)) (/ h l))) (* 2.0 d))))
(if (<= d 5e-304)
(*
(fma -0.5 (/ (* (* h t_0) (/ t_0 4.0)) l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (/ d (sqrt (* h l))) (- 1.0 (/ (* t_2 (* t_2 (* 0.5 h))) l))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / d) * D_m;
double t_1 = (D_m / d) / 2.0;
double t_2 = t_1 * M;
double tmp;
if (d <= -9.5e+215) {
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
} else if (d <= -1.15e-80) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((M * D_m) * ((0.5 * (M * t_1)) * (h / l))) / (2.0 * d)));
} else if (d <= 5e-304) {
tmp = fma(-0.5, (((h * t_0) * (t_0 / 4.0)) / l), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = (d / sqrt((h * l))) * (1.0 - ((t_2 * (t_2 * (0.5 * h))) / l));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / d) * D_m) t_1 = Float64(Float64(D_m / d) / 2.0) t_2 = Float64(t_1 * M) tmp = 0.0 if (d <= -9.5e+215) tmp = Float64(-1.0 * Float64(d * sqrt(Float64(1.0 / Float64(h * l))))); elseif (d <= -1.15e-80) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(M * D_m) * Float64(Float64(0.5 * Float64(M * t_1)) * Float64(h / l))) / Float64(2.0 * d)))); elseif (d <= 5e-304) tmp = Float64(fma(-0.5, Float64(Float64(Float64(h * t_0) * Float64(t_0 / 4.0)) / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(t_2 * Float64(t_2 * Float64(0.5 * h))) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * M), $MachinePrecision]}, If[LessEqual[d, -9.5e+215], N[(-1.0 * N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.15e-80], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(M * D$95$m), $MachinePrecision] * N[(N[(0.5 * N[(M * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e-304], N[(N[(-0.5 * N[(N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 / 4.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$2 * N[(t$95$2 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{d} \cdot D\_m\\
t_1 := \frac{\frac{D\_m}{d}}{2}\\
t_2 := t\_1 \cdot M\\
\mathbf{if}\;d \leq -9.5 \cdot 10^{+215}:\\
\;\;\;\;-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-80}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(M \cdot D\_m\right) \cdot \left(\left(0.5 \cdot \left(M \cdot t\_1\right)\right) \cdot \frac{h}{\ell}\right)}{2 \cdot d}\right)\\
\mathbf{elif}\;d \leq 5 \cdot 10^{-304}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{\left(h \cdot t\_0\right) \cdot \frac{t\_0}{4}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 - \frac{t\_2 \cdot \left(t\_2 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -9.50000000000000036e215Initial program 70.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.6
Applied rewrites60.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.8
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6464.4
Applied rewrites64.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6463.5
Applied rewrites63.5%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6472.8
Applied rewrites72.8%
if -9.50000000000000036e215 < d < -1.1499999999999999e-80Initial program 78.1%
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-*.f6479.9
lift-/.f64N/A
metadata-eval79.9
Applied rewrites79.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites81.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6481.4
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6481.4
Applied rewrites81.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
lift-*.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites78.4%
if -1.1499999999999999e-80 < d < 4.99999999999999965e-304Initial program 48.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6448.6
Applied rewrites39.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.3
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6439.8
Applied rewrites39.8%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-commutativeN/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
Applied rewrites40.7%
if 4.99999999999999965e-304 < d Initial program 67.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-*.f6468.6
lift-/.f64N/A
metadata-eval68.6
Applied rewrites68.6%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.5
Applied rewrites69.5%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-sqrt.f6476.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.2
Applied rewrites76.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l))))
(if (<= d 1.1e-214)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_1)
(* (/ d (sqrt (* h l))) t_1))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double tmp;
if (d <= 1.1e-214) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1;
} else {
tmp = (d / sqrt((h * l))) * t_1;
}
return tmp;
}
D_m = private
NOTE: d, h, l, 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, 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
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((d_m / d) / 2.0d0) * m
t_1 = 1.0d0 - ((t_0 * (t_0 * (0.5d0 * h))) / l)
if (d <= 1.1d-214) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1
else
tmp = (d / sqrt((h * l))) * t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double tmp;
if (d <= 1.1e-214) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * t_1;
} else {
tmp = (d / Math.sqrt((h * l))) * t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = ((D_m / d) / 2.0) * M t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l) tmp = 0 if d <= 1.1e-214: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * t_1 else: tmp = (d / math.sqrt((h * l))) * t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) tmp = 0.0 if (d <= 1.1e-214) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_1); else tmp = Float64(Float64(d / sqrt(Float64(h * l))) * t_1); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = ((D_m / d) / 2.0) * M;
t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
tmp = 0.0;
if (d <= 1.1e-214)
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1;
else
tmp = (d / sqrt((h * l))) * t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 1.1e-214], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
\mathbf{if}\;d \leq 1.1 \cdot 10^{-214}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot t\_1\\
\end{array}
\end{array}
if d < 1.10000000000000001e-214Initial program 62.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-*.f6464.1
lift-/.f64N/A
metadata-eval64.1
Applied rewrites64.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites65.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6465.0
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6465.0
Applied rewrites65.0%
if 1.10000000000000001e-214 < d Initial program 72.1%
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-*.f6473.6
lift-/.f64N/A
metadata-eval73.6
Applied rewrites73.6%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites74.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.6
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6474.6
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6474.6
Applied rewrites74.6%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-sqrt.f6478.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.9
Applied rewrites78.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M d) D_m)) (t_1 (* (/ (/ D_m d) 2.0) M)))
(if (<= d -8e+215)
(* -1.0 (* d (sqrt (/ 1.0 (* h l)))))
(if (<= d 5e-304)
(*
(fma -0.5 (/ (* (* h t_0) (/ t_0 4.0)) l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(* (/ d (sqrt (* h l))) (- 1.0 (/ (* t_1 (* t_1 (* 0.5 h))) l)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / d) * D_m;
double t_1 = ((D_m / d) / 2.0) * M;
double tmp;
if (d <= -8e+215) {
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
} else if (d <= 5e-304) {
tmp = fma(-0.5, (((h * t_0) * (t_0 / 4.0)) / l), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = (d / sqrt((h * l))) * (1.0 - ((t_1 * (t_1 * (0.5 * h))) / l));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / d) * D_m) t_1 = Float64(Float64(Float64(D_m / d) / 2.0) * M) tmp = 0.0 if (d <= -8e+215) tmp = Float64(-1.0 * Float64(d * sqrt(Float64(1.0 / Float64(h * l))))); elseif (d <= 5e-304) tmp = Float64(fma(-0.5, Float64(Float64(Float64(h * t_0) * Float64(t_0 / 4.0)) / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * Float64(0.5 * h))) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M), $MachinePrecision]}, If[LessEqual[d, -8e+215], N[(-1.0 * N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e-304], N[(N[(-0.5 * N[(N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 / 4.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{d} \cdot D\_m\\
t_1 := \frac{\frac{D\_m}{d}}{2} \cdot M\\
\mathbf{if}\;d \leq -8 \cdot 10^{+215}:\\
\;\;\;\;-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{elif}\;d \leq 5 \cdot 10^{-304}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{\left(h \cdot t\_0\right) \cdot \frac{t\_0}{4}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 - \frac{t\_1 \cdot \left(t\_1 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -7.99999999999999925e215Initial program 70.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites60.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6463.7
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6464.3
Applied rewrites64.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6463.4
Applied rewrites63.4%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6472.8
Applied rewrites72.8%
if -7.99999999999999925e215 < d < 4.99999999999999965e-304Initial program 65.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.3
Applied rewrites54.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6456.4
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6456.2
Applied rewrites56.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6456.9
Applied rewrites56.9%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-commutativeN/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
Applied rewrites57.7%
if 4.99999999999999965e-304 < d Initial program 67.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-*.f6468.6
lift-/.f64N/A
metadata-eval68.6
Applied rewrites68.6%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6469.5
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6469.5
Applied rewrites69.5%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lower-/.f64N/A
lower-sqrt.f6476.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.2
Applied rewrites76.2%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* (/ M d) D_m)))
(if (<= l 1.95e-199)
(*
(fma -0.5 (/ (* (* h t_0) (/ t_0 4.0)) l) 1.0)
(sqrt (* (/ d l) (/ d h))))
(*
(fma -0.5 (* (/ h l) (/ (* t_0 t_0) 4.0)) 1.0)
(* d (sqrt (/ 1.0 (* h l))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (M / d) * D_m;
double tmp;
if (l <= 1.95e-199) {
tmp = fma(-0.5, (((h * t_0) * (t_0 / 4.0)) / l), 1.0) * sqrt(((d / l) * (d / h)));
} else {
tmp = fma(-0.5, ((h / l) * ((t_0 * t_0) / 4.0)), 1.0) * (d * sqrt((1.0 / (h * l))));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64(M / d) * D_m) tmp = 0.0 if (l <= 1.95e-199) tmp = Float64(fma(-0.5, Float64(Float64(Float64(h * t_0) * Float64(t_0 / 4.0)) / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(fma(-0.5, Float64(Float64(h / l) * Float64(Float64(t_0 * t_0) / 4.0)), 1.0) * Float64(d * sqrt(Float64(1.0 / Float64(h * l))))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(M / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[l, 1.95e-199], N[(N[(-0.5 * N[(N[(N[(h * t$95$0), $MachinePrecision] * N[(t$95$0 / 4.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[(N[(h / l), $MachinePrecision] * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{M}{d} \cdot D\_m\\
\mathbf{if}\;\ell \leq 1.95 \cdot 10^{-199}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{\left(h \cdot t\_0\right) \cdot \frac{t\_0}{4}}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{h}{\ell} \cdot \frac{t\_0 \cdot t\_0}{4}, 1\right) \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\\
\end{array}
\end{array}
if l < 1.9500000000000001e-199Initial program 66.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied rewrites57.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6460.0
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6459.8
Applied rewrites59.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6460.4
Applied rewrites60.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-commutativeN/A
associate-*r/N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
Applied rewrites61.0%
if 1.9500000000000001e-199 < l Initial program 66.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.6
Applied rewrites53.6%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval53.6
Applied rewrites53.6%
Taylor expanded in d around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6468.2
Applied rewrites68.2%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= l 7.5e-278) (* -1.0 (* d (sqrt (/ 1.0 (* h l))))) (/ (* d (sqrt (/ 1.0 h))) (sqrt l))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 7.5e-278) {
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
} else {
tmp = (d * sqrt((1.0 / h))) / sqrt(l);
}
return tmp;
}
D_m = private
NOTE: d, h, l, 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, 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
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 7.5d-278) then
tmp = (-1.0d0) * (d * sqrt((1.0d0 / (h * l))))
else
tmp = (d * sqrt((1.0d0 / h))) / sqrt(l)
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 7.5e-278) {
tmp = -1.0 * (d * Math.sqrt((1.0 / (h * l))));
} else {
tmp = (d * Math.sqrt((1.0 / h))) / Math.sqrt(l);
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if l <= 7.5e-278: tmp = -1.0 * (d * math.sqrt((1.0 / (h * l)))) else: tmp = (d * math.sqrt((1.0 / h))) / math.sqrt(l) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= 7.5e-278) tmp = Float64(-1.0 * Float64(d * sqrt(Float64(1.0 / Float64(h * l))))); else tmp = Float64(Float64(d * sqrt(Float64(1.0 / h))) / sqrt(l)); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (l <= 7.5e-278)
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
else
tmp = (d * sqrt((1.0 / h))) / sqrt(l);
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 7.5e-278], N[(-1.0 * N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d * N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.5 \cdot 10^{-278}:\\
\;\;\;\;-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d \cdot \sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 7.49999999999999946e-278Initial program 66.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.3
Applied rewrites56.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.7
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6458.6
Applied rewrites58.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6459.0
Applied rewrites59.0%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6441.8
Applied rewrites41.8%
if 7.49999999999999946e-278 < l Initial program 67.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-*.f6468.0
lift-/.f64N/A
metadata-eval68.0
Applied rewrites68.0%
Applied rewrites71.6%
Applied rewrites81.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6448.4
Applied rewrites48.4%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= l 7.5e-278) (* -1.0 (* d (sqrt (/ 1.0 (* h l))))) (/ (/ d (sqrt h)) (sqrt l))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 7.5e-278) {
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
} else {
tmp = (d / sqrt(h)) / sqrt(l);
}
return tmp;
}
D_m = private
NOTE: d, h, l, 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, 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
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= 7.5d-278) then
tmp = (-1.0d0) * (d * sqrt((1.0d0 / (h * l))))
else
tmp = (d / sqrt(h)) / sqrt(l)
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (l <= 7.5e-278) {
tmp = -1.0 * (d * Math.sqrt((1.0 / (h * l))));
} else {
tmp = (d / Math.sqrt(h)) / Math.sqrt(l);
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if l <= 7.5e-278: tmp = -1.0 * (d * math.sqrt((1.0 / (h * l)))) else: tmp = (d / math.sqrt(h)) / math.sqrt(l) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (l <= 7.5e-278) tmp = Float64(-1.0 * Float64(d * sqrt(Float64(1.0 / Float64(h * l))))); else tmp = Float64(Float64(d / sqrt(h)) / sqrt(l)); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (l <= 7.5e-278)
tmp = -1.0 * (d * sqrt((1.0 / (h * l))));
else
tmp = (d / sqrt(h)) / sqrt(l);
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[l, 7.5e-278], N[(-1.0 * N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.5 \cdot 10^{-278}:\\
\;\;\;\;-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 7.49999999999999946e-278Initial program 66.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.3
Applied rewrites56.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.7
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6458.6
Applied rewrites58.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6459.0
Applied rewrites59.0%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6441.8
Applied rewrites41.8%
if 7.49999999999999946e-278 < l Initial program 67.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-*.f6468.0
lift-/.f64N/A
metadata-eval68.0
Applied rewrites68.0%
Applied rewrites71.6%
Applied rewrites81.1%
Taylor expanded in d around inf
Applied rewrites48.4%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (let* ((t_0 (* d (sqrt (/ 1.0 (* h l)))))) (if (<= l 4.1e-226) (* -1.0 t_0) t_0)))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = d * sqrt((1.0 / (h * l)));
double tmp;
if (l <= 4.1e-226) {
tmp = -1.0 * t_0;
} else {
tmp = t_0;
}
return tmp;
}
D_m = private
NOTE: d, h, l, 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, 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
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = d * sqrt((1.0d0 / (h * l)))
if (l <= 4.1d-226) then
tmp = (-1.0d0) * t_0
else
tmp = t_0
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = d * Math.sqrt((1.0 / (h * l)));
double tmp;
if (l <= 4.1e-226) {
tmp = -1.0 * t_0;
} else {
tmp = t_0;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = d * math.sqrt((1.0 / (h * l))) tmp = 0 if l <= 4.1e-226: tmp = -1.0 * t_0 else: tmp = t_0 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(d * sqrt(Float64(1.0 / Float64(h * l)))) tmp = 0.0 if (l <= 4.1e-226) tmp = Float64(-1.0 * t_0); else tmp = t_0; end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = d * sqrt((1.0 / (h * l)));
tmp = 0.0;
if (l <= 4.1e-226)
tmp = -1.0 * t_0;
else
tmp = t_0;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, 4.1e-226], N[(-1.0 * t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{if}\;\ell \leq 4.1 \cdot 10^{-226}:\\
\;\;\;\;-1 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < 4.10000000000000037e-226Initial program 66.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.8
Applied rewrites57.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6459.7
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6459.5
Applied rewrites59.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-/.f64N/A
times-fracN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lower-/.f6460.0
Applied rewrites60.0%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6440.5
Applied rewrites40.5%
if 4.10000000000000037e-226 < l Initial program 66.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-*.f6467.3
lift-/.f64N/A
metadata-eval67.3
Applied rewrites67.3%
Applied rewrites71.4%
Applied rewrites80.9%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6443.8
Applied rewrites43.8%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (* d (sqrt (/ 1.0 (* h l)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
return d * sqrt((1.0 / (h * l)));
}
D_m = private
NOTE: d, h, l, 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, 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
real(8), intent (in) :: d_m
code = d * sqrt((1.0d0 / (h * l)))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
return d * Math.sqrt((1.0 / (h * l)));
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): return d * math.sqrt((1.0 / (h * l)))
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) return Float64(d * sqrt(Float64(1.0 / Float64(h * l)))) end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
tmp = d * sqrt((1.0 / (h * l)));
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Initial program 66.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-*.f6468.1
lift-/.f64N/A
metadata-eval68.1
Applied rewrites68.1%
Applied rewrites35.6%
Applied rewrites40.5%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.6
Applied rewrites25.6%
herbie shell --seed 2025108
(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)))))