
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
D_m = (fabs.f64 D) NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (/ (* h (* D_m (/ M (/ d 0.5)))) l) (* D_m (/ (* M 0.5) d)))))))
D_m = fabs(D);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0, double M, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 - (((h * (D_m * (M / (d / 0.5)))) / l) * (D_m * ((M * 0.5) / d)))));
}
D_m = abs(D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * sqrt((1.0d0 - (((h * (d_m * (m / (d / 0.5d0)))) / l) * (d_m * ((m * 0.5d0) / d)))))
end function
D_m = Math.abs(D);
assert w0 < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (((h * (D_m * (M / (d / 0.5)))) / l) * (D_m * ((M * 0.5) / d)))));
}
D_m = math.fabs(D) [w0, M, D_m, h, l, d] = sort([w0, M, D_m, h, l, d]) def code(w0, M, D_m, h, l, d): return w0 * math.sqrt((1.0 - (((h * (D_m * (M / (d / 0.5)))) / l) * (D_m * ((M * 0.5) / d)))))
D_m = abs(D) w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d]) function code(w0, M, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h * Float64(D_m * Float64(M / Float64(d / 0.5)))) / l) * Float64(D_m * Float64(Float64(M * 0.5) / d)))))) end
D_m = abs(D);
w0, M, D_m, h, l, d = num2cell(sort([w0, M, D_m, h, l, d])){:}
function tmp = code(w0, M, D_m, h, l, d)
tmp = w0 * sqrt((1.0 - (((h * (D_m * (M / (d / 0.5)))) / l) * (D_m * ((M * 0.5) / d)))));
end
D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h * N[(D$95$m * N[(M / N[(d / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(D$95$m * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
[w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \frac{h \cdot \left(D\_m \cdot \frac{M}{\frac{d}{0.5}}\right)}{\ell} \cdot \left(D\_m \cdot \frac{M \cdot 0.5}{d}\right)}
\end{array}
Initial program 79.5%
Simplified79.1%
*-commutative79.1%
frac-times79.5%
*-commutative79.5%
associate-*l/85.0%
associate-*l/84.7%
*-commutative84.7%
div-inv84.6%
associate-/r*84.6%
metadata-eval84.6%
Applied egg-rr84.6%
associate-*l/79.1%
unpow279.1%
associate-*r*80.7%
associate-*r/80.7%
associate-*r/80.7%
Applied egg-rr80.7%
associate-*l/87.3%
associate-/l*87.3%
Applied egg-rr87.3%
D_m = (fabs.f64 D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d)
:precision binary64
(let* ((t_0 (/ (* D_m (* M 0.5)) d))
(t_1
(*
w0
(sqrt
(-
1.0
(*
(/ (* 0.5 (/ (* D_m (* M h)) d)) l)
(* D_m (/ (* M 0.5) d))))))))
(if (<= (/ h l) -1e+264)
t_1
(if (<= (/ h l) -1e-95)
(* w0 (sqrt (- 1.0 (* (* (/ h l) t_0) t_0))))
t_1))))D_m = fabs(D);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0, double M, double D_m, double h, double l, double d) {
double t_0 = (D_m * (M * 0.5)) / d;
double t_1 = w0 * sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * (D_m * ((M * 0.5) / d)))));
double tmp;
if ((h / l) <= -1e+264) {
tmp = t_1;
} else if ((h / l) <= -1e-95) {
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
D_m = abs(D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_m * (m * 0.5d0)) / d
t_1 = w0 * sqrt((1.0d0 - (((0.5d0 * ((d_m * (m * h)) / d)) / l) * (d_m * ((m * 0.5d0) / d)))))
if ((h / l) <= (-1d+264)) then
tmp = t_1
else if ((h / l) <= (-1d-95)) then
tmp = w0 * sqrt((1.0d0 - (((h / l) * t_0) * t_0)))
else
tmp = t_1
end if
code = tmp
end function
D_m = Math.abs(D);
assert w0 < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M, double D_m, double h, double l, double d) {
double t_0 = (D_m * (M * 0.5)) / d;
double t_1 = w0 * Math.sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * (D_m * ((M * 0.5) / d)))));
double tmp;
if ((h / l) <= -1e+264) {
tmp = t_1;
} else if ((h / l) <= -1e-95) {
tmp = w0 * Math.sqrt((1.0 - (((h / l) * t_0) * t_0)));
} else {
tmp = t_1;
}
return tmp;
}
D_m = math.fabs(D) [w0, M, D_m, h, l, d] = sort([w0, M, D_m, h, l, d]) def code(w0, M, D_m, h, l, d): t_0 = (D_m * (M * 0.5)) / d t_1 = w0 * math.sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * (D_m * ((M * 0.5) / d))))) tmp = 0 if (h / l) <= -1e+264: tmp = t_1 elif (h / l) <= -1e-95: tmp = w0 * math.sqrt((1.0 - (((h / l) * t_0) * t_0))) else: tmp = t_1 return tmp
D_m = abs(D) w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d]) function code(w0, M, D_m, h, l, d) t_0 = Float64(Float64(D_m * Float64(M * 0.5)) / d) t_1 = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(0.5 * Float64(Float64(D_m * Float64(M * h)) / d)) / l) * Float64(D_m * Float64(Float64(M * 0.5) / d)))))) tmp = 0.0 if (Float64(h / l) <= -1e+264) tmp = t_1; elseif (Float64(h / l) <= -1e-95) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * t_0) * t_0)))); else tmp = t_1; end return tmp end
D_m = abs(D);
w0, M, D_m, h, l, d = num2cell(sort([w0, M, D_m, h, l, d])){:}
function tmp_2 = code(w0, M, D_m, h, l, d)
t_0 = (D_m * (M * 0.5)) / d;
t_1 = w0 * sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * (D_m * ((M * 0.5) / d)))));
tmp = 0.0;
if ((h / l) <= -1e+264)
tmp = t_1;
elseif ((h / l) <= -1e-95)
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * t_0)));
else
tmp = t_1;
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D$95$m * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(0.5 * N[(N[(D$95$m * N[(M * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(D$95$m * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(h / l), $MachinePrecision], -1e+264], t$95$1, If[LessEqual[N[(h / l), $MachinePrecision], -1e-95], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{D\_m \cdot \left(M \cdot 0.5\right)}{d}\\
t_1 := w0 \cdot \sqrt{1 - \frac{0.5 \cdot \frac{D\_m \cdot \left(M \cdot h\right)}{d}}{\ell} \cdot \left(D\_m \cdot \frac{M \cdot 0.5}{d}\right)}\\
\mathbf{if}\;\frac{h}{\ell} \leq -1 \cdot 10^{+264}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-95}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot t\_0\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 h l) < -1.00000000000000004e264 or -9.99999999999999989e-96 < (/.f64 h l) Initial program 81.1%
Simplified81.0%
*-commutative81.0%
frac-times81.1%
*-commutative81.1%
associate-*l/89.7%
associate-*l/89.7%
*-commutative89.7%
div-inv89.7%
associate-/r*89.7%
metadata-eval89.7%
Applied egg-rr89.7%
associate-*l/81.0%
unpow281.0%
associate-*r*83.4%
associate-*r/83.4%
associate-*r/83.4%
Applied egg-rr83.4%
associate-*l/93.5%
associate-/l*93.5%
Applied egg-rr93.5%
Taylor expanded in h around 0 90.1%
if -1.00000000000000004e264 < (/.f64 h l) < -9.99999999999999989e-96Initial program 75.9%
Simplified74.8%
*-commutative74.8%
frac-times75.9%
*-commutative75.9%
associate-*l/74.8%
associate-*l/73.6%
*-commutative73.6%
div-inv73.6%
associate-/r*73.6%
metadata-eval73.6%
Applied egg-rr73.6%
associate-*l/74.8%
unpow274.8%
associate-*r*74.7%
associate-*r/74.8%
associate-*r/74.8%
Applied egg-rr74.8%
associate-*r/74.8%
Applied egg-rr74.8%
associate-*r/77.1%
Applied egg-rr77.1%
D_m = (fabs.f64 D) NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d) :precision binary64 (let* ((t_0 (* D_m (/ (* M 0.5) d)))) (if (<= M 4.1e-225) w0 (* w0 (sqrt (- 1.0 (* (* (/ h l) t_0) t_0)))))))
D_m = fabs(D);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0, double M, double D_m, double h, double l, double d) {
double t_0 = D_m * ((M * 0.5) / d);
double tmp;
if (M <= 4.1e-225) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * t_0)));
}
return tmp;
}
D_m = abs(D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = d_m * ((m * 0.5d0) / d)
if (m <= 4.1d-225) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - (((h / l) * t_0) * t_0)))
end if
code = tmp
end function
D_m = Math.abs(D);
assert w0 < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M, double D_m, double h, double l, double d) {
double t_0 = D_m * ((M * 0.5) / d);
double tmp;
if (M <= 4.1e-225) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - (((h / l) * t_0) * t_0)));
}
return tmp;
}
D_m = math.fabs(D) [w0, M, D_m, h, l, d] = sort([w0, M, D_m, h, l, d]) def code(w0, M, D_m, h, l, d): t_0 = D_m * ((M * 0.5) / d) tmp = 0 if M <= 4.1e-225: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - (((h / l) * t_0) * t_0))) return tmp
D_m = abs(D) w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d]) function code(w0, M, D_m, h, l, d) t_0 = Float64(D_m * Float64(Float64(M * 0.5) / d)) tmp = 0.0 if (M <= 4.1e-225) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h / l) * t_0) * t_0)))); end return tmp end
D_m = abs(D);
w0, M, D_m, h, l, d = num2cell(sort([w0, M, D_m, h, l, d])){:}
function tmp_2 = code(w0, M, D_m, h, l, d)
t_0 = D_m * ((M * 0.5) / d);
tmp = 0.0;
if (M <= 4.1e-225)
tmp = w0;
else
tmp = w0 * sqrt((1.0 - (((h / l) * t_0) * t_0)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 4.1e-225], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{M \cdot 0.5}{d}\\
\mathbf{if}\;M \leq 4.1 \cdot 10^{-225}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(\frac{h}{\ell} \cdot t\_0\right) \cdot t\_0}\\
\end{array}
\end{array}
if M < 4.10000000000000022e-225Initial program 78.0%
Simplified78.0%
Taylor expanded in D around 0 72.4%
if 4.10000000000000022e-225 < M Initial program 81.7%
Simplified80.7%
*-commutative80.7%
frac-times81.7%
*-commutative81.7%
associate-*l/85.7%
associate-*l/84.7%
*-commutative84.7%
div-inv84.7%
associate-/r*84.7%
metadata-eval84.7%
Applied egg-rr84.7%
associate-*l/80.7%
unpow280.7%
associate-*r*81.7%
associate-*r/81.7%
associate-*r/81.7%
Applied egg-rr81.7%
D_m = (fabs.f64 D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d)
:precision binary64
(let* ((t_0 (* D_m (/ (* M 0.5) d))))
(if (<= d 1e-45)
(* w0 (sqrt (- 1.0 (* (/ (* h D_m) (* l (/ d (* M 0.5)))) t_0))))
(* w0 (sqrt (- 1.0 (* (/ (* 0.5 (/ (* D_m (* M h)) d)) l) t_0)))))))D_m = fabs(D);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0, double M, double D_m, double h, double l, double d) {
double t_0 = D_m * ((M * 0.5) / d);
double tmp;
if (d <= 1e-45) {
tmp = w0 * sqrt((1.0 - (((h * D_m) / (l * (d / (M * 0.5)))) * t_0)));
} else {
tmp = w0 * sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * t_0)));
}
return tmp;
}
D_m = abs(D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = d_m * ((m * 0.5d0) / d)
if (d <= 1d-45) then
tmp = w0 * sqrt((1.0d0 - (((h * d_m) / (l * (d / (m * 0.5d0)))) * t_0)))
else
tmp = w0 * sqrt((1.0d0 - (((0.5d0 * ((d_m * (m * h)) / d)) / l) * t_0)))
end if
code = tmp
end function
D_m = Math.abs(D);
assert w0 < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M, double D_m, double h, double l, double d) {
double t_0 = D_m * ((M * 0.5) / d);
double tmp;
if (d <= 1e-45) {
tmp = w0 * Math.sqrt((1.0 - (((h * D_m) / (l * (d / (M * 0.5)))) * t_0)));
} else {
tmp = w0 * Math.sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * t_0)));
}
return tmp;
}
D_m = math.fabs(D) [w0, M, D_m, h, l, d] = sort([w0, M, D_m, h, l, d]) def code(w0, M, D_m, h, l, d): t_0 = D_m * ((M * 0.5) / d) tmp = 0 if d <= 1e-45: tmp = w0 * math.sqrt((1.0 - (((h * D_m) / (l * (d / (M * 0.5)))) * t_0))) else: tmp = w0 * math.sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * t_0))) return tmp
D_m = abs(D) w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d]) function code(w0, M, D_m, h, l, d) t_0 = Float64(D_m * Float64(Float64(M * 0.5) / d)) tmp = 0.0 if (d <= 1e-45) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(h * D_m) / Float64(l * Float64(d / Float64(M * 0.5)))) * t_0)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(Float64(0.5 * Float64(Float64(D_m * Float64(M * h)) / d)) / l) * t_0)))); end return tmp end
D_m = abs(D);
w0, M, D_m, h, l, d = num2cell(sort([w0, M, D_m, h, l, d])){:}
function tmp_2 = code(w0, M, D_m, h, l, d)
t_0 = D_m * ((M * 0.5) / d);
tmp = 0.0;
if (d <= 1e-45)
tmp = w0 * sqrt((1.0 - (((h * D_m) / (l * (d / (M * 0.5)))) * t_0)));
else
tmp = w0 * sqrt((1.0 - (((0.5 * ((D_m * (M * h)) / d)) / l) * t_0)));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(N[(M * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 1e-45], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(h * D$95$m), $MachinePrecision] / N[(l * N[(d / N[(M * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[(0.5 * N[(N[(D$95$m * N[(M * h), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
D_m = \left|D\right|
\\
[w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \frac{M \cdot 0.5}{d}\\
\mathbf{if}\;d \leq 10^{-45}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot D\_m}{\ell \cdot \frac{d}{M \cdot 0.5}} \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{0.5 \cdot \frac{D\_m \cdot \left(M \cdot h\right)}{d}}{\ell} \cdot t\_0}\\
\end{array}
\end{array}
if d < 9.99999999999999984e-46Initial program 76.4%
Simplified76.3%
*-commutative76.3%
frac-times76.4%
*-commutative76.4%
associate-*l/82.6%
associate-*l/82.6%
*-commutative82.6%
div-inv82.5%
associate-/r*82.5%
metadata-eval82.5%
Applied egg-rr82.5%
associate-*l/76.3%
unpow276.3%
associate-*r*78.1%
associate-*r/78.1%
associate-*r/78.1%
Applied egg-rr78.1%
associate-*r/77.0%
Applied egg-rr77.0%
associate-/l*78.1%
frac-times79.7%
Applied egg-rr79.7%
if 9.99999999999999984e-46 < d Initial program 86.9%
Simplified85.7%
*-commutative85.7%
frac-times86.9%
*-commutative86.9%
associate-*l/90.9%
associate-*l/89.7%
*-commutative89.7%
div-inv89.7%
associate-/r*89.7%
metadata-eval89.7%
Applied egg-rr89.7%
associate-*l/85.7%
unpow285.7%
associate-*r*87.1%
associate-*r/87.1%
associate-*r/87.1%
Applied egg-rr87.1%
associate-*l/92.3%
associate-/l*92.3%
Applied egg-rr92.3%
Taylor expanded in h around 0 88.3%
D_m = (fabs.f64 D) NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d) :precision binary64 w0)
D_m = fabs(D);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d);
double code(double w0, double M, double D_m, double h, double l, double d) {
return w0;
}
D_m = abs(D)
NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0
end function
D_m = Math.abs(D);
assert w0 < M && M < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M, double D_m, double h, double l, double d) {
return w0;
}
D_m = math.fabs(D) [w0, M, D_m, h, l, d] = sort([w0, M, D_m, h, l, d]) def code(w0, M, D_m, h, l, d): return w0
D_m = abs(D) w0, M, D_m, h, l, d = sort([w0, M, D_m, h, l, d]) function code(w0, M, D_m, h, l, d) return w0 end
D_m = abs(D);
w0, M, D_m, h, l, d = num2cell(sort([w0, M, D_m, h, l, d])){:}
function tmp = code(w0, M, D_m, h, l, d)
tmp = w0;
end
D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
D_m = \left|D\right|
\\
[w0, M, D_m, h, l, d] = \mathsf{sort}([w0, M, D_m, h, l, d])\\
\\
w0
\end{array}
Initial program 79.5%
Simplified79.1%
Taylor expanded in D around 0 68.2%
herbie shell --seed 2024034 -o generate:simplify
(FPCore (w0 M D h l d)
:name "Henrywood and Agarwal, Equation (9a)"
:precision binary64
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))