
(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 7 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)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(*
w0
(sqrt
(+
1.0
(/
h
(*
(/ -1.0 (* D_m (/ (* M_m 0.5) d)))
(/ l (/ (* D_m 0.5) (/ d M_m)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 + (h / ((-1.0 / (D_m * ((M_m * 0.5) / d))) * (l / ((D_m * 0.5) / (d / M_m)))))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * sqrt((1.0d0 + (h / (((-1.0d0) / (d_m * ((m_m * 0.5d0) / d))) * (l / ((d_m * 0.5d0) / (d / m_m)))))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 + (h / ((-1.0 / (D_m * ((M_m * 0.5) / d))) * (l / ((D_m * 0.5) / (d / M_m)))))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * math.sqrt((1.0 + (h / ((-1.0 / (D_m * ((M_m * 0.5) / d))) * (l / ((D_m * 0.5) / (d / M_m)))))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 + Float64(h / Float64(Float64(-1.0 / Float64(D_m * Float64(Float64(M_m * 0.5) / d))) * Float64(l / Float64(Float64(D_m * 0.5) / Float64(d / M_m)))))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * sqrt((1.0 + (h / ((-1.0 / (D_m * ((M_m * 0.5) / d))) * (l / ((D_m * 0.5) / (d / M_m)))))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 + N[(h / N[(N[(-1.0 / N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l / N[(N[(D$95$m * 0.5), $MachinePrecision] / N[(d / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 + \frac{h}{\frac{-1}{D_m \cdot \frac{M_m \cdot 0.5}{d}} \cdot \frac{\ell}{\frac{D_m \cdot 0.5}{\frac{d}{M_m}}}}}
\end{array}
Initial program 80.3%
Simplified79.9%
associate-*r/85.8%
frac-times86.2%
*-commutative86.2%
frac-2neg86.2%
*-commutative86.2%
associate-*l/85.8%
*-commutative85.8%
div-inv85.8%
associate-/r*85.8%
metadata-eval85.8%
Applied egg-rr85.8%
distribute-lft-neg-in85.8%
associate-/l*86.9%
Simplified86.9%
neg-mul-186.9%
unpow286.9%
times-frac89.5%
associate-*r/89.5%
associate-*r/89.5%
Applied egg-rr89.5%
Taylor expanded in D around 0 88.1%
associate-/l*89.5%
associate-*r/89.5%
Simplified89.5%
Final simplification89.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= d 5.6e-45)
(*
w0
(sqrt
(+
1.0
(* (* D_m (/ M_m (/ d 0.5))) (/ h (* (/ l D_m) (/ -2.0 (/ M_m d))))))))
(*
w0
(sqrt
(-
1.0
(* (* 0.5 (* (/ D_m d) (/ (* h M_m) l))) (/ (* D_m M_m) (* d 2.0))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (d <= 5.6e-45) {
tmp = w0 * sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
} else {
tmp = w0 * sqrt((1.0 - ((0.5 * ((D_m / d) * ((h * M_m) / l))) * ((D_m * M_m) / (d * 2.0)))));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (d <= 5.6d-45) then
tmp = w0 * sqrt((1.0d0 + ((d_m * (m_m / (d / 0.5d0))) * (h / ((l / d_m) * ((-2.0d0) / (m_m / d)))))))
else
tmp = w0 * sqrt((1.0d0 - ((0.5d0 * ((d_m / d) * ((h * m_m) / l))) * ((d_m * m_m) / (d * 2.0d0)))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (d <= 5.6e-45) {
tmp = w0 * Math.sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
} else {
tmp = w0 * Math.sqrt((1.0 - ((0.5 * ((D_m / d) * ((h * M_m) / l))) * ((D_m * M_m) / (d * 2.0)))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if d <= 5.6e-45: tmp = w0 * math.sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d))))))) else: tmp = w0 * math.sqrt((1.0 - ((0.5 * ((D_m / d) * ((h * M_m) / l))) * ((D_m * M_m) / (d * 2.0))))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (d <= 5.6e-45) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(D_m * Float64(M_m / Float64(d / 0.5))) * Float64(h / Float64(Float64(l / D_m) * Float64(-2.0 / Float64(M_m / d)))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(0.5 * Float64(Float64(D_m / d) * Float64(Float64(h * M_m) / l))) * Float64(Float64(D_m * M_m) / Float64(d * 2.0)))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (d <= 5.6e-45)
tmp = w0 * sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
else
tmp = w0 * sqrt((1.0 - ((0.5 * ((D_m / d) * ((h * M_m) / l))) * ((D_m * M_m) / (d * 2.0)))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[d, 5.6e-45], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(D$95$m * N[(M$95$m / N[(d / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / N[(N[(l / D$95$m), $MachinePrecision] * N[(-2.0 / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(0.5 * N[(N[(D$95$m / d), $MachinePrecision] * N[(N[(h * M$95$m), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(D$95$m * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 5.6 \cdot 10^{-45}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \left(D_m \cdot \frac{M_m}{\frac{d}{0.5}}\right) \cdot \frac{h}{\frac{\ell}{D_m} \cdot \frac{-2}{\frac{M_m}{d}}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \left(0.5 \cdot \left(\frac{D_m}{d} \cdot \frac{h \cdot M_m}{\ell}\right)\right) \cdot \frac{D_m \cdot M_m}{d \cdot 2}}\\
\end{array}
\end{array}
if d < 5.6000000000000003e-45Initial program 80.4%
Simplified79.8%
associate-*r/82.7%
frac-times83.3%
*-commutative83.3%
frac-2neg83.3%
*-commutative83.3%
associate-*l/82.7%
*-commutative82.7%
div-inv82.7%
associate-/r*82.7%
metadata-eval82.7%
Applied egg-rr82.7%
distribute-lft-neg-in82.7%
associate-/l*84.3%
Simplified84.3%
neg-mul-184.3%
unpow284.3%
times-frac88.0%
associate-*r/88.1%
associate-*r/88.0%
Applied egg-rr88.0%
associate-*l/88.1%
associate-/r*86.4%
associate-/l*86.4%
neg-mul-186.4%
associate-/l*86.4%
associate-/r/85.4%
distribute-neg-frac85.4%
associate-/r/85.4%
associate-*r/83.8%
div-inv83.8%
metadata-eval83.8%
Applied egg-rr83.8%
associate-*l/84.3%
associate-/l*84.8%
neg-mul-184.8%
*-commutative84.8%
times-frac84.8%
metadata-eval84.8%
*-commutative84.8%
times-frac86.4%
Simplified86.4%
expm1-log1p-u85.9%
expm1-udef85.9%
Applied egg-rr82.3%
expm1-def82.3%
expm1-log1p82.7%
sub-neg82.7%
*-commutative82.7%
distribute-rgt-neg-in82.7%
times-frac83.8%
*-rgt-identity83.8%
times-frac83.8%
associate-*r/85.4%
metadata-eval85.4%
associate-*l*85.4%
associate-/r/85.4%
distribute-frac-neg85.4%
remove-double-neg85.4%
Simplified85.4%
if 5.6000000000000003e-45 < d Initial program 79.9%
Simplified80.0%
associate-*r/92.8%
frac-times92.8%
*-commutative92.8%
frac-2neg92.8%
*-commutative92.8%
associate-*l/92.8%
*-commutative92.8%
div-inv92.8%
associate-/r*92.8%
metadata-eval92.8%
Applied egg-rr92.8%
distribute-lft-neg-in92.8%
associate-/l*92.8%
Simplified92.8%
neg-mul-192.8%
unpow292.8%
times-frac92.8%
associate-*r/92.8%
associate-*r/92.8%
Applied egg-rr92.8%
associate-*l/92.8%
associate-/r*87.8%
associate-/l*87.8%
neg-mul-187.8%
associate-/l*87.8%
associate-/r/87.8%
distribute-neg-frac87.8%
associate-/r/87.8%
associate-*r/86.6%
div-inv86.6%
metadata-eval86.6%
Applied egg-rr86.6%
Taylor expanded in h around 0 87.7%
times-frac85.1%
Simplified85.1%
Final simplification85.3%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(if (<= d 2.2e-45)
(*
w0
(sqrt
(+
1.0
(* (* D_m (/ M_m (/ d 0.5))) (/ h (* (/ l D_m) (/ -2.0 (/ M_m d))))))))
(*
w0
(sqrt
(+
1.0
(/ h (/ (* -2.0 (* (/ d D_m) (/ l M_m))) (* (/ M_m d) (/ D_m 2.0)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (d <= 2.2e-45) {
tmp = w0 * sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
} else {
tmp = w0 * sqrt((1.0 + (h / ((-2.0 * ((d / D_m) * (l / M_m))) / ((M_m / d) * (D_m / 2.0))))));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: tmp
if (d <= 2.2d-45) then
tmp = w0 * sqrt((1.0d0 + ((d_m * (m_m / (d / 0.5d0))) * (h / ((l / d_m) * ((-2.0d0) / (m_m / d)))))))
else
tmp = w0 * sqrt((1.0d0 + (h / (((-2.0d0) * ((d / d_m) * (l / m_m))) / ((m_m / d) * (d_m / 2.0d0))))))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (d <= 2.2e-45) {
tmp = w0 * Math.sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
} else {
tmp = w0 * Math.sqrt((1.0 + (h / ((-2.0 * ((d / D_m) * (l / M_m))) / ((M_m / d) * (D_m / 2.0))))));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if d <= 2.2e-45: tmp = w0 * math.sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d))))))) else: tmp = w0 * math.sqrt((1.0 + (h / ((-2.0 * ((d / D_m) * (l / M_m))) / ((M_m / d) * (D_m / 2.0)))))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (d <= 2.2e-45) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(D_m * Float64(M_m / Float64(d / 0.5))) * Float64(h / Float64(Float64(l / D_m) * Float64(-2.0 / Float64(M_m / d)))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(h / Float64(Float64(-2.0 * Float64(Float64(d / D_m) * Float64(l / M_m))) / Float64(Float64(M_m / d) * Float64(D_m / 2.0))))))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (d <= 2.2e-45)
tmp = w0 * sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
else
tmp = w0 * sqrt((1.0 + (h / ((-2.0 * ((d / D_m) * (l / M_m))) / ((M_m / d) * (D_m / 2.0))))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[d, 2.2e-45], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(D$95$m * N[(M$95$m / N[(d / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / N[(N[(l / D$95$m), $MachinePrecision] * N[(-2.0 / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(h / N[(N[(-2.0 * N[(N[(d / D$95$m), $MachinePrecision] * N[(l / M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(M$95$m / d), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;d \leq 2.2 \cdot 10^{-45}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \left(D_m \cdot \frac{M_m}{\frac{d}{0.5}}\right) \cdot \frac{h}{\frac{\ell}{D_m} \cdot \frac{-2}{\frac{M_m}{d}}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{h}{\frac{-2 \cdot \left(\frac{d}{D_m} \cdot \frac{\ell}{M_m}\right)}{\frac{M_m}{d} \cdot \frac{D_m}{2}}}}\\
\end{array}
\end{array}
if d < 2.19999999999999993e-45Initial program 80.4%
Simplified79.8%
associate-*r/82.7%
frac-times83.3%
*-commutative83.3%
frac-2neg83.3%
*-commutative83.3%
associate-*l/82.7%
*-commutative82.7%
div-inv82.7%
associate-/r*82.7%
metadata-eval82.7%
Applied egg-rr82.7%
distribute-lft-neg-in82.7%
associate-/l*84.3%
Simplified84.3%
neg-mul-184.3%
unpow284.3%
times-frac88.0%
associate-*r/88.1%
associate-*r/88.0%
Applied egg-rr88.0%
associate-*l/88.1%
associate-/r*86.4%
associate-/l*86.4%
neg-mul-186.4%
associate-/l*86.4%
associate-/r/85.4%
distribute-neg-frac85.4%
associate-/r/85.4%
associate-*r/83.8%
div-inv83.8%
metadata-eval83.8%
Applied egg-rr83.8%
associate-*l/84.3%
associate-/l*84.8%
neg-mul-184.8%
*-commutative84.8%
times-frac84.8%
metadata-eval84.8%
*-commutative84.8%
times-frac86.4%
Simplified86.4%
expm1-log1p-u85.9%
expm1-udef85.9%
Applied egg-rr82.3%
expm1-def82.3%
expm1-log1p82.7%
sub-neg82.7%
*-commutative82.7%
distribute-rgt-neg-in82.7%
times-frac83.8%
*-rgt-identity83.8%
times-frac83.8%
associate-*r/85.4%
metadata-eval85.4%
associate-*l*85.4%
associate-/r/85.4%
distribute-frac-neg85.4%
remove-double-neg85.4%
Simplified85.4%
if 2.19999999999999993e-45 < d Initial program 79.9%
Simplified80.0%
associate-*r/92.8%
frac-times92.8%
*-commutative92.8%
frac-2neg92.8%
*-commutative92.8%
associate-*l/92.8%
*-commutative92.8%
div-inv92.8%
associate-/r*92.8%
metadata-eval92.8%
Applied egg-rr92.8%
distribute-lft-neg-in92.8%
associate-/l*92.8%
Simplified92.8%
neg-mul-192.8%
unpow292.8%
times-frac92.8%
associate-*r/92.8%
associate-*r/92.8%
Applied egg-rr92.8%
associate-*l/92.8%
associate-/r*87.8%
associate-/l*87.8%
neg-mul-187.8%
associate-/l*87.8%
associate-/r/87.8%
distribute-neg-frac87.8%
associate-/r/87.8%
associate-*r/86.6%
div-inv86.6%
metadata-eval86.6%
Applied egg-rr86.6%
associate-*l/86.6%
associate-/l*86.6%
neg-mul-186.6%
*-commutative86.6%
times-frac86.6%
metadata-eval86.6%
*-commutative86.6%
times-frac87.8%
Simplified87.8%
Taylor expanded in l around 0 91.6%
times-frac89.1%
Simplified89.1%
Final simplification86.5%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (let* ((t_0 (* D_m (/ (* M_m 0.5) d)))) (* w0 (sqrt (+ 1.0 (/ h (* (/ -1.0 t_0) (/ l t_0))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * ((M_m * 0.5) / d);
return w0 * sqrt((1.0 + (h / ((-1.0 / t_0) * (l / t_0)))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
real(8) :: t_0
t_0 = d_m * ((m_m * 0.5d0) / d)
code = w0 * sqrt((1.0d0 + (h / (((-1.0d0) / t_0) * (l / t_0)))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * ((M_m * 0.5) / d);
return w0 * Math.sqrt((1.0 + (h / ((-1.0 / t_0) * (l / t_0)))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): t_0 = D_m * ((M_m * 0.5) / d) return w0 * math.sqrt((1.0 + (h / ((-1.0 / t_0) * (l / t_0)))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(D_m * Float64(Float64(M_m * 0.5) / d)) return Float64(w0 * sqrt(Float64(1.0 + Float64(h / Float64(Float64(-1.0 / t_0) * Float64(l / t_0)))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
t_0 = D_m * ((M_m * 0.5) / d);
tmp = w0 * sqrt((1.0 + (h / ((-1.0 / t_0) * (l / t_0)))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(N[(M$95$m * 0.5), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 + N[(h / N[(N[(-1.0 / t$95$0), $MachinePrecision] * N[(l / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D_m \cdot \frac{M_m \cdot 0.5}{d}\\
w0 \cdot \sqrt{1 + \frac{h}{\frac{-1}{t_0} \cdot \frac{\ell}{t_0}}}
\end{array}
\end{array}
Initial program 80.3%
Simplified79.9%
associate-*r/85.8%
frac-times86.2%
*-commutative86.2%
frac-2neg86.2%
*-commutative86.2%
associate-*l/85.8%
*-commutative85.8%
div-inv85.8%
associate-/r*85.8%
metadata-eval85.8%
Applied egg-rr85.8%
distribute-lft-neg-in85.8%
associate-/l*86.9%
Simplified86.9%
neg-mul-186.9%
unpow286.9%
times-frac89.5%
associate-*r/89.5%
associate-*r/89.5%
Applied egg-rr89.5%
Final simplification89.5%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(*
w0
(sqrt
(+
1.0
(* (* D_m (/ M_m (/ d 0.5))) (/ h (* (/ l D_m) (/ -2.0 (/ M_m d)))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * sqrt((1.0d0 + ((d_m * (m_m / (d / 0.5d0))) * (h / ((l / d_m) * ((-2.0d0) / (m_m / d)))))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * math.sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(D_m * Float64(M_m / Float64(d / 0.5))) * Float64(h / Float64(Float64(l / D_m) * Float64(-2.0 / Float64(M_m / d)))))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * sqrt((1.0 + ((D_m * (M_m / (d / 0.5))) * (h / ((l / D_m) * (-2.0 / (M_m / d)))))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 + N[(N[(D$95$m * N[(M$95$m / N[(d / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / N[(N[(l / D$95$m), $MachinePrecision] * N[(-2.0 / N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 + \left(D_m \cdot \frac{M_m}{\frac{d}{0.5}}\right) \cdot \frac{h}{\frac{\ell}{D_m} \cdot \frac{-2}{\frac{M_m}{d}}}}
\end{array}
Initial program 80.3%
Simplified79.9%
associate-*r/85.8%
frac-times86.2%
*-commutative86.2%
frac-2neg86.2%
*-commutative86.2%
associate-*l/85.8%
*-commutative85.8%
div-inv85.8%
associate-/r*85.8%
metadata-eval85.8%
Applied egg-rr85.8%
distribute-lft-neg-in85.8%
associate-/l*86.9%
Simplified86.9%
neg-mul-186.9%
unpow286.9%
times-frac89.5%
associate-*r/89.5%
associate-*r/89.5%
Applied egg-rr89.5%
associate-*l/89.5%
associate-/r*86.8%
associate-/l*86.8%
neg-mul-186.8%
associate-/l*86.8%
associate-/r/86.1%
distribute-neg-frac86.1%
associate-/r/86.1%
associate-*r/84.7%
div-inv84.7%
metadata-eval84.7%
Applied egg-rr84.7%
associate-*l/85.0%
associate-/l*85.4%
neg-mul-185.4%
*-commutative85.4%
times-frac85.4%
metadata-eval85.4%
*-commutative85.4%
times-frac86.8%
Simplified86.8%
expm1-log1p-u86.3%
expm1-udef86.3%
Applied egg-rr83.8%
expm1-def83.8%
expm1-log1p84.2%
sub-neg84.2%
*-commutative84.2%
distribute-rgt-neg-in84.2%
times-frac84.7%
*-rgt-identity84.7%
times-frac84.7%
associate-*r/86.1%
metadata-eval86.1%
associate-*l*86.1%
associate-/r/86.1%
distribute-frac-neg86.1%
remove-double-neg86.1%
Simplified86.1%
Final simplification86.1%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(*
w0
(sqrt
(-
1.0
(* (* D_m (/ M_m (/ d 0.5))) (* 0.5 (/ h (* d (/ l (* D_m M_m))))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 - ((D_m * (M_m / (d / 0.5))) * (0.5 * (h / (d * (l / (D_m * M_m))))))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0 * sqrt((1.0d0 - ((d_m * (m_m / (d / 0.5d0))) * (0.5d0 * (h / (d * (l / (d_m * m_m))))))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((D_m * (M_m / (d / 0.5))) * (0.5 * (h / (d * (l / (D_m * M_m))))))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * math.sqrt((1.0 - ((D_m * (M_m / (d / 0.5))) * (0.5 * (h / (d * (l / (D_m * M_m))))))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(D_m * Float64(M_m / Float64(d / 0.5))) * Float64(0.5 * Float64(h / Float64(d * Float64(l / Float64(D_m * M_m))))))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * sqrt((1.0 - ((D_m * (M_m / (d / 0.5))) * (0.5 * (h / (d * (l / (D_m * M_m))))))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(D$95$m * N[(M$95$m / N[(d / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(h / N[(d * N[(l / N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 - \left(D_m \cdot \frac{M_m}{\frac{d}{0.5}}\right) \cdot \left(0.5 \cdot \frac{h}{d \cdot \frac{\ell}{D_m \cdot M_m}}\right)}
\end{array}
Initial program 80.3%
Simplified79.9%
associate-*r/85.8%
frac-times86.2%
*-commutative86.2%
frac-2neg86.2%
*-commutative86.2%
associate-*l/85.8%
*-commutative85.8%
div-inv85.8%
associate-/r*85.8%
metadata-eval85.8%
Applied egg-rr85.8%
distribute-lft-neg-in85.8%
associate-/l*86.9%
Simplified86.9%
neg-mul-186.9%
unpow286.9%
times-frac89.5%
associate-*r/89.5%
associate-*r/89.5%
Applied egg-rr89.5%
associate-*l/89.5%
associate-/r*86.8%
associate-/l*86.8%
neg-mul-186.8%
associate-/l*86.8%
associate-/r/86.1%
distribute-neg-frac86.1%
associate-/r/86.1%
associate-*r/84.7%
div-inv84.7%
metadata-eval84.7%
Applied egg-rr84.7%
associate-*l/85.0%
associate-/l*85.4%
neg-mul-185.4%
*-commutative85.4%
times-frac85.4%
metadata-eval85.4%
*-commutative85.4%
times-frac86.8%
Simplified86.8%
*-un-lft-identity86.8%
associate-/r/86.1%
*-commutative86.1%
div-inv86.1%
clear-num86.1%
frac-times84.7%
*-commutative84.7%
times-frac84.2%
Applied egg-rr84.2%
*-commutative84.2%
associate-*r*84.2%
*-commutative84.2%
times-frac84.7%
associate-*l/84.7%
times-frac84.7%
metadata-eval84.7%
associate-*r/86.1%
associate-*l*86.1%
associate-/r/86.1%
neg-mul-186.1%
*-commutative86.1%
times-frac86.1%
metadata-eval86.1%
times-frac83.1%
*-commutative83.1%
associate-*r/86.2%
Simplified86.2%
Final simplification86.2%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return w0 end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Initial program 80.3%
Simplified79.9%
Taylor expanded in D around 0 64.4%
Final simplification64.4%
herbie shell --seed 2024021
(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))))))