
(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 16 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
(fma
(/ (/ (* M D) (* d -2.0)) l)
(/ (/ (* M D) (* d 2.0)) (/ 1.0 h))
1.0))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt(fma((((M * D) / (d * -2.0)) / l), (((M * D) / (d * 2.0)) / (1.0 / h)), 1.0));
}
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(fma(Float64(Float64(Float64(M * D) / Float64(d * -2.0)) / l), Float64(Float64(Float64(M * D) / Float64(d * 2.0)) / Float64(1.0 / h)), 1.0))) end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(N[(N[(N[(M * D), $MachinePrecision] / N[(d * -2.0), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 / h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{\mathsf{fma}\left(\frac{\frac{M \cdot D}{d \cdot -2}}{\ell}, \frac{\frac{M \cdot D}{d \cdot 2}}{\frac{1}{h}}, 1\right)}
\end{array}
Initial program 79.4%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lift-pow.f64N/A
unpow2N/A
distribute-lft-neg-inN/A
div-invN/A
times-fracN/A
lower-fma.f64N/A
Applied rewrites91.8%
Final simplification91.8%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* M D) (* d 2.0)) 2.0) (/ h l)) -5e+172) (* (* M (* (* h (* D D)) (/ -0.125 d))) (* w0 (/ M (* d l)))) (* w0 1.0)))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -5e+172) {
tmp = (M * ((h * (D * D)) * (-0.125 / d))) * (w0 * (M / (d * l)));
} else {
tmp = w0 * 1.0;
}
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 * d) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-5d+172)) then
tmp = (m * ((h * (d * d)) * ((-0.125d0) / d_1))) * (w0 * (m / (d_1 * l)))
else
tmp = w0 * 1.0d0
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 ((Math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -5e+172) {
tmp = (M * ((h * (D * D)) * (-0.125 / d))) * (w0 * (M / (d * l)));
} else {
tmp = w0 * 1.0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((M * D) / (d * 2.0)), 2.0) * (h / l)) <= -5e+172: tmp = (M * ((h * (D * D)) * (-0.125 / d))) * (w0 * (M / (d * l))) else: tmp = w0 * 1.0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(M * D) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -5e+172) tmp = Float64(Float64(M * Float64(Float64(h * Float64(D * D)) * Float64(-0.125 / d))) * Float64(w0 * Float64(M / Float64(d * l)))); else tmp = Float64(w0 * 1.0); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (((((M * D) / (d * 2.0)) ^ 2.0) * (h / l)) <= -5e+172) tmp = (M * ((h * (D * D)) * (-0.125 / d))) * (w0 * (M / (d * l))); else tmp = w0 * 1.0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -5e+172], N[(N[(M * N[(N[(h * N[(D * D), $MachinePrecision]), $MachinePrecision] * N[(-0.125 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(w0 * N[(M / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(w0 * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -5 \cdot 10^{+172}:\\
\;\;\;\;\left(M \cdot \left(\left(h \cdot \left(D \cdot D\right)\right) \cdot \frac{-0.125}{d}\right)\right) \cdot \left(w0 \cdot \frac{M}{d \cdot \ell}\right)\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot 1\\
\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)) < -5.0000000000000001e172Initial program 59.4%
Taylor expanded in M around 0
Applied rewrites4.9%
Taylor expanded in M around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.5%
Taylor expanded in D around inf
Applied rewrites40.4%
Applied rewrites47.0%
if -5.0000000000000001e172 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 89.4%
Taylor expanded in M around 0
Applied rewrites90.7%
Final simplification78.9%
herbie shell --seed 2024222
(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))))))