
(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)));
}
real(8) function code(d, h, l, m, d_1)
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)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (pow (/ d h) (pow 2.0 -1.0)))
(t_1
(*
(* t_0 (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 4e+250)
(*
(* t_0 (sqrt (/ d l)))
(- 1.0 (* (/ (* (* (/ D_m d) M) 0.5) l) (* (* (/ M d) (* 0.25 D_m)) h))))
(if (<= t_1 INFINITY)
(fabs (/ d (sqrt (* l h))))
(*
(/ (fma (/ (* (pow (* D_m M) 2.0) -0.125) d) (/ h l) d) h)
(sqrt (/ h l)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = pow((d / h), pow(2.0, -1.0));
double t_1 = (t_0 * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 4e+250) {
tmp = (t_0 * sqrt((d / l))) * (1.0 - (((((D_m / d) * M) * 0.5) / l) * (((M / d) * (0.25 * D_m)) * h)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = (fma(((pow((D_m * M), 2.0) * -0.125) / d), (h / l), d) / h) * sqrt((h / l));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(d / h) ^ (2.0 ^ -1.0) t_1 = Float64(Float64(t_0 * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 4e+250) tmp = Float64(Float64(t_0 * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D_m / d) * M) * 0.5) / l) * Float64(Float64(Float64(M / d) * Float64(0.25 * D_m)) * h)))); elseif (t_1 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(fma(Float64(Float64((Float64(D_m * M) ^ 2.0) * -0.125) / d), Float64(h / l), d) / h) * sqrt(Float64(h / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * 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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e+250], N[(N[(t$95$0 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M), $MachinePrecision] * 0.5), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M / d), $MachinePrecision] * N[(0.25 * D$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[(N[(N[(N[Power[N[(D$95$m * M), $MachinePrecision], 2.0], $MachinePrecision] * -0.125), $MachinePrecision] / d), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision] / h), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)}\\
t_1 := \left(t\_0 \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \frac{\left(\frac{D\_m}{d} \cdot M\right) \cdot 0.5}{\ell} \cdot \left(\left(\frac{M}{d} \cdot \left(0.25 \cdot D\_m\right)\right) \cdot h\right)\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(D\_m \cdot M\right)}^{2} \cdot -0.125}{d}, \frac{h}{\ell}, d\right)}{h} \cdot \sqrt{\frac{h}{\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.9999999999999997e250Initial program 88.4%
lift-*.f64N/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
div-invN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites91.0%
lift-/.f64N/A
div-invN/A
lift-pow.f64N/A
unpow-1N/A
remove-double-divN/A
lower-*.f6491.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6491.0
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
metadata-eval91.0
Applied rewrites91.0%
lift-/.f64N/A
metadata-eval91.0
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6491.0
Applied rewrites91.0%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites15.6%
Applied rewrites18.4%
Applied rewrites62.1%
Applied rewrites67.0%
Final simplification88.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (* -0.125 (* D_m D_m)))
(t_1 (/ (* M M) d))
(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 D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_3 (sqrt (/ d l)))
(t_4 (sqrt (/ h l))))
(if (<= t_2 -1e+250)
(*
(* t_3 (sqrt (/ d h)))
(* (* (* h (* M (/ M l))) -0.125) (/ (/ (* D_m D_m) d) d)))
(if (<= t_2 -1e+131)
(*
(fma (* (* (* (* (/ h l) -0.25) M) (/ D_m d)) (* M 0.5)) (/ D_m d) 1.0)
(sqrt (* (/ (/ d l) h) d)))
(if (<= t_2 2.5e-112)
(/ (* t_4 (fma (/ h l) (* t_0 t_1) d)) h)
(if (<= t_2 4e+250)
(/ t_3 (sqrt (/ h d)))
(if (<= t_2 INFINITY)
(fabs (/ d (sqrt (* l h))))
(/ (* t_4 (/ (fma t_0 (* h t_1) (* l d)) l)) h))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = -0.125 * (D_m * D_m);
double t_1 = (M * M) / d;
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = sqrt((d / l));
double t_4 = sqrt((h / l));
double tmp;
if (t_2 <= -1e+250) {
tmp = (t_3 * sqrt((d / h))) * (((h * (M * (M / l))) * -0.125) * (((D_m * D_m) / d) / d));
} else if (t_2 <= -1e+131) {
tmp = fma((((((h / l) * -0.25) * M) * (D_m / d)) * (M * 0.5)), (D_m / d), 1.0) * sqrt((((d / l) / h) * d));
} else if (t_2 <= 2.5e-112) {
tmp = (t_4 * fma((h / l), (t_0 * t_1), d)) / h;
} else if (t_2 <= 4e+250) {
tmp = t_3 / sqrt((h / d));
} else if (t_2 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = (t_4 * (fma(t_0, (h * t_1), (l * d)) / l)) / h;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(-0.125 * Float64(D_m * D_m)) t_1 = Float64(Float64(M * M) / d) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = sqrt(Float64(d / l)) t_4 = sqrt(Float64(h / l)) tmp = 0.0 if (t_2 <= -1e+250) tmp = Float64(Float64(t_3 * sqrt(Float64(d / h))) * Float64(Float64(Float64(h * Float64(M * Float64(M / l))) * -0.125) * Float64(Float64(Float64(D_m * D_m) / d) / d))); elseif (t_2 <= -1e+131) tmp = Float64(fma(Float64(Float64(Float64(Float64(Float64(h / l) * -0.25) * M) * Float64(D_m / d)) * Float64(M * 0.5)), Float64(D_m / d), 1.0) * sqrt(Float64(Float64(Float64(d / l) / h) * d))); elseif (t_2 <= 2.5e-112) tmp = Float64(Float64(t_4 * fma(Float64(h / l), Float64(t_0 * t_1), d)) / h); elseif (t_2 <= 4e+250) tmp = Float64(t_3 / sqrt(Float64(h / d))); elseif (t_2 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(t_4 * Float64(fma(t_0, Float64(h * t_1), Float64(l * d)) / l)) / h); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(M * M), $MachinePrecision] / d), $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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -1e+250], N[(N[(t$95$3 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(h * N[(M * N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -1e+131], N[(N[(N[(N[(N[(N[(N[(h / l), $MachinePrecision] * -0.25), $MachinePrecision] * M), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.5e-112], N[(N[(t$95$4 * N[(N[(h / l), $MachinePrecision] * N[(t$95$0 * t$95$1), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$2, 4e+250], N[(t$95$3 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$4 * N[(N[(t$95$0 * N[(h * t$95$1), $MachinePrecision] + N[(l * d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := -0.125 \cdot \left(D\_m \cdot D\_m\right)\\
t_1 := \frac{M \cdot M}{d}\\
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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \sqrt{\frac{d}{\ell}}\\
t_4 := \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{+250}:\\
\;\;\;\;\left(t\_3 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(\left(\left(h \cdot \left(M \cdot \frac{M}{\ell}\right)\right) \cdot -0.125\right) \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right)\\
\mathbf{elif}\;t\_2 \leq -1 \cdot 10^{+131}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(\frac{h}{\ell} \cdot -0.25\right) \cdot M\right) \cdot \frac{D\_m}{d}\right) \cdot \left(M \cdot 0.5\right), \frac{D\_m}{d}, 1\right) \cdot \sqrt{\frac{\frac{d}{\ell}}{h} \cdot d}\\
\mathbf{elif}\;t\_2 \leq 2.5 \cdot 10^{-112}:\\
\;\;\;\;\frac{t\_4 \cdot \mathsf{fma}\left(\frac{h}{\ell}, t\_0 \cdot t\_1, d\right)}{h}\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{t\_3}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_4 \cdot \frac{\mathsf{fma}\left(t\_0, h \cdot t\_1, \ell \cdot d\right)}{\ell}}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -9.9999999999999992e249Initial program 86.4%
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.f6441.8
Applied rewrites41.8%
Taylor expanded in d around 0
metadata-evalN/A
distribute-lft-neg-inN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
times-fracN/A
*-commutativeN/A
associate-*l/N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites39.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.3
lift-/.f64N/A
metadata-eval39.3
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6439.3
lift-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-neg.f64N/A
lift-neg.f64N/A
frac-2negN/A
lift-/.f64N/A
lower-sqrt.f6483.4
Applied rewrites83.4%
if -9.9999999999999992e249 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -9.9999999999999991e130Initial program 98.8%
Applied rewrites82.8%
lift-fma.f64N/A
lift-pow.f64N/A
metadata-evalN/A
pow-powN/A
inv-powN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
*-commutativeN/A
clear-numN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites82.9%
metadata-evalN/A
metadata-evalN/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites67.6%
if -9.9999999999999991e130 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.50000000000000022e-112Initial program 67.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites47.2%
Applied rewrites69.8%
Applied rewrites79.5%
Taylor expanded in d around 0
Applied rewrites77.2%
if 2.50000000000000022e-112 < (*.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.9999999999999997e250Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.8
Applied rewrites36.8%
Applied rewrites99.6%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites15.6%
Applied rewrites18.4%
Applied rewrites62.1%
Taylor expanded in l around 0
Applied rewrites39.5%
Final simplification81.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (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 D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_2 (sqrt (/ h l))))
(if (<= t_1 (- INFINITY))
(*
(* t_0 (sqrt (/ d h)))
(* (* (* h (* M (/ M l))) -0.125) (/ (/ (* D_m D_m) d) d)))
(if (<= t_1 2.5e-112)
(/
(fma
(* (* (* -0.125 (* M M)) D_m) (/ D_m d))
(* (/ h l) t_2)
(* t_2 d))
h)
(if (<= t_1 4e+250)
(/ t_0 (sqrt (/ h d)))
(if (<= t_1 INFINITY)
(fabs (/ d (sqrt (* l h))))
(/
(*
t_2
(/ (fma (* -0.125 (* D_m D_m)) (* h (/ (* M M) d)) (* l d)) l))
h)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_2 = sqrt((h / l));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (t_0 * sqrt((d / h))) * (((h * (M * (M / l))) * -0.125) * (((D_m * D_m) / d) / d));
} else if (t_1 <= 2.5e-112) {
tmp = fma((((-0.125 * (M * M)) * D_m) * (D_m / d)), ((h / l) * t_2), (t_2 * d)) / h;
} else if (t_1 <= 4e+250) {
tmp = t_0 / sqrt((h / d));
} else if (t_1 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = (t_2 * (fma((-0.125 * (D_m * D_m)), (h * ((M * M) / d)), (l * d)) / l)) / h;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_2 = sqrt(Float64(h / l)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * Float64(Float64(Float64(h * Float64(M * Float64(M / l))) * -0.125) * Float64(Float64(Float64(D_m * D_m) / d) / d))); elseif (t_1 <= 2.5e-112) tmp = Float64(fma(Float64(Float64(Float64(-0.125 * Float64(M * M)) * D_m) * Float64(D_m / d)), Float64(Float64(h / l) * t_2), Float64(t_2 * d)) / h); elseif (t_1 <= 4e+250) tmp = Float64(t_0 / sqrt(Float64(h / d))); elseif (t_1 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(t_2 * Float64(fma(Float64(-0.125 * Float64(D_m * D_m)), Float64(h * Float64(Float64(M * M) / d)), Float64(l * d)) / l)) / h); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(h * N[(M * N[(M / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.5e-112], N[(N[(N[(N[(N[(-0.125 * N[(M * M), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision] * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * t$95$2), $MachinePrecision] + N[(t$95$2 * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$1, 4e+250], N[(t$95$0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$2 * N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + N[(l * d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_2 := \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(\left(\left(h \cdot \left(M \cdot \frac{M}{\ell}\right)\right) \cdot -0.125\right) \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right)\\
\mathbf{elif}\;t\_1 \leq 2.5 \cdot 10^{-112}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(\left(-0.125 \cdot \left(M \cdot M\right)\right) \cdot D\_m\right) \cdot \frac{D\_m}{d}, \frac{h}{\ell} \cdot t\_2, t\_2 \cdot d\right)}{h}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{t\_0}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2 \cdot \frac{\mathsf{fma}\left(-0.125 \cdot \left(D\_m \cdot D\_m\right), h \cdot \frac{M \cdot M}{d}, \ell \cdot d\right)}{\ell}}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -inf.0Initial program 86.2%
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.f6442.3
Applied rewrites42.3%
Taylor expanded in d around 0
metadata-evalN/A
distribute-lft-neg-inN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
times-fracN/A
*-commutativeN/A
associate-*l/N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites39.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6439.8
lift-/.f64N/A
metadata-eval39.8
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6439.8
lift-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lift-neg.f64N/A
lift-neg.f64N/A
frac-2negN/A
lift-/.f64N/A
lower-sqrt.f6483.2
Applied rewrites83.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)))) < 2.50000000000000022e-112Initial program 73.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites38.0%
Applied rewrites58.7%
Applied rewrites68.6%
if 2.50000000000000022e-112 < (*.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.9999999999999997e250Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.8
Applied rewrites36.8%
Applied rewrites99.6%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites15.6%
Applied rewrites18.4%
Applied rewrites62.1%
Taylor expanded in l around 0
Applied rewrites39.5%
Final simplification80.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1
(*
(/ (fma (/ (* (pow (* D_m M) 2.0) -0.125) d) (/ h l) d) h)
(sqrt (/ h l)))))
(if (<= t_0 2.5e-112)
t_1
(if (<= t_0 4e+250)
(/ (sqrt (/ d l)) (sqrt (/ h d)))
(if (<= t_0 INFINITY) (fabs (/ d (sqrt (* l h)))) t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (fma(((pow((D_m * M), 2.0) * -0.125) / d), (h / l), d) / h) * sqrt((h / l));
double tmp;
if (t_0 <= 2.5e-112) {
tmp = t_1;
} else if (t_0 <= 4e+250) {
tmp = sqrt((d / l)) / sqrt((h / d));
} else if (t_0 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = t_1;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(fma(Float64(Float64((Float64(D_m * M) ^ 2.0) * -0.125) / d), Float64(h / l), d) / h) * sqrt(Float64(h / l))) tmp = 0.0 if (t_0 <= 2.5e-112) tmp = t_1; elseif (t_0 <= 4e+250) tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); elseif (t_0 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = t_1; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(N[Power[N[(D$95$m * M), $MachinePrecision], 2.0], $MachinePrecision] * -0.125), $MachinePrecision] / d), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision] / h), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.5e-112], t$95$1, If[LessEqual[t$95$0, 4e+250], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\mathsf{fma}\left(\frac{{\left(D\_m \cdot M\right)}^{2} \cdot -0.125}{d}, \frac{h}{\ell}, d\right)}{h} \cdot \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq 2.5 \cdot 10^{-112}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.50000000000000022e-112 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 61.5%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites43.7%
Applied rewrites53.5%
Applied rewrites78.3%
Applied rewrites80.1%
if 2.50000000000000022e-112 < (*.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.9999999999999997e250Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.8
Applied rewrites36.8%
Applied rewrites99.6%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
Final simplification87.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h l)))
(t_1 (* -0.125 (* D_m D_m)))
(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 D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_3 (/ (* M M) d)))
(if (<= t_2 2.5e-112)
(/ (* t_0 (fma (/ h l) (* t_1 t_3) d)) h)
(if (<= t_2 4e+250)
(/ (sqrt (/ d l)) (sqrt (/ h d)))
(if (<= t_2 INFINITY)
(fabs (/ d (sqrt (* l h))))
(/ (* t_0 (/ (fma t_1 (* h t_3) (* l d)) l)) h))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((h / l));
double t_1 = -0.125 * (D_m * D_m);
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_3 = (M * M) / d;
double tmp;
if (t_2 <= 2.5e-112) {
tmp = (t_0 * fma((h / l), (t_1 * t_3), d)) / h;
} else if (t_2 <= 4e+250) {
tmp = sqrt((d / l)) / sqrt((h / d));
} else if (t_2 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = (t_0 * (fma(t_1, (h * t_3), (l * d)) / l)) / h;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(h / l)) t_1 = Float64(-0.125 * Float64(D_m * D_m)) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_3 = Float64(Float64(M * M) / d) tmp = 0.0 if (t_2 <= 2.5e-112) tmp = Float64(Float64(t_0 * fma(Float64(h / l), Float64(t_1 * t_3), d)) / h); elseif (t_2 <= 4e+250) tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); elseif (t_2 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(t_0 * Float64(fma(t_1, Float64(h * t_3), Float64(l * d)) / l)) / h); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(-0.125 * N[(D$95$m * D$95$m), $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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[t$95$2, 2.5e-112], N[(N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(t$95$1 * t$95$3), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$2, 4e+250], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$0 * N[(N[(t$95$1 * N[(h * t$95$3), $MachinePrecision] + N[(l * d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\ell}}\\
t_1 := -0.125 \cdot \left(D\_m \cdot D\_m\right)\\
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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_3 := \frac{M \cdot M}{d}\\
\mathbf{if}\;t\_2 \leq 2.5 \cdot 10^{-112}:\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(\frac{h}{\ell}, t\_1 \cdot t\_3, d\right)}{h}\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \frac{\mathsf{fma}\left(t\_1, h \cdot t\_3, \ell \cdot d\right)}{\ell}}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.50000000000000022e-112Initial program 82.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites53.3%
Applied rewrites65.5%
Applied rewrites83.8%
Taylor expanded in d around 0
Applied rewrites76.1%
if 2.50000000000000022e-112 < (*.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.9999999999999997e250Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.8
Applied rewrites36.8%
Applied rewrites99.6%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites15.6%
Applied rewrites18.4%
Applied rewrites62.1%
Taylor expanded in l around 0
Applied rewrites39.5%
Final simplification79.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1
(/
(*
(sqrt (/ h l))
(fma (/ h l) (* (* -0.125 (* D_m D_m)) (/ (* M M) d)) d))
h)))
(if (<= t_0 2.5e-112)
t_1
(if (<= t_0 4e+250)
(/ (sqrt (/ d l)) (sqrt (/ h d)))
(if (<= t_0 INFINITY) (fabs (/ d (sqrt (* l h)))) t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (sqrt((h / l)) * fma((h / l), ((-0.125 * (D_m * D_m)) * ((M * M) / d)), d)) / h;
double tmp;
if (t_0 <= 2.5e-112) {
tmp = t_1;
} else if (t_0 <= 4e+250) {
tmp = sqrt((d / l)) / sqrt((h / d));
} else if (t_0 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = t_1;
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(sqrt(Float64(h / l)) * fma(Float64(h / l), Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(M * M) / d)), d)) / h) tmp = 0.0 if (t_0 <= 2.5e-112) tmp = t_1; elseif (t_0 <= 4e+250) tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); elseif (t_0 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = t_1; end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[t$95$0, 2.5e-112], t$95$1, If[LessEqual[t$95$0, 4e+250], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\sqrt{\frac{h}{\ell}} \cdot \mathsf{fma}\left(\frac{h}{\ell}, \left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{M \cdot M}{d}, d\right)}{h}\\
\mathbf{if}\;t\_0 \leq 2.5 \cdot 10^{-112}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.50000000000000022e-112 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 61.5%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites43.7%
Applied rewrites53.5%
Applied rewrites78.3%
Taylor expanded in d around 0
Applied rewrites66.6%
if 2.50000000000000022e-112 < (*.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.9999999999999997e250Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6436.8
Applied rewrites36.8%
Applied rewrites99.6%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
Final simplification79.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1
(/
(*
(sqrt (/ h l))
(* (* (* D_m D_m) -0.125) (* (/ (* M M) l) (/ h d))))
h)))
(if (<= t_0 -5e-138)
t_1
(if (<= t_0 4e+250)
(/ (sqrt (/ d l)) (sqrt (/ h d)))
(if (<= t_0 INFINITY) (fabs (/ d (sqrt (* l h)))) t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (sqrt((h / l)) * (((D_m * D_m) * -0.125) * (((M * M) / l) * (h / d)))) / h;
double tmp;
if (t_0 <= -5e-138) {
tmp = t_1;
} else if (t_0 <= 4e+250) {
tmp = sqrt((d / l)) / sqrt((h / d));
} else if (t_0 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = t_1;
}
return tmp;
}
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (Math.sqrt((h / l)) * (((D_m * D_m) * -0.125) * (((M * M) / l) * (h / d)))) / h;
double tmp;
if (t_0 <= -5e-138) {
tmp = t_1;
} else if (t_0 <= 4e+250) {
tmp = Math.sqrt((d / l)) / Math.sqrt((h / d));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = Math.abs((d / Math.sqrt((l * h))));
} else {
tmp = t_1;
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = (math.sqrt((h / l)) * (((D_m * D_m) * -0.125) * (((M * M) / l) * (h / d)))) / h tmp = 0 if t_0 <= -5e-138: tmp = t_1 elif t_0 <= 4e+250: tmp = math.sqrt((d / l)) / math.sqrt((h / d)) elif t_0 <= math.inf: tmp = math.fabs((d / math.sqrt((l * h)))) else: tmp = t_1 return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(sqrt(Float64(h / l)) * Float64(Float64(Float64(D_m * D_m) * -0.125) * Float64(Float64(Float64(M * M) / l) * Float64(h / d)))) / h) tmp = 0.0 if (t_0 <= -5e-138) tmp = t_1; elseif (t_0 <= 4e+250) tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); elseif (t_0 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = t_1; end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = (sqrt((h / l)) * (((D_m * D_m) * -0.125) * (((M * M) / l) * (h / d)))) / h;
tmp = 0.0;
if (t_0 <= -5e-138)
tmp = t_1;
elseif (t_0 <= 4e+250)
tmp = sqrt((d / l)) / sqrt((h / d));
elseif (t_0 <= Inf)
tmp = abs((d / sqrt((l * h))));
else
tmp = t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * -0.125), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision] * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-138], t$95$1, If[LessEqual[t$95$0, 4e+250], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\sqrt{\frac{h}{\ell}} \cdot \left(\left(\left(D\_m \cdot D\_m\right) \cdot -0.125\right) \cdot \left(\frac{M \cdot M}{\ell} \cdot \frac{h}{d}\right)\right)}{h}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-138}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -4.99999999999999989e-138 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 62.1%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites41.9%
Applied rewrites50.9%
Applied rewrites78.2%
Taylor expanded in d around 0
Applied rewrites62.2%
if -4.99999999999999989e-138 < (*.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.9999999999999997e250Initial program 88.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.4
Applied rewrites38.4%
Applied rewrites88.9%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
Final simplification76.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 4e+250)
(*
(*
(fma (* (/ h l) -0.5) (* (pow (* (/ D_m d) M) 2.0) 0.25) 1.0)
(sqrt (/ d l)))
(sqrt (/ d h)))
(if (<= t_0 INFINITY)
(fabs (/ d (sqrt (* l h))))
(*
(/ (fma (/ (* (pow (* D_m M) 2.0) -0.125) d) (/ h l) d) h)
(sqrt (/ h l)))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= 4e+250) {
tmp = (fma(((h / l) * -0.5), (pow(((D_m / d) * M), 2.0) * 0.25), 1.0) * sqrt((d / l))) * sqrt((d / h));
} else if (t_0 <= ((double) INFINITY)) {
tmp = fabs((d / sqrt((l * h))));
} else {
tmp = (fma(((pow((D_m * M), 2.0) * -0.125) / d), (h / l), d) / h) * sqrt((h / l));
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= 4e+250) tmp = Float64(Float64(fma(Float64(Float64(h / l) * -0.5), Float64((Float64(Float64(D_m / d) * M) ^ 2.0) * 0.25), 1.0) * sqrt(Float64(d / l))) * sqrt(Float64(d / h))); elseif (t_0 <= Inf) tmp = abs(Float64(d / sqrt(Float64(l * h)))); else tmp = Float64(Float64(fma(Float64(Float64((Float64(D_m * M) ^ 2.0) * -0.125) / d), Float64(h / l), d) / h) * sqrt(Float64(h / l))); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+250], N[(N[(N[(N[(N[(h / l), $MachinePrecision] * -0.5), $MachinePrecision] * N[(N[Power[N[(N[(D$95$m / d), $MachinePrecision] * M), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[(N[(N[(N[Power[N[(D$95$m * M), $MachinePrecision], 2.0], $MachinePrecision] * -0.125), $MachinePrecision] / d), $MachinePrecision] * N[(h / l), $MachinePrecision] + d), $MachinePrecision] / h), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{h}{\ell} \cdot -0.5, {\left(\frac{D\_m}{d} \cdot M\right)}^{2} \cdot 0.25, 1\right) \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{{\left(D\_m \cdot M\right)}^{2} \cdot -0.125}{d}, \frac{h}{\ell}, d\right)}{h} \cdot \sqrt{\frac{h}{\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.9999999999999997e250Initial program 88.4%
Applied rewrites61.4%
Applied rewrites88.4%
if 3.9999999999999997e250 < (*.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 47.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6450.3
Applied rewrites50.3%
Applied rewrites97.7%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites15.6%
Applied rewrites18.4%
Applied rewrites62.1%
Applied rewrites67.0%
Final simplification86.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -5e-138)
(/ (* (- d) (sqrt (/ h l))) h)
(if (<= t_0 4e+250)
(/ (sqrt (/ d l)) (sqrt (/ h d)))
(fabs (/ d (sqrt (* l h))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-138) {
tmp = (-d * sqrt((h / l))) / h;
} else if (t_0 <= 4e+250) {
tmp = sqrt((d / l)) / sqrt((h / d));
} else {
tmp = fabs((d / sqrt((l * h))));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d-138)) then
tmp = (-d * sqrt((h / l))) / h
else if (t_0 <= 4d+250) then
tmp = sqrt((d / l)) / sqrt((h / d))
else
tmp = abs((d / sqrt((l * h))))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-138) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else if (t_0 <= 4e+250) {
tmp = Math.sqrt((d / l)) / Math.sqrt((h / d));
} else {
tmp = Math.abs((d / Math.sqrt((l * h))));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e-138: tmp = (-d * math.sqrt((h / l))) / h elif t_0 <= 4e+250: tmp = math.sqrt((d / l)) / math.sqrt((h / d)) else: tmp = math.fabs((d / math.sqrt((l * h)))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e-138) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); elseif (t_0 <= 4e+250) tmp = Float64(sqrt(Float64(d / l)) / sqrt(Float64(h / d))); else tmp = abs(Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e-138)
tmp = (-d * sqrt((h / l))) / h;
elseif (t_0 <= 4e+250)
tmp = sqrt((d / l)) / sqrt((h / d));
else
tmp = abs((d / sqrt((l * h))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-138], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$0, 4e+250], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-138}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{\ell}}}{\sqrt{\frac{h}{d}}}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\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.99999999999999989e-138Initial program 87.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites52.8%
Taylor expanded in l around -inf
Applied rewrites15.1%
if -4.99999999999999989e-138 < (*.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.9999999999999997e250Initial program 88.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.4
Applied rewrites38.4%
Applied rewrites88.9%
if 3.9999999999999997e250 < (*.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 25.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
Applied rewrites59.8%
Final simplification52.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -5e-138)
(/ (* (- d) (sqrt (/ h l))) h)
(if (<= t_0 4e+250)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(fabs (/ d (sqrt (* l h))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-138) {
tmp = (-d * sqrt((h / l))) / h;
} else if (t_0 <= 4e+250) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = fabs((d / sqrt((l * h))));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-5d-138)) then
tmp = (-d * sqrt((h / l))) / h
else if (t_0 <= 4d+250) then
tmp = sqrt((d / l)) * sqrt((d / h))
else
tmp = abs((d / sqrt((l * h))))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -5e-138) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else if (t_0 <= 4e+250) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else {
tmp = Math.abs((d / Math.sqrt((l * h))));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -5e-138: tmp = (-d * math.sqrt((h / l))) / h elif t_0 <= 4e+250: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) else: tmp = math.fabs((d / math.sqrt((l * h)))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -5e-138) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); elseif (t_0 <= 4e+250) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = abs(Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -5e-138)
tmp = (-d * sqrt((h / l))) / h;
elseif (t_0 <= 4e+250)
tmp = sqrt((d / l)) * sqrt((d / h));
else
tmp = abs((d / sqrt((l * h))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-138], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$0, 4e+250], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-138}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\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.99999999999999989e-138Initial program 87.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites52.8%
Taylor expanded in l around -inf
Applied rewrites15.1%
if -4.99999999999999989e-138 < (*.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.9999999999999997e250Initial program 88.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.4
Applied rewrites38.4%
Applied rewrites88.9%
if 3.9999999999999997e250 < (*.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 25.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
Applied rewrites59.8%
Final simplification52.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (/ h 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 D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 -5e-138)
(/ (* (- d) t_0) h)
(if (<= t_1 4e+250) (/ (* t_0 d) h) (fabs (/ d (sqrt (* l h))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((h / 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= -5e-138) {
tmp = (-d * t_0) / h;
} else if (t_1 <= 4e+250) {
tmp = (t_0 * d) / h;
} else {
tmp = fabs((d / sqrt((l * h))));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((h / l))
t_1 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_1 <= (-5d-138)) then
tmp = (-d * t_0) / h
else if (t_1 <= 4d+250) then
tmp = (t_0 * d) / h
else
tmp = abs((d / sqrt((l * h))))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((h / l));
double t_1 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= -5e-138) {
tmp = (-d * t_0) / h;
} else if (t_1 <= 4e+250) {
tmp = (t_0 * d) / h;
} else {
tmp = Math.abs((d / Math.sqrt((l * h))));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((h / l)) t_1 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_1 <= -5e-138: tmp = (-d * t_0) / h elif t_1 <= 4e+250: tmp = (t_0 * d) / h else: tmp = math.fabs((d / math.sqrt((l * h)))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(h / 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= -5e-138) tmp = Float64(Float64(Float64(-d) * t_0) / h); elseif (t_1 <= 4e+250) tmp = Float64(Float64(t_0 * d) / h); else tmp = abs(Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((h / l));
t_1 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_1 <= -5e-138)
tmp = (-d * t_0) / h;
elseif (t_1 <= 4e+250)
tmp = (t_0 * d) / h;
else
tmp = abs((d / sqrt((l * h))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-138], N[(N[((-d) * t$95$0), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$1, 4e+250], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{h}{\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-138}:\\
\;\;\;\;\frac{\left(-d\right) \cdot t\_0}{h}\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\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.99999999999999989e-138Initial program 87.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites52.8%
Taylor expanded in l around -inf
Applied rewrites15.1%
if -4.99999999999999989e-138 < (*.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.9999999999999997e250Initial program 88.9%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites52.0%
Taylor expanded in d around inf
Applied rewrites82.5%
if 3.9999999999999997e250 < (*.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 25.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
Applied rewrites59.8%
Final simplification50.4%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_0 -4e-135)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= t_0 4e+250)
(/ (* (sqrt (/ h l)) d) h)
(fabs (/ d (sqrt (* l h))))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -4e-135) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (t_0 <= 4e+250) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = fabs((d / sqrt((l * h))));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_0 <= (-4d-135)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (t_0 <= 4d+250) then
tmp = (sqrt((h / l)) * d) / h
else
tmp = abs((d / sqrt((l * h))))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_0 <= -4e-135) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (t_0 <= 4e+250) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = Math.abs((d / Math.sqrt((l * h))));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_0 <= -4e-135: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif t_0 <= 4e+250: tmp = (math.sqrt((h / l)) * d) / h else: tmp = math.fabs((d / math.sqrt((l * h)))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_0 <= -4e-135) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (t_0 <= 4e+250) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = abs(Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_0 <= -4e-135)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (t_0 <= 4e+250)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = abs((d / sqrt((l * h))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-135], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+250], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-135}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+250}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\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.0000000000000002e-135Initial program 87.8%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.7
Applied rewrites10.7%
if -4.0000000000000002e-135 < (*.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.9999999999999997e250Initial program 89.0%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites51.3%
Taylor expanded in d around inf
Applied rewrites81.5%
if 3.9999999999999997e250 < (*.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 25.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
Applied rewrites59.8%
Final simplification48.8%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (sqrt (* l h)))
(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 D_m) (* 2.0 d)) 2.0)) (/ h l))))))
(if (<= t_1 5e-170)
(pow (/ t_0 d) -1.0)
(if (<= t_1 2e+104) (sqrt (* (/ (/ d l) h) d)) (fabs (/ d t_0))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = sqrt((l * h));
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 5e-170) {
tmp = pow((t_0 / d), -1.0);
} else if (t_1 <= 2e+104) {
tmp = sqrt((((d / l) / h) * d));
} else {
tmp = fabs((d / t_0));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((l * h))
t_1 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
if (t_1 <= 5d-170) then
tmp = (t_0 / d) ** (-1.0d0)
else if (t_1 <= 2d+104) then
tmp = sqrt((((d / l) / h) * d))
else
tmp = abs((d / t_0))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = Math.sqrt((l * h));
double t_1 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double tmp;
if (t_1 <= 5e-170) {
tmp = Math.pow((t_0 / d), -1.0);
} else if (t_1 <= 2e+104) {
tmp = Math.sqrt((((d / l) / h) * d));
} else {
tmp = Math.abs((d / t_0));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = math.sqrt((l * h)) t_1 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) tmp = 0 if t_1 <= 5e-170: tmp = math.pow((t_0 / d), -1.0) elif t_1 <= 2e+104: tmp = math.sqrt((((d / l) / h) * d)) else: tmp = math.fabs((d / t_0)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = sqrt(Float64(l * h)) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) tmp = 0.0 if (t_1 <= 5e-170) tmp = Float64(t_0 / d) ^ -1.0; elseif (t_1 <= 2e+104) tmp = sqrt(Float64(Float64(Float64(d / l) / h) * d)); else tmp = abs(Float64(d / t_0)); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = sqrt((l * h));
t_1 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
tmp = 0.0;
if (t_1 <= 5e-170)
tmp = (t_0 / d) ^ -1.0;
elseif (t_1 <= 2e+104)
tmp = sqrt((((d / l) / h) * d));
else
tmp = abs((d / t_0));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $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 * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-170], N[Power[N[(t$95$0 / d), $MachinePrecision], -1.0], $MachinePrecision], If[LessEqual[t$95$1, 2e+104], N[Sqrt[N[(N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision], N[Abs[N[(d / t$95$0), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-170}:\\
\;\;\;\;{\left(\frac{t\_0}{d}\right)}^{-1}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+104}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{\ell}}{h} \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{t\_0}\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)))) < 5.0000000000000001e-170Initial program 82.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6416.3
Applied rewrites16.3%
Applied rewrites16.3%
Applied rewrites16.3%
if 5.0000000000000001e-170 < (*.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)))) < 2e104Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.3
Applied rewrites38.3%
Applied rewrites96.6%
if 2e104 < (*.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 36.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.6
Applied rewrites28.6%
Applied rewrites61.1%
Final simplification47.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (/ d (sqrt (* l h)))))
(if (<= t_0 5e-170)
t_1
(if (<= t_0 2e+104) (sqrt (* (/ (/ d l) h) d)) (fabs t_1)))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = (pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = d / sqrt((l * h));
double tmp;
if (t_0 <= 5e-170) {
tmp = t_1;
} else if (t_0 <= 2e+104) {
tmp = sqrt((((d / l) / h) * d));
} else {
tmp = fabs(t_1);
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
t_1 = d / sqrt((l * h))
if (t_0 <= 5d-170) then
tmp = t_1
else if (t_0 <= 2d+104) then
tmp = sqrt((((d / l) / h) * d))
else
tmp = abs(t_1)
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = d / Math.sqrt((l * h));
double tmp;
if (t_0 <= 5e-170) {
tmp = t_1;
} else if (t_0 <= 2e+104) {
tmp = Math.sqrt((((d / l) / h) * d));
} else {
tmp = Math.abs(t_1);
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = (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 * D_m) / (2.0 * d)), 2.0)) * (h / l))) t_1 = d / math.sqrt((l * h)) tmp = 0 if t_0 <= 5e-170: tmp = t_1 elif t_0 <= 2e+104: tmp = math.sqrt((((d / l) / h) * d)) else: tmp = math.fabs(t_1) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(d / sqrt(Float64(l * h))) tmp = 0.0 if (t_0 <= 5e-170) tmp = t_1; elseif (t_0 <= 2e+104) tmp = sqrt(Float64(Float64(Float64(d / l) / h) * d)); else tmp = abs(t_1); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = (((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = d / sqrt((l * h));
tmp = 0.0;
if (t_0 <= 5e-170)
tmp = t_1;
elseif (t_0 <= 2e+104)
tmp = sqrt((((d / l) / h) * d));
else
tmp = abs(t_1);
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-170], t$95$1, If[LessEqual[t$95$0, 2e+104], N[Sqrt[N[(N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{d}{\sqrt{\ell \cdot h}}\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-170}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+104}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{\ell}}{h} \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\left|t\_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)))) < 5.0000000000000001e-170Initial program 82.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6416.3
Applied rewrites16.3%
Applied rewrites16.3%
if 5.0000000000000001e-170 < (*.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)))) < 2e104Initial program 99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.3
Applied rewrites38.3%
Applied rewrites96.6%
if 2e104 < (*.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 36.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.6
Applied rewrites28.6%
Applied rewrites61.1%
Final simplification47.9%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(if (<=
(*
(* (pow (/ d h) (pow 2.0 -1.0)) (pow (/ d l) (pow 2.0 -1.0)))
(-
1.0
(* (* (pow 2.0 -1.0) (pow (/ (* M D_m) (* 2.0 d)) 2.0)) (/ h l))))
-4e-135)
(* (- d) (sqrt (pow (* l h) -1.0)))
(fabs (/ d (sqrt (* l h))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (((pow((d / h), pow(2.0, -1.0)) * pow((d / l), pow(2.0, -1.0))) * (1.0 - ((pow(2.0, -1.0) * pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -4e-135) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = fabs((d / sqrt((l * h))));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: tmp
if (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-4d-135)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = abs((d / sqrt((l * h))))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (((Math.pow((d / h), Math.pow(2.0, -1.0)) * Math.pow((d / l), Math.pow(2.0, -1.0))) * (1.0 - ((Math.pow(2.0, -1.0) * Math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -4e-135) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = Math.abs((d / Math.sqrt((l * h))));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if ((math.pow((d / h), math.pow(2.0, -1.0)) * math.pow((d / l), math.pow(2.0, -1.0))) * (1.0 - ((math.pow(2.0, -1.0) * math.pow(((M * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -4e-135: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = math.fabs((d / math.sqrt((l * h)))) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (Float64(Float64((Float64(d / h) ^ (2.0 ^ -1.0)) * (Float64(d / l) ^ (2.0 ^ -1.0))) * Float64(1.0 - Float64(Float64((2.0 ^ -1.0) * (Float64(Float64(M * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -4e-135) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = abs(Float64(d / sqrt(Float64(l * h)))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -4e-135)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = abs((d / sqrt((l * h))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-135], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Abs[N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left({2}^{-1}\right)}\right) \cdot \left(1 - \left({2}^{-1} \cdot {\left(\frac{M \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -4 \cdot 10^{-135}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{d}{\sqrt{\ell \cdot h}}\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.0000000000000002e-135Initial program 87.8%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.7
Applied rewrites10.7%
if -4.0000000000000002e-135 < (*.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 56.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.4
Applied rewrites33.4%
Applied rewrites62.4%
Final simplification43.6%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0 (/ d (sqrt (* l h)))))
(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 D_m) (* 2.0 d)) 2.0)) (/ h l))))
-5e-138)
t_0
(fabs t_0))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = d / sqrt((l * h));
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-138) {
tmp = t_0;
} else {
tmp = fabs(t_0);
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: t_0
real(8) :: tmp
t_0 = d / sqrt((l * h))
if (((((d / h) ** (2.0d0 ** (-1.0d0))) * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= (-5d-138)) then
tmp = t_0
else
tmp = abs(t_0)
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double t_0 = d / Math.sqrt((l * h));
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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-138) {
tmp = t_0;
} else {
tmp = Math.abs(t_0);
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): t_0 = d / math.sqrt((l * h)) 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 * D_m) / (2.0 * d)), 2.0)) * (h / l)))) <= -5e-138: tmp = t_0 else: tmp = math.fabs(t_0) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(d / sqrt(Float64(l * h))) 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 * D_m) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -5e-138) tmp = t_0; else tmp = abs(t_0); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
t_0 = d / sqrt((l * h));
tmp = 0.0;
if (((((d / h) ^ (2.0 ^ -1.0)) * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= -5e-138)
tmp = t_0;
else
tmp = abs(t_0);
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[Power[2.0, -1.0], $MachinePrecision] * N[Power[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-138], t$95$0, N[Abs[t$95$0], $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \frac{d}{\sqrt{\ell \cdot h}}\\
\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 \cdot D\_m}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{-138}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left|t\_0\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.99999999999999989e-138Initial program 87.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6410.3
Applied rewrites10.3%
Applied rewrites10.3%
if -4.99999999999999989e-138 < (*.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 56.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.5
Applied rewrites33.5%
Applied rewrites62.8%
Final simplification43.5%
D_m = (fabs.f64 D)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
(FPCore (d h l M D_m)
:precision binary64
(let* ((t_0
(*
(fma (* -0.5 (/ h l)) (pow (* (/ d M) (/ 2.0 D_m)) -2.0) 1.0)
(sqrt (/ d l)))))
(if (<= d -9e-57)
(/ (* t_0 (sqrt (- d))) (sqrt (- h)))
(if (<= d 6e+205)
(/
(* (sqrt (/ h l)) (fma (/ (* h (pow (* D_m M) 2.0)) l) (/ -0.125 d) d))
h)
(/ (* t_0 (sqrt d)) (sqrt h))))))D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double t_0 = fma((-0.5 * (h / l)), pow(((d / M) * (2.0 / D_m)), -2.0), 1.0) * sqrt((d / l));
double tmp;
if (d <= -9e-57) {
tmp = (t_0 * sqrt(-d)) / sqrt(-h);
} else if (d <= 6e+205) {
tmp = (sqrt((h / l)) * fma(((h * pow((D_m * M), 2.0)) / l), (-0.125 / d), d)) / h;
} else {
tmp = (t_0 * sqrt(d)) / sqrt(h);
}
return tmp;
}
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) t_0 = Float64(fma(Float64(-0.5 * Float64(h / l)), (Float64(Float64(d / M) * Float64(2.0 / D_m)) ^ -2.0), 1.0) * sqrt(Float64(d / l))) tmp = 0.0 if (d <= -9e-57) tmp = Float64(Float64(t_0 * sqrt(Float64(-d))) / sqrt(Float64(-h))); elseif (d <= 6e+205) tmp = Float64(Float64(sqrt(Float64(h / l)) * fma(Float64(Float64(h * (Float64(D_m * M) ^ 2.0)) / l), Float64(-0.125 / d), d)) / h); else tmp = Float64(Float64(t_0 * sqrt(d)) / sqrt(h)); end return tmp end
D_m = N[Abs[D], $MachinePrecision]
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D$95$m_] := Block[{t$95$0 = N[(N[(N[(-0.5 * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(d / M), $MachinePrecision] * N[(2.0 / D$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -9e-57], N[(N[(t$95$0 * N[Sqrt[(-d)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6e+205], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(h * N[Power[N[(D$95$m * M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(-0.125 / d), $MachinePrecision] + d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], N[(N[(t$95$0 * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.5 \cdot \frac{h}{\ell}, {\left(\frac{d}{M} \cdot \frac{2}{D\_m}\right)}^{-2}, 1\right) \cdot \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -9 \cdot 10^{-57}:\\
\;\;\;\;\frac{t\_0 \cdot \sqrt{-d}}{\sqrt{-h}}\\
\mathbf{elif}\;d \leq 6 \cdot 10^{+205}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot \mathsf{fma}\left(\frac{h \cdot {\left(D\_m \cdot M\right)}^{2}}{\ell}, \frac{-0.125}{d}, d\right)}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \sqrt{d}}{\sqrt{h}}\\
\end{array}
\end{array}
if d < -8.99999999999999945e-57Initial program 76.0%
Applied rewrites89.7%
if -8.99999999999999945e-57 < d < 5.9999999999999999e205Initial program 64.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites44.1%
Applied rewrites55.6%
Applied rewrites82.2%
Applied rewrites83.8%
if 5.9999999999999999e205 < d Initial program 60.9%
Applied rewrites99.4%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (if (<= d 1.08e-173) (* (- d) (sqrt (pow (* l h) -1.0))) (/ d (* (sqrt l) (sqrt h)))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= 1.08e-173) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = d / (sqrt(l) * sqrt(h));
}
return tmp;
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
real(8) :: tmp
if (d <= 1.08d-173) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = d / (sqrt(l) * sqrt(h))
end if
code = tmp
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
double tmp;
if (d <= 1.08e-173) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = d / (Math.sqrt(l) * Math.sqrt(h));
}
return tmp;
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): tmp = 0 if d <= 1.08e-173: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = d / (math.sqrt(l) * math.sqrt(h)) return tmp
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) tmp = 0.0 if (d <= 1.08e-173) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(d / Float64(sqrt(l) * sqrt(h))); end return tmp end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp_2 = code(d, h, l, M, D_m)
tmp = 0.0;
if (d <= 1.08e-173)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = d / (sqrt(l) * sqrt(h));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := If[LessEqual[d, 1.08e-173], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 1.08 \cdot 10^{-173}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\
\end{array}
\end{array}
if d < 1.07999999999999995e-173Initial program 66.1%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6438.5
Applied rewrites38.5%
if 1.07999999999999995e-173 < d Initial program 70.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6446.2
Applied rewrites46.2%
Applied rewrites46.1%
Applied rewrites54.8%
Final simplification45.2%
D_m = (fabs.f64 D) NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. (FPCore (d h l M D_m) :precision binary64 (/ d (sqrt (* l h))))
D_m = fabs(D);
assert(d < h && h < l && l < M && M < D_m);
double code(double d, double h, double l, double M, double D_m) {
return d / sqrt((l * h));
}
D_m = abs(d)
NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function.
real(8) function code(d, h, l, m, d_m)
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_m
code = d / sqrt((l * h))
end function
D_m = Math.abs(D);
assert d < h && h < l && l < M && M < D_m;
public static double code(double d, double h, double l, double M, double D_m) {
return d / Math.sqrt((l * h));
}
D_m = math.fabs(D) [d, h, l, M, D_m] = sort([d, h, l, M, D_m]) def code(d, h, l, M, D_m): return d / math.sqrt((l * h))
D_m = abs(D) d, h, l, M, D_m = sort([d, h, l, M, D_m]) function code(d, h, l, M, D_m) return Float64(d / sqrt(Float64(l * h))) end
D_m = abs(D);
d, h, l, M, D_m = num2cell(sort([d, h, l, M, D_m])){:}
function tmp = code(d, h, l, M, D_m)
tmp = d / sqrt((l * h));
end
D_m = N[Abs[D], $MachinePrecision] NOTE: d, h, l, M, and D_m should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D$95$m_] := N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\frac{d}{\sqrt{\ell \cdot h}}
\end{array}
Initial program 67.9%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6425.0
Applied rewrites25.0%
Applied rewrites25.0%
herbie shell --seed 2024322
(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)))))