
(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 16 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 (* (/ M (* d 2.0)) D_m)) (t_1 (pow (/ d h) (pow 2.0 -1.0))))
(if (<=
(*
(* t_1 (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))))
2e+245)
(* (* t_1 (sqrt (/ d l))) (- 1.0 (* t_0 (* (/ h l) (* 0.5 t_0)))))
(*
(- 1.0 (* (/ (* (* (* (/ D_m d) M) (/ h l)) (* 0.5 D_m)) 4.0) (/ M d)))
(/ (fabs d) (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 = (M / (d * 2.0)) * D_m;
double t_1 = pow((d / h), pow(2.0, -1.0));
double tmp;
if (((t_1 * 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)))) <= 2e+245) {
tmp = (t_1 * sqrt((d / l))) * (1.0 - (t_0 * ((h / l) * (0.5 * t_0))));
} else {
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (fabs(d) / sqrt((h * l)));
}
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 = (m / (d * 2.0d0)) * d_m
t_1 = (d / h) ** (2.0d0 ** (-1.0d0))
if (((t_1 * ((d / l) ** (2.0d0 ** (-1.0d0)))) * (1.0d0 - (((2.0d0 ** (-1.0d0)) * (((m * d_m) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 2d+245) then
tmp = (t_1 * sqrt((d / l))) * (1.0d0 - (t_0 * ((h / l) * (0.5d0 * t_0))))
else
tmp = (1.0d0 - ((((((d_m / d) * m) * (h / l)) * (0.5d0 * d_m)) / 4.0d0) * (m / d))) * (abs(d) / sqrt((h * l)))
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 = (M / (d * 2.0)) * D_m;
double t_1 = Math.pow((d / h), Math.pow(2.0, -1.0));
double tmp;
if (((t_1 * 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)))) <= 2e+245) {
tmp = (t_1 * Math.sqrt((d / l))) * (1.0 - (t_0 * ((h / l) * (0.5 * t_0))));
} else {
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (Math.abs(d) / Math.sqrt((h * l)));
}
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 = (M / (d * 2.0)) * D_m t_1 = math.pow((d / h), math.pow(2.0, -1.0)) tmp = 0 if ((t_1 * 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)))) <= 2e+245: tmp = (t_1 * math.sqrt((d / l))) * (1.0 - (t_0 * ((h / l) * (0.5 * t_0)))) else: tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (math.fabs(d) / math.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(M / Float64(d * 2.0)) * D_m) t_1 = Float64(d / h) ^ (2.0 ^ -1.0) tmp = 0.0 if (Float64(Float64(t_1 * (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)))) <= 2e+245) tmp = Float64(Float64(t_1 * sqrt(Float64(d / l))) * Float64(1.0 - Float64(t_0 * Float64(Float64(h / l) * Float64(0.5 * t_0))))); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D_m / d) * M) * Float64(h / l)) * Float64(0.5 * D_m)) / 4.0) * Float64(M / d))) * Float64(abs(d) / sqrt(Float64(h * l)))); 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 = (M / (d * 2.0)) * D_m;
t_1 = (d / h) ^ (2.0 ^ -1.0);
tmp = 0.0;
if (((t_1 * ((d / l) ^ (2.0 ^ -1.0))) * (1.0 - (((2.0 ^ -1.0) * (((M * D_m) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 2e+245)
tmp = (t_1 * sqrt((d / l))) * (1.0 - (t_0 * ((h / l) * (0.5 * t_0))));
else
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (abs(d) / sqrt((h * l)));
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[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] * D$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(d / h), $MachinePrecision], N[Power[2.0, -1.0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * 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], 2e+245], N[(N[(t$95$1 * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(t$95$0 * N[(N[(h / l), $MachinePrecision] * N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(0.5 * D$95$m), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $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 := \frac{M}{d \cdot 2} \cdot D\_m\\
t_1 := {\left(\frac{d}{h}\right)}^{\left({2}^{-1}\right)}\\
\mathbf{if}\;\left(t\_1 \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 2 \cdot 10^{+245}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - t\_0 \cdot \left(\frac{h}{\ell} \cdot \left(0.5 \cdot t\_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{\left(\left(\frac{D\_m}{d} \cdot M\right) \cdot \frac{h}{\ell}\right) \cdot \left(0.5 \cdot D\_m\right)}{4} \cdot \frac{M}{d}\right) \cdot \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 88.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.5%
lift-/.f64N/A
metadata-eval86.5
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6486.5
Applied rewrites86.5%
metadata-evalN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lift-*.f64N/A
lower-*.f64N/A
Applied rewrites90.4%
if 2.00000000000000009e245 < (*.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 32.3%
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.f6418.1
Applied rewrites18.1%
Applied rewrites68.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6468.0
Applied rewrites68.0%
Applied rewrites70.4%
Final simplification83.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 (/ (fabs d) (sqrt (* h l))))
(t_2
(* (* (* -0.125 (/ (/ (* D_m D_m) d) d)) (* h (/ (* M M) l))) t_1)))
(if (<= t_0 -1e+306)
t_2
(if (<= t_0 0.0)
(* (fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M M) d) d)) (/ h l) 1.0) t_1)
(if (<= t_0 2e+245)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(if (<= t_0 INFINITY) (* t_1 1.0) t_2))))))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 = fabs(d) / sqrt((h * l));
double t_2 = ((-0.125 * (((D_m * D_m) / d) / d)) * (h * ((M * M) / l))) * t_1;
double tmp;
if (t_0 <= -1e+306) {
tmp = t_2;
} else if (t_0 <= 0.0) {
tmp = fma(((-0.125 * (D_m * D_m)) * (((M * M) / d) / d)), (h / l), 1.0) * t_1;
} else if (t_0 <= 2e+245) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_1 * 1.0;
} else {
tmp = t_2;
}
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(abs(d) / sqrt(Float64(h * l))) t_2 = Float64(Float64(Float64(-0.125 * Float64(Float64(Float64(D_m * D_m) / d) / d)) * Float64(h * Float64(Float64(M * M) / l))) * t_1) tmp = 0.0 if (t_0 <= -1e+306) tmp = t_2; elseif (t_0 <= 0.0) tmp = Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M * M) / d) / d)), Float64(h / l), 1.0) * t_1); elseif (t_0 <= 2e+245) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); elseif (t_0 <= Inf) tmp = Float64(t_1 * 1.0); else tmp = t_2; 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[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-0.125 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+306], t$95$2, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 2e+245], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(t$95$1 * 1.0), $MachinePrecision], t$95$2]]]]]]]
\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{\left|d\right|}{\sqrt{h \cdot \ell}}\\
t_2 := \left(\left(-0.125 \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right) \cdot \left(h \cdot \frac{M \cdot M}{\ell}\right)\right) \cdot t\_1\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+306}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M \cdot M}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_1 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.00000000000000002e306 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 52.1%
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.f6426.9
Applied rewrites26.9%
Applied rewrites66.3%
Taylor expanded in d around 0
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6455.6
Applied rewrites55.6%
if -1.00000000000000002e306 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 68.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.f6437.1
Applied rewrites37.1%
Applied rewrites75.1%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6446.8
Applied rewrites46.8%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
if 2.00000000000000009e245 < (*.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 64.6%
Taylor expanded in d around inf
Applied rewrites64.6%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6497.5
Applied rewrites97.5%
Final simplification74.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)))))
(t_1 (/ (fabs d) (sqrt (* h l))))
(t_2 (* t_1 1.0))
(t_3
(* (* (* -0.125 (/ (/ (* D_m D_m) d) d)) (* h (/ (* M M) l))) t_1)))
(if (<= t_0 -10000000000000.0)
t_3
(if (<= t_0 0.0)
t_2
(if (<= t_0 2e+245)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(if (<= t_0 INFINITY) t_2 t_3))))))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 = fabs(d) / sqrt((h * l));
double t_2 = t_1 * 1.0;
double t_3 = ((-0.125 * (((D_m * D_m) / d) / d)) * (h * ((M * M) / l))) * t_1;
double tmp;
if (t_0 <= -10000000000000.0) {
tmp = t_3;
} else if (t_0 <= 0.0) {
tmp = t_2;
} else if (t_0 <= 2e+245) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = t_3;
}
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.abs(d) / Math.sqrt((h * l));
double t_2 = t_1 * 1.0;
double t_3 = ((-0.125 * (((D_m * D_m) / d) / d)) * (h * ((M * M) / l))) * t_1;
double tmp;
if (t_0 <= -10000000000000.0) {
tmp = t_3;
} else if (t_0 <= 0.0) {
tmp = t_2;
} else if (t_0 <= 2e+245) {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = t_3;
}
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.fabs(d) / math.sqrt((h * l)) t_2 = t_1 * 1.0 t_3 = ((-0.125 * (((D_m * D_m) / d) / d)) * (h * ((M * M) / l))) * t_1 tmp = 0 if t_0 <= -10000000000000.0: tmp = t_3 elif t_0 <= 0.0: tmp = t_2 elif t_0 <= 2e+245: tmp = math.sqrt((d / l)) * math.sqrt((d / h)) elif t_0 <= math.inf: tmp = t_2 else: tmp = t_3 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(abs(d) / sqrt(Float64(h * l))) t_2 = Float64(t_1 * 1.0) t_3 = Float64(Float64(Float64(-0.125 * Float64(Float64(Float64(D_m * D_m) / d) / d)) * Float64(h * Float64(Float64(M * M) / l))) * t_1) tmp = 0.0 if (t_0 <= -10000000000000.0) tmp = t_3; elseif (t_0 <= 0.0) tmp = t_2; elseif (t_0 <= 2e+245) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); elseif (t_0 <= Inf) tmp = t_2; else tmp = t_3; 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 = abs(d) / sqrt((h * l));
t_2 = t_1 * 1.0;
t_3 = ((-0.125 * (((D_m * D_m) / d) / d)) * (h * ((M * M) / l))) * t_1;
tmp = 0.0;
if (t_0 <= -10000000000000.0)
tmp = t_3;
elseif (t_0 <= 0.0)
tmp = t_2;
elseif (t_0 <= 2e+245)
tmp = sqrt((d / l)) * sqrt((d / h));
elseif (t_0 <= Inf)
tmp = t_2;
else
tmp = t_3;
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[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(-0.125 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$0, -10000000000000.0], t$95$3, If[LessEqual[t$95$0, 0.0], t$95$2, If[LessEqual[t$95$0, 2e+245], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$2, t$95$3]]]]]]]]
\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{\left|d\right|}{\sqrt{h \cdot \ell}}\\
t_2 := t\_1 \cdot 1\\
t_3 := \left(\left(-0.125 \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right) \cdot \left(h \cdot \frac{M \cdot M}{\ell}\right)\right) \cdot t\_1\\
\mathbf{if}\;t\_0 \leq -10000000000000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\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)))) < -1e13 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 56.6%
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.f6429.8
Applied rewrites29.8%
Applied rewrites67.1%
Taylor expanded in d around 0
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6452.8
Applied rewrites52.8%
if -1e13 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0 or 2.00000000000000009e245 < (*.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 58.7%
Taylor expanded in d around inf
Applied rewrites53.3%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6489.1
Applied rewrites89.1%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
Final simplification74.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
(*
(* (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 (/ (fabs d) (sqrt (* h l)))))
(if (<= t_0 -1e+306)
(* (* (* -0.125 (/ (/ (* D_m D_m) d) d)) (* h (/ (* M M) l))) t_1)
(if (<= t_0 0.0)
(* (fma (* (* -0.125 (* D_m D_m)) (/ (/ (* M M) d) d)) (/ h l) 1.0) t_1)
(if (<= t_0 5e+257)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(fma
(* -0.5 (/ (* (* (- D_m) M) (* D_m M)) (* (* -2.0 d) (* 2.0 d))))
(/ h l)
1.0)
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 = fabs(d) / sqrt((h * l));
double tmp;
if (t_0 <= -1e+306) {
tmp = ((-0.125 * (((D_m * D_m) / d) / d)) * (h * ((M * M) / l))) * t_1;
} else if (t_0 <= 0.0) {
tmp = fma(((-0.125 * (D_m * D_m)) * (((M * M) / d) / d)), (h / l), 1.0) * t_1;
} else if (t_0 <= 5e+257) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = fma((-0.5 * (((-D_m * M) * (D_m * M)) / ((-2.0 * d) * (2.0 * d)))), (h / l), 1.0) * 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(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (t_0 <= -1e+306) tmp = Float64(Float64(Float64(-0.125 * Float64(Float64(Float64(D_m * D_m) / d) / d)) * Float64(h * Float64(Float64(M * M) / l))) * t_1); elseif (t_0 <= 0.0) tmp = Float64(fma(Float64(Float64(-0.125 * Float64(D_m * D_m)) * Float64(Float64(Float64(M * M) / d) / d)), Float64(h / l), 1.0) * t_1); elseif (t_0 <= 5e+257) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(Float64(-D_m) * M) * Float64(D_m * M)) / Float64(Float64(-2.0 * d) * Float64(2.0 * d)))), Float64(h / l), 1.0) * 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[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+306], N[(N[(N[(-0.125 * N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(N[(M * M), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(-0.125 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 5e+257], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.5 * N[(N[(N[((-D$95$m) * M), $MachinePrecision] * N[(D$95$m * M), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 * d), $MachinePrecision] * N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * 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{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+306}:\\
\;\;\;\;\left(\left(-0.125 \cdot \frac{\frac{D\_m \cdot D\_m}{d}}{d}\right) \cdot \left(h \cdot \frac{M \cdot M}{\ell}\right)\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.125 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \frac{\frac{M \cdot M}{d}}{d}, \frac{h}{\ell}, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+257}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \frac{\left(\left(-D\_m\right) \cdot M\right) \cdot \left(D\_m \cdot M\right)}{\left(-2 \cdot d\right) \cdot \left(2 \cdot d\right)}, \frac{h}{\ell}, 1\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.00000000000000002e306Initial program 83.0%
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.7
Applied rewrites42.7%
Applied rewrites82.8%
Taylor expanded in d around 0
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6468.4
Applied rewrites68.4%
if -1.00000000000000002e306 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 68.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.f6437.1
Applied rewrites37.1%
Applied rewrites75.1%
Taylor expanded in d around 0
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6446.8
Applied rewrites46.8%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.00000000000000028e257Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6435.8
Applied rewrites35.8%
Applied rewrites37.0%
Applied rewrites99.5%
if 5.00000000000000028e257 < (*.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 31.5%
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.f6418.3
Applied rewrites18.3%
Applied rewrites67.6%
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
unpow2N/A
frac-2negN/A
*-commutativeN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites61.6%
Final simplification73.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 -2e-90)
(/ (* (* (* -0.25 (* D_m D_m)) (* M M)) (* (/ h l) (sqrt (/ h l)))) h)
(if (or (<= t_0 0.0) (not (<= t_0 2e+245)))
(* (/ (fabs d) (sqrt (* h l))) 1.0)
(* (sqrt (/ d l)) (sqrt (/ d 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 <= -2e-90) {
tmp = (((-0.25 * (D_m * D_m)) * (M * M)) * ((h / l) * sqrt((h / l)))) / h;
} else if ((t_0 <= 0.0) || !(t_0 <= 2e+245)) {
tmp = (fabs(d) / sqrt((h * l))) * 1.0;
} else {
tmp = sqrt((d / l)) * sqrt((d / 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 <= (-2d-90)) then
tmp = ((((-0.25d0) * (d_m * d_m)) * (m * m)) * ((h / l) * sqrt((h / l)))) / h
else if ((t_0 <= 0.0d0) .or. (.not. (t_0 <= 2d+245))) then
tmp = (abs(d) / sqrt((h * l))) * 1.0d0
else
tmp = sqrt((d / l)) * sqrt((d / 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 <= -2e-90) {
tmp = (((-0.25 * (D_m * D_m)) * (M * M)) * ((h / l) * Math.sqrt((h / l)))) / h;
} else if ((t_0 <= 0.0) || !(t_0 <= 2e+245)) {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * 1.0;
} else {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / 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 <= -2e-90: tmp = (((-0.25 * (D_m * D_m)) * (M * M)) * ((h / l) * math.sqrt((h / l)))) / h elif (t_0 <= 0.0) or not (t_0 <= 2e+245): tmp = (math.fabs(d) / math.sqrt((h * l))) * 1.0 else: tmp = math.sqrt((d / l)) * math.sqrt((d / 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 <= -2e-90) tmp = Float64(Float64(Float64(Float64(-0.25 * Float64(D_m * D_m)) * Float64(M * M)) * Float64(Float64(h / l) * sqrt(Float64(h / l)))) / h); elseif ((t_0 <= 0.0) || !(t_0 <= 2e+245)) tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * 1.0); else tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / 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 <= -2e-90)
tmp = (((-0.25 * (D_m * D_m)) * (M * M)) * ((h / l) * sqrt((h / l)))) / h;
elseif ((t_0 <= 0.0) || ~((t_0 <= 2e+245)))
tmp = (abs(d) / sqrt((h * l))) * 1.0;
else
tmp = sqrt((d / l)) * sqrt((d / 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, -2e-90], N[(N[(N[(N[(-0.25 * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(M * M), $MachinePrecision]), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 2e+245]], $MachinePrecision]], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / 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}
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 -2 \cdot 10^{-90}:\\
\;\;\;\;\frac{\left(\left(-0.25 \cdot \left(D\_m \cdot D\_m\right)\right) \cdot \left(M \cdot M\right)\right) \cdot \left(\frac{h}{\ell} \cdot \sqrt{\frac{h}{\ell}}\right)}{h}\\
\mathbf{elif}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 2 \cdot 10^{+245}\right):\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.99999999999999999e-90Initial program 85.7%
Applied rewrites34.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites20.3%
Taylor expanded in h around -inf
Applied rewrites23.1%
Applied rewrites24.5%
if -1.99999999999999999e-90 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0 or 2.00000000000000009e245 < (*.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 30.9%
Taylor expanded in d around inf
Applied rewrites34.1%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6460.9
Applied rewrites60.9%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
Final simplification60.3%
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 -2e-90)
(/ (* (- d) (sqrt (/ h l))) h)
(if (or (<= t_0 0.0) (not (<= t_0 2e+245)))
(* (/ (fabs d) (sqrt (* h l))) 1.0)
(* (sqrt (/ d l)) (sqrt (/ d 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 <= -2e-90) {
tmp = (-d * sqrt((h / l))) / h;
} else if ((t_0 <= 0.0) || !(t_0 <= 2e+245)) {
tmp = (fabs(d) / sqrt((h * l))) * 1.0;
} else {
tmp = sqrt((d / l)) * sqrt((d / 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 <= (-2d-90)) then
tmp = (-d * sqrt((h / l))) / h
else if ((t_0 <= 0.0d0) .or. (.not. (t_0 <= 2d+245))) then
tmp = (abs(d) / sqrt((h * l))) * 1.0d0
else
tmp = sqrt((d / l)) * sqrt((d / 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 <= -2e-90) {
tmp = (-d * Math.sqrt((h / l))) / h;
} else if ((t_0 <= 0.0) || !(t_0 <= 2e+245)) {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * 1.0;
} else {
tmp = Math.sqrt((d / l)) * Math.sqrt((d / 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 <= -2e-90: tmp = (-d * math.sqrt((h / l))) / h elif (t_0 <= 0.0) or not (t_0 <= 2e+245): tmp = (math.fabs(d) / math.sqrt((h * l))) * 1.0 else: tmp = math.sqrt((d / l)) * math.sqrt((d / 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 <= -2e-90) tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); elseif ((t_0 <= 0.0) || !(t_0 <= 2e+245)) tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * 1.0); else tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / 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 <= -2e-90)
tmp = (-d * sqrt((h / l))) / h;
elseif ((t_0 <= 0.0) || ~((t_0 <= 2e+245)))
tmp = (abs(d) / sqrt((h * l))) * 1.0;
else
tmp = sqrt((d / l)) * sqrt((d / 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, -2e-90], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 2e+245]], $MachinePrecision]], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / 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}
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 -2 \cdot 10^{-90}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\mathbf{elif}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 2 \cdot 10^{+245}\right):\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.99999999999999999e-90Initial program 85.7%
Applied rewrites34.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites20.3%
Taylor expanded in l around -inf
Applied rewrites18.8%
if -1.99999999999999999e-90 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0 or 2.00000000000000009e245 < (*.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 30.9%
Taylor expanded in d around inf
Applied rewrites34.1%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6460.9
Applied rewrites60.9%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
Final simplification58.3%
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_m M) (* -2.0 d)))
(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 (/ (fabs d) (sqrt (* h l)))))
(if (<= t_1 0.0)
(* (fma (* -0.5 (* t_0 t_0)) (/ h l) 1.0) t_2)
(if (<= t_1 2e+245)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(*
(- 1.0 (* (/ (* (* (* (/ D_m d) M) (/ h l)) (* 0.5 D_m)) 4.0) (/ M d)))
t_2)))))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_m * M) / (-2.0 * d);
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 = fabs(d) / sqrt((h * l));
double tmp;
if (t_1 <= 0.0) {
tmp = fma((-0.5 * (t_0 * t_0)), (h / l), 1.0) * t_2;
} else if (t_1 <= 2e+245) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * t_2;
}
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(D_m * M) / Float64(-2.0 * d)) 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 = Float64(abs(d) / sqrt(Float64(h * l))) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(fma(Float64(-0.5 * Float64(t_0 * t_0)), Float64(h / l), 1.0) * t_2); elseif (t_1 <= 2e+245) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D_m / d) * M) * Float64(h / l)) * Float64(0.5 * D_m)) / 4.0) * Float64(M / d))) * t_2); 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[(D$95$m * M), $MachinePrecision] / N[(-2.0 * d), $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[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(-0.5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 2e+245], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(0.5 * D$95$m), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $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\_m \cdot M}{-2 \cdot d}\\
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 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \left(t\_0 \cdot t\_0\right), \frac{h}{\ell}, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{\left(\left(\frac{D\_m}{d} \cdot M\right) \cdot \frac{h}{\ell}\right) \cdot \left(0.5 \cdot D\_m\right)}{4} \cdot \frac{M}{d}\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 79.3%
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.3
Applied rewrites41.3%
Applied rewrites80.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
unpow2N/A
frac-2negN/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-neg2N/A
sqr-negN/A
lower-*.f64N/A
Applied rewrites82.9%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
if 2.00000000000000009e245 < (*.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 32.3%
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.f6418.1
Applied rewrites18.1%
Applied rewrites68.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6468.0
Applied rewrites68.0%
Applied rewrites70.4%
Final simplification83.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)))))
(t_1 (/ M (* d 2.0))))
(if (or (<= t_0 0.0) (not (<= t_0 2e+245)))
(*
(fma (* -0.5 (* (* (* t_1 D_m) t_1) D_m)) (/ h l) 1.0)
(/ (fabs d) (sqrt (* h l))))
(* (sqrt (/ d l)) (sqrt (/ d 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 t_1 = M / (d * 2.0);
double tmp;
if ((t_0 <= 0.0) || !(t_0 <= 2e+245)) {
tmp = fma((-0.5 * (((t_1 * D_m) * t_1) * D_m)), (h / l), 1.0) * (fabs(d) / sqrt((h * l)));
} else {
tmp = sqrt((d / l)) * sqrt((d / 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)))) t_1 = Float64(M / Float64(d * 2.0)) tmp = 0.0 if ((t_0 <= 0.0) || !(t_0 <= 2e+245)) tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(t_1 * D_m) * t_1) * D_m)), Float64(h / l), 1.0) * Float64(abs(d) / sqrt(Float64(h * l)))); else tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / 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[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[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 2e+245]], $MachinePrecision]], N[(N[(N[(-0.5 * N[(N[(N[(t$95$1 * D$95$m), $MachinePrecision] * t$95$1), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / 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}
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{M}{d \cdot 2}\\
\mathbf{if}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 2 \cdot 10^{+245}\right):\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \left(\left(\left(t\_1 \cdot D\_m\right) \cdot t\_1\right) \cdot D\_m\right), \frac{h}{\ell}, 1\right) \cdot \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0 or 2.00000000000000009e245 < (*.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 57.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.f6430.4
Applied rewrites30.4%
Applied rewrites74.8%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6475.4
Applied rewrites75.4%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6473.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.8
Applied rewrites73.8%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
Final simplification81.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 (/ (* D_m M) (* -2.0 d)))
(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 (/ (fabs d) (sqrt (* h l))))
(t_3 (/ M (* d 2.0))))
(if (<= t_1 0.0)
(* (fma (* -0.5 (* t_0 t_0)) (/ h l) 1.0) t_2)
(if (<= t_1 2e+245)
(* (sqrt (/ d l)) (sqrt (/ d h)))
(* (fma (* -0.5 (* (* (* t_3 D_m) t_3) D_m)) (/ h l) 1.0) t_2)))))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_m * M) / (-2.0 * d);
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 = fabs(d) / sqrt((h * l));
double t_3 = M / (d * 2.0);
double tmp;
if (t_1 <= 0.0) {
tmp = fma((-0.5 * (t_0 * t_0)), (h / l), 1.0) * t_2;
} else if (t_1 <= 2e+245) {
tmp = sqrt((d / l)) * sqrt((d / h));
} else {
tmp = fma((-0.5 * (((t_3 * D_m) * t_3) * D_m)), (h / l), 1.0) * t_2;
}
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(D_m * M) / Float64(-2.0 * d)) 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 = Float64(abs(d) / sqrt(Float64(h * l))) t_3 = Float64(M / Float64(d * 2.0)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(fma(Float64(-0.5 * Float64(t_0 * t_0)), Float64(h / l), 1.0) * t_2); elseif (t_1 <= 2e+245) tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))); else tmp = Float64(fma(Float64(-0.5 * Float64(Float64(Float64(t_3 * D_m) * t_3) * D_m)), Float64(h / l), 1.0) * t_2); 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[(D$95$m * M), $MachinePrecision] / N[(-2.0 * d), $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[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(-0.5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, 2e+245], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.5 * N[(N[(N[(t$95$3 * D$95$m), $MachinePrecision] * t$95$3), $MachinePrecision] * D$95$m), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $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\_m \cdot M}{-2 \cdot d}\\
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 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
t_3 := \frac{M}{d \cdot 2}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \left(t\_0 \cdot t\_0\right), \frac{h}{\ell}, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+245}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot \left(\left(\left(t\_3 \cdot D\_m\right) \cdot t\_3\right) \cdot D\_m\right), \frac{h}{\ell}, 1\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 79.3%
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.3
Applied rewrites41.3%
Applied rewrites80.9%
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
unpow2N/A
frac-2negN/A
frac-2negN/A
distribute-frac-neg2N/A
distribute-frac-neg2N/A
sqr-negN/A
lower-*.f64N/A
Applied rewrites82.9%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 99.5%
Taylor expanded in d around inf
Applied rewrites99.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6434.9
Applied rewrites34.9%
Applied rewrites36.2%
Applied rewrites99.5%
if 2.00000000000000009e245 < (*.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 32.3%
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.f6418.1
Applied rewrites18.1%
Applied rewrites68.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6468.0
Applied rewrites68.0%
lift-pow.f64N/A
unpow2N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6468.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.0
Applied rewrites68.0%
Final simplification83.0%
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 -2e-90)
(/ (* (- d) t_0) h)
(if (<= t_1 5e+295)
(/ (* t_0 d) h)
(* (/ (fabs d) (sqrt (* h l))) 1.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((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 <= -2e-90) {
tmp = (-d * t_0) / h;
} else if (t_1 <= 5e+295) {
tmp = (t_0 * d) / h;
} else {
tmp = (fabs(d) / sqrt((h * l))) * 1.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((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 <= (-2d-90)) then
tmp = (-d * t_0) / h
else if (t_1 <= 5d+295) then
tmp = (t_0 * d) / h
else
tmp = (abs(d) / sqrt((h * l))) * 1.0d0
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 <= -2e-90) {
tmp = (-d * t_0) / h;
} else if (t_1 <= 5e+295) {
tmp = (t_0 * d) / h;
} else {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * 1.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((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 <= -2e-90: tmp = (-d * t_0) / h elif t_1 <= 5e+295: tmp = (t_0 * d) / h else: tmp = (math.fabs(d) / math.sqrt((h * l))) * 1.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(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 <= -2e-90) tmp = Float64(Float64(Float64(-d) * t_0) / h); elseif (t_1 <= 5e+295) tmp = Float64(Float64(t_0 * d) / h); else tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * 1.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((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 <= -2e-90)
tmp = (-d * t_0) / h;
elseif (t_1 <= 5e+295)
tmp = (t_0 * d) / h;
else
tmp = (abs(d) / sqrt((h * l))) * 1.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[(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, -2e-90], N[(N[((-d) * t$95$0), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[t$95$1, 5e+295], N[(N[(t$95$0 * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.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 := \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 -2 \cdot 10^{-90}:\\
\;\;\;\;\frac{\left(-d\right) \cdot t\_0}{h}\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;\frac{t\_0 \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.99999999999999999e-90Initial program 85.7%
Applied rewrites34.8%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites20.3%
Taylor expanded in l around -inf
Applied rewrites18.8%
if -1.99999999999999999e-90 < (*.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.99999999999999991e295Initial program 91.3%
Applied rewrites86.6%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites55.7%
Taylor expanded in d around inf
Applied rewrites87.6%
if 4.99999999999999991e295 < (*.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 29.0%
Taylor expanded in d around inf
Applied rewrites32.8%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6457.0
Applied rewrites57.0%
Final simplification54.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))))))
(if (<= t_0 0.0)
(* (sqrt (pow (* l h) -1.0)) d)
(if (<= t_0 5e+295)
(/ (* (sqrt (/ h l)) d) h)
(* (/ (fabs d) (sqrt (* h l))) 1.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 = (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 <= 0.0) {
tmp = sqrt(pow((l * h), -1.0)) * d;
} else if (t_0 <= 5e+295) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = (fabs(d) / sqrt((h * l))) * 1.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 / 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 <= 0.0d0) then
tmp = sqrt(((l * h) ** (-1.0d0))) * d
else if (t_0 <= 5d+295) then
tmp = (sqrt((h / l)) * d) / h
else
tmp = (abs(d) / sqrt((h * l))) * 1.0d0
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 <= 0.0) {
tmp = Math.sqrt(Math.pow((l * h), -1.0)) * d;
} else if (t_0 <= 5e+295) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * 1.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.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 <= 0.0: tmp = math.sqrt(math.pow((l * h), -1.0)) * d elif t_0 <= 5e+295: tmp = (math.sqrt((h / l)) * d) / h else: tmp = (math.fabs(d) / math.sqrt((h * l))) * 1.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(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 <= 0.0) tmp = Float64(sqrt((Float64(l * h) ^ -1.0)) * d); elseif (t_0 <= 5e+295) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * 1.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 / 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 <= 0.0)
tmp = sqrt(((l * h) ^ -1.0)) * d;
elseif (t_0 <= 5e+295)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = (abs(d) / sqrt((h * l))) * 1.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[(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, 0.0], N[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], If[LessEqual[t$95$0, 5e+295], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.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 := \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 0:\\
\;\;\;\;\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 0.0Initial program 79.3%
Taylor expanded in d around inf
Applied rewrites2.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6413.9
Applied rewrites13.9%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 4.99999999999999991e295Initial program 99.5%
Applied rewrites94.2%
Taylor expanded in h around 0
lower-/.f64N/A
Applied rewrites59.1%
Taylor expanded in d around inf
Applied rewrites93.3%
if 4.99999999999999991e295 < (*.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 29.0%
Taylor expanded in d around inf
Applied rewrites32.8%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6457.0
Applied rewrites57.0%
Final simplification52.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
(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))))
2e+245)
(*
(* (sqrt (/ d h)) (sqrt (/ d l)))
(-
1.0
(* (* (/ (/ D_m d) 2.0) (* M (/ h l))) (* (* 0.5 (/ D_m 2.0)) (/ M d)))))
(*
(- 1.0 (* (/ (* (* (* (/ D_m d) M) (/ h l)) (* 0.5 D_m)) 4.0) (/ M d)))
(/ (fabs d) (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 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)))) <= 2e+245) {
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - ((((D_m / d) / 2.0) * (M * (h / l))) * ((0.5 * (D_m / 2.0)) * (M / d))));
} else {
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (fabs(d) / sqrt((h * l)));
}
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)))) <= 2d+245) then
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0d0 - ((((d_m / d) / 2.0d0) * (m * (h / l))) * ((0.5d0 * (d_m / 2.0d0)) * (m / d))))
else
tmp = (1.0d0 - ((((((d_m / d) * m) * (h / l)) * (0.5d0 * d_m)) / 4.0d0) * (m / d))) * (abs(d) / sqrt((h * l)))
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)))) <= 2e+245) {
tmp = (Math.sqrt((d / h)) * Math.sqrt((d / l))) * (1.0 - ((((D_m / d) / 2.0) * (M * (h / l))) * ((0.5 * (D_m / 2.0)) * (M / d))));
} else {
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (Math.abs(d) / Math.sqrt((h * l)));
}
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)))) <= 2e+245: tmp = (math.sqrt((d / h)) * math.sqrt((d / l))) * (1.0 - ((((D_m / d) / 2.0) * (M * (h / l))) * ((0.5 * (D_m / 2.0)) * (M / d)))) else: tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (math.fabs(d) / math.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) 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)))) <= 2e+245) tmp = Float64(Float64(sqrt(Float64(d / h)) * sqrt(Float64(d / l))) * Float64(1.0 - Float64(Float64(Float64(Float64(D_m / d) / 2.0) * Float64(M * Float64(h / l))) * Float64(Float64(0.5 * Float64(D_m / 2.0)) * Float64(M / d))))); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(Float64(D_m / d) * M) * Float64(h / l)) * Float64(0.5 * D_m)) / 4.0) * Float64(M / d))) * Float64(abs(d) / sqrt(Float64(h * l)))); 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)))) <= 2e+245)
tmp = (sqrt((d / h)) * sqrt((d / l))) * (1.0 - ((((D_m / d) / 2.0) * (M * (h / l))) * ((0.5 * (D_m / 2.0)) * (M / d))));
else
tmp = (1.0 - ((((((D_m / d) * M) * (h / l)) * (0.5 * D_m)) / 4.0) * (M / d))) * (abs(d) / sqrt((h * l)));
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], 2e+245], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D$95$m / d), $MachinePrecision] / 2.0), $MachinePrecision] * N[(M * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(0.5 * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(N[(N[(N[(D$95$m / d), $MachinePrecision] * M), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] * N[(0.5 * D$95$m), $MachinePrecision]), $MachinePrecision] / 4.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $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 2 \cdot 10^{+245}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - \left(\frac{\frac{D\_m}{d}}{2} \cdot \left(M \cdot \frac{h}{\ell}\right)\right) \cdot \left(\left(0.5 \cdot \frac{D\_m}{2}\right) \cdot \frac{M}{d}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{\left(\left(\frac{D\_m}{d} \cdot M\right) \cdot \frac{h}{\ell}\right) \cdot \left(0.5 \cdot D\_m\right)}{4} \cdot \frac{M}{d}\right) \cdot \frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.00000000000000009e245Initial program 88.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.5%
lift-/.f64N/A
metadata-eval86.5
lift-pow.f64N/A
unpow1/2N/A
lower-sqrt.f6486.5
Applied rewrites86.5%
Taylor expanded in d around -inf
mul-1-negN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
remove-double-negN/A
lower-sqrt.f64N/A
lower-/.f6486.5
Applied rewrites86.5%
if 2.00000000000000009e245 < (*.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 32.3%
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.f6418.1
Applied rewrites18.1%
Applied rewrites68.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6468.0
Applied rewrites68.0%
Applied rewrites70.4%
Final simplification81.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
(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))))
-1e-53)
(* (- d) (sqrt (pow (* l h) -1.0)))
(* (/ (fabs d) (sqrt (* h l))) 1.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 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)))) <= -1e-53) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = (fabs(d) / sqrt((h * l))) * 1.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) :: 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)))) <= (-1d-53)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = (abs(d) / sqrt((h * l))) * 1.0d0
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)))) <= -1e-53) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = (Math.abs(d) / Math.sqrt((h * l))) * 1.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): 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)))) <= -1e-53: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = (math.fabs(d) / math.sqrt((h * l))) * 1.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) 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)))) <= -1e-53) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * 1.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)
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)))) <= -1e-53)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = (abs(d) / sqrt((h * l))) * 1.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_] := 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], -1e-53], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.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}
\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 -1 \cdot 10^{-53}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot 1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.00000000000000003e-53Initial program 85.6%
Taylor expanded in d around inf
Applied rewrites0.8%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6411.3
Applied rewrites11.3%
if -1.00000000000000003e-53 < (*.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.2%
Taylor expanded in d around inf
Applied rewrites63.4%
lift-*.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow-prod-downN/A
unpow1/2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqrt-divN/A
rem-sqrt-square-revN/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-*.f6466.7
Applied rewrites66.7%
Final simplification48.3%
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.55e-236) (* (- d) (sqrt (pow (* l h) -1.0))) (/ 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 (d <= 1.55e-236) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = 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 <= 1.55d-236) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = 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 (d <= 1.55e-236) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = 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 d <= 1.55e-236: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = 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 (d <= 1.55e-236) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = 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 <= 1.55e-236)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = 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[d, 1.55e-236], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
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.55 \cdot 10^{-236}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\
\end{array}
\end{array}
if d < 1.5499999999999999e-236Initial program 71.6%
Taylor expanded in d around inf
Applied rewrites40.9%
Taylor expanded in l around -inf
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6440.1
Applied rewrites40.1%
if 1.5499999999999999e-236 < d Initial program 68.1%
Taylor expanded in d around inf
Applied rewrites44.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.4
Applied rewrites49.4%
Applied rewrites50.2%
Applied rewrites50.2%
Final simplification44.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 (* (sqrt (pow (* l h) -1.0)) d))
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 sqrt(pow((l * h), -1.0)) * d;
}
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 = sqrt(((l * h) ** (-1.0d0))) * d
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 Math.sqrt(Math.pow((l * h), -1.0)) * d;
}
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 math.sqrt(math.pow((l * h), -1.0)) * d
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(sqrt((Float64(l * h) ^ -1.0)) * d) 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 = sqrt(((l * h) ^ -1.0)) * d;
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[(N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[d, h, l, M, D_m] = \mathsf{sort}([d, h, l, M, D_m])\\
\\
\sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d
\end{array}
Initial program 69.9%
Taylor expanded in d around inf
Applied rewrites42.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.9
Applied rewrites26.9%
Final simplification26.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 (/ 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 69.9%
Taylor expanded in d around inf
Applied rewrites42.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6426.9
Applied rewrites26.9%
Applied rewrites26.6%
Applied rewrites26.6%
herbie shell --seed 2024329
(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)))))