
(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}
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (/ (pow (* (/ M_m d) (/ D 2.0)) 2.0) l) h)))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((pow(((M_m / d) * (D / 2.0)), 2.0) / l) * h)));
}
M_m = abs(M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_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_m / d_1) * (d / 2.0d0)) ** 2.0d0) / l) * h)))
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((Math.pow(((M_m / d) * (D / 2.0)), 2.0) / l) * h)));
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0 * math.sqrt((1.0 - ((math.pow(((M_m / d) * (D / 2.0)), 2.0) / l) * h)))
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64((Float64(Float64(M_m / d) * Float64(D / 2.0)) ^ 2.0) / l) * h)))) end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0 * sqrt((1.0 - (((((M_m / d) * (D / 2.0)) ^ 2.0) / l) * h)));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(N[Power[N[(N[(M$95$m / d), $MachinePrecision] * N[(D / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \frac{{\left(\frac{M_m}{d} \cdot \frac{D}{2}\right)}^{2}}{\ell} \cdot h}
\end{array}
Initial program 83.7%
Simplified84.9%
frac-times83.7%
associate-*l/83.4%
clear-num83.3%
un-div-inv84.4%
associate-*l/84.8%
*-commutative84.8%
times-frac84.4%
Applied egg-rr84.4%
associate-/r/87.7%
Simplified87.7%
Final simplification87.7%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (or (<= d 3.2e-259) (and (not (<= d 3.2e-227)) (<= d 5.4e-10))) (+ w0 (* -0.125 (* (/ (/ (pow (* M_m D) 2.0) l) d) (/ (* w0 h) d)))) w0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((d <= 3.2e-259) || (!(d <= 3.2e-227) && (d <= 5.4e-10))) {
tmp = w0 + (-0.125 * (((pow((M_m * D), 2.0) / l) / d) * ((w0 * h) / d)));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if ((d_1 <= 3.2d-259) .or. (.not. (d_1 <= 3.2d-227)) .and. (d_1 <= 5.4d-10)) then
tmp = w0 + ((-0.125d0) * (((((m_m * d) ** 2.0d0) / l) / d_1) * ((w0 * h) / d_1)))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((d <= 3.2e-259) || (!(d <= 3.2e-227) && (d <= 5.4e-10))) {
tmp = w0 + (-0.125 * (((Math.pow((M_m * D), 2.0) / l) / d) * ((w0 * h) / d)));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (d <= 3.2e-259) or (not (d <= 3.2e-227) and (d <= 5.4e-10)): tmp = w0 + (-0.125 * (((math.pow((M_m * D), 2.0) / l) / d) * ((w0 * h) / d))) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if ((d <= 3.2e-259) || (!(d <= 3.2e-227) && (d <= 5.4e-10))) tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64((Float64(M_m * D) ^ 2.0) / l) / d) * Float64(Float64(w0 * h) / d)))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if ((d <= 3.2e-259) || (~((d <= 3.2e-227)) && (d <= 5.4e-10)))
tmp = w0 + (-0.125 * (((((M_m * D) ^ 2.0) / l) / d) * ((w0 * h) / d)));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[Or[LessEqual[d, 3.2e-259], And[N[Not[LessEqual[d, 3.2e-227]], $MachinePrecision], LessEqual[d, 5.4e-10]]], N[(w0 + N[(-0.125 * N[(N[(N[(N[Power[N[(M$95$m * D), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision] / d), $MachinePrecision] * N[(N[(w0 * h), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.2 \cdot 10^{-259} \lor \neg \left(d \leq 3.2 \cdot 10^{-227}\right) \land d \leq 5.4 \cdot 10^{-10}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\frac{\frac{{\left(M_m \cdot D\right)}^{2}}{\ell}}{d} \cdot \frac{w0 \cdot h}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if d < 3.19999999999999988e-259 or 3.2000000000000001e-227 < d < 5.4e-10Initial program 82.2%
Simplified83.4%
Taylor expanded in M around 0 47.9%
add-exp-log36.7%
associate-*r*37.3%
pow-prod-down43.9%
Applied egg-rr43.9%
rem-exp-log60.3%
*-commutative60.3%
frac-times59.1%
associate-*r/60.3%
unpow260.3%
times-frac66.9%
Applied egg-rr66.9%
if 3.19999999999999988e-259 < d < 3.2000000000000001e-227 or 5.4e-10 < d Initial program 87.0%
Simplified88.1%
Taylor expanded in M around 0 83.5%
Final simplification72.2%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= d 7.6e-10) (+ w0 (* -0.125 (/ (/ (* (pow (* M_m D) 2.0) (/ h (/ l w0))) d) d))) w0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (d <= 7.6e-10) {
tmp = w0 + (-0.125 * (((pow((M_m * D), 2.0) * (h / (l / w0))) / d) / d));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (d_1 <= 7.6d-10) then
tmp = w0 + ((-0.125d0) * (((((m_m * d) ** 2.0d0) * (h / (l / w0))) / d_1) / d_1))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (d <= 7.6e-10) {
tmp = w0 + (-0.125 * (((Math.pow((M_m * D), 2.0) * (h / (l / w0))) / d) / d));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if d <= 7.6e-10: tmp = w0 + (-0.125 * (((math.pow((M_m * D), 2.0) * (h / (l / w0))) / d) / d)) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (d <= 7.6e-10) tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64((Float64(M_m * D) ^ 2.0) * Float64(h / Float64(l / w0))) / d) / d))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (d <= 7.6e-10)
tmp = w0 + (-0.125 * (((((M_m * D) ^ 2.0) * (h / (l / w0))) / d) / d));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[d, 7.6e-10], N[(w0 + N[(-0.125 * N[(N[(N[(N[Power[N[(M$95$m * D), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / N[(l / w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 7.6 \cdot 10^{-10}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{\frac{{\left(M_m \cdot D\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if d < 7.5999999999999996e-10Initial program 81.4%
Simplified82.5%
Taylor expanded in M around 0 45.1%
add-exp-log34.2%
associate-*r*34.7%
pow-prod-down41.4%
Applied egg-rr41.4%
rem-exp-log56.6%
*-commutative56.6%
frac-times55.5%
associate-*r/56.6%
unpow256.6%
times-frac65.0%
Applied egg-rr65.0%
associate-*l/65.0%
associate-*r/66.8%
associate-*l/66.9%
associate-*r/63.1%
associate-/l*64.2%
Simplified64.2%
if 7.5999999999999996e-10 < d Initial program 90.0%
Simplified91.4%
Taylor expanded in M around 0 87.5%
Final simplification70.5%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 w0)
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0;
}
M_m = abs(M)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return w0 end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0
\end{array}
Initial program 83.7%
Simplified84.9%
Taylor expanded in M around 0 67.4%
Final simplification67.4%
herbie shell --seed 2023331
(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))))))