
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Herbie found 19 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}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* M_m (/ D_m (+ d d))))
(t_1 (* (sqrt (/ d l)) (- 1.0 (* (* (* t_0 t_0) 0.5) (/ h l)))))
(t_2
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<= h -3.4e+215)
(* (sqrt (/ d h)) t_1)
(if (<= h -5e-310)
(* (* (- d) (sqrt (/ 1.0 (* l h)))) t_2)
(if (<= h 1.3e+68)
(* (* (pow (/ d h) (/ 1.0 2.0)) (/ (sqrt d) (sqrt l))) t_2)
(* (/ (sqrt d) (sqrt h)) t_1))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * (D_m / (d + d));
double t_1 = sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l)));
double t_2 = 1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -3.4e+215) {
tmp = sqrt((d / h)) * t_1;
} else if (h <= -5e-310) {
tmp = (-d * sqrt((1.0 / (l * h)))) * t_2;
} else if (h <= 1.3e+68) {
tmp = (pow((d / h), (1.0 / 2.0)) * (sqrt(d) / sqrt(l))) * t_2;
} else {
tmp = (sqrt(d) / sqrt(h)) * t_1;
}
return tmp;
}
M_m = private
D_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 = m_m * (d_m / (d + d))
t_1 = sqrt((d / l)) * (1.0d0 - (((t_0 * t_0) * 0.5d0) * (h / l)))
t_2 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
if (h <= (-3.4d+215)) then
tmp = sqrt((d / h)) * t_1
else if (h <= (-5d-310)) then
tmp = (-d * sqrt((1.0d0 / (l * h)))) * t_2
else if (h <= 1.3d+68) then
tmp = (((d / h) ** (1.0d0 / 2.0d0)) * (sqrt(d) / sqrt(l))) * t_2
else
tmp = (sqrt(d) / sqrt(h)) * t_1
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * (D_m / (d + d));
double t_1 = Math.sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l)));
double t_2 = 1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -3.4e+215) {
tmp = Math.sqrt((d / h)) * t_1;
} else if (h <= -5e-310) {
tmp = (-d * Math.sqrt((1.0 / (l * h)))) * t_2;
} else if (h <= 1.3e+68) {
tmp = (Math.pow((d / h), (1.0 / 2.0)) * (Math.sqrt(d) / Math.sqrt(l))) * t_2;
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * t_1;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = M_m * (D_m / (d + d)) t_1 = math.sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l))) t_2 = 1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if h <= -3.4e+215: tmp = math.sqrt((d / h)) * t_1 elif h <= -5e-310: tmp = (-d * math.sqrt((1.0 / (l * h)))) * t_2 elif h <= 1.3e+68: tmp = (math.pow((d / h), (1.0 / 2.0)) * (math.sqrt(d) / math.sqrt(l))) * t_2 else: tmp = (math.sqrt(d) / math.sqrt(h)) * t_1 return tmp
M_m = abs(M) D_m = abs(D) 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(M_m * Float64(D_m / Float64(d + d))) t_1 = Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.5) * Float64(h / l)))) t_2 = 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 (h <= -3.4e+215) tmp = Float64(sqrt(Float64(d / h)) * t_1); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))) * t_2); elseif (h <= 1.3e+68) tmp = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * Float64(sqrt(d) / sqrt(l))) * t_2); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * t_1); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = M_m * (D_m / (d + d));
t_1 = sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l)));
t_2 = 1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (h <= -3.4e+215)
tmp = sqrt((d / h)) * t_1;
elseif (h <= -5e-310)
tmp = (-d * sqrt((1.0 / (l * h)))) * t_2;
elseif (h <= 1.3e+68)
tmp = (((d / h) ^ (1.0 / 2.0)) * (sqrt(d) / sqrt(l))) * t_2;
else
tmp = (sqrt(d) / sqrt(h)) * t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(M$95$m * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[h, -3.4e+215], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[h, 1.3e+68], N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D\_m}{d + d}\\
t_1 := \sqrt{\frac{d}{\ell}} \cdot \left(1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\
t_2 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;h \leq -3.4 \cdot 10^{+215}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot t\_1\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\right) \cdot t\_2\\
\mathbf{elif}\;h \leq 1.3 \cdot 10^{+68}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \frac{\sqrt{d}}{\sqrt{\ell}}\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_1\\
\end{array}
\end{array}
if h < -3.40000000000000018e215Initial program 47.4%
Applied rewrites47.9%
if -3.40000000000000018e215 < h < -4.999999999999985e-310Initial program 70.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6458.5
lift-/.f64N/A
metadata-eval58.5
Applied rewrites58.5%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6475.3
Applied rewrites75.3%
if -4.999999999999985e-310 < h < 1.2999999999999999e68Initial program 71.6%
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6478.0
Applied rewrites78.0%
if 1.2999999999999999e68 < h Initial program 55.8%
Applied rewrites55.8%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6470.8
Applied rewrites70.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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))))
(t_1 (* M_m (/ D_m (+ d d))))
(t_2 (* (sqrt (/ d l)) (- 1.0 (* (* (* t_1 t_1) 0.5) (/ h l)))))
(t_3
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(if (<= h -3.4e+215)
(* (sqrt (/ d h)) t_2)
(if (<= h -5e-310)
(* (* (- d) t_0) t_3)
(if (<= h 1.35e+115)
(* (* t_0 d) t_3)
(* (/ (sqrt d) (sqrt h)) t_2))))))M_m = fabs(M);
D_m = fabs(D);
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 t_1 = M_m * (D_m / (d + d));
double t_2 = sqrt((d / l)) * (1.0 - (((t_1 * t_1) * 0.5) * (h / l)));
double t_3 = 1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -3.4e+215) {
tmp = sqrt((d / h)) * t_2;
} else if (h <= -5e-310) {
tmp = (-d * t_0) * t_3;
} else if (h <= 1.35e+115) {
tmp = (t_0 * d) * t_3;
} else {
tmp = (sqrt(d) / sqrt(h)) * t_2;
}
return tmp;
}
M_m = private
D_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) :: t_3
real(8) :: tmp
t_0 = sqrt((1.0d0 / (l * h)))
t_1 = m_m * (d_m / (d + d))
t_2 = sqrt((d / l)) * (1.0d0 - (((t_1 * t_1) * 0.5d0) * (h / l)))
t_3 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l))
if (h <= (-3.4d+215)) then
tmp = sqrt((d / h)) * t_2
else if (h <= (-5d-310)) then
tmp = (-d * t_0) * t_3
else if (h <= 1.35d+115) then
tmp = (t_0 * d) * t_3
else
tmp = (sqrt(d) / sqrt(h)) * t_2
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
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 t_1 = M_m * (D_m / (d + d));
double t_2 = Math.sqrt((d / l)) * (1.0 - (((t_1 * t_1) * 0.5) * (h / l)));
double t_3 = 1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l));
double tmp;
if (h <= -3.4e+215) {
tmp = Math.sqrt((d / h)) * t_2;
} else if (h <= -5e-310) {
tmp = (-d * t_0) * t_3;
} else if (h <= 1.35e+115) {
tmp = (t_0 * d) * t_3;
} else {
tmp = (Math.sqrt(d) / Math.sqrt(h)) * t_2;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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))) t_1 = M_m * (D_m / (d + d)) t_2 = math.sqrt((d / l)) * (1.0 - (((t_1 * t_1) * 0.5) * (h / l))) t_3 = 1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)) tmp = 0 if h <= -3.4e+215: tmp = math.sqrt((d / h)) * t_2 elif h <= -5e-310: tmp = (-d * t_0) * t_3 elif h <= 1.35e+115: tmp = (t_0 * d) * t_3 else: tmp = (math.sqrt(d) / math.sqrt(h)) * t_2 return tmp
M_m = abs(M) D_m = abs(D) 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))) t_1 = Float64(M_m * Float64(D_m / Float64(d + d))) t_2 = Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(Float64(t_1 * t_1) * 0.5) * Float64(h / l)))) t_3 = 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 (h <= -3.4e+215) tmp = Float64(sqrt(Float64(d / h)) * t_2); elseif (h <= -5e-310) tmp = Float64(Float64(Float64(-d) * t_0) * t_3); elseif (h <= 1.35e+115) tmp = Float64(Float64(t_0 * d) * t_3); else tmp = Float64(Float64(sqrt(d) / sqrt(h)) * t_2); end return tmp end
M_m = abs(M);
D_m = abs(D);
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)));
t_1 = M_m * (D_m / (d + d));
t_2 = sqrt((d / l)) * (1.0 - (((t_1 * t_1) * 0.5) * (h / l)));
t_3 = 1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l));
tmp = 0.0;
if (h <= -3.4e+215)
tmp = sqrt((d / h)) * t_2;
elseif (h <= -5e-310)
tmp = (-d * t_0) * t_3;
elseif (h <= 1.35e+115)
tmp = (t_0 * d) * t_3;
else
tmp = (sqrt(d) / sqrt(h)) * t_2;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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]}, Block[{t$95$1 = N[(M$95$m * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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]}, If[LessEqual[h, -3.4e+215], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[h, -5e-310], N[(N[((-d) * t$95$0), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[h, 1.35e+115], N[(N[(t$95$0 * d), $MachinePrecision] * t$95$3), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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}}\\
t_1 := M\_m \cdot \frac{D\_m}{d + d}\\
t_2 := \sqrt{\frac{d}{\ell}} \cdot \left(1 - \left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\\
t_3 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;h \leq -3.4 \cdot 10^{+215}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot t\_2\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\left(-d\right) \cdot t\_0\right) \cdot t\_3\\
\mathbf{elif}\;h \leq 1.35 \cdot 10^{+115}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d}}{\sqrt{h}} \cdot t\_2\\
\end{array}
\end{array}
if h < -3.40000000000000018e215Initial program 47.4%
Applied rewrites47.9%
if -3.40000000000000018e215 < h < -4.999999999999985e-310Initial program 70.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6458.5
lift-/.f64N/A
metadata-eval58.5
Applied rewrites58.5%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6475.3
Applied rewrites75.3%
if -4.999999999999985e-310 < h < 1.35000000000000002e115Initial program 71.0%
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.35000000000000002e115 < h Initial program 53.3%
Applied rewrites53.3%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6470.6
Applied rewrites70.6%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (/ D_m (+ d d))))
(if (<= t_0 1e+208)
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(- 1.0 (* (* (* (* (* t_1 M_m) M_m) t_1) 0.5) (/ h l)))))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(*
(fma
(/ 1.0 (sqrt (* (* (* h h) h) l)))
d
(*
(/
(* (* (* (* M_m D_m) D_m) M_m) (/ 1.0 (sqrt (* (* (* l l) l) h))))
d)
-0.125))
h)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = D_m / (d + d);
double tmp;
if (t_0 <= 1e+208) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (((((t_1 * M_m) * M_m) * t_1) * 0.5) * (h / l))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = fma((1.0 / sqrt((((h * h) * h) * l))), d, ((((((M_m * D_m) * D_m) * M_m) * (1.0 / sqrt((((l * l) * l) * h)))) / d) * -0.125)) * h;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(D_m / Float64(d + d)) tmp = 0.0 if (t_0 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(t_1 * M_m) * M_m) * t_1) * 0.5) * Float64(h / l))))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(fma(Float64(1.0 / sqrt(Float64(Float64(Float64(h * h) * h) * l))), d, Float64(Float64(Float64(Float64(Float64(Float64(M_m * D_m) * D_m) * M_m) * Float64(1.0 / sqrt(Float64(Float64(Float64(l * l) * l) * h)))) / d) * -0.125)) * h); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(t$95$1 * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[N[(N[(N[(h * h), $MachinePrecision] * h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d + N[(N[(N[(N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision] * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{D\_m}{d + d}\\
\mathbf{if}\;t\_0 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \left(\left(\left(\left(t\_1 \cdot M\_m\right) \cdot M\_m\right) \cdot t\_1\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\sqrt{\left(\left(h \cdot h\right) \cdot h\right) \cdot \ell}}, d, \frac{\left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right) \cdot \frac{1}{\sqrt{\left(\left(\ell \cdot \ell\right) \cdot \ell\right) \cdot h}}}{d} \cdot -0.125\right) \cdot h\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.9999999999999998e207Initial program 86.7%
Applied rewrites85.5%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f6485.1
Applied rewrites85.1%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites12.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in h around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites25.7%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (/ D_m (+ d d)))
(t_2 (* (sqrt (/ h l)) d)))
(if (<= t_0 1e+208)
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(- 1.0 (* (* (* (* (* t_1 M_m) M_m) t_1) 0.5) (/ h l)))))
(if (<= t_0 INFINITY)
(/ t_2 h)
(/
(fma
(* (* (* D_m D_m) (/ (* M_m M_m) d)) (sqrt (pow (/ h l) 3.0)))
-0.125
t_2)
h)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = D_m / (d + d);
double t_2 = sqrt((h / l)) * d;
double tmp;
if (t_0 <= 1e+208) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (((((t_1 * M_m) * M_m) * t_1) * 0.5) * (h / l))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_2 / h;
} else {
tmp = fma((((D_m * D_m) * ((M_m * M_m) / d)) * sqrt(pow((h / l), 3.0))), -0.125, t_2) / h;
}
return tmp;
}
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(D_m / Float64(d + d)) t_2 = Float64(sqrt(Float64(h / l)) * d) tmp = 0.0 if (t_0 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(t_1 * M_m) * M_m) * t_1) * 0.5) * Float64(h / l))))); elseif (t_0 <= Inf) tmp = Float64(t_2 / h); else tmp = Float64(fma(Float64(Float64(Float64(D_m * D_m) * Float64(Float64(M_m * M_m) / d)) * sqrt((Float64(h / l) ^ 3.0))), -0.125, t_2) / h); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(t$95$1 * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$2 / h), $MachinePrecision], N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Power[N[(h / l), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.125 + t$95$2), $MachinePrecision] / h), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{D\_m}{d + d}\\
t_2 := \sqrt{\frac{h}{\ell}} \cdot d\\
\mathbf{if}\;t\_0 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \left(\left(\left(\left(t\_1 \cdot M\_m\right) \cdot M\_m\right) \cdot t\_1\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{t\_2}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(\left(D\_m \cdot D\_m\right) \cdot \frac{M\_m \cdot M\_m}{d}\right) \cdot \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, -0.125, t\_2\right)}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.9999999999999998e207Initial program 86.7%
Applied rewrites85.5%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f6485.1
Applied rewrites85.1%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f640.0
Applied rewrites0.0%
Taylor expanded in h around 0
Applied rewrites11.2%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
cube-div-revN/A
lift-/.f64N/A
lower-pow.f6418.4
Applied rewrites18.4%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (/ D_m (+ d d))))
(if (<= t_0 1e+208)
(*
(sqrt (/ d h))
(*
(sqrt (/ d l))
(- 1.0 (* (* (* (* (* t_1 M_m) M_m) t_1) 0.5) (/ h l)))))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(/
(* (/ (* (sqrt (* l h)) (* (* (* M_m D_m) D_m) M_m)) d) -0.125)
(* l l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = D_m / (d + d);
double tmp;
if (t_0 <= 1e+208) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (((((t_1 * M_m) * M_m) * t_1) * 0.5) * (h / l))));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = D_m / (d + d);
double tmp;
if (t_0 <= 1e+208) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - (((((t_1 * M_m) * M_m) * t_1) * 0.5) * (h / l))));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = (((Math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = D_m / (d + d) tmp = 0 if t_0 <= 1e+208: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - (((((t_1 * M_m) * M_m) * t_1) * 0.5) * (h / l)))) elif t_0 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = (((math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(D_m / Float64(d + d)) tmp = 0.0 if (t_0 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(t_1 * M_m) * M_m) * t_1) * 0.5) * Float64(h / l))))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M_m * D_m) * D_m) * M_m)) / d) * -0.125) / Float64(l * l)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = D_m / (d + d);
tmp = 0.0;
if (t_0 <= 1e+208)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (((((t_1 * M_m) * M_m) * t_1) * 0.5) * (h / l))));
elseif (t_0 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(t$95$1 * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{D\_m}{d + d}\\
\mathbf{if}\;t\_0 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \left(\left(\left(\left(t\_1 \cdot M\_m\right) \cdot M\_m\right) \cdot t\_1\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right)}{d} \cdot -0.125}{\ell \cdot \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)))) < 9.9999999999999998e207Initial program 86.7%
Applied rewrites85.5%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f6485.1
Applied rewrites85.1%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites12.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites19.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (* M_m (/ D_m (+ d d))))
(t_1
(*
(* (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_1 1e+208)
(*
(sqrt (/ d h))
(* (sqrt (/ d l)) (- 1.0 (* (* (* t_0 t_0) 0.5) (/ h l)))))
(if (<= t_1 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(/
(* (/ (* (sqrt (* l h)) (* (* (* M_m D_m) D_m) M_m)) d) -0.125)
(* l l))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * (D_m / (d + d));
double t_1 = (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_1 <= 1e+208) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l))));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = M_m * (D_m / (d + d));
double t_1 = (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_1 <= 1e+208) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l))));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = (((Math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = M_m * (D_m / (d + d)) t_1 = (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_1 <= 1e+208: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l)))) elif t_1 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = (((math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l) return tmp
M_m = abs(M) D_m = abs(D) 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(M_m * Float64(D_m / Float64(d + d))) t_1 = 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_1 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(Float64(t_0 * t_0) * 0.5) * Float64(h / l))))); elseif (t_1 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M_m * D_m) * D_m) * M_m)) / d) * -0.125) / Float64(l * l)); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = M_m * (D_m / (d + d));
t_1 = (((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_1 <= 1e+208)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - (((t_0 * t_0) * 0.5) * (h / l))));
elseif (t_1 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(M$95$m * N[(D$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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$1, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := M\_m \cdot \frac{D\_m}{d + d}\\
t_1 := \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\_1 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right)}{d} \cdot -0.125}{\ell \cdot \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)))) < 9.9999999999999998e207Initial program 86.7%
Applied rewrites85.5%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites12.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites19.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l)))
(t_1 (* (* (* M_m D_m) D_m) M_m))
(t_2
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_3 (sqrt (/ d h))))
(if (<= t_2 -2e-58)
(* t_3 (* t_0 (- 1.0 (* (* (/ t_1 (* d d)) 0.125) (/ h l)))))
(if (<= t_2 0.0)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= t_2 1e+208)
(* t_3 t_0)
(if (<= t_2 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(/ (* (/ (* (sqrt (* l h)) t_1) d) -0.125) (* l l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = ((M_m * D_m) * D_m) * M_m;
double t_2 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = sqrt((d / h));
double tmp;
if (t_2 <= -2e-58) {
tmp = t_3 * (t_0 * (1.0 - (((t_1 / (d * d)) * 0.125) * (h / l))));
} else if (t_2 <= 0.0) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (t_2 <= 1e+208) {
tmp = t_3 * t_0;
} else if (t_2 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = (((sqrt((l * h)) * t_1) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
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((d / l));
double t_1 = ((M_m * D_m) * D_m) * M_m;
double t_2 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = Math.sqrt((d / h));
double tmp;
if (t_2 <= -2e-58) {
tmp = t_3 * (t_0 * (1.0 - (((t_1 / (d * d)) * 0.125) * (h / l))));
} else if (t_2 <= 0.0) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (t_2 <= 1e+208) {
tmp = t_3 * t_0;
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = (((Math.sqrt((l * h)) * t_1) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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((d / l)) t_1 = ((M_m * D_m) * D_m) * M_m t_2 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_3 = math.sqrt((d / h)) tmp = 0 if t_2 <= -2e-58: tmp = t_3 * (t_0 * (1.0 - (((t_1 / (d * d)) * 0.125) * (h / l)))) elif t_2 <= 0.0: tmp = -d * math.sqrt((1.0 / (l * h))) elif t_2 <= 1e+208: tmp = t_3 * t_0 elif t_2 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = (((math.sqrt((l * h)) * t_1) / d) * -0.125) / (l * l) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) t_1 = Float64(Float64(Float64(M_m * D_m) * D_m) * M_m) t_2 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = sqrt(Float64(d / h)) tmp = 0.0 if (t_2 <= -2e-58) tmp = Float64(t_3 * Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(t_1 / Float64(d * d)) * 0.125) * Float64(h / l))))); elseif (t_2 <= 0.0) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (t_2 <= 1e+208) tmp = Float64(t_3 * t_0); elseif (t_2 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * t_1) / d) * -0.125) / Float64(l * l)); end return tmp end
M_m = abs(M);
D_m = abs(D);
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((d / l));
t_1 = ((M_m * D_m) * D_m) * M_m;
t_2 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_3 = sqrt((d / h));
tmp = 0.0;
if (t_2 <= -2e-58)
tmp = t_3 * (t_0 * (1.0 - (((t_1 / (d * d)) * 0.125) * (h / l))));
elseif (t_2 <= 0.0)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (t_2 <= 1e+208)
tmp = t_3 * t_0;
elseif (t_2 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = (((sqrt((l * h)) * t_1) / d) * -0.125) / (l * l);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -2e-58], N[(t$95$3 * N[(t$95$0 * N[(1.0 - N[(N[(N[(t$95$1 / N[(d * d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+208], N[(t$95$3 * t$95$0), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\\
t_2 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-58}:\\
\;\;\;\;t\_3 \cdot \left(t\_0 \cdot \left(1 - \left(\frac{t\_1}{d \cdot d} \cdot 0.125\right) \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;t\_2 \leq 10^{+208}:\\
\;\;\;\;t\_3 \cdot t\_0\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot t\_1}{d} \cdot -0.125}{\ell \cdot \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)))) < -2.0000000000000001e-58Initial program 85.8%
Applied rewrites85.0%
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
lift-+.f6484.4
Applied rewrites84.4%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6465.0
Applied rewrites65.0%
if -2.0000000000000001e-58 < (*.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 44.8%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6436.1
lift-/.f64N/A
metadata-eval36.1
Applied rewrites36.1%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6448.9
Applied rewrites48.9%
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)))) < 9.9999999999999998e207Initial program 98.8%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.9
Applied rewrites97.9%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites12.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites19.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0 (sqrt (/ d l)))
(t_1
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (sqrt (/ d h))))
(if (<= t_1 -5e+108)
(*
t_2
(* t_0 (* (/ (* (* (* M_m M_m) h) (* D_m D_m)) (* (* d d) l)) -0.125)))
(if (<= t_1 0.0)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= t_1 1e+208)
(* t_2 t_0)
(if (<= t_1 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(/
(* (/ (* (sqrt (* l h)) (* (* (* M_m D_m) D_m) M_m)) d) -0.125)
(* l l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = sqrt((d / l));
double t_1 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((d / h));
double tmp;
if (t_1 <= -5e+108) {
tmp = t_2 * (t_0 * (((((M_m * M_m) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125));
} else if (t_1 <= 0.0) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (t_1 <= 1e+208) {
tmp = t_2 * t_0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
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((d / l));
double t_1 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = Math.sqrt((d / h));
double tmp;
if (t_1 <= -5e+108) {
tmp = t_2 * (t_0 * (((((M_m * M_m) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125));
} else if (t_1 <= 0.0) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (t_1 <= 1e+208) {
tmp = t_2 * t_0;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = (((Math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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((d / l)) t_1 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_2 = math.sqrt((d / h)) tmp = 0 if t_1 <= -5e+108: tmp = t_2 * (t_0 * (((((M_m * M_m) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125)) elif t_1 <= 0.0: tmp = -d * math.sqrt((1.0 / (l * h))) elif t_1 <= 1e+208: tmp = t_2 * t_0 elif t_1 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = (((math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l) return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = sqrt(Float64(d / l)) t_1 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(d / h)) tmp = 0.0 if (t_1 <= -5e+108) tmp = Float64(t_2 * Float64(t_0 * Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * Float64(D_m * D_m)) / Float64(Float64(d * d) * l)) * -0.125))); elseif (t_1 <= 0.0) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (t_1 <= 1e+208) tmp = Float64(t_2 * t_0); elseif (t_1 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M_m * D_m) * D_m) * M_m)) / d) * -0.125) / Float64(l * l)); end return tmp end
M_m = abs(M);
D_m = abs(D);
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((d / l));
t_1 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_2 = sqrt((d / h));
tmp = 0.0;
if (t_1 <= -5e+108)
tmp = t_2 * (t_0 * (((((M_m * M_m) * h) * (D_m * D_m)) / ((d * d) * l)) * -0.125));
elseif (t_1 <= 0.0)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (t_1 <= 1e+208)
tmp = t_2 * t_0;
elseif (t_1 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -5e+108], N[(t$95$2 * N[(t$95$0 * N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+208], N[(t$95$2 * t$95$0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+108}:\\
\;\;\;\;t\_2 \cdot \left(t\_0 \cdot \left(\frac{\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right)\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;t\_1 \leq 10^{+208}:\\
\;\;\;\;t\_2 \cdot t\_0\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right)}{d} \cdot -0.125}{\ell \cdot \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)))) < -4.99999999999999991e108Initial program 85.0%
Applied rewrites84.9%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6452.5
Applied rewrites52.5%
if -4.99999999999999991e108 < (*.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 56.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6445.4
lift-/.f64N/A
metadata-eval45.4
Applied rewrites45.4%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6438.6
Applied rewrites38.6%
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)))) < 9.9999999999999998e207Initial program 98.8%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.9
Applied rewrites97.9%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites12.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites19.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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+112)
(*
(sqrt (/ (* d d) (* l h)))
(* (/ (* (* (* (* M_m M_m) h) D_m) D_m) (* (* d d) l)) -0.125))
(if (<= t_0 0.0)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= t_0 1e+208)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_0 INFINITY)
(/ (* (sqrt (/ h l)) d) h)
(/
(* (/ (* (sqrt (* l h)) (* (* (* M_m D_m) D_m) M_m)) d) -0.125)
(* l l))))))))M_m = fabs(M);
D_m = fabs(D);
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+112) {
tmp = sqrt(((d * d) / (l * h))) * ((((((M_m * M_m) * h) * D_m) * D_m) / ((d * d) * l)) * -0.125);
} else if (t_0 <= 0.0) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (t_0 <= 1e+208) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
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+112) {
tmp = Math.sqrt(((d * d) / (l * h))) * ((((((M_m * M_m) * h) * D_m) * D_m) / ((d * d) * l)) * -0.125);
} else if (t_0 <= 0.0) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (t_0 <= 1e+208) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = (((Math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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+112: tmp = math.sqrt(((d * d) / (l * h))) * ((((((M_m * M_m) * h) * D_m) * D_m) / ((d * d) * l)) * -0.125) elif t_0 <= 0.0: tmp = -d * math.sqrt((1.0 / (l * h))) elif t_0 <= 1e+208: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif t_0 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = (((math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l) return tmp
M_m = abs(M) D_m = abs(D) 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+112) tmp = Float64(sqrt(Float64(Float64(d * d) / Float64(l * h))) * Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / Float64(Float64(d * d) * l)) * -0.125)); elseif (t_0 <= 0.0) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (t_0 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M_m * D_m) * D_m) * M_m)) / d) * -0.125) / Float64(l * l)); end return tmp end
M_m = abs(M);
D_m = abs(D);
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+112)
tmp = sqrt(((d * d) / (l * h))) * ((((((M_m * M_m) * h) * D_m) * D_m) / ((d * d) * l)) * -0.125);
elseif (t_0 <= 0.0)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (t_0 <= 1e+208)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (t_0 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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+112], N[(N[Sqrt[N[(N[(d * d), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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^{+112}:\\
\;\;\;\;\sqrt{\frac{d \cdot d}{\ell \cdot h}} \cdot \left(\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right)}{d} \cdot -0.125}{\ell \cdot \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)))) < -5e112Initial program 84.9%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6474.8
lift-/.f64N/A
metadata-eval74.8
Applied rewrites74.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6444.5
Applied rewrites44.5%
Applied rewrites37.5%
if -5e112 < (*.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 57.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6445.7
lift-/.f64N/A
metadata-eval45.7
Applied rewrites45.7%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6438.4
Applied rewrites38.4%
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)))) < 9.9999999999999998e207Initial program 98.8%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.9
Applied rewrites97.9%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites12.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f642.7
Applied rewrites2.7%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites19.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= d -1.02e-66)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= d -5e-310)
(*
(* -0.125 (* (- (/ (* M_m M_m) d)) (* D_m D_m)))
(sqrt (/ h (* (* l l) l))))
(if (<= d 3.8e+24)
(/
(* (/ (* (sqrt (* l h)) (* (* (* M_m D_m) D_m) M_m)) d) -0.125)
(* l l))
(* (/ 1.0 (* (sqrt l) (sqrt h))) d)))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.02e-66) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (d <= -5e-310) {
tmp = (-0.125 * (-((M_m * M_m) / d) * (D_m * D_m))) * sqrt((h / ((l * l) * l)));
} else if (d <= 3.8e+24) {
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (d <= (-1.02d-66)) then
tmp = sqrt((d / h)) * sqrt((d / l))
else if (d <= (-5d-310)) then
tmp = ((-0.125d0) * (-((m_m * m_m) / d) * (d_m * d_m))) * sqrt((h / ((l * l) * l)))
else if (d <= 3.8d+24) then
tmp = (((sqrt((l * h)) * (((m_m * d_m) * d_m) * m_m)) / d) * (-0.125d0)) / (l * l)
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (d <= -1.02e-66) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (d <= -5e-310) {
tmp = (-0.125 * (-((M_m * M_m) / d) * (D_m * D_m))) * Math.sqrt((h / ((l * l) * l)));
} else if (d <= 3.8e+24) {
tmp = (((Math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if d <= -1.02e-66: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif d <= -5e-310: tmp = (-0.125 * (-((M_m * M_m) / d) * (D_m * D_m))) * math.sqrt((h / ((l * l) * l))) elif d <= 3.8e+24: tmp = (((math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (d <= -1.02e-66) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (d <= -5e-310) tmp = Float64(Float64(-0.125 * Float64(Float64(-Float64(Float64(M_m * M_m) / d)) * Float64(D_m * D_m))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); elseif (d <= 3.8e+24) tmp = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M_m * D_m) * D_m) * M_m)) / d) * -0.125) / Float64(l * l)); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (d <= -1.02e-66)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (d <= -5e-310)
tmp = (-0.125 * (-((M_m * M_m) / d) * (D_m * D_m))) * sqrt((h / ((l * l) * l)));
elseif (d <= 3.8e+24)
tmp = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[d, -1.02e-66], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(N[(-0.125 * N[((-N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]) * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.8e+24], N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.02 \cdot 10^{-66}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(-\frac{M\_m \cdot M\_m}{d}\right) \cdot \left(D\_m \cdot D\_m\right)\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{+24}:\\
\;\;\;\;\frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right)}{d} \cdot -0.125}{\ell \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < -1.01999999999999996e-66Initial program 77.1%
Applied rewrites77.3%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6449.1
Applied rewrites49.1%
if -1.01999999999999996e-66 < d < -4.999999999999985e-310Initial program 50.5%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6450.4
Applied rewrites50.4%
Taylor expanded in h around 0
Applied rewrites26.0%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites36.0%
if -4.999999999999985e-310 < d < 3.80000000000000015e24Initial program 58.1%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites33.1%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f643.7
Applied rewrites3.7%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites38.7%
if 3.80000000000000015e24 < d Initial program 73.8%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6460.9
Applied rewrites60.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6461.1
Applied rewrites61.1%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6471.4
Applied rewrites71.4%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1
(/
(* (/ (* (sqrt (* l h)) (* (* (* M_m D_m) D_m) M_m)) d) -0.125)
(* l l))))
(if (<= t_0 -1e+159)
t_1
(if (<= t_0 0.0)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= t_0 1e+208)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_0 INFINITY) (/ (* (sqrt (/ h l)) d) h) t_1))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
double tmp;
if (t_0 <= -1e+159) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (t_0 <= 1e+208) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (((Math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
double tmp;
if (t_0 <= -1e+159) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (t_0 <= 1e+208) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = (((math.sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l) tmp = 0 if t_0 <= -1e+159: tmp = t_1 elif t_0 <= 0.0: tmp = -d * math.sqrt((1.0 / (l * h))) elif t_0 <= 1e+208: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif t_0 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = t_1 return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M_m * D_m) * D_m) * M_m)) / d) * -0.125) / Float64(l * l)) tmp = 0.0 if (t_0 <= -1e+159) tmp = t_1; elseif (t_0 <= 0.0) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (t_0 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = t_1; end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = (((sqrt((l * h)) * (((M_m * D_m) * D_m) * M_m)) / d) * -0.125) / (l * l);
tmp = 0.0;
if (t_0 <= -1e+159)
tmp = t_1;
elseif (t_0 <= 0.0)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (t_0 <= 1e+208)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (t_0 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M$95$m * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+159], t$95$1, If[LessEqual[t$95$0, 0.0], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\frac{\sqrt{\ell \cdot h} \cdot \left(\left(\left(M\_m \cdot D\_m\right) \cdot D\_m\right) \cdot M\_m\right)}{d} \cdot -0.125}{\ell \cdot \ell}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+159}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;t\_0 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -9.9999999999999993e158 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 51.9%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites20.6%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
pow3N/A
lower-sqrt.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-/.f643.1
Applied rewrites3.1%
Taylor expanded in d around 0
*-commutativeN/A
Applied rewrites27.0%
if -9.9999999999999993e158 < (*.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 60.4%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6449.7
lift-/.f64N/A
metadata-eval49.7
Applied rewrites49.7%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6435.6
Applied rewrites35.6%
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)))) < 9.9999999999999998e207Initial program 98.8%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.9
Applied rewrites97.9%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (- d) (sqrt (/ 1.0 (* l h))))))
(if (<= t_0 -1.5e+241)
(*
(* -0.125 (* (* D_m D_m) (/ (* M_m M_m) d)))
(sqrt (/ h (* (* l l) l))))
(if (<= t_0 0.0)
t_1
(if (<= t_0 1e+208)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_0 INFINITY) (/ (* (sqrt (/ h l)) d) h) t_1))))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = -d * sqrt((1.0 / (l * h)));
double tmp;
if (t_0 <= -1.5e+241) {
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * sqrt((h / ((l * l) * l)));
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 1e+208) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = -d * Math.sqrt((1.0 / (l * h)));
double tmp;
if (t_0 <= -1.5e+241) {
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * Math.sqrt((h / ((l * l) * l)));
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 1e+208) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = -d * math.sqrt((1.0 / (l * h))) tmp = 0 if t_0 <= -1.5e+241: tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * math.sqrt((h / ((l * l) * l))) elif t_0 <= 0.0: tmp = t_1 elif t_0 <= 1e+208: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif t_0 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = t_1 return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))) tmp = 0.0 if (t_0 <= -1.5e+241) tmp = Float64(Float64(-0.125 * Float64(Float64(D_m * D_m) * Float64(Float64(M_m * M_m) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = t_1; end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = -d * sqrt((1.0 / (l * h)));
tmp = 0.0;
if (t_0 <= -1.5e+241)
tmp = (-0.125 * ((D_m * D_m) * ((M_m * M_m) / d))) * sqrt((h / ((l * l) * l)));
elseif (t_0 <= 0.0)
tmp = t_1;
elseif (t_0 <= 1e+208)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (t_0 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.5e+241], N[(N[(-0.125 * N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq -1.5 \cdot 10^{+241}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D\_m \cdot D\_m\right) \cdot \frac{M\_m \cdot M\_m}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.50000000000000008e241Initial program 84.0%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
unpow3N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6433.3
Applied rewrites33.3%
if -1.50000000000000008e241 < (*.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.0 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 24.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6420.1
lift-/.f64N/A
metadata-eval20.1
Applied rewrites20.1%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6419.2
Applied rewrites19.2%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.9999999999999998e207Initial program 98.8%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.9
Applied rewrites97.9%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 (/ h l)))
(t_1 (* (- d) (sqrt (/ 1.0 (* l h)))))
(t_2
(*
(* (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_2 -2e-58)
(/ (* d (- t_0)) h)
(if (<= t_2 0.0)
t_1
(if (<= t_2 1e+208)
(* (sqrt (/ d h)) (sqrt (/ d l)))
(if (<= t_2 INFINITY) (/ (* t_0 d) h) t_1))))))M_m = fabs(M);
D_m = fabs(D);
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((h / l));
double t_1 = -d * sqrt((1.0 / (l * h)));
double t_2 = (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_2 <= -2e-58) {
tmp = (d * -t_0) / h;
} else if (t_2 <= 0.0) {
tmp = t_1;
} else if (t_2 <= 1e+208) {
tmp = sqrt((d / h)) * sqrt((d / l));
} else if (t_2 <= ((double) INFINITY)) {
tmp = (t_0 * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
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((h / l));
double t_1 = -d * Math.sqrt((1.0 / (l * h)));
double t_2 = (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_2 <= -2e-58) {
tmp = (d * -t_0) / h;
} else if (t_2 <= 0.0) {
tmp = t_1;
} else if (t_2 <= 1e+208) {
tmp = Math.sqrt((d / h)) * Math.sqrt((d / l));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = (t_0 * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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((h / l)) t_1 = -d * math.sqrt((1.0 / (l * h))) t_2 = (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_2 <= -2e-58: tmp = (d * -t_0) / h elif t_2 <= 0.0: tmp = t_1 elif t_2 <= 1e+208: tmp = math.sqrt((d / h)) * math.sqrt((d / l)) elif t_2 <= math.inf: tmp = (t_0 * d) / h else: tmp = t_1 return tmp
M_m = abs(M) D_m = abs(D) 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(h / l)) t_1 = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))) t_2 = 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_2 <= -2e-58) tmp = Float64(Float64(d * Float64(-t_0)) / h); elseif (t_2 <= 0.0) tmp = t_1; elseif (t_2 <= 1e+208) tmp = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))); elseif (t_2 <= Inf) tmp = Float64(Float64(t_0 * d) / h); else tmp = t_1; end return tmp end
M_m = abs(M);
D_m = abs(D);
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((h / l));
t_1 = -d * sqrt((1.0 / (l * h)));
t_2 = (((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_2 <= -2e-58)
tmp = (d * -t_0) / h;
elseif (t_2 <= 0.0)
tmp = t_1;
elseif (t_2 <= 1e+208)
tmp = sqrt((d / h)) * sqrt((d / l));
elseif (t_2 <= Inf)
tmp = (t_0 * d) / h;
else
tmp = t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$2, -2e-58], N[(N[(d * (-t$95$0)), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$2, 0.0], t$95$1, If[LessEqual[t$95$2, 1e+208], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := \left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
t_2 := \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\_2 \leq -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{d \cdot \left(-t\_0\right)}{h}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+208}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.0000000000000001e-58Initial program 85.8%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6485.8
Applied rewrites85.8%
Taylor expanded in h around 0
Applied rewrites26.6%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f64N/A
lift-sqrt.f6423.5
Applied rewrites23.5%
if -2.0000000000000001e-58 < (*.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.0 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 12.1%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f649.7
lift-/.f64N/A
metadata-eval9.7
Applied rewrites9.7%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6421.8
Applied rewrites21.8%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 9.9999999999999998e207Initial program 98.8%
Applied rewrites97.6%
Taylor expanded in d around inf
lift-sqrt.f64N/A
lift-/.f6497.9
Applied rewrites97.9%
if 9.9999999999999998e207 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 57.3%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6457.3
Applied rewrites57.3%
Taylor expanded in h around 0
Applied rewrites22.3%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6472.9
Applied rewrites72.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D_m)
:precision binary64
(if (<= l -1.45e-149)
(* (- d) (sqrt (/ 1.0 (* l h))))
(if (<= l 1.9e-256)
(/ (* d (- (sqrt (/ h l)))) h)
(* (/ 1.0 (* (sqrt l) (sqrt h))) d))))M_m = fabs(M);
D_m = fabs(D);
assert(d < h && h < l && l < M_m && M_m < D_m);
double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.45e-149) {
tmp = -d * sqrt((1.0 / (l * h)));
} else if (l <= 1.9e-256) {
tmp = (d * -sqrt((h / l))) / h;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
D_m = private
NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m_m, d_m)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8) :: tmp
if (l <= (-1.45d-149)) then
tmp = -d * sqrt((1.0d0 / (l * h)))
else if (l <= 1.9d-256) then
tmp = (d * -sqrt((h / l))) / h
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d < h && h < l && l < M_m && M_m < D_m;
public static double code(double d, double h, double l, double M_m, double D_m) {
double tmp;
if (l <= -1.45e-149) {
tmp = -d * Math.sqrt((1.0 / (l * h)));
} else if (l <= 1.9e-256) {
tmp = (d * -Math.sqrt((h / l))) / h;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [d, h, l, M_m, D_m] = sort([d, h, l, M_m, D_m]) def code(d, h, l, M_m, D_m): tmp = 0 if l <= -1.45e-149: tmp = -d * math.sqrt((1.0 / (l * h))) elif l <= 1.9e-256: tmp = (d * -math.sqrt((h / l))) / h else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) D_m = abs(D) d, h, l, M_m, D_m = sort([d, h, l, M_m, D_m]) function code(d, h, l, M_m, D_m) tmp = 0.0 if (l <= -1.45e-149) tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); elseif (l <= 1.9e-256) tmp = Float64(Float64(d * Float64(-sqrt(Float64(h / l)))) / h); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
d, h, l, M_m, D_m = num2cell(sort([d, h, l, M_m, D_m])){:}
function tmp_2 = code(d, h, l, M_m, D_m)
tmp = 0.0;
if (l <= -1.45e-149)
tmp = -d * sqrt((1.0 / (l * h)));
elseif (l <= 1.9e-256)
tmp = (d * -sqrt((h / l))) / h;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M_m, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[l, -1.45e-149], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.9e-256], N[(N[(d * (-N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / h), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.45 \cdot 10^{-149}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{-256}:\\
\;\;\;\;\frac{d \cdot \left(-\sqrt{\frac{h}{\ell}}\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if l < -1.45e-149Initial program 65.1%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6451.9
lift-/.f64N/A
metadata-eval51.9
Applied rewrites51.9%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6446.8
Applied rewrites46.8%
if -1.45e-149 < l < 1.89999999999999988e-256Initial program 70.0%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6470.0
Applied rewrites70.0%
Taylor expanded in h around 0
Applied rewrites10.1%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f64N/A
lift-sqrt.f6431.9
Applied rewrites31.9%
if 1.89999999999999988e-256 < l Initial program 65.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6445.3
Applied rewrites45.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6453.0
Applied rewrites53.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
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 (/ h l)))
(t_1
(*
(* (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_1 -2e-58)
(/ (* d (- t_0)) h)
(if (<= t_1 INFINITY) (/ (* t_0 d) h) (* (- d) (sqrt (/ 1.0 (* l h))))))))M_m = fabs(M);
D_m = fabs(D);
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((h / l));
double t_1 = (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_1 <= -2e-58) {
tmp = (d * -t_0) / h;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (t_0 * d) / h;
} else {
tmp = -d * sqrt((1.0 / (l * h)));
}
return tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
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((h / l));
double t_1 = (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_1 <= -2e-58) {
tmp = (d * -t_0) / h;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (t_0 * d) / h;
} else {
tmp = -d * Math.sqrt((1.0 / (l * h)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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((h / l)) t_1 = (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_1 <= -2e-58: tmp = (d * -t_0) / h elif t_1 <= math.inf: tmp = (t_0 * d) / h else: tmp = -d * math.sqrt((1.0 / (l * h))) return tmp
M_m = abs(M) D_m = abs(D) 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(h / l)) t_1 = 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_1 <= -2e-58) tmp = Float64(Float64(d * Float64(-t_0)) / h); elseif (t_1 <= Inf) tmp = Float64(Float64(t_0 * d) / h); else tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(l * h)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
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((h / l));
t_1 = (((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_1 <= -2e-58)
tmp = (d * -t_0) / h;
elseif (t_1 <= Inf)
tmp = (t_0 * d) / h;
else
tmp = -d * sqrt((1.0 / (l * h)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = 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$1, -2e-58], N[(N[(d * (-t$95$0)), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], N[((-d) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := \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\_1 \leq -2 \cdot 10^{-58}:\\
\;\;\;\;\frac{d \cdot \left(-t\_0\right)}{h}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.0000000000000001e-58Initial program 85.8%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6485.8
Applied rewrites85.8%
Taylor expanded in h around 0
Applied rewrites26.6%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
associate-*l*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f64N/A
lift-sqrt.f6423.5
Applied rewrites23.5%
if -2.0000000000000001e-58 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 78.2%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6478.0
Applied rewrites78.0%
Taylor expanded in h around 0
Applied rewrites29.7%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6474.7
Applied rewrites74.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f640.0
lift-/.f64N/A
metadata-eval0.0
Applied rewrites0.0%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6411.8
Applied rewrites11.8%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) 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 (<= l 9e-275) (* (- d) t_0) (* t_0 d))))
M_m = fabs(M);
D_m = fabs(D);
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 (l <= 9e-275) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
M_m = private
D_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 (l <= 9d-275) then
tmp = -d * t_0
else
tmp = t_0 * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
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 (l <= 9e-275) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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 l <= 9e-275: tmp = -d * t_0 else: tmp = t_0 * d return tmp
M_m = abs(M) D_m = abs(D) 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 (l <= 9e-275) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(t_0 * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
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 (l <= 9e-275)
tmp = -d * t_0;
else
tmp = t_0 * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $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[l, 9e-275], N[((-d) * t$95$0), $MachinePrecision], N[(t$95$0 * d), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\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}\;\ell \leq 9 \cdot 10^{-275}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot d\\
\end{array}
\end{array}
if l < 8.99999999999999957e-275Initial program 66.4%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6456.1
lift-/.f64N/A
metadata-eval56.1
Applied rewrites56.1%
Taylor expanded in d around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-*.f6441.7
Applied rewrites41.7%
if 8.99999999999999957e-275 < l Initial program 65.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6444.7
Applied rewrites44.7%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) 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 -9.5e-213) (/ (* (sqrt (/ h l)) d) h) (* (sqrt (/ 1.0 (* l h))) d)))
M_m = fabs(M);
D_m = fabs(D);
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 <= -9.5e-213) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = private
D_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 <= (-9.5d-213)) then
tmp = (sqrt((h / l)) * d) / h
else
tmp = sqrt((1.0d0 / (l * h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
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 <= -9.5e-213) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = Math.sqrt((1.0 / (l * h))) * d;
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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 <= -9.5e-213: tmp = (math.sqrt((h / l)) * d) / h else: tmp = math.sqrt((1.0 / (l * h))) * d return tmp
M_m = abs(M) D_m = abs(D) 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 <= -9.5e-213) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * d); end return tmp end
M_m = abs(M);
D_m = abs(D);
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 <= -9.5e-213)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = sqrt((1.0 / (l * h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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, -9.5e-213], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d, h, l, M_m, D_m] = \mathsf{sort}([d, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9.5 \cdot 10^{-213}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot d\\
\end{array}
\end{array}
if l < -9.50000000000000055e-213Initial program 65.9%
lift-/.f64N/A
lift-pow.f64N/A
sqr-powN/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6465.7
Applied rewrites65.7%
Taylor expanded in h around 0
Applied rewrites28.6%
Taylor expanded in d around inf
*-commutativeN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6439.3
Applied rewrites39.3%
if -9.50000000000000055e-213 < l Initial program 66.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6440.8
Applied rewrites40.8%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) 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))
M_m = fabs(M);
D_m = fabs(D);
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;
}
M_m = private
D_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
M_m = Math.abs(M);
D_m = Math.abs(D);
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;
}
M_m = math.fabs(M) D_m = math.fabs(D) [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
M_m = abs(M) D_m = abs(D) 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
M_m = abs(M);
D_m = abs(D);
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
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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}
M_m = \left|M\right|
\\
D_m = \left|D\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 66.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) 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))))
M_m = fabs(M);
D_m = fabs(D);
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));
}
M_m = private
D_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
M_m = Math.abs(M);
D_m = Math.abs(D);
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));
}
M_m = math.fabs(M) D_m = math.fabs(D) [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))
M_m = abs(M) D_m = abs(D) 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
M_m = abs(M);
D_m = abs(D);
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
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $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}
M_m = \left|M\right|
\\
D_m = \left|D\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 66.0%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lift-sqrt.f64N/A
lift-*.f6427.0
Applied rewrites27.0%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lift-*.f6427.0
Applied rewrites27.0%
lift-*.f64N/A
*-lft-identity27.0
Applied rewrites27.0%
herbie shell --seed 2025113
(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)))))