
(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
(let* ((t_0 (pow (/ d l) (/ 1.0 2.0)))
(t_1 (* (/ (/ D_m d) 2.0) M_m))
(t_2 (- 1.0 (/ (* t_1 (* t_1 (* 0.5 h))) l)))
(t_3 (pow (/ h l) 0.75)))
(if (<= d -7.6e-106)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_2)
(if (<= d 2.1e-181)
(/
(fma
(* -0.125 D_m)
(* D_m (* t_3 (* t_3 (* (/ M_m d) M_m))))
(* (sqrt (/ h l)) d))
h)
(* (* (/ (sqrt d) (sqrt h)) t_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 = pow((d / l), (1.0 / 2.0));
double t_1 = ((D_m / d) / 2.0) * M_m;
double t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l);
double t_3 = pow((h / l), 0.75);
double tmp;
if (d <= -7.6e-106) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
} else if (d <= 2.1e-181) {
tmp = fma((-0.125 * D_m), (D_m * (t_3 * (t_3 * ((M_m / d) * M_m)))), (sqrt((h / l)) * d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * t_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(d / l) ^ Float64(1.0 / 2.0) t_1 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_2 = Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * Float64(0.5 * h))) / l)) t_3 = Float64(h / l) ^ 0.75 tmp = 0.0 if (d <= -7.6e-106) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_2); elseif (d <= 2.1e-181) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(D_m * Float64(t_3 * Float64(t_3 * Float64(Float64(M_m / d) * M_m)))), Float64(sqrt(Float64(h / l)) * d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * t_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[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(h / l), $MachinePrecision], 0.75], $MachinePrecision]}, If[LessEqual[d, -7.6e-106], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[d, 2.1e-181], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(D$95$m * N[(t$95$3 * N[(t$95$3 * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $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 := {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\\
t_1 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_2 := 1 - \frac{t\_1 \cdot \left(t\_1 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_3 := {\left(\frac{h}{\ell}\right)}^{0.75}\\
\mathbf{if}\;d \leq -7.6 \cdot 10^{-106}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_2\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{-181}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, D\_m \cdot \left(t\_3 \cdot \left(t\_3 \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right)\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\right) \cdot t\_2\\
\end{array}
\end{array}
if d < -7.5999999999999999e-106Initial program 78.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6479.4
lift-/.f64N/A
metadata-eval79.4
Applied rewrites79.4%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites83.5%
lift-/.f64N/A
metadata-eval83.5
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6491.4
Applied rewrites91.4%
if -7.5999999999999999e-106 < d < 2.10000000000000003e-181Initial program 42.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6440.9
lift-/.f64N/A
metadata-eval40.9
Applied rewrites40.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites42.3%
Applied rewrites57.6%
Applied rewrites62.3%
if 2.10000000000000003e-181 < d Initial program 78.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.1
lift-/.f64N/A
metadata-eval80.1
Applied rewrites80.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites82.2%
lift-/.f64N/A
metadata-eval82.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.8
Applied rewrites91.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) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -5e-115)
(/ (* (- d) (sqrt (/ h l))) h)
(if (<= t_0 0.0)
(* (- (sqrt (/ 1.0 (* l h)))) d)
(* (sqrt (/ d h)) (sqrt (/ d l)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-115) {
tmp = (-d * sqrt((h / l))) / h;
} else if (t_0 <= 0.0) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = sqrt((d / h)) * sqrt((d / l));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d-115)) then
tmp = (-d * sqrt((h / l))) / h
else if (t_0 <= 0.0d0) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = sqrt((d / h)) * sqrt((d / l))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-115) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else if (t_0 <= 0.0) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e-115: tmp = (-d * math.sqrt((h / l))) / h elif t_0 <= 0.0: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e-115) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); elseif (t_0 <= 0.0) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e-115)
tmp = (-d * sqrt((h / l))) / h;
elseif (t_0 <= 0.0)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = sqrt((d / h)) * sqrt((d / l));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-115], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-115}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.0000000000000003e-115Initial program 89.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6486.5
lift-/.f64N/A
metadata-eval86.5
Applied rewrites86.5%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites45.7%
Taylor expanded in l around -inf
Applied rewrites27.3%
if -5.0000000000000003e-115 < (*.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 37.0%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.1
Applied rewrites49.1%
Taylor expanded in h around -inf
Applied rewrites67.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)))) Initial program 61.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites60.3%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval60.3
Applied rewrites60.3%
Taylor expanded in d around -inf
associate-*r*N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
*-lft-identityN/A
lower-sqrt.f64N/A
lower-/.f6463.7
Applied rewrites63.7%
Final simplification51.7%
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 l) (/ 1.0 2.0)))
(t_1 (* (/ (/ D_m d) 2.0) M_m))
(t_2 (- 1.0 (/ (* t_1 (* t_1 (* 0.5 h))) l))))
(if (<= d -7.6e-106)
(* (* (/ (sqrt (- d)) (sqrt (- h))) t_0) t_2)
(if (<= d 1.6e-185)
(/
(fma
(* -0.125 D_m)
(* (* (pow (/ h l) 1.5) (/ M_m d)) (* M_m D_m))
(* (sqrt (/ h l)) d))
h)
(* (* (/ (sqrt d) (sqrt h)) t_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 = pow((d / l), (1.0 / 2.0));
double t_1 = ((D_m / d) / 2.0) * M_m;
double t_2 = 1.0 - ((t_1 * (t_1 * (0.5 * h))) / l);
double tmp;
if (d <= -7.6e-106) {
tmp = ((sqrt(-d) / sqrt(-h)) * t_0) * t_2;
} else if (d <= 1.6e-185) {
tmp = fma((-0.125 * D_m), ((pow((h / l), 1.5) * (M_m / d)) * (M_m * D_m)), (sqrt((h / l)) * d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * t_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(d / l) ^ Float64(1.0 / 2.0) t_1 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_2 = Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * Float64(0.5 * h))) / l)) tmp = 0.0 if (d <= -7.6e-106) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * t_0) * t_2); elseif (d <= 1.6e-185) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(Float64((Float64(h / l) ^ 1.5) * Float64(M_m / d)) * Float64(M_m * D_m)), Float64(sqrt(Float64(h / l)) * d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * t_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[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.6e-106], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[d, 1.6e-185], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $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 := {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\\
t_1 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_2 := 1 - \frac{t\_1 \cdot \left(t\_1 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
\mathbf{if}\;d \leq -7.6 \cdot 10^{-106}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot t\_0\right) \cdot t\_2\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-185}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, \left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{M\_m}{d}\right) \cdot \left(M\_m \cdot D\_m\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_0\right) \cdot t\_2\\
\end{array}
\end{array}
if d < -7.5999999999999999e-106Initial program 78.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6479.4
lift-/.f64N/A
metadata-eval79.4
Applied rewrites79.4%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites83.5%
lift-/.f64N/A
metadata-eval83.5
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6491.4
Applied rewrites91.4%
if -7.5999999999999999e-106 < d < 1.5999999999999999e-185Initial program 42.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6440.9
lift-/.f64N/A
metadata-eval40.9
Applied rewrites40.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites42.3%
Applied rewrites57.6%
Applied rewrites59.3%
if 1.5999999999999999e-185 < d Initial program 78.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.1
lift-/.f64N/A
metadata-eval80.1
Applied rewrites80.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites82.2%
lift-/.f64N/A
metadata-eval82.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.8
Applied rewrites91.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 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l))))
(if (<= d -2.05e-197)
(* (* (- d) (sqrt (/ 1.0 (* l h)))) t_1)
(if (<= d 1.6e-185)
(/
(fma
(* -0.125 D_m)
(* (* (pow (/ h l) 1.5) (/ M_m d)) (* M_m D_m))
(* (sqrt (/ h l)) d))
h)
(* (* (/ (sqrt d) (sqrt h)) (pow (/ d l) (/ 1.0 2.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 = ((D_m / d) / 2.0) * M_m;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double tmp;
if (d <= -2.05e-197) {
tmp = (-d * sqrt((1.0 / (l * h)))) * t_1;
} else if (d <= 1.6e-185) {
tmp = fma((-0.125 * D_m), ((pow((h / l), 1.5) * (M_m / d)) * (M_m * D_m)), (sqrt((h / l)) * d)) / h;
} else {
tmp = ((sqrt(d) / sqrt(h)) * pow((d / l), (1.0 / 2.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_m / d) / 2.0) * M_m) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) tmp = 0.0 if (d <= -2.05e-197) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))) * t_1); elseif (d <= 1.6e-185) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(Float64((Float64(h / l) ^ 1.5) * Float64(M_m / d)) * Float64(M_m * D_m)), Float64(sqrt(Float64(h / l)) * d)) / h); else tmp = Float64(Float64(Float64(sqrt(d) / sqrt(h)) * (Float64(d / l) ^ Float64(1.0 / 2.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[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.05e-197], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 1.6e-185], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.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 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{-197}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-185}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, \left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{M\_m}{d}\right) \cdot \left(M\_m \cdot D\_m\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_1\\
\end{array}
\end{array}
if d < -2.05e-197Initial program 75.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6475.7
lift-/.f64N/A
metadata-eval75.7
Applied rewrites75.7%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites79.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -2.05e-197 < d < 1.5999999999999999e-185Initial program 32.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6430.0
lift-/.f64N/A
metadata-eval30.0
Applied rewrites30.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites36.8%
Applied rewrites51.2%
Applied rewrites53.6%
if 1.5999999999999999e-185 < d Initial program 78.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.1
lift-/.f64N/A
metadata-eval80.1
Applied rewrites80.1%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites82.2%
lift-/.f64N/A
metadata-eval82.2
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6491.8
Applied rewrites91.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 (sqrt (/ 1.0 (* l h)))))
(if (<= d -2.05e-197)
(* (* (- d) t_1) (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(if (<= d 2.05e-178)
(/
(fma
(* -0.125 D_m)
(* (* (pow (/ h l) 1.5) (/ M_m d)) (* M_m D_m))
(* (sqrt (/ h l)) d))
h)
(if (<= d 1.55e+38)
(*
(* t_1 d)
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M_m d)) 2.0) (* 0.5 h)) l)))
(/
(*
(sqrt d)
(* (fma (* (/ h l) -0.5) (pow t_0 2.0) 1.0) (sqrt (/ d l))))
(sqrt h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= -2.05e-197) {
tmp = (-d * t_1) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else if (d <= 2.05e-178) {
tmp = fma((-0.125 * D_m), ((pow((h / l), 1.5) * (M_m / d)) * (M_m * D_m)), (sqrt((h / l)) * d)) / h;
} else if (d <= 1.55e+38) {
tmp = (t_1 * d) * (1.0 - ((pow(((D_m / 2.0) * (M_m / d)), 2.0) * (0.5 * h)) / l));
} else {
tmp = (sqrt(d) * (fma(((h / l) * -0.5), pow(t_0, 2.0), 1.0) * sqrt((d / l)))) / sqrt(h);
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= -2.05e-197) tmp = Float64(Float64(Float64(-d) * t_1) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l))); elseif (d <= 2.05e-178) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(Float64((Float64(h / l) ^ 1.5) * Float64(M_m / d)) * Float64(M_m * D_m)), Float64(sqrt(Float64(h / l)) * d)) / h); elseif (d <= 1.55e+38) tmp = Float64(Float64(t_1 * d) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0) * Float64(0.5 * h)) / l))); else tmp = Float64(Float64(sqrt(d) * Float64(fma(Float64(Float64(h / l) * -0.5), (t_0 ^ 2.0), 1.0) * sqrt(Float64(d / l)))) / sqrt(h)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.05e-197], N[(N[((-d) * t$95$1), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.05e-178], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[d, 1.55e+38], N[(N[(t$95$1 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] * N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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} \cdot M\_m\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{-197}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_1\right) \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{elif}\;d \leq 2.05 \cdot 10^{-178}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, \left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{M\_m}{d}\right) \cdot \left(M\_m \cdot D\_m\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{+38}:\\
\;\;\;\;\left(t\_1 \cdot d\right) \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {t\_0}^{2}, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right)}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -2.05e-197Initial program 75.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6475.7
lift-/.f64N/A
metadata-eval75.7
Applied rewrites75.7%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites79.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -2.05e-197 < d < 2.05e-178Initial program 34.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6431.7
lift-/.f64N/A
metadata-eval31.7
Applied rewrites31.7%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites38.2%
Applied rewrites52.3%
Applied rewrites54.6%
if 2.05e-178 < d < 1.55000000000000009e38Initial program 68.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6468.6
lift-/.f64N/A
metadata-eval68.6
Applied rewrites68.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6478.9
Applied rewrites78.9%
if 1.55000000000000009e38 < d Initial program 83.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6486.9
lift-/.f64N/A
metadata-eval86.9
Applied rewrites86.9%
Applied rewrites96.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) M_m)))
(if (<= d -2.05e-197)
(*
(* (- d) (sqrt (/ 1.0 (* l h))))
(- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(if (<= d 1.6e-185)
(/
(fma
(* -0.125 D_m)
(* (* (pow (/ h l) 1.5) (/ M_m d)) (* M_m D_m))
(* (sqrt (/ h l)) d))
h)
(*
(* (sqrt d) (/ (sqrt (/ d l)) (sqrt h)))
(- 1.0 (/ (* (pow (* (/ D_m 2.0) (/ M_m d)) 2.0) (* 0.5 h)) l)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double tmp;
if (d <= -2.05e-197) {
tmp = (-d * sqrt((1.0 / (l * h)))) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else if (d <= 1.6e-185) {
tmp = fma((-0.125 * D_m), ((pow((h / l), 1.5) * (M_m / d)) * (M_m * D_m)), (sqrt((h / l)) * d)) / h;
} else {
tmp = (sqrt(d) * (sqrt((d / l)) / sqrt(h))) * (1.0 - ((pow(((D_m / 2.0) * (M_m / d)), 2.0) * (0.5 * h)) / l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) tmp = 0.0 if (d <= -2.05e-197) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l))); elseif (d <= 1.6e-185) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(Float64((Float64(h / l) ^ 1.5) * Float64(M_m / d)) * Float64(M_m * D_m)), Float64(sqrt(Float64(h / l)) * d)) / h); else tmp = Float64(Float64(sqrt(d) * Float64(sqrt(Float64(d / l)) / sqrt(h))) * Float64(1.0 - Float64(Float64((Float64(Float64(D_m / 2.0) * Float64(M_m / d)) ^ 2.0) * Float64(0.5 * h)) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, If[LessEqual[d, -2.05e-197], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e-185], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{-197}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{-185}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, \left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{M\_m}{d}\right) \cdot \left(M\_m \cdot D\_m\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{d} \cdot \frac{\sqrt{\frac{d}{\ell}}}{\sqrt{h}}\right) \cdot \left(1 - \frac{{\left(\frac{D\_m}{2} \cdot \frac{M\_m}{d}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -2.05e-197Initial program 75.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6475.7
lift-/.f64N/A
metadata-eval75.7
Applied rewrites75.7%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites79.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -2.05e-197 < d < 1.5999999999999999e-185Initial program 32.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6430.0
lift-/.f64N/A
metadata-eval30.0
Applied rewrites30.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites36.8%
Applied rewrites51.2%
Applied rewrites53.6%
if 1.5999999999999999e-185 < d Initial program 78.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.1
lift-/.f64N/A
metadata-eval80.1
Applied rewrites80.1%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
lift-/.f64N/A
sqrt-divN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6489.7
lift-/.f64N/A
metadata-eval89.7
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6489.7
Applied rewrites89.7%
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 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (* (/ M_m d) D_m))
(t_3 (sqrt (/ 1.0 (* l h)))))
(if (<= d -2.05e-197)
(* (* (- d) t_3) t_1)
(if (<= d 2e-178)
(/
(fma
(* -0.125 D_m)
(* (* (pow (/ h l) 1.5) (/ M_m d)) (* M_m D_m))
(* (sqrt (/ h l)) d))
h)
(if (<= d 7e+172)
(* (* t_3 d) t_1)
(*
(* (fma (* -0.5 (/ (* t_2 t_2) 4.0)) (/ h l) 1.0) (sqrt (/ d h)))
(/ (sqrt d) (sqrt l))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = (M_m / d) * D_m;
double t_3 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= -2.05e-197) {
tmp = (-d * t_3) * t_1;
} else if (d <= 2e-178) {
tmp = fma((-0.125 * D_m), ((pow((h / l), 1.5) * (M_m / d)) * (M_m * D_m)), (sqrt((h / l)) * d)) / h;
} else if (d <= 7e+172) {
tmp = (t_3 * d) * t_1;
} else {
tmp = (fma((-0.5 * ((t_2 * t_2) / 4.0)), (h / l), 1.0) * sqrt((d / h))) * (sqrt(d) / sqrt(l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = Float64(Float64(M_m / d) * D_m) t_3 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= -2.05e-197) tmp = Float64(Float64(Float64(-d) * t_3) * t_1); elseif (d <= 2e-178) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(Float64((Float64(h / l) ^ 1.5) * Float64(M_m / d)) * Float64(M_m * D_m)), Float64(sqrt(Float64(h / l)) * d)) / h); elseif (d <= 7e+172) tmp = Float64(Float64(t_3 * d) * t_1); else tmp = Float64(Float64(fma(Float64(-0.5 * Float64(Float64(t_2 * t_2) / 4.0)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * Float64(sqrt(d) / sqrt(l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.05e-197], N[(N[((-d) * t$95$3), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 2e-178], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[d, 7e+172], N[(N[(t$95$3 * d), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(-0.5 * N[(N[(t$95$2 * t$95$2), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \frac{M\_m}{d} \cdot D\_m\\
t_3 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{-197}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_3\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 2 \cdot 10^{-178}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, \left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{M\_m}{d}\right) \cdot \left(M\_m \cdot D\_m\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+172}:\\
\;\;\;\;\left(t\_3 \cdot d\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot \frac{t\_2 \cdot t\_2}{4}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if d < -2.05e-197Initial program 75.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6475.7
lift-/.f64N/A
metadata-eval75.7
Applied rewrites75.7%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites79.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -2.05e-197 < d < 1.9999999999999999e-178Initial program 34.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6431.7
lift-/.f64N/A
metadata-eval31.7
Applied rewrites31.7%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites38.2%
Applied rewrites52.3%
Applied rewrites54.6%
if 1.9999999999999999e-178 < d < 6.99999999999999955e172Initial program 72.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6473.0
lift-/.f64N/A
metadata-eval73.0
Applied rewrites73.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites76.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.5
Applied rewrites84.5%
if 6.99999999999999955e172 < d Initial program 89.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites92.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval92.7
Applied rewrites92.7%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6492.9
Applied rewrites92.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) M_m))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (* (/ M_m d) D_m))
(t_3 (sqrt (/ 1.0 (* l h)))))
(if (<= d -1.3e-197)
(* (* (- d) t_3) t_1)
(if (<= d 1.35e-179)
(/
(fma
(* -0.125 D_m)
(* D_m (* (pow (/ h l) 1.5) (* (/ M_m d) M_m)))
(* (sqrt (/ h l)) d))
h)
(if (<= d 7e+172)
(* (* t_3 d) t_1)
(*
(* (fma (* -0.5 (/ (* t_2 t_2) 4.0)) (/ h l) 1.0) (sqrt (/ d h)))
(/ (sqrt d) (sqrt l))))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = (M_m / d) * D_m;
double t_3 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= -1.3e-197) {
tmp = (-d * t_3) * t_1;
} else if (d <= 1.35e-179) {
tmp = fma((-0.125 * D_m), (D_m * (pow((h / l), 1.5) * ((M_m / d) * M_m))), (sqrt((h / l)) * d)) / h;
} else if (d <= 7e+172) {
tmp = (t_3 * d) * t_1;
} else {
tmp = (fma((-0.5 * ((t_2 * t_2) / 4.0)), (h / l), 1.0) * sqrt((d / h))) * (sqrt(d) / sqrt(l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = Float64(Float64(M_m / d) * D_m) t_3 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= -1.3e-197) tmp = Float64(Float64(Float64(-d) * t_3) * t_1); elseif (d <= 1.35e-179) tmp = Float64(fma(Float64(-0.125 * D_m), Float64(D_m * Float64((Float64(h / l) ^ 1.5) * Float64(Float64(M_m / d) * M_m))), Float64(sqrt(Float64(h / l)) * d)) / h); elseif (d <= 7e+172) tmp = Float64(Float64(t_3 * d) * t_1); else tmp = Float64(Float64(fma(Float64(-0.5 * Float64(Float64(t_2 * t_2) / 4.0)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * Float64(sqrt(d) / sqrt(l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -1.3e-197], N[(N[((-d) * t$95$3), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 1.35e-179], N[(N[(N[(-0.125 * D$95$m), $MachinePrecision] * N[(D$95$m * N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(N[(M$95$m / d), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[d, 7e+172], N[(N[(t$95$3 * d), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(-0.5 * N[(N[(t$95$2 * t$95$2), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \frac{M\_m}{d} \cdot D\_m\\
t_3 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{-197}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_3\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 1.35 \cdot 10^{-179}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot D\_m, D\_m \cdot \left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \left(\frac{M\_m}{d} \cdot M\_m\right)\right), \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+172}:\\
\;\;\;\;\left(t\_3 \cdot d\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot \frac{t\_2 \cdot t\_2}{4}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if d < -1.3000000000000001e-197Initial program 75.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6475.7
lift-/.f64N/A
metadata-eval75.7
Applied rewrites75.7%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites79.0%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if -1.3000000000000001e-197 < d < 1.34999999999999994e-179Initial program 34.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6431.7
lift-/.f64N/A
metadata-eval31.7
Applied rewrites31.7%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites38.2%
Applied rewrites52.3%
if 1.34999999999999994e-179 < d < 6.99999999999999955e172Initial program 72.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6473.0
lift-/.f64N/A
metadata-eval73.0
Applied rewrites73.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites76.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.5
Applied rewrites84.5%
if 6.99999999999999955e172 < d Initial program 89.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites92.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval92.7
Applied rewrites92.7%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6492.9
Applied rewrites92.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) M_m))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (* (/ M_m d) D_m))
(t_3 (sqrt (/ 1.0 (* l h)))))
(if (<= l -5e-310)
(* (* (- d) t_3) t_1)
(if (<= l 6.2e+36)
(* (* t_3 d) t_1)
(*
(* (fma (* -0.5 (/ (* t_2 t_2) 4.0)) (/ h l) 1.0) (sqrt (/ d h)))
(/ (sqrt d) (sqrt l)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = (M_m / d) * D_m;
double t_3 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-d * t_3) * t_1;
} else if (l <= 6.2e+36) {
tmp = (t_3 * d) * t_1;
} else {
tmp = (fma((-0.5 * ((t_2 * t_2) / 4.0)), (h / l), 1.0) * sqrt((d / h))) * (sqrt(d) / sqrt(l));
}
return tmp;
}
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = Float64(Float64(M_m / d) * D_m) t_3 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-d) * t_3) * t_1); elseif (l <= 6.2e+36) tmp = Float64(Float64(t_3 * d) * t_1); else tmp = Float64(Float64(fma(Float64(-0.5 * Float64(Float64(t_2 * t_2) / 4.0)), Float64(h / l), 1.0) * sqrt(Float64(d / h))) * Float64(sqrt(d) / sqrt(l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[((-d) * t$95$3), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 6.2e+36], N[(N[(t$95$3 * d), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(-0.5 * N[(N[(t$95$2 * t$95$2), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \frac{M\_m}{d} \cdot D\_m\\
t_3 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_3\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 6.2 \cdot 10^{+36}:\\
\;\;\;\;\left(t\_3 \cdot d\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5 \cdot \frac{t\_2 \cdot t\_2}{4}, \frac{h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 68.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6468.5
lift-/.f64N/A
metadata-eval68.5
Applied rewrites68.5%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites71.2%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.7
Applied rewrites80.7%
if -4.999999999999985e-310 < l < 6.1999999999999999e36Initial program 75.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.0
lift-/.f64N/A
metadata-eval80.0
Applied rewrites80.0%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites80.3%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6485.0
Applied rewrites85.0%
if 6.1999999999999999e36 < l Initial program 63.5%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites61.7%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval61.7
Applied rewrites61.7%
lift-sqrt.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6470.8
Applied rewrites70.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 (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(t_2 (sqrt (/ 1.0 (* l h)))))
(if (<= l -5e-310)
(* (* (- d) t_2) t_1)
(if (<= l 1.25e+138) (* (* t_2 d) t_1) (/ d (* (sqrt l) (sqrt h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-d * t_2) * t_1;
} else if (l <= 1.25e+138) {
tmp = (t_2 * d) * t_1;
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((d_m / d) / 2.0d0) * m_m
t_1 = 1.0d0 - ((t_0 * (t_0 * (0.5d0 * h))) / l)
t_2 = sqrt((1.0d0 / (l * h)))
if (l <= (-5d-310)) then
tmp = (-d * t_2) * t_1
else if (l <= 1.25d+138) then
tmp = (t_2 * d) * t_1
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
double t_2 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-d * t_2) * t_1;
} else if (l <= 1.25e+138) {
tmp = (t_2 * d) * t_1;
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = ((D_m / d) / 2.0) * M_m t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l) t_2 = math.sqrt((1.0 / (l * h))) tmp = 0 if l <= -5e-310: tmp = (-d * t_2) * t_1 elif l <= 1.25e+138: tmp = (t_2 * d) * t_1 else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l)) t_2 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-d) * t_2) * t_1); elseif (l <= 1.25e+138) tmp = Float64(Float64(t_2 * d) * t_1); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = ((D_m / d) / 2.0) * M_m;
t_1 = 1.0 - ((t_0 * (t_0 * (0.5 * h))) / l);
t_2 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (l <= -5e-310)
tmp = (-d * t_2) * t_1;
elseif (l <= 1.25e+138)
tmp = (t_2 * d) * t_1;
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[((-d) * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[l, 1.25e+138], N[(N[(t$95$2 * d), $MachinePrecision] * t$95$1), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\\
t_2 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_2\right) \cdot t\_1\\
\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{+138}:\\
\;\;\;\;\left(t\_2 \cdot d\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 68.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6468.5
lift-/.f64N/A
metadata-eval68.5
Applied rewrites68.5%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites71.2%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6480.7
Applied rewrites80.7%
if -4.999999999999985e-310 < l < 1.25000000000000004e138Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.9
lift-/.f64N/A
metadata-eval80.9
Applied rewrites80.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if 1.25000000000000004e138 < l Initial program 53.5%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.8
Applied rewrites45.8%
Applied rewrites45.8%
Applied rewrites45.7%
Applied rewrites64.3%
Final simplification79.6%
D_m = (fabs.f64 D)
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* (/ (/ D_m d) 2.0) M_m)) (t_1 (sqrt (/ 1.0 (* l h)))))
(if (<= l -5e-310)
(* (* (- t_1) d) (- 1.0 (* (* t_0 (* 0.25 (* (/ M_m d) D_m))) (/ h l))))
(if (<= l 1.25e+138)
(* (* t_1 d) (- 1.0 (/ (* t_0 (* t_0 (* 0.5 h))) l)))
(/ d (* (sqrt l) (sqrt h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-t_1 * d) * (1.0 - ((t_0 * (0.25 * ((M_m / d) * D_m))) * (h / l)));
} else if (l <= 1.25e+138) {
tmp = (t_1 * d) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((d_m / d) / 2.0d0) * m_m
t_1 = sqrt((1.0d0 / (l * h)))
if (l <= (-5d-310)) then
tmp = (-t_1 * d) * (1.0d0 - ((t_0 * (0.25d0 * ((m_m / d) * d_m))) * (h / l)))
else if (l <= 1.25d+138) then
tmp = (t_1 * d) * (1.0d0 - ((t_0 * (t_0 * (0.5d0 * h))) / l))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = ((D_m / d) / 2.0) * M_m;
double t_1 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-t_1 * d) * (1.0 - ((t_0 * (0.25 * ((M_m / d) * D_m))) * (h / l)));
} else if (l <= 1.25e+138) {
tmp = (t_1 * d) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = ((D_m / d) / 2.0) * M_m t_1 = math.sqrt((1.0 / (l * h))) tmp = 0 if l <= -5e-310: tmp = (-t_1 * d) * (1.0 - ((t_0 * (0.25 * ((M_m / d) * D_m))) * (h / l))) elif l <= 1.25e+138: tmp = (t_1 * d) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(Float64(D_m / d) / 2.0) * M_m) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-t_1) * d) * Float64(1.0 - Float64(Float64(t_0 * Float64(0.25 * Float64(Float64(M_m / d) * D_m))) * Float64(h / l)))); elseif (l <= 1.25e+138) tmp = Float64(Float64(t_1 * d) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(0.5 * h))) / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = ((D_m / d) / 2.0) * M_m;
t_1 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (l <= -5e-310)
tmp = (-t_1 * d) * (1.0 - ((t_0 * (0.25 * ((M_m / d) * D_m))) * (h / l)));
elseif (l <= 1.25e+138)
tmp = (t_1 * d) * (1.0 - ((t_0 * (t_0 * (0.5 * h))) / l));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[((-t$95$1) * d), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(0.25 * N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.25e+138], N[(N[(t$95$1 * d), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(0.5 * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2} \cdot M\_m\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-t\_1\right) \cdot d\right) \cdot \left(1 - \left(t\_0 \cdot \left(0.25 \cdot \left(\frac{M\_m}{d} \cdot D\_m\right)\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{+138}:\\
\;\;\;\;\left(t\_1 \cdot d\right) \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(0.5 \cdot h\right)\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 68.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.9
Applied rewrites2.9%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
Applied rewrites2.9%
Taylor expanded in d around 0
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f642.9
Applied rewrites2.9%
Taylor expanded in h around -inf
Applied rewrites70.7%
if -4.999999999999985e-310 < l < 1.25000000000000004e138Initial program 77.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6480.9
lift-/.f64N/A
metadata-eval80.9
Applied rewrites80.9%
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites82.2%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6484.6
Applied rewrites84.6%
if 1.25000000000000004e138 < l Initial program 53.5%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.8
Applied rewrites45.8%
Applied rewrites45.8%
Applied rewrites45.7%
Applied rewrites64.3%
Final simplification74.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
(let* ((t_0 (/ (/ D_m d) 2.0)) (t_1 (sqrt (/ 1.0 (* l h)))))
(if (<= l -5e-310)
(*
(* (- t_1) d)
(- 1.0 (* (* (* t_0 M_m) (* 0.25 (* (/ M_m d) D_m))) (/ h l))))
(if (<= l 1.25e+138)
(*
(* t_1 d)
(- 1.0 (/ (* (* (* 0.25 D_m) (/ M_m d)) (* (* M_m t_0) h)) l)))
(/ d (* (sqrt l) (sqrt h)))))))D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-t_1 * d) * (1.0 - (((t_0 * M_m) * (0.25 * ((M_m / d) * D_m))) * (h / l)));
} else if (l <= 1.25e+138) {
tmp = (t_1 * d) * (1.0 - ((((0.25 * D_m) * (M_m / d)) * ((M_m * t_0) * h)) / l));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_m / d) / 2.0d0
t_1 = sqrt((1.0d0 / (l * h)))
if (l <= (-5d-310)) then
tmp = (-t_1 * d) * (1.0d0 - (((t_0 * m_m) * (0.25d0 * ((m_m / d) * d_m))) * (h / l)))
else if (l <= 1.25d+138) then
tmp = (t_1 * d) * (1.0d0 - ((((0.25d0 * d_m) * (m_m / d)) * ((m_m * t_0) * h)) / l))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (D_m / d) / 2.0;
double t_1 = Math.sqrt((1.0 / (l * h)));
double tmp;
if (l <= -5e-310) {
tmp = (-t_1 * d) * (1.0 - (((t_0 * M_m) * (0.25 * ((M_m / d) * D_m))) * (h / l)));
} else if (l <= 1.25e+138) {
tmp = (t_1 * d) * (1.0 - ((((0.25 * D_m) * (M_m / d)) * ((M_m * t_0) * h)) / l));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (D_m / d) / 2.0 t_1 = math.sqrt((1.0 / (l * h))) tmp = 0 if l <= -5e-310: tmp = (-t_1 * d) * (1.0 - (((t_0 * M_m) * (0.25 * ((M_m / d) * D_m))) * (h / l))) elif l <= 1.25e+138: tmp = (t_1 * d) * (1.0 - ((((0.25 * D_m) * (M_m / d)) * ((M_m * t_0) * h)) / l)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64(D_m / d) / 2.0) t_1 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(-t_1) * d) * Float64(1.0 - Float64(Float64(Float64(t_0 * M_m) * Float64(0.25 * Float64(Float64(M_m / d) * D_m))) * Float64(h / l)))); elseif (l <= 1.25e+138) tmp = Float64(Float64(t_1 * d) * Float64(1.0 - Float64(Float64(Float64(Float64(0.25 * D_m) * Float64(M_m / d)) * Float64(Float64(M_m * t_0) * h)) / l))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (D_m / d) / 2.0;
t_1 = sqrt((1.0 / (l * h)));
tmp = 0.0;
if (l <= -5e-310)
tmp = (-t_1 * d) * (1.0 - (((t_0 * M_m) * (0.25 * ((M_m / d) * D_m))) * (h / l)));
elseif (l <= 1.25e+138)
tmp = (t_1 * d) * (1.0 - ((((0.25 * D_m) * (M_m / d)) * ((M_m * t_0) * h)) / l));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-310], N[(N[((-t$95$1) * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * M$95$m), $MachinePrecision] * N[(0.25 * N[(N[(M$95$m / d), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.25e+138], N[(N[(t$95$1 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(0.25 * D$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * t$95$0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{D\_m}{d}}{2}\\
t_1 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-t\_1\right) \cdot d\right) \cdot \left(1 - \left(\left(t\_0 \cdot M\_m\right) \cdot \left(0.25 \cdot \left(\frac{M\_m}{d} \cdot D\_m\right)\right)\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{+138}:\\
\;\;\;\;\left(t\_1 \cdot d\right) \cdot \left(1 - \frac{\left(\left(0.25 \cdot D\_m\right) \cdot \frac{M\_m}{d}\right) \cdot \left(\left(M\_m \cdot t\_0\right) \cdot h\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 68.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f642.9
Applied rewrites2.9%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
Applied rewrites2.9%
Taylor expanded in d around 0
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f642.9
Applied rewrites2.9%
Taylor expanded in h around -inf
Applied rewrites70.7%
if -4.999999999999985e-310 < l < 1.25000000000000004e138Initial program 77.0%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
Applied rewrites75.9%
Taylor expanded in d around 0
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.8
Applied rewrites75.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites84.4%
if 1.25000000000000004e138 < l Initial program 53.5%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.8
Applied rewrites45.8%
Applied rewrites45.8%
Applied rewrites45.7%
Applied rewrites64.3%
Final simplification74.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
(let* ((t_0 (sqrt (/ 1.0 (* l h)))))
(if (<= d -3.65e+127)
(* (- t_0) d)
(if (<= d -2.3e-200)
(*
(*
(fma (* (* M_m M_m) -0.125) (* (/ h (* d d)) (/ (* D_m D_m) l)) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(*
(* t_0 d)
(-
1.0
(/
(* (* (* 0.25 D_m) (/ M_m d)) (* (* M_m (/ (/ D_m 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 t_0 = sqrt((1.0 / (l * h)));
double tmp;
if (d <= -3.65e+127) {
tmp = -t_0 * d;
} else if (d <= -2.3e-200) {
tmp = (fma(((M_m * M_m) * -0.125), ((h / (d * d)) * ((D_m * D_m) / l)), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = (t_0 * d) * (1.0 - ((((0.25 * D_m) * (M_m / d)) * ((M_m * ((D_m / 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) t_0 = sqrt(Float64(1.0 / Float64(l * h))) tmp = 0.0 if (d <= -3.65e+127) tmp = Float64(Float64(-t_0) * d); elseif (d <= -2.3e-200) tmp = Float64(Float64(fma(Float64(Float64(M_m * M_m) * -0.125), Float64(Float64(h / Float64(d * d)) * Float64(Float64(D_m * D_m) / l)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64(Float64(0.25 * D_m) * Float64(M_m / d)) * Float64(Float64(M_m * Float64(Float64(D_m / d) / 2.0)) * h)) / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.65e+127], N[((-t$95$0) * d), $MachinePrecision], If[LessEqual[d, -2.3e-200], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(0.25 * D$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -3.65 \cdot 10^{+127}:\\
\;\;\;\;\left(-t\_0\right) \cdot d\\
\mathbf{elif}\;d \leq -2.3 \cdot 10^{-200}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(M\_m \cdot M\_m\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{D\_m \cdot D\_m}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{\left(\left(0.25 \cdot D\_m\right) \cdot \frac{M\_m}{d}\right) \cdot \left(\left(M\_m \cdot \frac{\frac{D\_m}{d}}{2}\right) \cdot h\right)}{\ell}\right)\\
\end{array}
\end{array}
if d < -3.6499999999999998e127Initial program 80.7%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f648.7
Applied rewrites8.7%
Taylor expanded in h around -inf
Applied rewrites70.8%
if -3.6499999999999998e127 < d < -2.30000000000000007e-200Initial program 72.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites71.5%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval71.5
Applied rewrites71.5%
Taylor expanded in M around inf
distribute-lft-inN/A
associate-*r*N/A
rgt-mult-inverseN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6454.3
Applied rewrites54.3%
if -2.30000000000000007e-200 < d Initial program 64.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.5
Applied rewrites58.5%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
Applied rewrites59.2%
Taylor expanded in d around 0
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6458.3
Applied rewrites58.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites63.4%
Final simplification61.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 (sqrt (/ 1.0 (* l h)))))
(if (<= d -3.65e+127)
(* (- t_0) d)
(if (<= d -2.3e-200)
(*
(*
(fma (* (* M_m M_m) -0.125) (* (/ h (* d d)) (/ (* D_m D_m) l)) 1.0)
(sqrt (/ d h)))
(sqrt (/ d l)))
(*
(* t_0 d)
(-
1.0
(/
(* (* M_m D_m) (* (/ h l) (* (* 0.25 D_m) (/ M_m d))))
(* 2.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((1.0 / (l * h)));
double tmp;
if (d <= -3.65e+127) {
tmp = -t_0 * d;
} else if (d <= -2.3e-200) {
tmp = (fma(((M_m * M_m) * -0.125), ((h / (d * d)) * ((D_m * D_m) / l)), 1.0) * sqrt((d / h))) * sqrt((d / l));
} else {
tmp = (t_0 * d) * (1.0 - (((M_m * D_m) * ((h / l) * ((0.25 * D_m) * (M_m / d)))) / (2.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(1.0 / Float64(l * h))) tmp = 0.0 if (d <= -3.65e+127) tmp = Float64(Float64(-t_0) * d); elseif (d <= -2.3e-200) tmp = Float64(Float64(fma(Float64(Float64(M_m * M_m) * -0.125), Float64(Float64(h / Float64(d * d)) * Float64(Float64(D_m * D_m) / l)), 1.0) * sqrt(Float64(d / h))) * sqrt(Float64(d / l))); else tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64(M_m * D_m) * Float64(Float64(h / l) * Float64(Float64(0.25 * D_m) * Float64(M_m / d)))) / Float64(2.0 * d)))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.65e+127], N[((-t$95$0) * d), $MachinePrecision], If[LessEqual[d, -2.3e-200], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(h / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * D$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(N[(0.25 * D$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $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 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq -3.65 \cdot 10^{+127}:\\
\;\;\;\;\left(-t\_0\right) \cdot d\\
\mathbf{elif}\;d \leq -2.3 \cdot 10^{-200}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(M\_m \cdot M\_m\right) \cdot -0.125, \frac{h}{d \cdot d} \cdot \frac{D\_m \cdot D\_m}{\ell}, 1\right) \cdot \sqrt{\frac{d}{h}}\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \left(\frac{h}{\ell} \cdot \left(\left(0.25 \cdot D\_m\right) \cdot \frac{M\_m}{d}\right)\right)}{2 \cdot d}\right)\\
\end{array}
\end{array}
if d < -3.6499999999999998e127Initial program 80.7%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f648.7
Applied rewrites8.7%
Taylor expanded in h around -inf
Applied rewrites70.8%
if -3.6499999999999998e127 < d < -2.30000000000000007e-200Initial program 72.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites71.5%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-eval71.5
Applied rewrites71.5%
Taylor expanded in M around inf
distribute-lft-inN/A
associate-*r*N/A
rgt-mult-inverseN/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6454.3
Applied rewrites54.3%
if -2.30000000000000007e-200 < d Initial program 64.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6458.5
Applied rewrites58.5%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
Applied rewrites59.2%
Taylor expanded in d around 0
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6458.3
Applied rewrites58.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites59.5%
Final simplification59.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 (/ 1.0 (* l h)))))
(if (<= h 2.9e-303)
(* (- t_0) d)
(if (<= h 1.45e+221)
(*
(* t_0 d)
(-
1.0
(/ (* (* M_m D_m) (* (/ h l) (* (* 0.25 D_m) (/ M_m d)))) (* 2.0 d))))
(* (/ (/ 1.0 (sqrt l)) (sqrt h)) 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((1.0 / (l * h)));
double tmp;
if (h <= 2.9e-303) {
tmp = -t_0 * d;
} else if (h <= 1.45e+221) {
tmp = (t_0 * d) * (1.0 - (((M_m * D_m) * ((h / l) * ((0.25 * D_m) * (M_m / d)))) / (2.0 * d)));
} else {
tmp = ((1.0 / sqrt(l)) / sqrt(h)) * 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((1.0d0 / (l * h)))
if (h <= 2.9d-303) then
tmp = -t_0 * d
else if (h <= 1.45d+221) then
tmp = (t_0 * d) * (1.0d0 - (((m_m * d_m) * ((h / l) * ((0.25d0 * d_m) * (m_m / d)))) / (2.0d0 * d)))
else
tmp = ((1.0d0 / sqrt(l)) / sqrt(h)) * 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((1.0 / (l * h)));
double tmp;
if (h <= 2.9e-303) {
tmp = -t_0 * d;
} else if (h <= 1.45e+221) {
tmp = (t_0 * d) * (1.0 - (((M_m * D_m) * ((h / l) * ((0.25 * D_m) * (M_m / d)))) / (2.0 * d)));
} else {
tmp = ((1.0 / Math.sqrt(l)) / Math.sqrt(h)) * 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((1.0 / (l * h))) tmp = 0 if h <= 2.9e-303: tmp = -t_0 * d elif h <= 1.45e+221: tmp = (t_0 * d) * (1.0 - (((M_m * D_m) * ((h / l) * ((0.25 * D_m) * (M_m / d)))) / (2.0 * d))) else: tmp = ((1.0 / math.sqrt(l)) / math.sqrt(h)) * 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(1.0 / Float64(l * h))) tmp = 0.0 if (h <= 2.9e-303) tmp = Float64(Float64(-t_0) * d); elseif (h <= 1.45e+221) tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64(M_m * D_m) * Float64(Float64(h / l) * Float64(Float64(0.25 * D_m) * Float64(M_m / d)))) / Float64(2.0 * d)))); else tmp = Float64(Float64(Float64(1.0 / sqrt(l)) / sqrt(h)) * 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((1.0 / (l * h)));
tmp = 0.0;
if (h <= 2.9e-303)
tmp = -t_0 * d;
elseif (h <= 1.45e+221)
tmp = (t_0 * d) * (1.0 - (((M_m * D_m) * ((h / l) * ((0.25 * D_m) * (M_m / d)))) / (2.0 * d)));
else
tmp = ((1.0 / sqrt(l)) / sqrt(h)) * 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[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, 2.9e-303], N[((-t$95$0) * d), $MachinePrecision], If[LessEqual[h, 1.45e+221], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(N[(0.25 * D$95$m), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;h \leq 2.9 \cdot 10^{-303}:\\
\;\;\;\;\left(-t\_0\right) \cdot d\\
\mathbf{elif}\;h \leq 1.45 \cdot 10^{+221}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{\left(M\_m \cdot D\_m\right) \cdot \left(\frac{h}{\ell} \cdot \left(\left(0.25 \cdot D\_m\right) \cdot \frac{M\_m}{d}\right)\right)}{2 \cdot d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\ell}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if h < 2.90000000000000014e-303Initial program 68.4%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.2
Applied rewrites10.2%
Taylor expanded in h around -inf
Applied rewrites44.2%
if 2.90000000000000014e-303 < h < 1.4499999999999999e221Initial program 71.1%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6475.1
Applied rewrites75.1%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
Applied rewrites76.1%
Taylor expanded in d around 0
lower-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6475.0
Applied rewrites75.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites76.6%
if 1.4499999999999999e221 < h Initial program 66.3%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6418.8
Applied rewrites18.8%
Applied rewrites56.1%
Applied rewrites56.2%
Final simplification57.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 (sqrt (/ 1.0 (* l h)))))
(if (<= d 2.25e-278)
(* (- t_0) d)
(if (<= d 60000000000000.0)
(*
(* t_0 d)
(- 1.0 (* (* (* 0.125 (* D_m D_m)) (/ (* M_m (/ M_m d)) d)) (/ h l))))
(* (/ (/ 1.0 (sqrt l)) (sqrt h)) 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((1.0 / (l * h)));
double tmp;
if (d <= 2.25e-278) {
tmp = -t_0 * d;
} else if (d <= 60000000000000.0) {
tmp = (t_0 * d) * (1.0 - (((0.125 * (D_m * D_m)) * ((M_m * (M_m / d)) / d)) * (h / l)));
} else {
tmp = ((1.0 / sqrt(l)) / sqrt(h)) * 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((1.0d0 / (l * h)))
if (d <= 2.25d-278) then
tmp = -t_0 * d
else if (d <= 60000000000000.0d0) then
tmp = (t_0 * d) * (1.0d0 - (((0.125d0 * (d_m * d_m)) * ((m_m * (m_m / d)) / d)) * (h / l)))
else
tmp = ((1.0d0 / sqrt(l)) / sqrt(h)) * 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((1.0 / (l * h)));
double tmp;
if (d <= 2.25e-278) {
tmp = -t_0 * d;
} else if (d <= 60000000000000.0) {
tmp = (t_0 * d) * (1.0 - (((0.125 * (D_m * D_m)) * ((M_m * (M_m / d)) / d)) * (h / l)));
} else {
tmp = ((1.0 / Math.sqrt(l)) / Math.sqrt(h)) * 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((1.0 / (l * h))) tmp = 0 if d <= 2.25e-278: tmp = -t_0 * d elif d <= 60000000000000.0: tmp = (t_0 * d) * (1.0 - (((0.125 * (D_m * D_m)) * ((M_m * (M_m / d)) / d)) * (h / l))) else: tmp = ((1.0 / math.sqrt(l)) / math.sqrt(h)) * 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(1.0 / Float64(l * h))) tmp = 0.0 if (d <= 2.25e-278) tmp = Float64(Float64(-t_0) * d); elseif (d <= 60000000000000.0) tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64(0.125 * Float64(D_m * D_m)) * Float64(Float64(M_m * Float64(M_m / d)) / d)) * Float64(h / l)))); else tmp = Float64(Float64(Float64(1.0 / sqrt(l)) / sqrt(h)) * 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((1.0 / (l * h)));
tmp = 0.0;
if (d <= 2.25e-278)
tmp = -t_0 * d;
elseif (d <= 60000000000000.0)
tmp = (t_0 * d) * (1.0 - (((0.125 * (D_m * D_m)) * ((M_m * (M_m / d)) / d)) * (h / l)));
else
tmp = ((1.0 / sqrt(l)) / sqrt(h)) * 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[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, 2.25e-278], N[((-t$95$0) * d), $MachinePrecision], If[LessEqual[d, 60000000000000.0], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;d \leq 2.25 \cdot 10^{-278}:\\
\;\;\;\;\left(-t\_0\right) \cdot d\\
\mathbf{elif}\;d \leq 60000000000000:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \left(\left(0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{M\_m \cdot \frac{M\_m}{d}}{d}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\ell}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 2.2499999999999999e-278Initial program 66.1%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.0
Applied rewrites10.0%
Taylor expanded in h around -inf
Applied rewrites42.8%
if 2.2499999999999999e-278 < d < 6e13Initial program 61.3%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6465.5
Applied rewrites65.5%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6452.7
Applied rewrites52.7%
if 6e13 < d Initial program 82.9%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6456.1
Applied rewrites56.1%
Applied rewrites72.5%
Applied rewrites72.6%
Final simplification52.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 (<= d 9.5e-250) (* (- (sqrt (/ 1.0 (* l h)))) d) (* (/ (/ 1.0 (sqrt l)) (sqrt h)) d)))
D_m = fabs(D);
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= 9.5e-250) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = ((1.0 / sqrt(l)) / sqrt(h)) * 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) :: tmp
if (d <= 9.5d-250) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = ((1.0d0 / sqrt(l)) / sqrt(h)) * 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 tmp;
if (d <= 9.5e-250) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = ((1.0 / Math.sqrt(l)) / Math.sqrt(h)) * 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): tmp = 0 if d <= 9.5e-250: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = ((1.0 / math.sqrt(l)) / math.sqrt(h)) * d return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= 9.5e-250) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(Float64(Float64(1.0 / sqrt(l)) / sqrt(h)) * 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)
tmp = 0.0;
if (d <= 9.5e-250)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = ((1.0 / sqrt(l)) / sqrt(h)) * 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_] := If[LessEqual[d, 9.5e-250], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $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])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 9.5 \cdot 10^{-250}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\ell}}}{\sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < 9.5000000000000002e-250Initial program 65.2%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f649.7
Applied rewrites9.7%
Taylor expanded in h around -inf
Applied rewrites42.1%
if 9.5000000000000002e-250 < d Initial program 75.1%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.9
Applied rewrites46.9%
Applied rewrites58.4%
Applied rewrites58.5%
Final simplification48.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 9.5e-250) (* (- (sqrt (/ 1.0 (* l h)))) d) (/ 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 <= 9.5e-250) {
tmp = -sqrt((1.0 / (l * h))) * d;
} 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 <= 9.5d-250) then
tmp = -sqrt((1.0d0 / (l * h))) * d
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 <= 9.5e-250) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} 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 <= 9.5e-250: tmp = -math.sqrt((1.0 / (l * h))) * d 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 <= 9.5e-250) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); 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 <= 9.5e-250)
tmp = -sqrt((1.0 / (l * h))) * d;
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, 9.5e-250], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $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 9.5 \cdot 10^{-250}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < 9.5000000000000002e-250Initial program 65.2%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f649.7
Applied rewrites9.7%
Taylor expanded in h around -inf
Applied rewrites42.1%
if 9.5000000000000002e-250 < d Initial program 75.1%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.9
Applied rewrites46.9%
Applied rewrites46.9%
Applied rewrites46.9%
Applied rewrites58.4%
Final simplification48.9%
D_m = (fabs.f64 D) M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M_m D_m) :precision binary64 (if (<= l -4.2e-266) (* (- (sqrt (/ 1.0 (* l h)))) d) (/ 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 (l <= -4.2e-266) {
tmp = -sqrt((1.0 / (l * h))) * d;
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
D_m = private
M_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= (-4.2d-266)) then
tmp = -sqrt((1.0d0 / (l * h))) * d
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
D_m = Math.abs(D);
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -4.2e-266) {
tmp = -Math.sqrt((1.0 / (l * h))) * d;
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
D_m = math.fabs(D) M_m = math.fabs(M) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -4.2e-266: tmp = -math.sqrt((1.0 / (l * h))) * d else: tmp = d / math.sqrt((l * h)) return tmp
D_m = abs(D) M_m = abs(M) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -4.2e-266) tmp = Float64(Float64(-sqrt(Float64(1.0 / Float64(l * h)))) * d); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
D_m = abs(D);
M_m = abs(M);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -4.2e-266)
tmp = -sqrt((1.0 / (l * h))) * d;
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -4.2e-266], N[((-N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * d), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
M_m = \left|M\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.2 \cdot 10^{-266}:\\
\;\;\;\;\left(-\sqrt{\frac{1}{\ell \cdot h}}\right) \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if l < -4.19999999999999994e-266Initial program 67.6%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f647.3
Applied rewrites7.3%
Taylor expanded in h around -inf
Applied rewrites46.5%
if -4.19999999999999994e-266 < l Initial program 70.9%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6441.9
Applied rewrites41.9%
Applied rewrites41.9%
Applied rewrites41.9%
Final simplification44.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 (* (sqrt (/ 1.0 (* l h))) 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((1.0 / (l * h))) * 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((1.0d0 / (l * h))) * 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((1.0 / (l * h))) * 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((1.0 / (l * h))) * 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(1.0 / Float64(l * h))) * 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((1.0 / (l * h))) * 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[(1.0 / N[(l * h), $MachinePrecision]), $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{\frac{1}{\ell \cdot h}} \cdot d
\end{array}
Initial program 69.3%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6425.1
Applied rewrites25.1%
Final simplification25.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 (/ 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 69.3%
Taylor expanded in d around -inf
mul-1-negN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
associate-*l*N/A
*-commutativeN/A
mul-1-negN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6425.1
Applied rewrites25.1%
Applied rewrites24.8%
Applied rewrites24.8%
Final simplification24.8%
herbie shell --seed 2025017
(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)))))