
(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 4 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 (let* ((t_0 (* D_m (* M (/ 0.5 d))))) (* w0 (sqrt (- 1.0 (* h (/ t_0 (/ 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));
return w0 * sqrt((1.0 - (h * (t_0 / (l / t_0)))));
}
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
t_0 = d_m * (m * (0.5d0 / d))
code = w0 * sqrt((1.0d0 - (h * (t_0 / (l / t_0)))))
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));
return w0 * Math.sqrt((1.0 - (h * (t_0 / (l / t_0)))));
}
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)) return w0 * math.sqrt((1.0 - (h * (t_0 / (l / t_0)))))
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(M * Float64(0.5 / d))) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 / Float64(l / t_0)))))) 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)
t_0 = D_m * (M * (0.5 / d));
tmp = w0 * sqrt((1.0 - (h * (t_0 / (l / t_0)))));
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[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 / N[(l / t$95$0), $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])\\
\\
\begin{array}{l}
t_0 := D\_m \cdot \left(M \cdot \frac{0.5}{d}\right)\\
w0 \cdot \sqrt{1 - h \cdot \frac{t\_0}{\frac{\ell}{t\_0}}}
\end{array}
\end{array}
Initial program 85.1%
Simplified83.7%
associate-/l*85.1%
clear-num85.1%
un-div-inv85.1%
associate-/l*83.7%
div-inv83.6%
clear-num83.6%
associate-/r*83.6%
Applied egg-rr83.6%
associate-/r/86.9%
*-commutative86.9%
associate-*r/88.4%
associate-*l/88.4%
associate-*r/88.4%
associate-*l/88.4%
metadata-eval88.4%
associate-/l*88.4%
*-commutative88.4%
associate-*r/88.4%
associate-*l/88.4%
associate-*r*88.4%
*-commutative88.4%
*-commutative88.4%
/-rgt-identity88.4%
associate-*r/88.4%
associate-/l*88.4%
Simplified88.4%
div-inv88.4%
associate-*r/88.4%
div-inv88.4%
clear-num88.4%
associate-*r*88.4%
Applied egg-rr88.4%
un-div-inv88.4%
unpow288.4%
associate-*r/90.2%
/-rgt-identity90.2%
clear-num90.2%
frac-times90.2%
metadata-eval90.2%
div-inv90.2%
/-rgt-identity90.2%
metadata-eval90.2%
times-frac90.2%
*-un-lft-identity90.2%
*-un-lft-identity90.2%
Applied egg-rr90.2%
Final simplification90.2%
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 (if (<= D_m 1.08e+45) w0 (+ w0 (* -0.125 (* (* w0 h) (/ (pow (/ (* D_m M) d) 2.0) l))))))
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 tmp;
if (D_m <= 1.08e+45) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((w0 * h) * (pow(((D_m * M) / d), 2.0) / l)));
}
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) :: tmp
if (d_m <= 1.08d+45) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((w0 * h) * ((((d_m * m) / d) ** 2.0d0) / l)))
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 tmp;
if (D_m <= 1.08e+45) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((w0 * h) * (Math.pow(((D_m * M) / d), 2.0) / l)));
}
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): tmp = 0 if D_m <= 1.08e+45: tmp = w0 else: tmp = w0 + (-0.125 * ((w0 * h) * (math.pow(((D_m * M) / d), 2.0) / l))) 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) tmp = 0.0 if (D_m <= 1.08e+45) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(w0 * h) * Float64((Float64(Float64(D_m * M) / d) ^ 2.0) / l)))); 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)
tmp = 0.0;
if (D_m <= 1.08e+45)
tmp = w0;
else
tmp = w0 + (-0.125 * ((w0 * h) * ((((D_m * M) / d) ^ 2.0) / l)));
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_] := If[LessEqual[D$95$m, 1.08e+45], w0, N[(w0 + N[(-0.125 * N[(N[(w0 * h), $MachinePrecision] * N[(N[Power[N[(N[(D$95$m * M), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision] / l), $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}
\mathbf{if}\;D\_m \leq 1.08 \cdot 10^{+45}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(w0 \cdot h\right) \cdot \frac{{\left(\frac{D\_m \cdot M}{d}\right)}^{2}}{\ell}\right)\\
\end{array}
\end{array}
if D < 1.08e45Initial program 86.8%
Simplified85.8%
Taylor expanded in M around 0 72.5%
if 1.08e45 < D Initial program 80.1%
Simplified77.3%
Taylor expanded in M around 0 53.0%
times-frac56.0%
Simplified56.0%
unpow256.0%
unpow256.0%
times-frac70.6%
Applied egg-rr70.6%
Taylor expanded in D around 0 53.0%
*-commutative53.0%
*-commutative53.0%
times-frac56.0%
associate-/l*56.0%
associate-*l/54.4%
unpow254.4%
unpow254.4%
associate-/l/58.0%
unpow258.0%
associate-*l/64.2%
associate-*r/69.0%
swap-sqr71.4%
unpow271.4%
associate-/r/71.6%
*-commutative71.6%
Simplified71.6%
associate-*r/73.2%
Applied egg-rr73.2%
Final simplification72.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 (* M (/ D_m d)))) (if (<= D_m 1.04e+45) w0 (+ w0 (* -0.125 (* (* w0 h) (/ (* t_0 t_0) l)))))))
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 = M * (D_m / d);
double tmp;
if (D_m <= 1.04e+45) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((w0 * h) * ((t_0 * t_0) / l)));
}
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 = m * (d_m / d)
if (d_m <= 1.04d+45) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((w0 * h) * ((t_0 * t_0) / l)))
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 = M * (D_m / d);
double tmp;
if (D_m <= 1.04e+45) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((w0 * h) * ((t_0 * t_0) / l)));
}
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 = M * (D_m / d) tmp = 0 if D_m <= 1.04e+45: tmp = w0 else: tmp = w0 + (-0.125 * ((w0 * h) * ((t_0 * t_0) / l))) 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(M * Float64(D_m / d)) tmp = 0.0 if (D_m <= 1.04e+45) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(w0 * h) * Float64(Float64(t_0 * t_0) / l)))); 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 = M * (D_m / d);
tmp = 0.0;
if (D_m <= 1.04e+45)
tmp = w0;
else
tmp = w0 + (-0.125 * ((w0 * h) * ((t_0 * t_0) / l)));
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[(M * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D$95$m, 1.04e+45], w0, N[(w0 + N[(-0.125 * N[(N[(w0 * h), $MachinePrecision] * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / l), $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 := M \cdot \frac{D\_m}{d}\\
\mathbf{if}\;D\_m \leq 1.04 \cdot 10^{+45}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\left(w0 \cdot h\right) \cdot \frac{t\_0 \cdot t\_0}{\ell}\right)\\
\end{array}
\end{array}
if D < 1.04e45Initial program 86.8%
Simplified85.8%
Taylor expanded in M around 0 72.5%
if 1.04e45 < D Initial program 80.1%
Simplified77.3%
Taylor expanded in M around 0 53.0%
times-frac56.0%
Simplified56.0%
unpow256.0%
unpow256.0%
times-frac70.6%
Applied egg-rr70.6%
Taylor expanded in D around 0 53.0%
*-commutative53.0%
*-commutative53.0%
times-frac56.0%
associate-/l*56.0%
associate-*l/54.4%
unpow254.4%
unpow254.4%
associate-/l/58.0%
unpow258.0%
associate-*l/64.2%
associate-*r/69.0%
swap-sqr71.4%
unpow271.4%
associate-/r/71.6%
*-commutative71.6%
Simplified71.6%
unpow271.6%
Applied egg-rr71.6%
Final simplification72.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 85.1%
Simplified83.7%
Taylor expanded in M around 0 64.9%
Final simplification64.9%
herbie shell --seed 2024026
(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))))))