
(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 3 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 (/ (pow (* M (/ (* D 0.5) d)) 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 * 0.5) / d)), 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 * 0.5d0) / d_1)) ** 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 * 0.5) / d)), 2.0) / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((M * ((D * 0.5) / d)), 2.0) / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M * Float64(Float64(D * 0.5) / d)) ^ 2.0) / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - (h * (((M * ((D * 0.5) / d)) ^ 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[(N[(D * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(M \cdot \frac{D \cdot 0.5}{d}\right)}^{2}}{\ell}}
\end{array}
Initial program 78.0%
Simplified78.0%
associate-/r*78.0%
associate-*r/78.0%
*-commutative78.0%
associate-*r/78.4%
unpow278.4%
unpow278.4%
associate-*r/85.1%
clear-num85.1%
unpow285.1%
unpow285.1%
associate-*r/84.3%
times-frac85.1%
div-inv85.1%
metadata-eval85.1%
Applied egg-rr85.1%
associate-/r/85.1%
*-commutative85.1%
associate-*r/84.3%
*-commutative84.3%
associate-/l*84.3%
associate-*r/84.3%
Simplified84.3%
*-un-lft-identity84.3%
associate-*l/84.3%
*-un-lft-identity84.3%
Applied egg-rr84.3%
*-lft-identity84.3%
associate-/l*85.0%
associate-*r/85.1%
associate-*r/84.7%
*-commutative84.7%
associate-/l*85.1%
associate-*r*85.1%
*-commutative85.1%
associate-*l/85.1%
Simplified85.1%
Final simplification85.1%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 5.4e+143) w0 (+ w0 (* -0.125 (* (pow (* M D) 2.0) (* (/ (/ h l) d) (/ w0 d)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 5.4e+143) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (pow((M * D), 2.0) * (((h / l) / d) * (w0 / d))));
}
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 <= 5.4d+143) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((m * d) ** 2.0d0) * (((h / l) / d_1) * (w0 / d_1))))
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 <= 5.4e+143) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (Math.pow((M * D), 2.0) * (((h / l) / d) * (w0 / d))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 5.4e+143: tmp = w0 else: tmp = w0 + (-0.125 * (math.pow((M * D), 2.0) * (((h / l) / d) * (w0 / d)))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 5.4e+143) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64((Float64(M * D) ^ 2.0) * Float64(Float64(Float64(h / l) / d) * Float64(w0 / d))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 5.4e+143) tmp = w0; else tmp = w0 + (-0.125 * (((M * D) ^ 2.0) * (((h / l) / d) * (w0 / d)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 5.4e+143], w0, N[(w0 + N[(-0.125 * N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] * N[(N[(N[(h / l), $MachinePrecision] / d), $MachinePrecision] * N[(w0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 5.4 \cdot 10^{+143}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left({\left(M \cdot D\right)}^{2} \cdot \left(\frac{\frac{h}{\ell}}{d} \cdot \frac{w0}{d}\right)\right)\\
\end{array}
\end{array}
if D < 5.4000000000000003e143Initial program 79.9%
Simplified79.9%
Taylor expanded in D around 0 72.3%
if 5.4000000000000003e143 < D Initial program 62.2%
Simplified62.6%
*-commutative62.6%
associate-*l/62.2%
associate-*r/65.8%
clear-num65.8%
frac-times62.6%
*-un-lft-identity62.6%
Applied egg-rr62.6%
Taylor expanded in D around 0 33.4%
associate-*r*37.0%
unpow237.0%
unpow237.0%
swap-sqr55.1%
unpow255.1%
*-commutative55.1%
associate-*r/51.4%
Simplified51.4%
frac-times51.3%
associate-*r/51.3%
unpow251.3%
times-frac54.9%
Applied egg-rr54.9%
Final simplification70.4%
(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 78.0%
Simplified78.0%
Taylor expanded in D around 0 67.3%
Final simplification67.3%
herbie shell --seed 2024074
(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))))))