
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 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)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d -5e-310)
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (/ (sqrt (- d)) (sqrt (- l))))
(-
1.0
(*
(/ (* (/ M_m d) (* (* D_m M_m) (* h 0.5))) (* 2.0 l))
(/ (/ D_m d) 2.0))))
(if (<= d 7e-189)
(/
(fma
(* (* (/ (pow (* D_m M_m) 2.0) d) -0.125) (sqrt l))
(sqrt h)
(* (/ (pow l 1.5) (sqrt h)) d))
(* l l))
(*
(* (/ (sqrt d) (sqrt h)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -5e-310) {
tmp = (pow((d / h), pow(2.0, -1.0)) * (sqrt(-d) / sqrt(-l))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * ((D_m / d) / 2.0)));
} else if (d <= 7e-189) {
tmp = fma((((pow((D_m * M_m), 2.0) / d) * -0.125) * sqrt(l)), sqrt(h), ((pow(l, 1.5) / sqrt(h)) * d)) / (l * l);
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -5e-310) tmp = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(Float64(D_m * M_m) * Float64(h * 0.5))) / Float64(2.0 * l)) * Float64(Float64(D_m / d) / 2.0)))); elseif (d <= 7e-189) tmp = Float64(fma(Float64(Float64(Float64((Float64(D_m * M_m) ^ 2.0) / d) * -0.125) * sqrt(l)), sqrt(h), Float64(Float64((l ^ 1.5) / sqrt(h)) * d)) / Float64(l * l)); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -5e-310], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(h * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e-189], N[(N[(N[(N[(N[(N[Power[N[(D$95$m * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(N[(N[Power[l, 1.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - \frac{\frac{M\_m}{d} \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \left(h \cdot 0.5\right)\right)}{2 \cdot \ell} \cdot \frac{\frac{D\_m}{d}}{2}\right)\\
\mathbf{elif}\;d \leq 7 \cdot 10^{-189}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(\frac{{\left(D\_m \cdot M\_m\right)}^{2}}{d} \cdot -0.125\right) \cdot \sqrt{\ell}, \sqrt{h}, \frac{{\ell}^{1.5}}{\sqrt{h}} \cdot d\right)}{\ell \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.7%
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
lift-/.f64N/A
metadata-eval70.9
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
if -4.999999999999985e-310 < d < 7.0000000000000003e-189Initial program 29.3%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites25.3%
Applied rewrites68.6%
if 7.0000000000000003e-189 < d Initial program 80.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6488.6
Applied rewrites88.6%
Final simplification82.1%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M_m))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_2 (/ d (sqrt (* l h)))))
(if (<= t_1 (- INFINITY))
(* (fma (* (* (/ M_m 2.0) D_m) t_0) (* -0.5 (/ h l)) 1.0) t_2)
(if (<= t_1 -2e-48)
(* (fma (* -0.5 (pow t_0 2.0)) (/ h l) 1.0) (sqrt (* (/ d l) (/ d h))))
(if (<= t_1 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
t_2))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = d / sqrt((l * h));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((((M_m / 2.0) * D_m) * t_0), (-0.5 * (h / l)), 1.0) * t_2;
} else if (t_1 <= -2e-48) {
tmp = fma((-0.5 * pow(t_0, 2.0)), (h / l), 1.0) * sqrt(((d / l) * (d / h)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * t_2;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(Float64(Float64(Float64(M_m / 2.0) * D_m) * t_0), Float64(-0.5 * Float64(h / l)), 1.0) * t_2); elseif (t_1 <= -2e-48) tmp = Float64(fma(Float64(-0.5 * (t_0 ^ 2.0)), Float64(h / l), 1.0) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_1 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * t_2); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(N[(M$95$m / 2.0), $MachinePrecision] * D$95$m), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, -2e-48], N[(N[(N[(-0.5 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m}{2} \cdot D\_m\right) \cdot t\_0, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot {t\_0}^{2}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 83.1%
Applied rewrites46.4%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6446.4
Applied rewrites73.1%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6476.3
Applied rewrites76.3%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.9999999999999999e-48Initial program 99.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.1%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6435.3
Applied rewrites35.3%
Applied rewrites65.4%
if -1.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 89.0%
Applied rewrites83.3%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6487.7
Applied rewrites87.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification72.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M_m))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_2 (/ d (sqrt (* l h)))))
(if (<= t_1 (- INFINITY))
(* (fma (* (* (/ M_m 2.0) D_m) t_0) (* -0.5 (/ h l)) 1.0) t_2)
(if (<= t_1 0.0)
(* (fma (* -0.5 (pow t_0 2.0)) (/ h l) 1.0) t_2)
(if (<= t_1 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
t_2))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = d / sqrt((l * h));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((((M_m / 2.0) * D_m) * t_0), (-0.5 * (h / l)), 1.0) * t_2;
} else if (t_1 <= 0.0) {
tmp = fma((-0.5 * pow(t_0, 2.0)), (h / l), 1.0) * t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * t_2;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(Float64(Float64(Float64(M_m / 2.0) * D_m) * t_0), Float64(-0.5 * Float64(h / l)), 1.0) * t_2); elseif (t_1 <= 0.0) tmp = Float64(fma(Float64(-0.5 * (t_0 ^ 2.0)), Float64(h / l), 1.0) * t_2); elseif (t_1 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * t_2); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(N[(M$95$m / 2.0), $MachinePrecision] * D$95$m), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[(-0.5 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m}{2} \cdot D\_m\right) \cdot t\_0, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot {t\_0}^{2}, \frac{h}{\ell}, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 83.1%
Applied rewrites46.4%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6446.4
Applied rewrites73.1%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6476.3
Applied rewrites76.3%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 82.2%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6482.2
Applied rewrites82.2%
Applied rewrites47.2%
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)))) < +inf.0Initial program 91.9%
Applied rewrites86.6%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification71.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_2 (/ d (sqrt (* l h)))))
(if (<= t_1 (- INFINITY))
(* (fma (* (* (/ M_m 2.0) D_m) (* t_0 M_m)) (* -0.5 (/ h l)) 1.0) t_2)
(if (<= t_1 0.0)
(*
(* (/ (sqrt d) (sqrt h)) (/ (sqrt d) (sqrt l)))
(- 1.0 (* (* (* (/ h l) 0.5) (* (/ D_m 2.0) (* (/ M_m d) M_m))) t_0)))
(if (<= t_1 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
t_2))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = d / sqrt((l * h));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma((((M_m / 2.0) * D_m) * (t_0 * M_m)), (-0.5 * (h / l)), 1.0) * t_2;
} else if (t_1 <= 0.0) {
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
} else if (t_1 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * t_2;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(Float64(Float64(Float64(M_m / 2.0) * D_m) * Float64(t_0 * M_m)), Float64(-0.5 * Float64(h / l)), 1.0) * t_2); elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * Float64(sqrt(d) / sqrt(l))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(Float64(D_m / 2.0) * Float64(Float64(M_m / d) * M_m))) * t_0))); elseif (t_1 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * t_2); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(N[(M$95$m / 2.0), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(t$95$0 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m}{2} \cdot D\_m\right) \cdot \left(t\_0 \cdot M\_m\right), -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(\frac{D\_m}{2} \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right) \cdot t\_0\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 83.1%
Applied rewrites46.4%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6446.4
Applied rewrites73.1%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6476.3
Applied rewrites76.3%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 82.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites56.3%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6432.3
Applied rewrites32.3%
lift-/.f64N/A
metadata-eval32.3
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6438.7
Applied rewrites38.7%
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)))) < +inf.0Initial program 91.9%
Applied rewrites86.6%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification71.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l)))
(t_1 (/ (/ D_m d) 2.0))
(t_2
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_3 (/ d (sqrt (* l h)))))
(if (<= t_2 (- INFINITY))
(* (fma (* (* (/ M_m 2.0) D_m) (* t_1 M_m)) (* -0.5 (/ h l)) 1.0) t_3)
(if (<= t_2 -4e-42)
(*
(* (/ (sqrt d) (sqrt h)) t_0)
(- 1.0 (* (* (* (/ h l) 0.5) (* (/ D_m 2.0) (* (/ M_m d) M_m))) t_1)))
(if (<= t_2 INFINITY)
(* t_0 (sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
t_3))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = (D_m / d) / 2.0;
double t_2 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = d / sqrt((l * h));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma((((M_m / 2.0) * D_m) * (t_1 * M_m)), (-0.5 * (h / l)), 1.0) * t_3;
} else if (t_2 <= -4e-42) {
tmp = ((sqrt(d) / sqrt(h)) * t_0) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_1));
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_0 * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * t_3;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) t_1 = Float64(Float64(D_m / d) / 2.0) t_2 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(fma(Float64(Float64(Float64(M_m / 2.0) * D_m) * Float64(t_1 * M_m)), Float64(-0.5 * Float64(h / l)), 1.0) * t_3); elseif (t_2 <= -4e-42) tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * t_0) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(Float64(D_m / 2.0) * Float64(Float64(M_m / d) * M_m))) * t_1))); elseif (t_2 <= Inf) tmp = Float64(t_0 * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * t_3); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(N[(N[(M$95$m / 2.0), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(t$95$1 * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$2, -4e-42], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \frac{\frac{D\_m}{d}}{2}\\
t_2 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m}{2} \cdot D\_m\right) \cdot \left(t\_1 \cdot M\_m\right), -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_3\\
\mathbf{elif}\;t\_2 \leq -4 \cdot 10^{-42}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(\frac{D\_m}{2} \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right) \cdot t\_1\right)\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot t\_3\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 83.1%
Applied rewrites46.4%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6446.4
Applied rewrites73.1%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6476.3
Applied rewrites76.3%
if -inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.00000000000000015e-42Initial program 98.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites69.0%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6437.5
Applied rewrites37.5%
lift-/.f64N/A
metadata-eval37.5
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6437.5
Applied rewrites37.5%
if -4.00000000000000015e-42 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 89.1%
Applied rewrites82.7%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6487.1
Applied rewrites87.1%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification70.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (/ d (sqrt (* l h)))))
(if (<= t_0 0.0)
(*
(fma
(* (* (/ M_m 2.0) D_m) (* (/ (/ D_m d) 2.0) M_m))
(* -0.5 (/ h l))
1.0)
t_1)
(if (<= t_0 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
t_1)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = d / sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = fma((((M_m / 2.0) * D_m) * (((D_m / d) / 2.0) * M_m)), (-0.5 * (h / l)), 1.0) * t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(fma(Float64(Float64(Float64(M_m / 2.0) * D_m) * Float64(Float64(Float64(D_m / d) / 2.0) * M_m)), Float64(-0.5 * Float64(h / l)), 1.0) * t_1); elseif (t_0 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(N[(M$95$m / 2.0), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m}{2} \cdot D\_m\right) \cdot \left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right), -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 82.8%
Applied rewrites37.3%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6437.3
Applied rewrites59.2%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
associate-/l/N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6461.5
Applied rewrites61.5%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 91.9%
Applied rewrites86.6%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification69.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (/ d (sqrt (* l h)))))
(if (<= t_0 0.0)
(*
(fma (/ (* (* (* 0.25 (* D_m D_m)) M_m) M_m) d) (* -0.5 (/ h l)) 1.0)
t_1)
(if (<= t_0 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
t_1)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = d / sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = fma(((((0.25 * (D_m * D_m)) * M_m) * M_m) / d), (-0.5 * (h / l)), 1.0) * t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.25 * Float64(D_m * D_m)) * M_m) * M_m) / d), Float64(-0.5 * Float64(h / l)), 1.0) * t_1); elseif (t_0 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(N[(N[(0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(\left(0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot M\_m\right) \cdot M\_m}{d}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 82.8%
Applied rewrites37.3%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6437.3
Applied rewrites59.2%
Taylor expanded in M around 0
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6459.0
Applied rewrites59.0%
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)))) < +inf.0Initial program 91.9%
Applied rewrites86.6%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification68.9%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(*
(* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0))
(/ h l)))))
(t_1 (/ d (sqrt (* l h)))))
(if (<= t_0 0.0)
(*
(fma (/ (* (* (* 0.25 (* D_m D_m)) M_m) M_m) d) (* -0.5 (/ h l)) 1.0)
t_1)
(if (<= t_0 INFINITY)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(* (* (/ (* (* D_m D_m) -0.125) l) (* (/ (* M_m M_m) d) h)) t_1)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = d / sqrt((l * h));
double tmp;
if (t_0 <= 0.0) {
tmp = fma(((((0.25 * (D_m * D_m)) * M_m) * M_m) / d), (-0.5 * (h / l)), 1.0) * t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = ((((D_m * D_m) * -0.125) / l) * (((M_m * M_m) / d) * h)) * t_1;
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(fma(Float64(Float64(Float64(Float64(0.25 * Float64(D_m * D_m)) * M_m) * M_m) / d), Float64(-0.5 * Float64(h / l)), 1.0) * t_1); elseif (t_0 <= Inf) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(Float64(Float64(D_m * D_m) * -0.125) / l) * Float64(Float64(Float64(M_m * M_m) / d) * h)) * t_1); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(N[(N[(0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(\left(0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot M\_m\right) \cdot M\_m}{d}, -0.5 \cdot \frac{h}{\ell}, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\left(D\_m \cdot D\_m\right) \cdot -0.125}{\ell} \cdot \left(\frac{M\_m \cdot M\_m}{d} \cdot h\right)\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 82.8%
Applied rewrites37.3%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6437.3
Applied rewrites59.2%
Taylor expanded in M around 0
associate-*r*N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6459.0
Applied rewrites59.0%
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)))) < +inf.0Initial program 91.9%
Applied rewrites86.6%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6491.4
Applied rewrites91.4%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.8
Applied rewrites26.8%
Final simplification67.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<=
(* (* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0))) t_0)
INFINITY)
(* (* (sqrt (/ d h)) (sqrt (/ d l))) t_0)
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
(/ d (sqrt (* l h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = 1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * t_0) <= ((double) INFINITY)) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * t_0;
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * (d / sqrt((l * h)));
}
return tmp;
}
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = 1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * t_0) <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * t_0;
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - Math.pow(h, -1.0))) * (d / Math.sqrt((l * h)));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = 1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * t_0) <= math.inf: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * t_0 else: tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - math.pow(h, -1.0))) * (d / math.sqrt((l * h))) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * t_0) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * t_0); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = 1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * t_0) <= Inf)
tmp = (sqrt((d / h)) * sqrt((d / l))) * t_0;
else
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - (h ^ -1.0))) * (d / sqrt((l * h)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := 1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot t\_0 \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6488.1
Applied rewrites88.1%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-sqrt.f6488.1
Applied rewrites88.1%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification77.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(*
(sqrt (/ d l))
(fma (* -0.5 (pow (* (/ (/ D_m d) 2.0) M_m) 2.0)) (/ h l) 1.0))
(sqrt (/ d h)))
(*
(*
(- h)
(- (* (/ (* (* D_m D_m) 0.125) l) (/ (* M_m M_m) d)) (pow h -1.0)))
(/ d (sqrt (* l h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / l)) * fma((-0.5 * pow((((D_m / d) / 2.0) * M_m), 2.0)), (h / l), 1.0)) * sqrt((d / h));
} else {
tmp = (-h * (((((D_m * D_m) * 0.125) / l) * ((M_m * M_m) / d)) - pow(h, -1.0))) * (d / sqrt((l * h)));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / l)) * fma(Float64(-0.5 * (Float64(Float64(Float64(D_m / d) / 2.0) * M_m) ^ 2.0)), Float64(h / l), 1.0)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(-h) * Float64(Float64(Float64(Float64(Float64(D_m * D_m) * 0.125) / l) * Float64(Float64(M_m * M_m) / d)) - (h ^ -1.0))) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.5 * N[Power[N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[((-h) * N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * 0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[Power[h, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left(-0.5 \cdot {\left(\frac{\frac{D\_m}{d}}{2} \cdot M\_m\right)}^{2}, \frac{h}{\ell}, 1\right)\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-h\right) \cdot \left(\frac{\left(D\_m \cdot D\_m\right) \cdot 0.125}{\ell} \cdot \frac{M\_m \cdot M\_m}{d} - {h}^{-1}\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6488.1
Applied rewrites88.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.1%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Applied rewrites2.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f642.0
Applied rewrites22.1%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
Applied rewrites32.8%
Final simplification76.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
0.0)
(* (sqrt (pow (* l h) -1.0)) d)
(* (sqrt (/ d l)) (sqrt (/ d h)))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = sqrt(pow((l * h), -1.0)) * d;
} else {
tmp = sqrt((d / l)) * sqrt((d / h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 0.0d0) then
tmp = sqrt(((l * h) ** (-1.0d0))) * d
else
tmp = sqrt((d / l)) * sqrt((d / h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = Math.sqrt(Math.pow((l * h), -1.0)) * d;
} else {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = math.sqrt(math.pow((l * h), -1.0)) * d else: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(sqrt((Float64(l * h) ^ -1.0)) * d); else tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 0.0)
tmp = sqrt(((l * h) ^ -1.0)) * d;
else
tmp = sqrt((d / l)) * sqrt((d / h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\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 82.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6416.7
Applied rewrites16.7%
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 64.7%
Applied rewrites61.6%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6469.4
Applied rewrites69.4%
Final simplification51.5%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0)))
(if (<= d -5e-310)
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (/ (sqrt (- d)) (sqrt (- l))))
(- 1.0 (* (/ (* (/ M_m d) (* (* D_m M_m) (* h 0.5))) (* 2.0 l)) t_0)))
(if (<= d 1.35e-188)
(/
(fma
(* (* (/ (pow (* D_m M_m) 2.0) d) -0.125) (sqrt l))
(sqrt h)
(* (/ (pow l 1.5) (sqrt h)) d))
(* l l))
(*
(* (/ (sqrt d) (sqrt h)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (* (/ h l) 0.5) (* (/ M_m d) (* D_m (/ M_m 2.0)))) t_0)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double tmp;
if (d <= -5e-310) {
tmp = (pow((d / h), pow(2.0, -1.0)) * (sqrt(-d) / sqrt(-l))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
} else if (d <= 1.35e-188) {
tmp = fma((((pow((D_m * M_m), 2.0) / d) * -0.125) * sqrt(l)), sqrt(h), ((pow(l, 1.5) / sqrt(h)) * d)) / (l * l);
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((((h / l) * 0.5) * ((M_m / d) * (D_m * (M_m / 2.0)))) * t_0));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) tmp = 0.0 if (d <= -5e-310) tmp = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(Float64(D_m * M_m) * Float64(h * 0.5))) / Float64(2.0 * l)) * t_0))); elseif (d <= 1.35e-188) tmp = Float64(fma(Float64(Float64(Float64((Float64(D_m * M_m) ^ 2.0) / d) * -0.125) * sqrt(l)), sqrt(h), Float64(Float64((l ^ 1.5) / sqrt(h)) * d)) / Float64(l * l)); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(Float64(M_m / d) * Float64(D_m * Float64(M_m / 2.0)))) * t_0))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[d, -5e-310], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(h * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.35e-188], N[(N[(N[(N[(N[(N[Power[N[(D$95$m * M$95$m), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision] + N[(N[(N[Power[l, 1.5], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - \frac{\frac{M\_m}{d} \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \left(h \cdot 0.5\right)\right)}{2 \cdot \ell} \cdot t\_0\right)\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-188}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(\frac{{\left(D\_m \cdot M\_m\right)}^{2}}{d} \cdot -0.125\right) \cdot \sqrt{\ell}, \sqrt{h}, \frac{{\ell}^{1.5}}{\sqrt{h}} \cdot d\right)}{\ell \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(\frac{M\_m}{d} \cdot \left(D\_m \cdot \frac{M\_m}{2}\right)\right)\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if d < -4.999999999999985e-310Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.7%
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
lift-/.f64N/A
metadata-eval70.9
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
if -4.999999999999985e-310 < d < 1.35e-188Initial program 29.3%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites25.3%
Applied rewrites68.6%
if 1.35e-188 < d Initial program 80.1%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites74.0%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6482.4
Applied rewrites82.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
Final simplification81.3%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0)))
(if (<= h -4e-310)
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (/ (sqrt (- d)) (sqrt (- l))))
(- 1.0 (* (/ (* (/ M_m d) (* (* D_m M_m) (* h 0.5))) (* 2.0 l)) t_0)))
(*
(* (/ (sqrt d) (sqrt h)) (/ (sqrt d) (sqrt l)))
(- 1.0 (* (* (* (/ h l) 0.5) (* (/ D_m 2.0) (* (/ M_m d) M_m))) t_0))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double tmp;
if (h <= -4e-310) {
tmp = (pow((d / h), pow(2.0, -1.0)) * (sqrt(-d) / sqrt(-l))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
} else {
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (d_m / d) / 2.0d0
if (h <= (-4d-310)) then
tmp = (((d / h) ** (2.0d0 ** (-1.0d0))) * (sqrt(-d) / sqrt(-l))) * (1.0d0 - ((((m_m / d) * ((d_m * m_m) * (h * 0.5d0))) / (2.0d0 * l)) * t_0))
else
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0d0 - ((((h / l) * 0.5d0) * ((d_m / 2.0d0) * ((m_m / d) * m_m))) * t_0))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double tmp;
if (h <= -4e-310) {
tmp = (Math.pow((d / h), Math.pow(2.0, -1.0)) * (Math.sqrt(-d) / Math.sqrt(-l))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * (Math.sqrt(d) / Math.sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m / d) / 2.0 tmp = 0 if h <= -4e-310: tmp = (math.pow((d / h), math.pow(2.0, -1.0)) * (math.sqrt(-d) / math.sqrt(-l))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0)) else: tmp = ((math.sqrt(d) / math.sqrt(h)) * (math.sqrt(d) / math.sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) tmp = 0.0 if (h <= -4e-310) tmp = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l)))) * Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(Float64(D_m * M_m) * Float64(h * 0.5))) / Float64(2.0 * l)) * t_0))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * Float64(sqrt(d) / sqrt(l))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(Float64(D_m / 2.0) * Float64(Float64(M_m / d) * M_m))) * t_0))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m / d) / 2.0;
tmp = 0.0;
if (h <= -4e-310)
tmp = (((d / h) ^ (2.0 ^ -1.0)) * (sqrt(-d) / sqrt(-l))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
else
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(h * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\right) \cdot \left(1 - \frac{\frac{M\_m}{d} \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \left(h \cdot 0.5\right)\right)}{2 \cdot \ell} \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(\frac{D\_m}{2} \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if h < -3.999999999999988e-310Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.7%
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
lift-/.f64N/A
metadata-eval70.9
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6478.6
Applied rewrites78.6%
if -3.999999999999988e-310 < h Initial program 71.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites66.7%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6476.0
Applied rewrites76.0%
lift-/.f64N/A
metadata-eval76.0
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6479.0
Applied rewrites79.0%
Final simplification78.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0)))
(if (<= h -4e-310)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) (pow (/ d l) (pow 2.0 -1.0)))
(- 1.0 (* (/ (* (/ M_m d) (* (* D_m M_m) (* h 0.5))) (* 2.0 l)) t_0)))
(*
(* (/ (sqrt d) (sqrt h)) (/ (sqrt d) (sqrt l)))
(- 1.0 (* (* (* (/ h l) 0.5) (* (/ D_m 2.0) (* (/ M_m d) M_m))) t_0))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double tmp;
if (h <= -4e-310) {
tmp = ((sqrt(-d) / sqrt(-h)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
} else {
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (d_m / d) / 2.0d0
if (h <= (-4d-310)) then
tmp = ((sqrt(-d) / sqrt(-h)) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - ((((m_m / d) * ((d_m * m_m) * (h * 0.5d0))) / (2.0d0 * l)) * t_0))
else
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0d0 - ((((h / l) * 0.5d0) * ((d_m / 2.0d0) * ((m_m / d) * m_m))) * t_0))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double tmp;
if (h <= -4e-310) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * (Math.sqrt(d) / Math.sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m / d) / 2.0 tmp = 0 if h <= -4e-310: tmp = ((math.sqrt(-d) / math.sqrt(-h)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0)) else: tmp = ((math.sqrt(d) / math.sqrt(h)) * (math.sqrt(d) / math.sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) tmp = 0.0 if (h <= -4e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64(Float64(Float64(M_m / d) * Float64(Float64(D_m * M_m) * Float64(h * 0.5))) / Float64(2.0 * l)) * t_0))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * Float64(sqrt(d) / sqrt(l))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(Float64(D_m / 2.0) * Float64(Float64(M_m / d) * M_m))) * t_0))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m / d) / 2.0;
tmp = 0.0;
if (h <= -4e-310)
tmp = ((sqrt(-d) / sqrt(-h)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - ((((M_m / d) * ((D_m * M_m) * (h * 0.5))) / (2.0 * l)) * t_0));
else
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * ((M_m / d) * M_m))) * t_0));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(M$95$m / d), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(h * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \frac{\frac{M\_m}{d} \cdot \left(\left(D\_m \cdot M\_m\right) \cdot \left(h \cdot 0.5\right)\right)}{2 \cdot \ell} \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(\frac{D\_m}{2} \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if h < -3.999999999999988e-310Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.7%
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6470.9
Applied rewrites70.9%
lift-/.f64N/A
metadata-eval70.9
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6475.6
Applied rewrites75.6%
if -3.999999999999988e-310 < h Initial program 71.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites66.7%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6476.0
Applied rewrites76.0%
lift-/.f64N/A
metadata-eval76.0
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6479.0
Applied rewrites79.0%
Final simplification77.4%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (/ (/ D_m d) 2.0)) (t_1 (* (/ M_m d) M_m)))
(if (<= h -4e-310)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) (pow (/ d l) (pow 2.0 -1.0)))
(- 1.0 (* (/ (* (* t_1 D_m) (* 0.5 h)) (* 2.0 l)) t_0)))
(*
(* (/ (sqrt d) (sqrt h)) (/ (sqrt d) (sqrt l)))
(- 1.0 (* (* (* (/ h l) 0.5) (* (/ D_m 2.0) t_1)) t_0))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = (M_m / d) * M_m;
double tmp;
if (h <= -4e-310) {
tmp = ((sqrt(-d) / sqrt(-h)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((((t_1 * D_m) * (0.5 * h)) / (2.0 * l)) * t_0));
} else {
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * t_1)) * t_0));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_m / d) / 2.0d0
t_1 = (m_m / d) * m_m
if (h <= (-4d-310)) then
tmp = ((sqrt(-d) / sqrt(-h)) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - ((((t_1 * d_m) * (0.5d0 * h)) / (2.0d0 * l)) * t_0))
else
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0d0 - ((((h / l) * 0.5d0) * ((d_m / 2.0d0) * t_1)) * t_0))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = (M_m / d) * M_m;
double tmp;
if (h <= -4e-310) {
tmp = ((Math.sqrt(-d) / Math.sqrt(-h)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((((t_1 * D_m) * (0.5 * h)) / (2.0 * l)) * t_0));
} else {
tmp = ((Math.sqrt(d) / Math.sqrt(h)) * (Math.sqrt(d) / Math.sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * t_1)) * t_0));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m / d) / 2.0 t_1 = (M_m / d) * M_m tmp = 0 if h <= -4e-310: tmp = ((math.sqrt(-d) / math.sqrt(-h)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((((t_1 * D_m) * (0.5 * h)) / (2.0 * l)) * t_0)) else: tmp = ((math.sqrt(d) / math.sqrt(h)) * (math.sqrt(d) / math.sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * t_1)) * t_0)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) t_1 = Float64(Float64(M_m / d) * M_m) tmp = 0.0 if (h <= -4e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * D_m) * Float64(0.5 * h)) / Float64(2.0 * l)) * t_0))); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * Float64(sqrt(d) / sqrt(l))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * Float64(Float64(D_m / 2.0) * t_1)) * t_0))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m / d) / 2.0;
t_1 = (M_m / d) * M_m;
tmp = 0.0;
if (h <= -4e-310)
tmp = ((sqrt(-d) / sqrt(-h)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - ((((t_1 * D_m) * (0.5 * h)) / (2.0 * l)) * t_0));
else
tmp = ((sqrt(d) / sqrt(h)) * (sqrt(d) / sqrt(l))) * (1.0 - ((((h / l) * 0.5) * ((D_m / 2.0) * t_1)) * t_0));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$1 * D$95$m), $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(D$95$m / 2.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
t_1 := \frac{M\_m}{d} \cdot M\_m\\
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \frac{\left(t\_1 \cdot D\_m\right) \cdot \left(0.5 \cdot h\right)}{2 \cdot \ell} \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot \left(\frac{D\_m}{2} \cdot t\_1\right)\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if h < -3.999999999999988e-310Initial program 69.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites65.7%
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6466.9
Applied rewrites66.9%
lift-/.f64N/A
metadata-eval66.9
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-neg.f6472.5
Applied rewrites72.5%
if -3.999999999999988e-310 < h Initial program 71.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites66.7%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6476.0
Applied rewrites76.0%
lift-/.f64N/A
metadata-eval76.0
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6479.0
Applied rewrites79.0%
Final simplification75.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= d 4.2e-170) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 4.2e-170) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= 4.2d-170) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 4.2e-170) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= 4.2e-170: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 4.2e-170) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= 4.2e-170)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, 4.2e-170], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 4.2 \cdot 10^{-170}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < 4.2000000000000001e-170Initial program 63.7%
Taylor expanded in l around -inf
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.3
Applied rewrites39.3%
if 4.2000000000000001e-170 < d Initial program 81.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.9
Applied rewrites48.9%
Applied rewrites48.8%
Applied rewrites48.8%
Applied rewrites62.7%
Final simplification48.8%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (let* ((t_0 (sqrt (pow (* l h) -1.0)))) (if (<= h -6e-288) (* (- d) t_0) (* t_0 d))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt(pow((l * h), -1.0));
double tmp;
if (h <= -6e-288) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((l * h) ** (-1.0d0)))
if (h <= (-6d-288)) then
tmp = -d * t_0
else
tmp = t_0 * d
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = Math.sqrt(Math.pow((l * h), -1.0));
double tmp;
if (h <= -6e-288) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = math.sqrt(math.pow((l * h), -1.0)) tmp = 0 if h <= -6e-288: tmp = -d * t_0 else: tmp = t_0 * d return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt((Float64(l * h) ^ -1.0)) tmp = 0.0 if (h <= -6e-288) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(t_0 * d); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = sqrt(((l * h) ^ -1.0));
tmp = 0.0;
if (h <= -6e-288)
tmp = -d * t_0;
else
tmp = t_0 * d;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -6e-288], N[((-d) * t$95$0), $MachinePrecision], N[(t$95$0 * d), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{if}\;h \leq -6 \cdot 10^{-288}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot d\\
\end{array}
\end{array}
if h < -5.99999999999999998e-288Initial program 69.1%
Taylor expanded in l around -inf
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.3
Applied rewrites44.3%
if -5.99999999999999998e-288 < h Initial program 72.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6442.5
Applied rewrites42.5%
Final simplification43.3%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (* (sqrt (pow (* l h) -1.0)) d))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return sqrt(pow((l * h), -1.0)) * d;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = sqrt(((l * h) ** (-1.0d0))) * d
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return Math.sqrt(Math.pow((l * h), -1.0)) * d;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return math.sqrt(math.pow((l * h), -1.0)) * d
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(sqrt((Float64(l * h) ^ -1.0)) * d) end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = sqrt(((l * h) ^ -1.0)) * d;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d
\end{array}
Initial program 70.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.0
Applied rewrites27.0%
Final simplification27.0%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= (* M_m D_m) 5e+71)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(* (/ (* (* D_m D_m) -0.125) l) (* (/ (* M_m M_m) d) h))
(/ d (sqrt (* l h))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 5e+71) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = ((((D_m * D_m) * -0.125) / l) * (((M_m * M_m) / d) * h)) * (d / sqrt((l * h)));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if ((m_m * d_m) <= 5d+71) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = ((((d_m * d_m) * (-0.125d0)) / l) * (((m_m * m_m) / d) * h)) * (d / sqrt((l * h)))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 5e+71) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = ((((D_m * D_m) * -0.125) / l) * (((M_m * M_m) / d) * h)) * (d / Math.sqrt((l * h)));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if (M_m * D_m) <= 5e+71: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = ((((D_m * D_m) * -0.125) / l) * (((M_m * M_m) / d) * h)) * (d / math.sqrt((l * h))) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(M_m * D_m) <= 5e+71) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(Float64(Float64(D_m * D_m) * -0.125) / l) * Float64(Float64(Float64(M_m * M_m) / d) * h)) * Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if ((M_m * D_m) <= 5e+71)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = ((((D_m * D_m) * -0.125) / l) * (((M_m * M_m) / d) * h)) * (d / sqrt((l * h)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+71], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+71}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\left(D\_m \cdot D\_m\right) \cdot -0.125}{\ell} \cdot \left(\frac{M\_m \cdot M\_m}{d} \cdot h\right)\right) \cdot \frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 M D) < 4.99999999999999972e71Initial program 73.1%
Applied rewrites58.3%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6454.2
Applied rewrites54.2%
if 4.99999999999999972e71 < (*.f64 M D) Initial program 58.1%
Applied rewrites24.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
lift-/.f64N/A
metadata-evalN/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6424.9
Applied rewrites61.3%
Taylor expanded in d around 0
associate-*r/N/A
associate-*r*N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6447.8
Applied rewrites47.8%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= (* M_m D_m) 1e+78)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(/
(* (* (* M_m M_m) (* (/ (* D_m D_m) d) -0.125)) (sqrt (* l h)))
(* l l))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 1e+78) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (((M_m * M_m) * (((D_m * D_m) / d) * -0.125)) * sqrt((l * h))) / (l * l);
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if ((m_m * d_m) <= 1d+78) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = (((m_m * m_m) * (((d_m * d_m) / d) * (-0.125d0))) * sqrt((l * h))) / (l * l)
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 1e+78) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = (((M_m * M_m) * (((D_m * D_m) / d) * -0.125)) * Math.sqrt((l * h))) / (l * l);
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if (M_m * D_m) <= 1e+78: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = (((M_m * M_m) * (((D_m * D_m) / d) * -0.125)) * math.sqrt((l * h))) / (l * l) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (Float64(M_m * D_m) <= 1e+78) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(Float64(Float64(M_m * M_m) * Float64(Float64(Float64(D_m * D_m) / d) * -0.125)) * sqrt(Float64(l * h))) / Float64(l * l)); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if ((M_m * D_m) <= 1e+78)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = (((M_m * M_m) * (((D_m * D_m) / d) * -0.125)) * sqrt((l * h))) / (l * l);
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e+78], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{+78}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(M\_m \cdot M\_m\right) \cdot \left(\frac{D\_m \cdot D\_m}{d} \cdot -0.125\right)\right) \cdot \sqrt{\ell \cdot h}}{\ell \cdot \ell}\\
\end{array}
\end{array}
if (*.f64 M D) < 1.00000000000000001e78Initial program 73.1%
Applied rewrites58.3%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
unpow2N/A
rem-square-sqrtN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
remove-double-negN/A
*-rgt-identityN/A
lower-sqrt.f64N/A
lower-/.f6454.2
Applied rewrites54.2%
if 1.00000000000000001e78 < (*.f64 M D) Initial program 58.1%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites23.6%
Taylor expanded in d around 0
Applied rewrites29.2%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (/ d (sqrt (* l h))))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
return d / sqrt((l * h));
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
code = d / sqrt((l * h))
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
return d / Math.sqrt((l * h));
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): return d / math.sqrt((l * h))
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) return Float64(d / sqrt(Float64(l * h))) end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp = code(d, h, l, M_m, D_m)
tmp = d / sqrt((l * h));
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 70.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.0
Applied rewrites27.0%
Applied rewrites26.6%
Applied rewrites26.6%
herbie shell --seed 2024353
(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)))))