
(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}
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ h (/ l (* 0.25 (pow (/ (* D M) d) 2.0))))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (h / (l / (0.25 * pow(((D * M) / d), 2.0))))));
}
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 - (h / (l / (0.25d0 * (((d * m) / d_1) ** 2.0d0))))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (h / (l / (0.25 * Math.pow(((D * M) / d), 2.0))))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h / (l / (0.25 * math.pow(((D * M) / d), 2.0))))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h / Float64(l / Float64(0.25 * (Float64(Float64(D * M) / d) ^ 2.0))))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (h / (l / (0.25 * (((D * M) / d) ^ 2.0)))))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h / N[(l / N[(0.25 * N[Power[N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{h}{\frac{\ell}{0.25 \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}}}
\end{array}
Initial program 77.3%
Simplified75.8%
associate-*r/83.4%
clear-num83.4%
associate-*l/84.7%
div-inv84.7%
associate-*l*83.8%
associate-/r*83.8%
metadata-eval83.8%
Applied egg-rr83.8%
associate-/r/83.8%
*-commutative83.8%
*-commutative83.8%
associate-*r*84.8%
*-commutative84.8%
associate-*l/84.7%
*-commutative84.7%
associate-*r/84.7%
associate-*r/83.4%
Simplified83.4%
expm1-log1p-u83.1%
expm1-udef83.1%
un-div-inv83.1%
unpow-prod-down83.1%
metadata-eval83.1%
associate-*r/84.4%
Applied egg-rr84.4%
expm1-def84.4%
expm1-log1p84.7%
associate-/l*84.7%
associate-/l*84.1%
Simplified84.1%
Taylor expanded in D around 0 84.7%
Final simplification84.7%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 2e+27) w0 (* w0 (fma -0.125 (* (pow (* D (/ M d)) 2.0) (/ h l)) 1.0))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 2e+27) {
tmp = w0;
} else {
tmp = w0 * fma(-0.125, (pow((D * (M / d)), 2.0) * (h / l)), 1.0);
}
return tmp;
}
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 2e+27) tmp = w0; else tmp = Float64(w0 * fma(-0.125, Float64((Float64(D * Float64(M / d)) ^ 2.0) * Float64(h / l)), 1.0)); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 2e+27], w0, N[(w0 * N[(-0.125 * N[(N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 2 \cdot 10^{+27}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, {\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\ell}, 1\right)\\
\end{array}
\end{array}
if D < 2e27Initial program 78.5%
Simplified76.6%
Taylor expanded in M around 0 71.7%
if 2e27 < D Initial program 72.0%
Simplified72.0%
associate-*r/76.2%
clear-num76.2%
associate-*l/76.2%
div-inv76.2%
associate-*l*74.1%
associate-/r*74.1%
metadata-eval74.1%
Applied egg-rr74.1%
associate-/r/74.1%
*-commutative74.1%
*-commutative74.1%
associate-*r*76.2%
*-commutative76.2%
associate-*l/76.2%
*-commutative76.2%
associate-*r/76.2%
associate-*r/76.2%
Simplified76.2%
expm1-log1p-u76.0%
expm1-udef76.0%
un-div-inv76.0%
unpow-prod-down76.0%
metadata-eval76.0%
associate-*r/76.0%
Applied egg-rr76.0%
expm1-def76.0%
expm1-log1p76.2%
associate-/l*76.2%
associate-/l*76.2%
Simplified76.2%
Taylor expanded in D around 0 76.2%
Taylor expanded in h around 0 53.3%
+-commutative53.3%
fma-def53.3%
associate-*r*53.3%
times-frac51.3%
unpow251.3%
unpow251.3%
swap-sqr64.0%
unpow264.0%
times-frac68.1%
associate-*l/66.0%
associate-/r/68.1%
associate-*l/66.0%
associate-/r/68.1%
unpow268.1%
associate-/r/66.0%
associate-*l/68.1%
*-commutative68.1%
associate-*l/68.1%
Simplified68.1%
Final simplification71.0%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (pow (/ M (/ d (* D 0.5))) 2.0) l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (h * (pow((M / (d / (D * 0.5))), 2.0) / 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 - (h * (((m / (d_1 / (d * 0.5d0))) ** 2.0d0) / 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 - (h * (Math.pow((M / (d / (D * 0.5))), 2.0) / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((M / (d / (D * 0.5))), 2.0) / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M / Float64(d / Float64(D * 0.5))) ^ 2.0) / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (h * (((M / (d / (D * 0.5))) ^ 2.0) / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(M / N[(d / N[(D * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(\frac{M}{\frac{d}{D \cdot 0.5}}\right)}^{2}}{\ell}}
\end{array}
Initial program 77.3%
Simplified75.8%
associate-*r/83.4%
associate-*l/84.7%
div-inv84.7%
associate-*l*83.8%
associate-/r*83.8%
metadata-eval83.8%
Applied egg-rr83.8%
expm1-log1p-u83.4%
expm1-udef83.4%
associate-/l*77.3%
associate-*r/77.3%
Applied egg-rr77.3%
expm1-def77.3%
expm1-log1p77.6%
associate-/r/83.8%
associate-*r/84.7%
associate-/l*84.1%
Simplified84.1%
Final simplification84.1%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 2.7e+84) w0 (+ w0 (* -0.125 (* (pow (* D (/ M d)) 2.0) (/ h (/ l w0)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 2.7e+84) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (pow((D * (M / d)), 2.0) * (h / (l / w0))));
}
return tmp;
}
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
real(8) :: tmp
if (d <= 2.7d+84) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((d * (m / d_1)) ** 2.0d0) * (h / (l / w0))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 2.7e+84) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (Math.pow((D * (M / d)), 2.0) * (h / (l / w0))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 2.7e+84: tmp = w0 else: tmp = w0 + (-0.125 * (math.pow((D * (M / d)), 2.0) * (h / (l / w0)))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 2.7e+84) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64((Float64(D * Float64(M / d)) ^ 2.0) * Float64(h / Float64(l / w0))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 2.7e+84) tmp = w0; else tmp = w0 + (-0.125 * (((D * (M / d)) ^ 2.0) * (h / (l / w0)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 2.7e+84], w0, N[(w0 + N[(-0.125 * N[(N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / N[(l / w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 2.7 \cdot 10^{+84}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left({\left(D \cdot \frac{M}{d}\right)}^{2} \cdot \frac{h}{\frac{\ell}{w0}}\right)\\
\end{array}
\end{array}
if D < 2.7e84Initial program 77.8%
Simplified76.0%
Taylor expanded in M around 0 69.7%
if 2.7e84 < D Initial program 73.8%
Simplified73.8%
Taylor expanded in M around 0 49.7%
expm1-log1p-u28.0%
expm1-udef28.0%
associate-*r*28.0%
unpow-prod-down37.4%
Applied egg-rr37.4%
expm1-def37.5%
expm1-log1p62.2%
*-commutative62.2%
Simplified62.2%
unpow262.2%
Applied egg-rr62.2%
Taylor expanded in h around 0 49.7%
associate-*r*49.7%
times-frac49.4%
unpow249.4%
unpow249.4%
swap-sqr61.9%
unpow261.9%
times-frac65.0%
associate-*l/61.9%
associate-/r/64.8%
associate-*l/61.8%
associate-/r/64.8%
unpow264.8%
associate-/r/61.9%
associate-*l/65.0%
*-commutative65.0%
associate-*l/64.8%
associate-/l*67.8%
Simplified67.8%
Final simplification69.5%
(FPCore (w0 M D h l d) :precision binary64 w0)
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
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
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
def code(w0, M, D, h, l, d): return w0
function code(w0, M, D, h, l, d) return w0 end
function tmp = code(w0, M, D, h, l, d) tmp = w0; end
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
\\
w0
\end{array}
Initial program 77.3%
Simplified75.8%
Taylor expanded in M around 0 66.1%
Final simplification66.1%
herbie shell --seed 2023338
(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))))))