
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<= l -5e-310)
(*
(* (/ (sqrt (- d)) (sqrt (- h))) (pow (/ d l) (pow 2.0 -1.0)))
(- 1.0 (* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
(/
(*
(fma (* (/ h l) -0.5) (pow (* (/ M_m -2.0) (/ D d)) 2.0) 1.0)
(/ d (sqrt l)))
(sqrt h))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= -5e-310) {
tmp = ((sqrt(-d) / sqrt(-h)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
} else {
tmp = (fma(((h / l) * -0.5), pow(((M_m / -2.0) * (D / d)), 2.0), 1.0) * (d / sqrt(l))) / sqrt(h);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= -5e-310) tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(fma(Float64(Float64(h / l) * -0.5), (Float64(Float64(M_m / -2.0) * Float64(D / d)) ^ 2.0), 1.0) * Float64(d / sqrt(l))) / sqrt(h)); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[N[(N[(M$95$m / -2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[(d / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{M\_m}{-2} \cdot \frac{D}{d}\right)}^{2}, 1\right) \cdot \frac{d}{\sqrt{\ell}}}{\sqrt{h}}\\
\end{array}
\end{array}
if l < -4.999999999999985e-310Initial program 78.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lift-/.f64N/A
frac-2negN/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-neg.f6486.2
Applied rewrites86.2%
if -4.999999999999985e-310 < l Initial program 74.2%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6474.2
Applied rewrites74.2%
Applied rewrites81.9%
Final simplification83.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (sqrt (/ d h)) (sqrt (/ d l))))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 5e-46)
(*
t_0
(- 1.0 (* (/ (* (* (/ D l) (* h (/ M_m d))) (* 0.5 D)) 4.0) (/ M_m d))))
(if (<= t_1 INFINITY)
(*
t_0
(-
1.0
(*
(* (/ h d) (/ M_m l))
(* (/ D 2.0) (* (/ (* 0.5 D) d) (/ M_m 2.0))))))
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((d / h)) * sqrt((d / l));
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 5e-46) {
tmp = t_0 * (1.0 - (((((D / l) * (h * (M_m / d))) * (0.5 * D)) / 4.0) * (M_m / d)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_0 * (1.0 - (((h / d) * (M_m / l)) * ((D / 2.0) * (((0.5 * D) / d) * (M_m / 2.0)))));
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 5e-46) tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D / l) * Float64(h * Float64(M_m / d))) * Float64(0.5 * D)) / 4.0) * Float64(M_m / d)))); elseif (t_1 <= Inf) tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(Float64(h / d) * Float64(M_m / l)) * Float64(Float64(D / 2.0) * Float64(Float64(Float64(0.5 * D) / d) * Float64(M_m / 2.0)))))); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := 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[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-46], N[(t$95$0 * N[(1.0 - N[(N[(N[(N[(N[(D / l), $MachinePrecision] * N[(h * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * D), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(t$95$0 * N[(1.0 - N[(N[(N[(h / d), $MachinePrecision] * N[(M$95$m / l), $MachinePrecision]), $MachinePrecision] * N[(N[(D / 2.0), $MachinePrecision] * N[(N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-46}:\\
\;\;\;\;t\_0 \cdot \left(1 - \frac{\left(\frac{D}{\ell} \cdot \left(h \cdot \frac{M\_m}{d}\right)\right) \cdot \left(0.5 \cdot D\right)}{4} \cdot \frac{M\_m}{d}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_0 \cdot \left(1 - \left(\frac{h}{d} \cdot \frac{M\_m}{\ell}\right) \cdot \left(\frac{D}{2} \cdot \left(\frac{0.5 \cdot D}{d} \cdot \frac{M\_m}{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999992e-46Initial program 93.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6493.1
Applied rewrites93.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6493.1
Applied rewrites93.1%
Applied rewrites88.1%
if 4.99999999999999992e-46 < (*.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 87.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6487.1
Applied rewrites87.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6487.1
Applied rewrites87.1%
Applied rewrites87.1%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification79.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ d h)))
(t_1 (sqrt (/ d l)))
(t_2
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_2 -4e-48)
(*
(* t_0 t_1)
(fma (* (/ (* -0.125 D) d) (/ (* h D) (* l d))) (* M_m M_m) 1.0))
(if (<= t_2 INFINITY)
(* (* t_0 1.0) t_1)
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double t_2 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= -4e-48) {
tmp = (t_0 * t_1) * fma((((-0.125 * D) / d) * ((h * D) / (l * d))), (M_m * M_m), 1.0);
} else if (t_2 <= ((double) INFINITY)) {
tmp = (t_0 * 1.0) * t_1;
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) t_2 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_2 <= -4e-48) tmp = Float64(Float64(t_0 * t_1) * fma(Float64(Float64(Float64(-0.125 * D) / d) * Float64(Float64(h * D) / Float64(l * d))), Float64(M_m * M_m), 1.0)); elseif (t_2 <= Inf) tmp = Float64(Float64(t_0 * 1.0) * t_1); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-48], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(N[(N[(N[(-0.125 * D), $MachinePrecision] / d), $MachinePrecision] * N[(N[(h * D), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(t$95$0 * 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot t\_1\right) \cdot \mathsf{fma}\left(\frac{-0.125 \cdot D}{d} \cdot \frac{h \cdot D}{\ell \cdot d}, M\_m \cdot M\_m, 1\right)\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left(t\_0 \cdot 1\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\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)))) < -3.9999999999999999e-48Initial program 92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites75.7%
Applied rewrites78.2%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification74.6%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ d h)))
(t_1 (sqrt (/ d l)))
(t_2
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_2 -4e-48)
(*
(* t_0 t_1)
(fma (* (/ -0.125 (* l d)) (/ (* (* D D) h) d)) (* M_m M_m) 1.0))
(if (<= t_2 INFINITY)
(* (* t_0 1.0) t_1)
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double t_2 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= -4e-48) {
tmp = (t_0 * t_1) * fma(((-0.125 / (l * d)) * (((D * D) * h) / d)), (M_m * M_m), 1.0);
} else if (t_2 <= ((double) INFINITY)) {
tmp = (t_0 * 1.0) * t_1;
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) t_2 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_2 <= -4e-48) tmp = Float64(Float64(t_0 * t_1) * fma(Float64(Float64(-0.125 / Float64(l * d)) * Float64(Float64(Float64(D * D) * h) / d)), Float64(M_m * M_m), 1.0)); elseif (t_2 <= Inf) tmp = Float64(Float64(t_0 * 1.0) * t_1); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-48], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(N[(N[(-0.125 / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(t$95$0 * 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot t\_1\right) \cdot \mathsf{fma}\left(\frac{-0.125}{\ell \cdot d} \cdot \frac{\left(D \cdot D\right) \cdot h}{d}, M\_m \cdot M\_m, 1\right)\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left(t\_0 \cdot 1\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\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)))) < -3.9999999999999999e-48Initial program 92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites75.7%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification73.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ d h)))
(t_1 (sqrt (/ d l)))
(t_2
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_2 -4e-48)
(*
(* t_0 t_1)
(fma (/ (* (* (* D D) h) -0.125) (* (* l d) d)) (* M_m M_m) 1.0))
(if (<= t_2 INFINITY)
(* (* t_0 1.0) t_1)
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0))))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double t_2 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_2 <= -4e-48) {
tmp = (t_0 * t_1) * fma(((((D * D) * h) * -0.125) / ((l * d) * d)), (M_m * M_m), 1.0);
} else if (t_2 <= ((double) INFINITY)) {
tmp = (t_0 * 1.0) * t_1;
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) t_2 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_2 <= -4e-48) tmp = Float64(Float64(t_0 * t_1) * fma(Float64(Float64(Float64(Float64(D * D) * h) * -0.125) / Float64(Float64(l * d) * d)), Float64(M_m * M_m), 1.0)); elseif (t_2 <= Inf) tmp = Float64(Float64(t_0 * 1.0) * t_1); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-48], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(N[(N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] * -0.125), $MachinePrecision] / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(t$95$0 * 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot t\_1\right) \cdot \mathsf{fma}\left(\frac{\left(\left(D \cdot D\right) \cdot h\right) \cdot -0.125}{\left(\ell \cdot d\right) \cdot d}, M\_m \cdot M\_m, 1\right)\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left(t\_0 \cdot 1\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\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)))) < -3.9999999999999999e-48Initial program 92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites75.7%
Applied rewrites69.9%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification71.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (or (<= t_0 -4e-48) (not (<= t_0 INFINITY)))
(*
(/ d (sqrt (* l h)))
(fma (/ (* M_m M_m) l) (* (/ (/ (* (* D D) h) d) d) -0.125) 1.0))
(* (* (sqrt (/ d h)) 1.0) (sqrt (/ d l))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if ((t_0 <= -4e-48) || !(t_0 <= ((double) INFINITY))) {
tmp = (d / sqrt((l * h))) * fma(((M_m * M_m) / l), (((((D * D) * h) / d) / d) * -0.125), 1.0);
} else {
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if ((t_0 <= -4e-48) || !(t_0 <= Inf)) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * fma(Float64(Float64(M_m * M_m) / l), Float64(Float64(Float64(Float64(Float64(D * D) * h) / d) / d) * -0.125), 1.0)); else tmp = Float64(Float64(sqrt(Float64(d / h)) * 1.0) * sqrt(Float64(d / l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-48], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-48} \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{M\_m \cdot M\_m}{\ell}, \frac{\frac{\left(D \cdot D\right) \cdot h}{d}}{d} \cdot -0.125, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -3.9999999999999999e-48 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 63.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6463.3
Applied rewrites63.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6463.3
Applied rewrites63.3%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites53.5%
Applied rewrites36.0%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
Final simplification60.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (sqrt (/ d h)))
(t_1 (sqrt (/ d l)))
(t_2 (* (* D D) h))
(t_3
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_3 -4e-48)
(* (* t_0 t_1) (fma (/ (* t_2 -0.125) (* (* l d) d)) (* M_m M_m) 1.0))
(if (<= t_3 INFINITY)
(* (* t_0 1.0) t_1)
(*
(/ d (sqrt (* l h)))
(fma (/ (* M_m M_m) l) (* (/ (/ t_2 d) d) -0.125) 1.0))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = sqrt((d / h));
double t_1 = sqrt((d / l));
double t_2 = (D * D) * h;
double t_3 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_3 <= -4e-48) {
tmp = (t_0 * t_1) * fma(((t_2 * -0.125) / ((l * d) * d)), (M_m * M_m), 1.0);
} else if (t_3 <= ((double) INFINITY)) {
tmp = (t_0 * 1.0) * t_1;
} else {
tmp = (d / sqrt((l * h))) * fma(((M_m * M_m) / l), (((t_2 / d) / d) * -0.125), 1.0);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = sqrt(Float64(d / h)) t_1 = sqrt(Float64(d / l)) t_2 = Float64(Float64(D * D) * h) t_3 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_3 <= -4e-48) tmp = Float64(Float64(t_0 * t_1) * fma(Float64(Float64(t_2 * -0.125) / Float64(Float64(l * d) * d)), Float64(M_m * M_m), 1.0)); elseif (t_3 <= Inf) tmp = Float64(Float64(t_0 * 1.0) * t_1); else tmp = Float64(Float64(d / sqrt(Float64(l * h))) * fma(Float64(Float64(M_m * M_m) / l), Float64(Float64(Float64(t_2 / d) / d) * -0.125), 1.0)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -4e-48], N[(N[(t$95$0 * t$95$1), $MachinePrecision] * N[(N[(N[(t$95$2 * -0.125), $MachinePrecision] / N[(N[(l * d), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(t$95$0 * 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(t$95$2 / d), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
t_2 := \left(D \cdot D\right) \cdot h\\
t_3 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_3 \leq -4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot t\_1\right) \cdot \mathsf{fma}\left(\frac{t\_2 \cdot -0.125}{\left(\ell \cdot d\right) \cdot d}, M\_m \cdot M\_m, 1\right)\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;\left(t\_0 \cdot 1\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{M\_m \cdot M\_m}{\ell}, \frac{\frac{t\_2}{d}}{d} \cdot -0.125, 1\right)\\
\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)))) < -3.9999999999999999e-48Initial program 92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites75.7%
Applied rewrites69.9%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites5.8%
Applied rewrites25.5%
Final simplification70.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (/ (* (* D D) h) d)))
(if (<= t_0 -4e-48)
(*
(sqrt (* (/ d l) (/ d h)))
(fma (* (/ -0.125 (* l d)) t_1) (* M_m M_m) 1.0))
(if (<= t_0 INFINITY)
(* (* (sqrt (/ d h)) 1.0) (sqrt (/ d l)))
(*
(/ d (sqrt (* l h)))
(fma (/ (* M_m M_m) l) (* (/ t_1 d) -0.125) 1.0))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = ((D * D) * h) / d;
double tmp;
if (t_0 <= -4e-48) {
tmp = sqrt(((d / l) * (d / h))) * fma(((-0.125 / (l * d)) * t_1), (M_m * M_m), 1.0);
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
} else {
tmp = (d / sqrt((l * h))) * fma(((M_m * M_m) / l), ((t_1 / d) * -0.125), 1.0);
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(Float64(D * D) * h) / d) tmp = 0.0 if (t_0 <= -4e-48) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * fma(Float64(Float64(-0.125 / Float64(l * d)) * t_1), Float64(M_m * M_m), 1.0)); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(d / h)) * 1.0) * sqrt(Float64(d / l))); else tmp = Float64(Float64(d / sqrt(Float64(l * h))) * fma(Float64(Float64(M_m * M_m) / l), Float64(Float64(t_1 / d) * -0.125), 1.0)); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $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[(D * D), $MachinePrecision] * h), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-48], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(-0.125 / N[(l * d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(t$95$1 / d), $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left(D \cdot D\right) \cdot h}{d}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-48}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \mathsf{fma}\left(\frac{-0.125}{\ell \cdot d} \cdot t\_1, M\_m \cdot M\_m, 1\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{M\_m \cdot M\_m}{\ell}, \frac{t\_1}{d} \cdot -0.125, 1\right)\\
\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)))) < -3.9999999999999999e-48Initial program 92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites75.7%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f6467.5
Applied rewrites67.5%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites5.8%
Applied rewrites25.5%
Final simplification69.3%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (or (<= t_0 -4e-48) (not (<= t_0 INFINITY)))
(*
(/ d (sqrt (* l h)))
(fma (* (/ -0.125 (* l d)) (/ (* (* D D) h) d)) (* M_m M_m) 1.0))
(* (* (sqrt (/ d h)) 1.0) (sqrt (/ d l))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if ((t_0 <= -4e-48) || !(t_0 <= ((double) INFINITY))) {
tmp = (d / sqrt((l * h))) * fma(((-0.125 / (l * d)) * (((D * D) * h) / d)), (M_m * M_m), 1.0);
} else {
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if ((t_0 <= -4e-48) || !(t_0 <= Inf)) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * fma(Float64(Float64(-0.125 / Float64(l * d)) * Float64(Float64(Float64(D * D) * h) / d)), Float64(M_m * M_m), 1.0)); else tmp = Float64(Float64(sqrt(Float64(d / h)) * 1.0) * sqrt(Float64(d / l))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e-48], N[Not[LessEqual[t$95$0, Infinity]], $MachinePrecision]], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.125 / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-48} \lor \neg \left(t\_0 \leq \infty\right):\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{-0.125}{\ell \cdot d} \cdot \frac{\left(D \cdot D\right) \cdot h}{d}, M\_m \cdot M\_m, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -3.9999999999999999e-48 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 63.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6463.3
Applied rewrites63.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6463.3
Applied rewrites63.3%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites53.5%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lower-/.f6433.6
Applied rewrites33.6%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
Final simplification59.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (fma (* (/ -0.125 (* l d)) (/ (* (* D D) h) d)) (* M_m M_m) 1.0))
(t_1
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 -4e-48)
(* (* (sqrt (pow (* l h) -1.0)) d) t_0)
(if (<= t_1 INFINITY)
(* (* (sqrt (/ d h)) 1.0) (sqrt (/ d l)))
(* (/ d (sqrt (* l h))) t_0)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = fma(((-0.125 / (l * d)) * (((D * D) * h) / d)), (M_m * M_m), 1.0);
double t_1 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= -4e-48) {
tmp = (sqrt(pow((l * h), -1.0)) * d) * t_0;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
} else {
tmp = (d / sqrt((l * h))) * t_0;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = fma(Float64(Float64(-0.125 / Float64(l * d)) * Float64(Float64(Float64(D * D) * h) / d)), Float64(M_m * M_m), 1.0) t_1 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= -4e-48) tmp = Float64(Float64(sqrt((Float64(l * h) ^ -1.0)) * d) * t_0); elseif (t_1 <= Inf) tmp = Float64(Float64(sqrt(Float64(d / h)) * 1.0) * sqrt(Float64(d / l))); else tmp = Float64(Float64(d / sqrt(Float64(l * h))) * t_0); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[(-0.125 / N[(l * d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-48], N[(N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{-0.125}{\ell \cdot d} \cdot \frac{\left(D \cdot D\right) \cdot h}{d}, M\_m \cdot M\_m, 1\right)\\
t_1 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-48}:\\
\;\;\;\;\left(\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d\right) \cdot t\_0\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \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)))) < -3.9999999999999999e-48Initial program 92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.8
Applied rewrites92.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites75.7%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6439.7
Applied rewrites39.7%
if -3.9999999999999999e-48 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 88.8%
Taylor expanded in d around inf
Applied rewrites83.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites83.9%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites5.8%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-unprodN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
lift-*.f64N/A
sqrt-divN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lower-/.f6420.4
Applied rewrites20.4%
Final simplification59.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (pow (/ (* M_m D) (* 2.0 d)) 2.0)))
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(- 1.0 (* (* (pow 2.0 -1.0) t_0) (/ h l))))
INFINITY)
(* (* (sqrt (/ d h)) (sqrt (/ d l))) (- 1.0 (* (* 0.5 t_0) (/ h l))))
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow(((M_m * D) / (2.0 * d)), 2.0);
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * t_0) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - ((0.5 * t_0) * (h / l)));
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0 tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * t_0) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(0.5 * t_0) * Float64(h / l)))); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\\
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot t\_0\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(0.5 \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 90.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
lift-/.f64N/A
metadata-eval90.4
Applied rewrites90.4%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification82.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(-
1.0
(* (* (/ (/ D d) 2.0) M_m) (* (/ h l) (* (/ (* 0.5 D) d) (/ M_m 2.0))))))
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - ((((D / d) / 2.0) * M_m) * ((h / l) * (((0.5 * D) / d) * (M_m / 2.0)))));
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(Float64(D / d) / 2.0) * M_m) * Float64(Float64(h / l) * Float64(Float64(Float64(0.5 * D) / d) * Float64(M_m / 2.0)))))); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(N[(N[(0.5 * D), $MachinePrecision] / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\frac{\frac{D}{d}}{2} \cdot M\_m\right) \cdot \left(\frac{h}{\ell} \cdot \left(\frac{0.5 \cdot D}{d} \cdot \frac{M\_m}{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 90.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
Applied rewrites90.0%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification81.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
INFINITY)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(- 1.0 (* (/ (* (* (/ D l) (* h (/ M_m d))) (* 0.5 D)) 4.0) (/ M_m d))))
(fma
(* (* (/ (sqrt (/ h l)) l) (* D D)) (/ (* (- M_m) M_m) d))
0.125
(* (- d) (sqrt (pow (* l h) -1.0))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= ((double) INFINITY)) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - (((((D / l) * (h * (M_m / d))) * (0.5 * D)) / 4.0) * (M_m / d)));
} else {
tmp = fma((((sqrt((h / l)) / l) * (D * D)) * ((-M_m * M_m) / d)), 0.125, (-d * sqrt(pow((l * h), -1.0))));
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= Inf) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D / l) * Float64(h * Float64(M_m / d))) * Float64(0.5 * D)) / 4.0) * Float64(M_m / d)))); else tmp = fma(Float64(Float64(Float64(sqrt(Float64(h / l)) / l) * Float64(D * D)) * Float64(Float64(Float64(-M_m) * M_m) / d)), 0.125, Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0)))); end return tmp end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(D / l), $MachinePrecision] * N[(h * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * D), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] / l), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(N[((-M$95$m) * M$95$m), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125 + N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq \infty:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(\frac{D}{\ell} \cdot \left(h \cdot \frac{M\_m}{d}\right)\right) \cdot \left(0.5 \cdot D\right)}{4} \cdot \frac{M\_m}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{\sqrt{\frac{h}{\ell}}}{\ell} \cdot \left(D \cdot D\right)\right) \cdot \frac{\left(-M\_m\right) \cdot M\_m}{d}, 0.125, \left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 90.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6490.4
Applied rewrites90.4%
Applied rewrites85.2%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f640.0
Applied rewrites0.0%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites15.7%
Taylor expanded in l around -inf
Applied rewrites16.7%
Applied rewrites36.8%
Final simplification77.7%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
-4e-69)
(/ (* (* (* D D) -0.125) (* (/ (* M_m M_m) d) (sqrt (* l h)))) (* l l))
(* (* (sqrt (/ d h)) 1.0) (sqrt (/ d l)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -4e-69) {
tmp = (((D * D) * -0.125) * (((M_m * M_m) / d) * sqrt((l * h)))) / (l * l);
} else {
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-4d-69)) then
tmp = (((d_1 * d_1) * (-0.125d0)) * (((m_m * m_m) / d) * sqrt((l * h)))) / (l * l)
else
tmp = (sqrt((d / h)) * 1.0d0) * sqrt((d / l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -4e-69) {
tmp = (((D * D) * -0.125) * (((M_m * M_m) / d) * Math.sqrt((l * h)))) / (l * l);
} else {
tmp = (Math.sqrt((d / h)) * 1.0) * Math.sqrt((d / l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -4e-69: tmp = (((D * D) * -0.125) * (((M_m * M_m) / d) * math.sqrt((l * h)))) / (l * l) else: tmp = (math.sqrt((d / h)) * 1.0) * math.sqrt((d / l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -4e-69) tmp = Float64(Float64(Float64(Float64(D * D) * -0.125) * Float64(Float64(Float64(M_m * M_m) / d) * sqrt(Float64(l * h)))) / Float64(l * l)); else tmp = Float64(Float64(sqrt(Float64(d / h)) * 1.0) * sqrt(Float64(d / l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -4e-69)
tmp = (((D * D) * -0.125) * (((M_m * M_m) / d) * sqrt((l * h)))) / (l * l);
else
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-69], N[(N[(N[(N[(D * D), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -4 \cdot 10^{-69}:\\
\;\;\;\;\frac{\left(\left(D \cdot D\right) \cdot -0.125\right) \cdot \left(\frac{M\_m \cdot M\_m}{d} \cdot \sqrt{\ell \cdot h}\right)}{\ell \cdot \ell}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -3.9999999999999999e-69Initial program 92.9%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6492.9
Applied rewrites92.9%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites25.4%
Taylor expanded in d around 0
Applied rewrites28.8%
if -3.9999999999999999e-69 < (*.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 67.8%
Taylor expanded in d around inf
Applied rewrites66.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites66.8%
Final simplification53.9%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (/ (* (* D D) h) d)))
(if (<= l -3.8e+122)
(* (* (sqrt (/ d h)) 1.0) (sqrt (/ d l)))
(if (<= l -1.5e-289)
(*
(* (- d) (sqrt (pow (* l h) -1.0)))
(fma (* (/ -0.125 (* l d)) t_0) (* M_m M_m) 1.0))
(if (<= l 4.3e+111)
(*
(/ d (sqrt (* l h)))
(fma (/ (* M_m M_m) l) (* (/ t_0 d) -0.125) 1.0))
(* (pow (* (sqrt l) (sqrt h)) -1.0) d))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = ((D * D) * h) / d;
double tmp;
if (l <= -3.8e+122) {
tmp = (sqrt((d / h)) * 1.0) * sqrt((d / l));
} else if (l <= -1.5e-289) {
tmp = (-d * sqrt(pow((l * h), -1.0))) * fma(((-0.125 / (l * d)) * t_0), (M_m * M_m), 1.0);
} else if (l <= 4.3e+111) {
tmp = (d / sqrt((l * h))) * fma(((M_m * M_m) / l), ((t_0 / d) * -0.125), 1.0);
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(Float64(D * D) * h) / d) tmp = 0.0 if (l <= -3.8e+122) tmp = Float64(Float64(sqrt(Float64(d / h)) * 1.0) * sqrt(Float64(d / l))); elseif (l <= -1.5e-289) tmp = Float64(Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))) * fma(Float64(Float64(-0.125 / Float64(l * d)) * t_0), Float64(M_m * M_m), 1.0)); elseif (l <= 4.3e+111) tmp = Float64(Float64(d / sqrt(Float64(l * h))) * fma(Float64(Float64(M_m * M_m) / l), Float64(Float64(t_0 / d) * -0.125), 1.0)); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); end return tmp end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(N[(D * D), $MachinePrecision] * h), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[l, -3.8e+122], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -1.5e-289], N[(N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.125 / N[(l * d), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(M$95$m * M$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.3e+111], N[(N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / l), $MachinePrecision] * N[(N[(t$95$0 / d), $MachinePrecision] * -0.125), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{\left(D \cdot D\right) \cdot h}{d}\\
\mathbf{if}\;\ell \leq -3.8 \cdot 10^{+122}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{elif}\;\ell \leq -1.5 \cdot 10^{-289}:\\
\;\;\;\;\left(\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\right) \cdot \mathsf{fma}\left(\frac{-0.125}{\ell \cdot d} \cdot t\_0, M\_m \cdot M\_m, 1\right)\\
\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{+111}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{M\_m \cdot M\_m}{\ell}, \frac{t\_0}{d} \cdot -0.125, 1\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if l < -3.7999999999999998e122Initial program 80.3%
Taylor expanded in d around inf
Applied rewrites68.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites68.5%
if -3.7999999999999998e122 < l < -1.4999999999999999e-289Initial program 78.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6478.8
Applied rewrites78.8%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6478.8
Applied rewrites78.8%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites59.8%
Taylor expanded in h around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6467.7
Applied rewrites67.7%
if -1.4999999999999999e-289 < l < 4.29999999999999993e111Initial program 78.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6478.1
Applied rewrites78.1%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6478.1
Applied rewrites78.1%
Taylor expanded in M around inf
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-rgt-inN/A
lft-mult-inverseN/A
lower-fma.f64N/A
Applied rewrites64.0%
Applied rewrites66.2%
if 4.29999999999999993e111 < l Initial program 65.6%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6465.6
Applied rewrites65.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.1
Applied rewrites49.1%
Applied rewrites49.2%
Applied rewrites69.7%
Final simplification67.6%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= h 6e-272) (* (- d) (sqrt (pow (* l h) -1.0))) (* (pow (* (sqrt l) (sqrt h)) -1.0) d)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 6e-272) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = pow((sqrt(l) * sqrt(h)), -1.0) * d;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= 6d-272) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = ((sqrt(l) * sqrt(h)) ** (-1.0d0)) * d
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (h <= 6e-272) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = Math.pow((Math.sqrt(l) * Math.sqrt(h)), -1.0) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if h <= 6e-272: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = math.pow((math.sqrt(l) * math.sqrt(h)), -1.0) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (h <= 6e-272) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64((Float64(sqrt(l) * sqrt(h)) ^ -1.0) * d); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (h <= 6e-272)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = ((sqrt(l) * sqrt(h)) ^ -1.0) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[h, 6e-272], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq 6 \cdot 10^{-272}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\ell} \cdot \sqrt{h}\right)}^{-1} \cdot d\\
\end{array}
\end{array}
if h < 6.0000000000000006e-272Initial program 79.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6479.3
Applied rewrites79.3%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.6
Applied rewrites46.6%
if 6.0000000000000006e-272 < h Initial program 73.6%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6473.6
Applied rewrites73.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.8
Applied rewrites38.8%
Applied rewrites38.8%
Applied rewrites51.5%
Final simplification49.2%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= d -8.4e-129) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (sqrt (* l h)))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -8.4e-129) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / sqrt((l * h));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (d <= (-8.4d-129)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / sqrt((l * h))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (d <= -8.4e-129) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / Math.sqrt((l * h));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if d <= -8.4e-129: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / math.sqrt((l * h)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (d <= -8.4e-129) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / sqrt(Float64(l * h))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (d <= -8.4e-129)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / sqrt((l * h));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[d, -8.4e-129], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.4 \cdot 10^{-129}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < -8.4e-129Initial program 85.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6485.3
Applied rewrites85.3%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6455.1
Applied rewrites55.1%
if -8.4e-129 < d Initial program 71.5%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6471.5
Applied rewrites71.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6435.9
Applied rewrites35.9%
Applied rewrites35.9%
Applied rewrites35.9%
Final simplification42.5%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (sqrt (pow (* l h) -1.0)) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return sqrt(pow((l * h), -1.0)) * d;
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
code = sqrt(((l * h) ** (-1.0d0))) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return Math.sqrt(Math.pow((l * h), -1.0)) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return math.sqrt(math.pow((l * h), -1.0)) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(sqrt((Float64(l * h) ^ -1.0)) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = sqrt(((l * h) ^ -1.0)) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d
\end{array}
Initial program 76.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6476.3
Applied rewrites76.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.5
Applied rewrites26.5%
Final simplification26.5%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (/ d (sqrt (* l h))))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return d / sqrt((l * h));
}
M_m = private
NOTE: d, h, l, M_m, and D 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_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_m
real(8), intent (in) :: d_1
code = d / sqrt((l * h))
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return d / Math.sqrt((l * h));
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return d / math.sqrt((l * h))
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(d / sqrt(Float64(l * h))) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = d / sqrt((l * h));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 76.3%
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
unpow1/2N/A
lower-sqrt.f6476.3
Applied rewrites76.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.5
Applied rewrites26.5%
Applied rewrites26.2%
Applied rewrites26.2%
herbie shell --seed 2024346
(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)))))