
(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 20 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 (/ (* D_m M_m) (+ d d))))
(if (<=
(*
(* (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))))
5e+262)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* (* (* (/ h l) 0.5) t_0) t_0)))
(*
(fma
(* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d)))
M_m
1.0)
(sqrt (* (/ d (* 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 t_0 = (D_m * M_m) / (d + d);
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((h / l) * 0.5) * t_0) * t_0));
} else {
tmp = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0) * sqrt(((d / (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) t_0 = Float64(Float64(D_m * M_m) / Float64(d + d)) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * t_0) * t_0))); else tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))); 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[(D$95$m * M$95$m), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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 := \frac{D\_m \cdot M\_m}{d + d}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot t\_0\right) \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6467.4
Applied rewrites67.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6467.9
Applied rewrites67.9%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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 (* (/ M_m (+ d d)) D_m)))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l))))
5e+262)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* (* (* (/ h l) 0.5) t_0) t_0)))
(*
(fma
(* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d)))
M_m
1.0)
(sqrt (* (/ d (* 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 t_0 = (M_m / (d + d)) * D_m;
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((h / l) * 0.5) * t_0) * t_0));
} else {
tmp = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0) * sqrt(((d / (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) t_0 = Float64(Float64(M_m / Float64(d + d)) * D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(h / l) * 0.5) * t_0) * t_0))); else tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))); 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[(M$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(h / l), $MachinePrecision] * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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 := \frac{M\_m}{d + d} \cdot D\_m\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(\left(\frac{h}{\ell} \cdot 0.5\right) \cdot t\_0\right) \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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 (* D_m (/ M_m (+ d d)))))
(if (<=
(*
(* (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))))
5e+262)
(*
(* (fma (* t_0 (* t_0 (/ h l))) -0.5 1.0) (sqrt (/ d l)))
(sqrt (/ d h)))
(*
(fma
(* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d)))
M_m
1.0)
(sqrt (* (/ d (* 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 t_0 = D_m * (M_m / (d + d));
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+262) {
tmp = (fma((t_0 * (t_0 * (h / l))), -0.5, 1.0) * sqrt((d / l))) * sqrt((d / h));
} else {
tmp = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0) * sqrt(((d / (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) t_0 = Float64(D_m * Float64(M_m / Float64(d + d))) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+262) tmp = Float64(Float64(fma(Float64(t_0 * Float64(t_0 * Float64(h / l))), -0.5, 1.0) * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); else tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))); 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[(D$95$m * N[(M$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+262], N[(N[(N[(N[(t$95$0 * N[(t$95$0 * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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 := D\_m \cdot \frac{M\_m}{d + d}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\mathsf{fma}\left(t\_0 \cdot \left(t\_0 \cdot \frac{h}{\ell}\right), -0.5, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
Applied rewrites43.1%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-/.f64N/A
*-commutativeN/A
Applied rewrites67.8%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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
(if (<=
(*
(* (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))))
5e+262)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (* (/ (* h (/ (* 0.25 (* D_m M_m)) d)) l) (* (/ M_m (+ d d)) D_m))))
(*
(fma (* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d))) M_m 1.0)
(sqrt (* (/ d (* 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 (((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)))) <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((h * ((0.25 * (D_m * M_m)) / d)) / l) * ((M_m / (d + d)) * D_m)));
} else {
tmp = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0) * sqrt(((d / (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 (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)))) <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(h * Float64(Float64(0.25 * Float64(D_m * M_m)) / d)) / l) * Float64(Float64(M_m / Float64(d + d)) * D_m)))); else tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))); 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_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(h * N[(N[(0.25 * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M$95$m / N[(d + d), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{h \cdot \frac{0.25 \cdot \left(D\_m \cdot M\_m\right)}{d}}{\ell} \cdot \left(\frac{M\_m}{d + d} \cdot D\_m\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites70.2%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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
(fma
(* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d)))
M_m
1.0))
(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)))
(t_3 (sqrt (/ d l))))
(if (<= t_1 -2e+114)
(* (* t_0 t_2) t_3)
(if (<= t_1 -2e-155)
(*
(*
(fma
(* (* (* (* (* D_m M_m) D_m) M_m) (/ 0.25 (* d d))) (/ h l))
-0.5
1.0)
t_3)
t_2)
(if (<= t_1 2e-227)
(/ (* (sqrt (* d h)) (sqrt (* d l))) (* h l))
(if (<= t_1 5e+262)
(* (* t_3 t_2) 1.0)
(* t_0 (sqrt (* (/ d (* 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 t_0 = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0);
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 t_3 = sqrt((d / l));
double tmp;
if (t_1 <= -2e+114) {
tmp = (t_0 * t_2) * t_3;
} else if (t_1 <= -2e-155) {
tmp = (fma((((((D_m * M_m) * D_m) * M_m) * (0.25 / (d * d))) * (h / l)), -0.5, 1.0) * t_3) * t_2;
} else if (t_1 <= 2e-227) {
tmp = (sqrt((d * h)) * sqrt((d * l))) / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_3 * t_2) * 1.0;
} else {
tmp = t_0 * sqrt(((d / (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) t_0 = fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) 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)) t_3 = sqrt(Float64(d / l)) tmp = 0.0 if (t_1 <= -2e+114) tmp = Float64(Float64(t_0 * t_2) * t_3); elseif (t_1 <= -2e-155) tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(Float64(D_m * M_m) * D_m) * M_m) * Float64(0.25 / Float64(d * d))) * Float64(h / l)), -0.5, 1.0) * t_3) * t_2); elseif (t_1 <= 2e-227) tmp = Float64(Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) / Float64(h * l)); elseif (t_1 <= 5e+262) tmp = Float64(Float64(t_3 * t_2) * 1.0); else tmp = Float64(t_0 * sqrt(Float64(Float64(d / Float64(l * h)) * d))); 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[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $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]}, Block[{t$95$3 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -2e+114], N[(N[(t$95$0 * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$1, -2e-155], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(0.25 / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$3), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 2e-227], N[(N[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+262], N[(N[(t$95$3 * t$95$2), $MachinePrecision] * 1.0), $MachinePrecision], N[(t$95$0 * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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 := \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right)\\
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}}\\
t_3 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+114}:\\
\;\;\;\;\left(t\_0 \cdot t\_2\right) \cdot t\_3\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-155}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(\left(\left(\left(D\_m \cdot M\_m\right) \cdot D\_m\right) \cdot M\_m\right) \cdot \frac{0.25}{d \cdot d}\right) \cdot \frac{h}{\ell}, -0.5, 1\right) \cdot t\_3\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{\sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}}{h \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(t\_3 \cdot t\_2\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\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)))) < -2e114Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites62.9%
if -2e114 < (*.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.00000000000000003e-155Initial program 66.2%
Applied rewrites43.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
metadata-evalN/A
swap-sqrN/A
metadata-evalN/A
mult-flipN/A
metadata-evalN/A
mult-flipN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6452.7
Applied rewrites52.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
times-fracN/A
lift-*.f64N/A
metadata-evalN/A
mult-flipN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
metadata-evalN/A
mult-flipN/A
associate-/l/N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites51.7%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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 (/ d l)))
(t_2 (sqrt (/ d h))))
(if (<= t_0 -2e-155)
(*
(*
(fma
(/ (/ (* (* h (* D_m M_m)) (* 0.25 (* D_m M_m))) (* l d)) d)
-0.5
1.0)
t_1)
t_2)
(if (<= t_0 2e-227)
(/ (* (sqrt (* d h)) (sqrt (* d l))) (* h l))
(if (<= t_0 5e+262)
(* (* t_1 t_2) 1.0)
(*
(fma
(* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d)))
M_m
1.0)
(sqrt (* (/ d (* 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 t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((d / l));
double t_2 = sqrt((d / h));
double tmp;
if (t_0 <= -2e-155) {
tmp = (fma(((((h * (D_m * M_m)) * (0.25 * (D_m * M_m))) / (l * d)) / d), -0.5, 1.0) * t_1) * t_2;
} else if (t_0 <= 2e-227) {
tmp = (sqrt((d * h)) * sqrt((d * l))) / (h * l);
} else if (t_0 <= 5e+262) {
tmp = (t_1 * t_2) * 1.0;
} else {
tmp = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0) * sqrt(((d / (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) 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 = sqrt(Float64(d / l)) t_2 = sqrt(Float64(d / h)) tmp = 0.0 if (t_0 <= -2e-155) tmp = Float64(Float64(fma(Float64(Float64(Float64(Float64(h * Float64(D_m * M_m)) * Float64(0.25 * Float64(D_m * M_m))) / Float64(l * d)) / d), -0.5, 1.0) * t_1) * t_2); elseif (t_0 <= 2e-227) tmp = Float64(Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) / Float64(h * l)); elseif (t_0 <= 5e+262) tmp = Float64(Float64(t_1 * t_2) * 1.0); else tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))); 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[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -2e-155], N[(N[(N[(N[(N[(N[(N[(h * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$0, 2e-227], N[(N[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+262], N[(N[(t$95$1 * t$95$2), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-155}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\frac{\left(h \cdot \left(D\_m \cdot M\_m\right)\right) \cdot \left(0.25 \cdot \left(D\_m \cdot M\_m\right)\right)}{\ell \cdot d}}{d}, -0.5, 1\right) \cdot t\_1\right) \cdot t\_2\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{\sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}}{h \cdot \ell}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(t\_1 \cdot t\_2\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\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.00000000000000003e-155Initial program 66.2%
Applied rewrites43.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
unswap-sqrN/A
metadata-evalN/A
swap-sqrN/A
metadata-evalN/A
mult-flipN/A
metadata-evalN/A
mult-flipN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6452.7
Applied rewrites52.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites63.1%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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 (sqrt (* (/ d (* l h)) 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)))))
(t_2 (* 0.25 (/ D_m d))))
(if (<= t_1 -5e-88)
(- (* (fma (* (/ h (* (+ d d) l)) (* D_m M_m)) (* t_2 M_m) -1.0) t_0))
(if (<= t_1 2e-227)
(/ (* (sqrt (* d h)) (sqrt (* d l))) (* h l))
(if (<= t_1 5e+262)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(*
(fma (* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) t_2) M_m 1.0)
t_0))))))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 * h)) * 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 t_2 = 0.25 * (D_m / d);
double tmp;
if (t_1 <= -5e-88) {
tmp = -(fma(((h / ((d + d) * l)) * (D_m * M_m)), (t_2 * M_m), -1.0) * t_0);
} else if (t_1 <= 2e-227) {
tmp = (sqrt((d * h)) * sqrt((d * l))) / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else {
tmp = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * t_2), M_m, 1.0) * t_0;
}
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(Float64(d / Float64(l * h)) * 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)))) t_2 = Float64(0.25 * Float64(D_m / d)) tmp = 0.0 if (t_1 <= -5e-88) tmp = Float64(-Float64(fma(Float64(Float64(h / Float64(Float64(d + d) * l)) * Float64(D_m * M_m)), Float64(t_2 * M_m), -1.0) * t_0)); elseif (t_1 <= 2e-227) tmp = Float64(Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) / Float64(h * l)); elseif (t_1 <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); else tmp = Float64(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * t_2), M_m, 1.0) * t_0); 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[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $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[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-88], (-N[(N[(N[(N[(h / N[(N[(d + d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * M$95$m), $MachinePrecision] + -1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), If[LessEqual[t$95$1, 2e-227], N[(N[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * t$95$0), $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 \cdot h} \cdot 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)\\
t_2 := 0.25 \cdot \frac{D\_m}{d}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-88}:\\
\;\;\;\;-\mathsf{fma}\left(\frac{h}{\left(d + d\right) \cdot \ell} \cdot \left(D\_m \cdot M\_m\right), t\_2 \cdot M\_m, -1\right) \cdot t\_0\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{\sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}}{h \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot t\_2, M\_m, 1\right) \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000009e-88Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites50.0%
if -5.00000000000000009e-88 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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 (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))))))
(if (<= t_1 0.0)
(*
(fma (/ (* (/ (* (* (* D_m D_m) M_m) M_m) d) 0.125) d) (/ (- h) l) 1.0)
(sqrt (* (/ d (* l h)) d)))
(if (<= t_1 5e+262)
(* (* t_0 (sqrt (/ d h))) 1.0)
(if (<= t_1 INFINITY)
(/ (/ (* (sqrt (* d h)) (sqrt (* d l))) l) h)
(* t_0 (/ (* (- d) (sqrt (/ h d))) 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((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 tmp;
if (t_1 <= 0.0) {
tmp = fma(((((((D_m * D_m) * M_m) * M_m) / d) * 0.125) / d), (-h / l), 1.0) * sqrt(((d / (l * h)) * d));
} else if (t_1 <= 5e+262) {
tmp = (t_0 * sqrt((d / h))) * 1.0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((sqrt((d * h)) * sqrt((d * l))) / l) / h;
} else {
tmp = t_0 * ((-d * sqrt((h / d))) / 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(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)))) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(fma(Float64(Float64(Float64(Float64(Float64(Float64(D_m * D_m) * M_m) * M_m) / d) * 0.125) / d), Float64(Float64(-h) / l), 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))); elseif (t_1 <= 5e+262) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * 1.0); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) / l) / h); else tmp = Float64(t_0 * Float64(Float64(Float64(-d) * sqrt(Float64(h / d))) / 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[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]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(N[(N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] * M$95$m), $MachinePrecision] / d), $MachinePrecision] * 0.125), $MachinePrecision] / d), $MachinePrecision] * N[((-h) / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+262], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] / h), $MachinePrecision], N[(t$95$0 * N[(N[((-d) * N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $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)\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(D\_m \cdot D\_m\right) \cdot M\_m\right) \cdot M\_m}{d} \cdot 0.125}{d}, \frac{-h}{\ell}, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{\sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}}{\ell}}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\left(-d\right) \cdot \sqrt{\frac{h}{d}}}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 66.2%
Applied rewrites24.8%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
distribute-lft1-inN/A
lower-*.f64N/A
Applied rewrites43.0%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f6431.9
Applied rewrites31.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6411.8
Applied rewrites11.8%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6411.4
Applied rewrites11.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
(*
(fma
(* (/ (* (* D_m M_m) h) (* (* -2.0 d) l)) (* 0.25 (/ D_m d)))
M_m
1.0)
(sqrt (* (/ d (* l h)) d)))))
(if (<= t_0 0.0)
t_1
(if (<= t_0 5e+262) (* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0) 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 = fma(((((D_m * M_m) * h) / ((-2.0 * d) * l)) * (0.25 * (D_m / d))), M_m, 1.0) * sqrt(((d / (l * h)) * d));
double tmp;
if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} 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(fma(Float64(Float64(Float64(Float64(D_m * M_m) * h) / Float64(Float64(-2.0 * d) * l)) * Float64(0.25 * Float64(D_m / d))), M_m, 1.0) * sqrt(Float64(Float64(d / Float64(l * h)) * d))) tmp = 0.0 if (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); else tmp = t_1; 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[(N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * M$95$m + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(d / N[(l * h), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $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 := \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot h}{\left(-2 \cdot d\right) \cdot \ell} \cdot \left(0.25 \cdot \frac{D\_m}{d}\right), M\_m, 1\right) \cdot \sqrt{\frac{d}{\ell \cdot h} \cdot d}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\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)))) < 0.0 or 5.00000000000000008e262 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
Applied rewrites51.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)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
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 h)) (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 l))))
(if (<= t_1 -5e-88)
(/ (* (* -1.0 (* d (sqrt (sqrt (* (/ h d) (/ h d)))))) t_2) h)
(if (<= t_1 2e-227)
(/ t_0 (* h l))
(if (<= t_1 5e+262)
(* (* t_2 (sqrt (/ d h))) 1.0)
(if (<= t_1 INFINITY)
(/ (/ t_0 l) h)
(* t_2 (/ (* (- d) (sqrt (/ h d))) 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((d * h)) * 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 / l));
double tmp;
if (t_1 <= -5e-88) {
tmp = ((-1.0 * (d * sqrt(sqrt(((h / d) * (h / d)))))) * t_2) / h;
} else if (t_1 <= 2e-227) {
tmp = t_0 / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_2 * sqrt((d / h))) * 1.0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (t_0 / l) / h;
} else {
tmp = t_2 * ((-d * sqrt((h / d))) / 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((d * h)) * 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 / l));
double tmp;
if (t_1 <= -5e-88) {
tmp = ((-1.0 * (d * Math.sqrt(Math.sqrt(((h / d) * (h / d)))))) * t_2) / h;
} else if (t_1 <= 2e-227) {
tmp = t_0 / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_2 * Math.sqrt((d / h))) * 1.0;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (t_0 / l) / h;
} else {
tmp = t_2 * ((-d * Math.sqrt((h / d))) / 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((d * h)) * 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 / l)) tmp = 0 if t_1 <= -5e-88: tmp = ((-1.0 * (d * math.sqrt(math.sqrt(((h / d) * (h / d)))))) * t_2) / h elif t_1 <= 2e-227: tmp = t_0 / (h * l) elif t_1 <= 5e+262: tmp = (t_2 * math.sqrt((d / h))) * 1.0 elif t_1 <= math.inf: tmp = (t_0 / l) / h else: tmp = t_2 * ((-d * math.sqrt((h / d))) / 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(sqrt(Float64(d * h)) * 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 / l)) tmp = 0.0 if (t_1 <= -5e-88) tmp = Float64(Float64(Float64(-1.0 * Float64(d * sqrt(sqrt(Float64(Float64(h / d) * Float64(h / d)))))) * t_2) / h); elseif (t_1 <= 2e-227) tmp = Float64(t_0 / Float64(h * l)); elseif (t_1 <= 5e+262) tmp = Float64(Float64(t_2 * sqrt(Float64(d / h))) * 1.0); elseif (t_1 <= Inf) tmp = Float64(Float64(t_0 / l) / h); else tmp = Float64(t_2 * Float64(Float64(Float64(-d) * sqrt(Float64(h / d))) / 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((d * h)) * 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 / l));
tmp = 0.0;
if (t_1 <= -5e-88)
tmp = ((-1.0 * (d * sqrt(sqrt(((h / d) * (h / d)))))) * t_2) / h;
elseif (t_1 <= 2e-227)
tmp = t_0 / (h * l);
elseif (t_1 <= 5e+262)
tmp = (t_2 * sqrt((d / h))) * 1.0;
elseif (t_1 <= Inf)
tmp = (t_0 / l) / h;
else
tmp = t_2 * ((-d * sqrt((h / d))) / 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[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $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]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -5e-88], N[(N[(N[(-1.0 * N[(d * N[Sqrt[N[Sqrt[N[(N[(h / d), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$1, 2e-227], N[(t$95$0 / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+262], N[(N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(t$95$0 / l), $MachinePrecision] / h), $MachinePrecision], N[(t$95$2 * N[(N[((-d) * N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $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{d \cdot h} \cdot \sqrt{d \cdot \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}{\ell}}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-88}:\\
\;\;\;\;\frac{\left(-1 \cdot \left(d \cdot \sqrt{\sqrt{\frac{h}{d} \cdot \frac{h}{d}}}\right)\right) \cdot t\_2}{h}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{t\_0}{h \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(t\_2 \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{t\_0}{\ell}}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot \frac{\left(-d\right) \cdot \sqrt{\frac{h}{d}}}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000009e-88Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6411.8
Applied rewrites11.8%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6415.6
Applied rewrites15.6%
if -5.00000000000000009e-88 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f6431.9
Applied rewrites31.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6411.8
Applied rewrites11.8%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6411.4
Applied rewrites11.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 (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)) (sqrt (* d l)))))
(if (<= t_1 -2e-155)
(* -1.0 (/ (* d (sqrt (/ h l))) h))
(if (<= t_1 2e-227)
(/ t_2 (* h l))
(if (<= t_1 5e+262)
(* (* t_0 (sqrt (/ d h))) 1.0)
(if (<= t_1 INFINITY)
(/ (/ t_2 l) h)
(* t_0 (/ (* (- d) (sqrt (/ h d))) 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((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)) * sqrt((d * l));
double tmp;
if (t_1 <= -2e-155) {
tmp = -1.0 * ((d * sqrt((h / l))) / h);
} else if (t_1 <= 2e-227) {
tmp = t_2 / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_0 * sqrt((d / h))) * 1.0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (t_2 / l) / h;
} else {
tmp = t_0 * ((-d * sqrt((h / d))) / 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((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)) * Math.sqrt((d * l));
double tmp;
if (t_1 <= -2e-155) {
tmp = -1.0 * ((d * Math.sqrt((h / l))) / h);
} else if (t_1 <= 2e-227) {
tmp = t_2 / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_0 * Math.sqrt((d / h))) * 1.0;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (t_2 / l) / h;
} else {
tmp = t_0 * ((-d * Math.sqrt((h / d))) / 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((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)) * math.sqrt((d * l)) tmp = 0 if t_1 <= -2e-155: tmp = -1.0 * ((d * math.sqrt((h / l))) / h) elif t_1 <= 2e-227: tmp = t_2 / (h * l) elif t_1 <= 5e+262: tmp = (t_0 * math.sqrt((d / h))) * 1.0 elif t_1 <= math.inf: tmp = (t_2 / l) / h else: tmp = t_0 * ((-d * math.sqrt((h / d))) / 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(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 = Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) tmp = 0.0 if (t_1 <= -2e-155) tmp = Float64(-1.0 * Float64(Float64(d * sqrt(Float64(h / l))) / h)); elseif (t_1 <= 2e-227) tmp = Float64(t_2 / Float64(h * l)); elseif (t_1 <= 5e+262) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * 1.0); elseif (t_1 <= Inf) tmp = Float64(Float64(t_2 / l) / h); else tmp = Float64(t_0 * Float64(Float64(Float64(-d) * sqrt(Float64(h / d))) / 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((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)) * sqrt((d * l));
tmp = 0.0;
if (t_1 <= -2e-155)
tmp = -1.0 * ((d * sqrt((h / l))) / h);
elseif (t_1 <= 2e-227)
tmp = t_2 / (h * l);
elseif (t_1 <= 5e+262)
tmp = (t_0 * sqrt((d / h))) * 1.0;
elseif (t_1 <= Inf)
tmp = (t_2 / l) / h;
else
tmp = t_0 * ((-d * sqrt((h / d))) / 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[(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[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-155], N[(-1.0 * N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-227], N[(t$95$2 / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+262], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(t$95$2 / l), $MachinePrecision] / h), $MachinePrecision], N[(t$95$0 * N[(N[((-d) * N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $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{d \cdot h} \cdot \sqrt{d \cdot \ell}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-155}:\\
\;\;\;\;-1 \cdot \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{t\_2}{h \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{t\_2}{\ell}}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{\left(-d\right) \cdot \sqrt{\frac{h}{d}}}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.00000000000000003e-155Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6413.5
Applied rewrites13.5%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f6431.9
Applied rewrites31.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6411.8
Applied rewrites11.8%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6411.4
Applied rewrites11.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 (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)) (sqrt (* d l)))))
(if (<= t_1 -2e-155)
(* -1.0 (/ (* d (sqrt (/ h l))) h))
(if (<= t_1 2e-227)
(/ t_2 (* h l))
(if (<= t_1 5e+262)
(* (* t_0 (sqrt (/ d h))) 1.0)
(if (<= t_1 INFINITY)
(/ (/ t_2 l) h)
(/ (* t_0 (* (- d) (sqrt (/ h d)))) 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((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)) * sqrt((d * l));
double tmp;
if (t_1 <= -2e-155) {
tmp = -1.0 * ((d * sqrt((h / l))) / h);
} else if (t_1 <= 2e-227) {
tmp = t_2 / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_0 * sqrt((d / h))) * 1.0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (t_2 / l) / h;
} else {
tmp = (t_0 * (-d * sqrt((h / d)))) / 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((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)) * Math.sqrt((d * l));
double tmp;
if (t_1 <= -2e-155) {
tmp = -1.0 * ((d * Math.sqrt((h / l))) / h);
} else if (t_1 <= 2e-227) {
tmp = t_2 / (h * l);
} else if (t_1 <= 5e+262) {
tmp = (t_0 * Math.sqrt((d / h))) * 1.0;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (t_2 / l) / h;
} else {
tmp = (t_0 * (-d * Math.sqrt((h / d)))) / 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((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)) * math.sqrt((d * l)) tmp = 0 if t_1 <= -2e-155: tmp = -1.0 * ((d * math.sqrt((h / l))) / h) elif t_1 <= 2e-227: tmp = t_2 / (h * l) elif t_1 <= 5e+262: tmp = (t_0 * math.sqrt((d / h))) * 1.0 elif t_1 <= math.inf: tmp = (t_2 / l) / h else: tmp = (t_0 * (-d * math.sqrt((h / d)))) / 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(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 = Float64(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) tmp = 0.0 if (t_1 <= -2e-155) tmp = Float64(-1.0 * Float64(Float64(d * sqrt(Float64(h / l))) / h)); elseif (t_1 <= 2e-227) tmp = Float64(t_2 / Float64(h * l)); elseif (t_1 <= 5e+262) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * 1.0); elseif (t_1 <= Inf) tmp = Float64(Float64(t_2 / l) / h); else tmp = Float64(Float64(t_0 * Float64(Float64(-d) * sqrt(Float64(h / d)))) / 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((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)) * sqrt((d * l));
tmp = 0.0;
if (t_1 <= -2e-155)
tmp = -1.0 * ((d * sqrt((h / l))) / h);
elseif (t_1 <= 2e-227)
tmp = t_2 / (h * l);
elseif (t_1 <= 5e+262)
tmp = (t_0 * sqrt((d / h))) * 1.0;
elseif (t_1 <= Inf)
tmp = (t_2 / l) / h;
else
tmp = (t_0 * (-d * sqrt((h / d)))) / 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[(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[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-155], N[(-1.0 * N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-227], N[(t$95$2 / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+262], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(t$95$2 / l), $MachinePrecision] / h), $MachinePrecision], N[(N[(t$95$0 * N[((-d) * N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $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 := \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{d \cdot h} \cdot \sqrt{d \cdot \ell}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-155}:\\
\;\;\;\;-1 \cdot \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{t\_2}{h \cdot \ell}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\frac{t\_2}{\ell}}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \left(\left(-d\right) \cdot \sqrt{\frac{h}{d}}\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)))) < -2.00000000000000003e-155Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6413.5
Applied rewrites13.5%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f6431.9
Applied rewrites31.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6411.8
Applied rewrites11.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6411.8
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.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
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(-
1.0
(* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (sqrt (* d h)) (sqrt (* d l)))))
(if (<= t_0 -2e-155)
(* -1.0 (/ (* d (sqrt (/ h l))) h))
(if (<= t_0 2e-227)
(/ t_1 (* h l))
(if (<= t_0 5e+262)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= t_0 INFINITY)
(/ (/ t_1 l) h)
(* d (sqrt (/ 1.0 (* h 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 = sqrt((d * h)) * sqrt((d * l));
double tmp;
if (t_0 <= -2e-155) {
tmp = -1.0 * ((d * sqrt((h / l))) / h);
} else if (t_0 <= 2e-227) {
tmp = t_1 / (h * l);
} else if (t_0 <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (t_0 <= ((double) INFINITY)) {
tmp = (t_1 / l) / h;
} else {
tmp = d * sqrt((1.0 / (h * 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 = Math.sqrt((d * h)) * Math.sqrt((d * l));
double tmp;
if (t_0 <= -2e-155) {
tmp = -1.0 * ((d * Math.sqrt((h / l))) / h);
} else if (t_0 <= 2e-227) {
tmp = t_1 / (h * l);
} else if (t_0 <= 5e+262) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (t_1 / l) / h;
} else {
tmp = d * Math.sqrt((1.0 / (h * 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 = math.sqrt((d * h)) * math.sqrt((d * l)) tmp = 0 if t_0 <= -2e-155: tmp = -1.0 * ((d * math.sqrt((h / l))) / h) elif t_0 <= 2e-227: tmp = t_1 / (h * l) elif t_0 <= 5e+262: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif t_0 <= math.inf: tmp = (t_1 / l) / h else: tmp = d * math.sqrt((1.0 / (h * 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(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) tmp = 0.0 if (t_0 <= -2e-155) tmp = Float64(-1.0 * Float64(Float64(d * sqrt(Float64(h / l))) / h)); elseif (t_0 <= 2e-227) tmp = Float64(t_1 / Float64(h * l)); elseif (t_0 <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (t_0 <= Inf) tmp = Float64(Float64(t_1 / l) / h); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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 = sqrt((d * h)) * sqrt((d * l));
tmp = 0.0;
if (t_0 <= -2e-155)
tmp = -1.0 * ((d * sqrt((h / l))) / h);
elseif (t_0 <= 2e-227)
tmp = t_1 / (h * l);
elseif (t_0 <= 5e+262)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (t_0 <= Inf)
tmp = (t_1 / l) / h;
else
tmp = d * sqrt((1.0 / (h * 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[(N[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-155], N[(-1.0 * N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-227], N[(t$95$1 / N[(h * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(t$95$1 / l), $MachinePrecision] / h), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-155}:\\
\;\;\;\;-1 \cdot \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;\frac{t\_1}{h \cdot \ell}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\frac{t\_1}{\ell}}{h}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \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.00000000000000003e-155Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6413.5
Applied rewrites13.5%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
if 5.00000000000000008e262 < (*.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f6431.9
Applied rewrites31.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 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.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 (* d h)) (sqrt (* d l))) (* 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-155)
(* -1.0 (/ (* d (sqrt (/ h l))) h))
(if (<= t_1 2e-227)
t_0
(if (<= t_1 5e+262)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= t_1 INFINITY) t_0 (* d (sqrt (/ 1.0 (* h 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 * h)) * sqrt((d * l))) / (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-155) {
tmp = -1.0 * ((d * sqrt((h / l))) / h);
} else if (t_1 <= 2e-227) {
tmp = t_0;
} else if (t_1 <= 5e+262) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = d * sqrt((1.0 / (h * 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 * h)) * Math.sqrt((d * l))) / (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-155) {
tmp = -1.0 * ((d * Math.sqrt((h / l))) / h);
} else if (t_1 <= 2e-227) {
tmp = t_0;
} else if (t_1 <= 5e+262) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = d * Math.sqrt((1.0 / (h * 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 * h)) * math.sqrt((d * l))) / (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-155: tmp = -1.0 * ((d * math.sqrt((h / l))) / h) elif t_1 <= 2e-227: tmp = t_0 elif t_1 <= 5e+262: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif t_1 <= math.inf: tmp = t_0 else: tmp = d * math.sqrt((1.0 / (h * 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(sqrt(Float64(d * h)) * sqrt(Float64(d * l))) / 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-155) tmp = Float64(-1.0 * Float64(Float64(d * sqrt(Float64(h / l))) / h)); elseif (t_1 <= 2e-227) tmp = t_0; elseif (t_1 <= 5e+262) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (t_1 <= Inf) tmp = t_0; else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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 * h)) * sqrt((d * l))) / (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-155)
tmp = -1.0 * ((d * sqrt((h / l))) / h);
elseif (t_1 <= 2e-227)
tmp = t_0;
elseif (t_1 <= 5e+262)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (t_1 <= Inf)
tmp = t_0;
else
tmp = d * sqrt((1.0 / (h * 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[Sqrt[N[(d * h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 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-155], N[(-1.0 * N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-227], t$95$0, If[LessEqual[t$95$1, 5e+262], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$0, N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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 := \frac{\sqrt{d \cdot h} \cdot \sqrt{d \cdot \ell}}{h \cdot \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^{-155}:\\
\;\;\;\;-1 \cdot \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \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.00000000000000003e-155Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6413.5
Applied rewrites13.5%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227 or 5.00000000000000008e262 < (*.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 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6429.6
Applied rewrites29.6%
if 1.99999999999999989e-227 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000008e262Initial program 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
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 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.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
(*
(* (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 -2e-155)
(* -1.0 (/ (* d (sqrt (/ h l))) h))
(if (<= t_0 2e-227)
(* d (sqrt (/ 1.0 (* h l))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))))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 <= -2e-155) {
tmp = -1.0 * ((d * sqrt((h / l))) / h);
} else if (t_0 <= 2e-227) {
tmp = d * sqrt((1.0 / (h * l)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
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 = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-2d-155)) then
tmp = (-1.0d0) * ((d * sqrt((h / l))) / h)
else if (t_0 <= 2d-227) then
tmp = d * sqrt((1.0d0 / (h * l)))
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
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.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 <= -2e-155) {
tmp = -1.0 * ((d * Math.sqrt((h / l))) / h);
} else if (t_0 <= 2e-227) {
tmp = d * Math.sqrt((1.0 / (h * l)));
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
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 <= -2e-155: tmp = -1.0 * ((d * math.sqrt((h / l))) / h) elif t_0 <= 2e-227: tmp = d * math.sqrt((1.0 / (h * l))) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 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 <= -2e-155) tmp = Float64(-1.0 * Float64(Float64(d * sqrt(Float64(h / l))) / h)); elseif (t_0 <= 2e-227) tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); 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 <= -2e-155)
tmp = -1.0 * ((d * sqrt((h / l))) / h);
elseif (t_0 <= 2e-227)
tmp = d * sqrt((1.0 / (h * l)));
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
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, -2e-155], N[(-1.0 * N[(N[(d * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-227], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
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 -2 \cdot 10^{-155}:\\
\;\;\;\;-1 \cdot \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-227}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -2.00000000000000003e-155Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6413.5
Applied rewrites13.5%
if -2.00000000000000003e-155 < (*.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.99999999999999989e-227Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.8%
if 1.99999999999999989e-227 < (*.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 66.2%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f6467.8
lift-/.f64N/A
metadata-eval67.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6467.8
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites39.5%
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 7.4e-175)
(* (sqrt (/ (/ 1.0 l) h)) (- d))
(if (<= d 5.7e+119)
(* (sqrt (/ d l)) (/ (sqrt (* h d)) h))
(* d (sqrt (/ 1.0 (* h 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 tmp;
if (d <= 7.4e-175) {
tmp = sqrt(((1.0 / l) / h)) * -d;
} else if (d <= 5.7e+119) {
tmp = sqrt((d / l)) * (sqrt((h * d)) / h);
} else {
tmp = d * sqrt((1.0 / (h * l)));
}
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 <= 7.4d-175) then
tmp = sqrt(((1.0d0 / l) / h)) * -d
else if (d <= 5.7d+119) then
tmp = sqrt((d / l)) * (sqrt((h * d)) / h)
else
tmp = d * sqrt((1.0d0 / (h * l)))
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 <= 7.4e-175) {
tmp = Math.sqrt(((1.0 / l) / h)) * -d;
} else if (d <= 5.7e+119) {
tmp = Math.sqrt((d / l)) * (Math.sqrt((h * d)) / h);
} else {
tmp = d * Math.sqrt((1.0 / (h * 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): tmp = 0 if d <= 7.4e-175: tmp = math.sqrt(((1.0 / l) / h)) * -d elif d <= 5.7e+119: tmp = math.sqrt((d / l)) * (math.sqrt((h * d)) / h) else: tmp = d * math.sqrt((1.0 / (h * 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) tmp = 0.0 if (d <= 7.4e-175) tmp = Float64(sqrt(Float64(Float64(1.0 / l) / h)) * Float64(-d)); elseif (d <= 5.7e+119) tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(h * d)) / h)); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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)
tmp = 0.0;
if (d <= 7.4e-175)
tmp = sqrt(((1.0 / l) / h)) * -d;
elseif (d <= 5.7e+119)
tmp = sqrt((d / l)) * (sqrt((h * d)) / h);
else
tmp = d * sqrt((1.0 / (h * 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_] := If[LessEqual[d, 7.4e-175], N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], If[LessEqual[d, 5.7e+119], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(h * d), $MachinePrecision]], $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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}
\mathbf{if}\;d \leq 7.4 \cdot 10^{-175}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot \left(-d\right)\\
\mathbf{elif}\;d \leq 5.7 \cdot 10^{+119}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{h \cdot d}}{h}\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
\end{array}
if d < 7.39999999999999997e-175Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6427.2
Applied rewrites27.2%
if 7.39999999999999997e-175 < d < 5.7000000000000002e119Initial program 66.2%
Taylor expanded in h around 0
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
lift-/.f64N/A
mult-flipN/A
lift-sqrt.f64N/A
pow1/2N/A
lift-pow.f64N/A
metadata-evalN/A
lift-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
lift-sqrt.f64N/A
mult-flip-revN/A
lower-/.f6422.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6422.7
Applied rewrites22.7%
if 5.7000000000000002e119 < d Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.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 (if (<= l -6.7e-276) (* (sqrt (/ (/ 1.0 l) h)) (- d)) (* d (sqrt (/ 1.0 (* h 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 tmp;
if (l <= -6.7e-276) {
tmp = sqrt(((1.0 / l) / h)) * -d;
} else {
tmp = d * sqrt((1.0 / (h * l)));
}
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 <= (-6.7d-276)) then
tmp = sqrt(((1.0d0 / l) / h)) * -d
else
tmp = d * sqrt((1.0d0 / (h * l)))
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 <= -6.7e-276) {
tmp = Math.sqrt(((1.0 / l) / h)) * -d;
} else {
tmp = d * Math.sqrt((1.0 / (h * 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): tmp = 0 if l <= -6.7e-276: tmp = math.sqrt(((1.0 / l) / h)) * -d else: tmp = d * math.sqrt((1.0 / (h * 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) tmp = 0.0 if (l <= -6.7e-276) tmp = Float64(sqrt(Float64(Float64(1.0 / l) / h)) * Float64(-d)); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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)
tmp = 0.0;
if (l <= -6.7e-276)
tmp = sqrt(((1.0 / l) / h)) * -d;
else
tmp = d * sqrt((1.0 / (h * 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_] := If[LessEqual[l, -6.7e-276], N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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}
\mathbf{if}\;\ell \leq -6.7 \cdot 10^{-276}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
\end{array}
if l < -6.69999999999999983e-276Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6427.2
Applied rewrites27.2%
if -6.69999999999999983e-276 < l Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.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 (if (<= l -6.7e-276) (* (sqrt (/ (/ 1.0 h) l)) (- d)) (* d (sqrt (/ 1.0 (* h 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 tmp;
if (l <= -6.7e-276) {
tmp = sqrt(((1.0 / h) / l)) * -d;
} else {
tmp = d * sqrt((1.0 / (h * l)));
}
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 <= (-6.7d-276)) then
tmp = sqrt(((1.0d0 / h) / l)) * -d
else
tmp = d * sqrt((1.0d0 / (h * l)))
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 <= -6.7e-276) {
tmp = Math.sqrt(((1.0 / h) / l)) * -d;
} else {
tmp = d * Math.sqrt((1.0 / (h * 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): tmp = 0 if l <= -6.7e-276: tmp = math.sqrt(((1.0 / h) / l)) * -d else: tmp = d * math.sqrt((1.0 / (h * 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) tmp = 0.0 if (l <= -6.7e-276) tmp = Float64(sqrt(Float64(Float64(1.0 / h) / l)) * Float64(-d)); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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)
tmp = 0.0;
if (l <= -6.7e-276)
tmp = sqrt(((1.0 / h) / l)) * -d;
else
tmp = d * sqrt((1.0 / (h * 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_] := If[LessEqual[l, -6.7e-276], N[(N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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}
\mathbf{if}\;\ell \leq -6.7 \cdot 10^{-276}:\\
\;\;\;\;\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
\end{array}
if l < -6.69999999999999983e-276Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6427.2
Applied rewrites27.2%
if -6.69999999999999983e-276 < l Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.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 (if (<= l -6.7e-276) (* (sqrt (/ 1.0 (* l h))) (- d)) (* d (sqrt (/ 1.0 (* h 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 tmp;
if (l <= -6.7e-276) {
tmp = sqrt((1.0 / (l * h))) * -d;
} else {
tmp = d * sqrt((1.0 / (h * l)));
}
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 <= (-6.7d-276)) then
tmp = sqrt((1.0d0 / (l * h))) * -d
else
tmp = d * sqrt((1.0d0 / (h * l)))
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 <= -6.7e-276) {
tmp = Math.sqrt((1.0 / (l * h))) * -d;
} else {
tmp = d * Math.sqrt((1.0 / (h * 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): tmp = 0 if l <= -6.7e-276: tmp = math.sqrt((1.0 / (l * h))) * -d else: tmp = d * math.sqrt((1.0 / (h * 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) tmp = 0.0 if (l <= -6.7e-276) tmp = Float64(sqrt(Float64(1.0 / Float64(l * h))) * Float64(-d)); else tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * 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)
tmp = 0.0;
if (l <= -6.7e-276)
tmp = sqrt((1.0 / (l * h))) * -d;
else
tmp = d * sqrt((1.0 / (h * 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_] := If[LessEqual[l, -6.7e-276], N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-d)), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $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}
\mathbf{if}\;\ell \leq -6.7 \cdot 10^{-276}:\\
\;\;\;\;\sqrt{\frac{1}{\ell \cdot h}} \cdot \left(-d\right)\\
\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\end{array}
\end{array}
if l < -6.69999999999999983e-276Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
if -6.69999999999999983e-276 < l Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.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 (* d (sqrt (/ 1.0 (* h 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) {
return d * sqrt((1.0 / (h * l)));
}
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((1.0d0 / (h * l)))
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((1.0 / (h * l)));
}
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((1.0 / (h * l)))
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(1.0 / Float64(h * l)))) 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((1.0 / (h * l)));
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[(1.0 / N[(h * l), $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])\\
\\
d \cdot \sqrt{\frac{1}{h \cdot \ell}}
\end{array}
Initial program 66.2%
Applied rewrites24.8%
Taylor expanded in d around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.1
Applied rewrites27.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6427.1
Applied rewrites27.1%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6425.8
Applied rewrites25.8%
herbie shell --seed 2025156
(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)))))