
(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 6 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 (let* ((t_0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))) (if (<= t_0 0.01) (* w0 (sqrt (- 1.0 t_0))) w0)))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= 0.01) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = (((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)
if (t_0 <= 0.01d0) then
tmp = w0 * sqrt((1.0d0 - t_0))
else
tmp = w0
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= 0.01) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l) tmp = 0 if t_0 <= 0.01: tmp = w0 * math.sqrt((1.0 - t_0)) else: tmp = w0 return tmp
function code(w0, M, D, h, l, d) t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= 0.01) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = w0; end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) t_0 = (((M * D) / (2.0 * d)) ^ 2.0) * (h / l); tmp = 0.0; if (t_0 <= 0.01) tmp = w0 * sqrt((1.0 - t_0)); else tmp = w0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.01], N[(w0 * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t\_0 \leq 0.01:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) < 0.0100000000000000002Initial program 85.1%
if 0.0100000000000000002 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 0.0%
Simplified5.0%
Taylor expanded in D around 0 67.0%
Final simplification83.7%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (/ h l) -2e-313) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D (/ (/ M 2.0) d)) 2.0))))) w0))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -2e-313) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D * ((M / 2.0) / d)), 2.0))));
} else {
tmp = 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 ((h / l) <= (-2d-313)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d * ((m / 2.0d0) / d_1)) ** 2.0d0))))
else
tmp = 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 ((h / l) <= -2e-313) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D * ((M / 2.0) / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (h / l) <= -2e-313: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D * ((M / 2.0) / d)), 2.0)))) else: tmp = w0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -2e-313) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D * Float64(Float64(M / 2.0) / d)) ^ 2.0))))); else tmp = w0; end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if ((h / l) <= -2e-313) tmp = w0 * sqrt((1.0 - ((h / l) * ((D * ((M / 2.0) / d)) ^ 2.0)))); else tmp = w0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -2e-313], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-313}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -1.99999999998e-313Initial program 74.4%
Simplified72.5%
if -1.99999999998e-313 < (/.f64 h l) Initial program 84.1%
Simplified83.2%
Taylor expanded in D around 0 92.2%
Final simplification80.7%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (/ h l) -2e-313) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (/ D (* 2.0 (/ d M))) 2.0))))) w0))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -2e-313) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D / (2.0 * (d / M))), 2.0))));
} else {
tmp = 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 ((h / l) <= (-2d-313)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d / (2.0d0 * (d_1 / m))) ** 2.0d0))))
else
tmp = 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 ((h / l) <= -2e-313) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D / (2.0 * (d / M))), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (h / l) <= -2e-313: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D / (2.0 * (d / M))), 2.0)))) else: tmp = w0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -2e-313) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D / Float64(2.0 * Float64(d / M))) ^ 2.0))))); else tmp = w0; end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if ((h / l) <= -2e-313) tmp = w0 * sqrt((1.0 - ((h / l) * ((D / (2.0 * (d / M))) ^ 2.0)))); else tmp = w0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -2e-313], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D / N[(2.0 * N[(d / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{-313}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2 \cdot \frac{d}{M}}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -1.99999999998e-313Initial program 74.4%
Simplified72.5%
clear-num72.5%
un-div-inv72.8%
associate-/r/72.7%
Applied egg-rr72.7%
if -1.99999999998e-313 < (/.f64 h l) Initial program 84.1%
Simplified83.2%
Taylor expanded in D around 0 92.2%
Final simplification80.9%
(FPCore (w0 M D h l d) :precision binary64 (if (<= D 3.3e+143) w0 (+ w0 (* w0 (* (* (/ h l) (pow (* D (/ M d)) 2.0)) -0.125)))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 3.3e+143) {
tmp = w0;
} else {
tmp = w0 + (w0 * (((h / l) * pow((D * (M / d)), 2.0)) * -0.125));
}
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 <= 3.3d+143) then
tmp = w0
else
tmp = w0 + (w0 * (((h / l) * ((d * (m / d_1)) ** 2.0d0)) * (-0.125d0)))
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 <= 3.3e+143) {
tmp = w0;
} else {
tmp = w0 + (w0 * (((h / l) * Math.pow((D * (M / d)), 2.0)) * -0.125));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if D <= 3.3e+143: tmp = w0 else: tmp = w0 + (w0 * (((h / l) * math.pow((D * (M / d)), 2.0)) * -0.125)) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 3.3e+143) tmp = w0; else tmp = Float64(w0 + Float64(w0 * Float64(Float64(Float64(h / l) * (Float64(D * Float64(M / d)) ^ 2.0)) * -0.125))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (D <= 3.3e+143) tmp = w0; else tmp = w0 + (w0 * (((h / l) * ((D * (M / d)) ^ 2.0)) * -0.125)); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[D, 3.3e+143], w0, N[(w0 + N[(w0 * N[(N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;D \leq 3.3 \cdot 10^{+143}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + w0 \cdot \left(\left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right) \cdot -0.125\right)\\
\end{array}
\end{array}
if D < 3.3e143Initial program 77.7%
Simplified76.0%
Taylor expanded in D around 0 68.0%
if 3.3e143 < D Initial program 85.1%
Simplified85.1%
unpow285.1%
unpow285.1%
associate-/r*85.1%
associate-*r/85.1%
*-commutative85.1%
associate-*r/89.4%
*-commutative89.4%
associate-*l/89.4%
associate-/r*89.4%
clear-num89.4%
associate-*l/89.4%
*-un-lft-identity89.4%
associate-/r/89.4%
Applied egg-rr89.4%
associate-*l/85.1%
*-commutative85.1%
associate-*l/85.1%
Applied egg-rr85.1%
Taylor expanded in D around 0 16.1%
+-commutative16.1%
*-commutative16.1%
fma-define16.1%
associate-*r*16.2%
unpow216.2%
unpow216.2%
swap-sqr54.7%
unpow254.7%
times-frac54.2%
unpow254.2%
unpow254.2%
times-frac72.9%
unpow272.9%
associate-/l*72.9%
Simplified72.9%
fma-undefine72.9%
distribute-rgt-in72.9%
*-un-lft-identity72.9%
Applied egg-rr72.9%
Final simplification68.5%
(FPCore (w0 M D h l d) :precision binary64 (if (<= M 9e+106) w0 (* w0 (* -0.125 (* h (/ (pow (* D (/ M d)) 2.0) l))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 9e+106) {
tmp = w0;
} else {
tmp = w0 * (-0.125 * (h * (pow((D * (M / d)), 2.0) / l)));
}
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 (m <= 9d+106) then
tmp = w0
else
tmp = w0 * ((-0.125d0) * (h * (((d * (m / d_1)) ** 2.0d0) / l)))
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 (M <= 9e+106) {
tmp = w0;
} else {
tmp = w0 * (-0.125 * (h * (Math.pow((D * (M / d)), 2.0) / l)));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if M <= 9e+106: tmp = w0 else: tmp = w0 * (-0.125 * (h * (math.pow((D * (M / d)), 2.0) / l))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 9e+106) tmp = w0; else tmp = Float64(w0 * Float64(-0.125 * Float64(h * Float64((Float64(D * Float64(M / d)) ^ 2.0) / l)))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (M <= 9e+106) tmp = w0; else tmp = w0 * (-0.125 * (h * (((D * (M / d)) ^ 2.0) / l))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 9e+106], w0, N[(w0 * N[(-0.125 * N[(h * N[(N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 9 \cdot 10^{+106}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(-0.125 \cdot \left(h \cdot \frac{{\left(D \cdot \frac{M}{d}\right)}^{2}}{\ell}\right)\right)\\
\end{array}
\end{array}
if M < 8.9999999999999994e106Initial program 79.3%
Simplified77.1%
Taylor expanded in D around 0 70.1%
if 8.9999999999999994e106 < M Initial program 72.5%
Simplified75.7%
unpow275.7%
unpow275.7%
associate-/r*75.7%
associate-*r/72.5%
*-commutative72.5%
associate-*r/67.3%
*-commutative67.3%
associate-*l/70.4%
associate-/r*70.4%
clear-num70.4%
associate-*l/70.4%
*-un-lft-identity70.4%
associate-/r/70.4%
Applied egg-rr70.4%
associate-*l/75.7%
*-commutative75.7%
associate-*l/75.7%
Applied egg-rr75.7%
Taylor expanded in D around 0 35.6%
+-commutative35.6%
*-commutative35.6%
fma-define35.6%
associate-*r*43.5%
unpow243.5%
unpow243.5%
swap-sqr56.3%
unpow256.3%
times-frac56.0%
unpow256.0%
unpow256.0%
times-frac66.6%
unpow266.6%
associate-/l*69.8%
Simplified69.8%
Taylor expanded in D around inf 29.4%
Simplified34.3%
Final simplification65.6%
(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.4%
Simplified76.9%
Taylor expanded in D around 0 66.2%
Final simplification66.2%
herbie shell --seed 2024112
(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))))))