
(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}
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M D_m h l d_m)
:precision binary64
(if (<= (/ (* M D_m) (* 2.0 d_m)) 1e-72)
(*
w0
(sqrt
(-
1.0
(/
(pow (* (pow (cbrt (* (* M 0.5) (/ D_m d_m))) 2.0) (cbrt h)) 3.0)
l))))
(* w0 (sqrt (- 1.0 (* (pow (* (/ D_m 2.0) (/ M d_m)) 2.0) (/ h l)))))))D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
double tmp;
if (((M * D_m) / (2.0 * d_m)) <= 1e-72) {
tmp = w0 * sqrt((1.0 - (pow((pow(cbrt(((M * 0.5) * (D_m / d_m))), 2.0) * cbrt(h)), 3.0) / l)));
} else {
tmp = w0 * sqrt((1.0 - (pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l))));
}
return tmp;
}
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
double tmp;
if (((M * D_m) / (2.0 * d_m)) <= 1e-72) {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((Math.pow(Math.cbrt(((M * 0.5) * (D_m / d_m))), 2.0) * Math.cbrt(h)), 3.0) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l))));
}
return tmp;
}
D_m = abs(D) d_m = abs(d) w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m]) function code(w0, M, D_m, h, l, d_m) tmp = 0.0 if (Float64(Float64(M * D_m) / Float64(2.0 * d_m)) <= 1e-72) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64((cbrt(Float64(Float64(M * 0.5) * Float64(D_m / d_m))) ^ 2.0) * cbrt(h)) ^ 3.0) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(D_m / 2.0) * Float64(M / d_m)) ^ 2.0) * Float64(h / l))))); end return tmp end
D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e-72], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[Power[N[Power[N[(N[(M * 0.5), $MachinePrecision] * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision] * N[Power[h, 1/3], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M \cdot D_m}{2 \cdot d_m} \leq 10^{-72}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left({\left(\sqrt[3]{\left(M \cdot 0.5\right) \cdot \frac{D_m}{d_m}}\right)}^{2} \cdot \sqrt[3]{h}\right)}^{3}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{D_m}{2} \cdot \frac{M}{d_m}\right)}^{2} \cdot \frac{h}{\ell}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 2 d)) < 9.9999999999999997e-73Initial program 84.6%
Simplified85.0%
unpow285.0%
associate-*l*86.0%
frac-times85.0%
*-commutative85.0%
associate-*l/86.0%
associate-/r/85.5%
frac-times86.0%
*-commutative86.0%
associate-*l/85.5%
associate-/r/86.9%
associate-*l*85.5%
unpow285.5%
associate-*r/92.7%
Applied egg-rr92.2%
add-cube-cbrt92.2%
pow392.2%
add-sqr-sqrt92.2%
pow292.2%
unpow292.2%
sqrt-prod52.2%
add-sqr-sqrt92.2%
div-inv92.2%
metadata-eval92.2%
Applied egg-rr92.2%
*-commutative92.2%
cbrt-prod92.2%
associate-/r/92.2%
pow292.2%
cbrt-prod93.8%
pow293.8%
associate-/r/93.8%
*-commutative93.8%
Applied egg-rr93.8%
if 9.9999999999999997e-73 < (/.f64 (*.f64 M D) (*.f64 2 d)) Initial program 69.9%
Simplified71.6%
Final simplification89.2%
D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d_m) :precision binary64 (if (<= (/ (* M D_m) (* 2.0 d_m)) 1e-72) (* w0 (sqrt (+ 1.0 (/ (* (* h (pow (* M (/ D_m d_m)) 2.0)) -0.25) l)))) (* w0 (sqrt (- 1.0 (* (pow (* (/ D_m 2.0) (/ M d_m)) 2.0) (/ h l)))))))
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
double tmp;
if (((M * D_m) / (2.0 * d_m)) <= 1e-72) {
tmp = w0 * sqrt((1.0 + (((h * pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)));
} else {
tmp = w0 * sqrt((1.0 - (pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l))));
}
return tmp;
}
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
real(8) :: tmp
if (((m * d_m) / (2.0d0 * d_m_1)) <= 1d-72) then
tmp = w0 * sqrt((1.0d0 + (((h * ((m * (d_m / d_m_1)) ** 2.0d0)) * (-0.25d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - ((((d_m / 2.0d0) * (m / d_m_1)) ** 2.0d0) * (h / l))))
end if
code = tmp
end function
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
double tmp;
if (((M * D_m) / (2.0 * d_m)) <= 1e-72) {
tmp = w0 * Math.sqrt((1.0 + (((h * Math.pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l))));
}
return tmp;
}
D_m = math.fabs(D) d_m = math.fabs(d) [w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m]) def code(w0, M, D_m, h, l, d_m): tmp = 0 if ((M * D_m) / (2.0 * d_m)) <= 1e-72: tmp = w0 * math.sqrt((1.0 + (((h * math.pow((M * (D_m / d_m)), 2.0)) * -0.25) / l))) else: tmp = w0 * math.sqrt((1.0 - (math.pow(((D_m / 2.0) * (M / d_m)), 2.0) * (h / l)))) return tmp
D_m = abs(D) d_m = abs(d) w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m]) function code(w0, M, D_m, h, l, d_m) tmp = 0.0 if (Float64(Float64(M * D_m) / Float64(2.0 * d_m)) <= 1e-72) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * (Float64(M * Float64(D_m / d_m)) ^ 2.0)) * -0.25) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(D_m / 2.0) * Float64(M / d_m)) ^ 2.0) * Float64(h / l))))); end return tmp end
D_m = abs(D);
d_m = abs(d);
w0, M, D_m, h, l, d_m = num2cell(sort([w0, M, D_m, h, l, d_m])){:}
function tmp_2 = code(w0, M, D_m, h, l, d_m)
tmp = 0.0;
if (((M * D_m) / (2.0 * d_m)) <= 1e-72)
tmp = w0 * sqrt((1.0 + (((h * ((M * (D_m / d_m)) ^ 2.0)) * -0.25) / l)));
else
tmp = w0 * sqrt((1.0 - ((((D_m / 2.0) * (M / d_m)) ^ 2.0) * (h / l))));
end
tmp_2 = tmp;
end
D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[N[(N[(M * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e-72], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[Power[N[(M * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(D$95$m / 2.0), $MachinePrecision] * N[(M / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{M \cdot D_m}{2 \cdot d_m} \leq 10^{-72}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{\left(h \cdot {\left(M \cdot \frac{D_m}{d_m}\right)}^{2}\right) \cdot -0.25}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - {\left(\frac{D_m}{2} \cdot \frac{M}{d_m}\right)}^{2} \cdot \frac{h}{\ell}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 2 d)) < 9.9999999999999997e-73Initial program 84.6%
Simplified85.0%
unpow285.0%
associate-*l*86.0%
frac-times85.0%
*-commutative85.0%
associate-*l/86.0%
associate-/r/85.5%
frac-times86.0%
*-commutative86.0%
associate-*l/85.5%
associate-/r/86.9%
associate-*l*85.5%
unpow285.5%
associate-*r/92.7%
Applied egg-rr92.2%
add-sqr-sqrt80.3%
add-cube-cbrt80.3%
times-frac80.3%
*-commutative80.3%
sqrt-prod49.1%
unpow249.1%
sqrt-prod26.5%
add-sqr-sqrt42.4%
div-inv42.4%
metadata-eval42.4%
pow242.4%
Applied egg-rr50.3%
associate-/l*50.3%
associate-*l/50.3%
associate-/l*48.8%
associate-/l*48.8%
associate-*l/50.2%
associate-/l*50.2%
Simplified50.2%
expm1-log1p-u50.1%
expm1-udef50.1%
Applied egg-rr85.4%
expm1-def85.4%
expm1-log1p85.5%
associate-/r/91.7%
associate-*l/92.2%
*-commutative92.2%
sub-neg92.2%
distribute-neg-frac92.2%
associate-*r*92.2%
distribute-rgt-neg-in92.2%
*-commutative92.2%
metadata-eval92.2%
Simplified92.2%
if 9.9999999999999997e-73 < (/.f64 (*.f64 M D) (*.f64 2 d)) Initial program 69.9%
Simplified71.6%
Final simplification87.9%
D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d_m) :precision binary64 (* w0 (sqrt (+ 1.0 (/ (* (* h (pow (* M (/ D_m d_m)) 2.0)) -0.25) l)))))
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
return w0 * sqrt((1.0 + (((h * pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)));
}
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
code = w0 * sqrt((1.0d0 + (((h * ((m * (d_m / d_m_1)) ** 2.0d0)) * (-0.25d0)) / l)))
end function
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
return w0 * Math.sqrt((1.0 + (((h * Math.pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)));
}
D_m = math.fabs(D) d_m = math.fabs(d) [w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m]) def code(w0, M, D_m, h, l, d_m): return w0 * math.sqrt((1.0 + (((h * math.pow((M * (D_m / d_m)), 2.0)) * -0.25) / l)))
D_m = abs(D) d_m = abs(d) w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m]) function code(w0, M, D_m, h, l, d_m) return Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(Float64(h * (Float64(M * Float64(D_m / d_m)) ^ 2.0)) * -0.25) / l)))) end
D_m = abs(D);
d_m = abs(d);
w0, M, D_m, h, l, d_m = num2cell(sort([w0, M, D_m, h, l, d_m])){:}
function tmp = code(w0, M, D_m, h, l, d_m)
tmp = w0 * sqrt((1.0 + (((h * ((M * (D_m / d_m)) ^ 2.0)) * -0.25) / l)));
end
D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := N[(w0 * N[Sqrt[N[(1.0 + N[(N[(N[(h * N[Power[N[(M * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
w0 \cdot \sqrt{1 + \frac{\left(h \cdot {\left(M \cdot \frac{D_m}{d_m}\right)}^{2}\right) \cdot -0.25}{\ell}}
\end{array}
Initial program 81.5%
Simplified82.2%
unpow282.2%
associate-*l*83.3%
frac-times81.4%
*-commutative81.4%
associate-*l/83.3%
associate-/r/82.9%
frac-times83.0%
*-commutative83.0%
associate-*l/82.9%
associate-/r/84.9%
associate-*l*83.4%
unpow283.4%
associate-*r/88.3%
Applied egg-rr87.9%
add-sqr-sqrt72.1%
add-cube-cbrt72.1%
times-frac72.1%
*-commutative72.1%
sqrt-prod46.7%
unpow246.7%
sqrt-prod28.9%
add-sqr-sqrt41.4%
div-inv41.4%
metadata-eval41.4%
pow241.4%
Applied egg-rr47.6%
associate-/l*47.6%
associate-*l/46.9%
associate-/l*46.5%
associate-/l*46.5%
associate-*l/46.8%
associate-/l*47.6%
Simplified47.6%
expm1-log1p-u47.4%
expm1-udef47.4%
Applied egg-rr83.0%
expm1-def83.0%
expm1-log1p83.3%
associate-/r/87.9%
associate-*l/87.9%
*-commutative87.9%
sub-neg87.9%
distribute-neg-frac87.9%
associate-*r*87.9%
distribute-rgt-neg-in87.9%
*-commutative87.9%
metadata-eval87.9%
Simplified87.9%
Final simplification87.9%
D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d_m) :precision binary64 (if (<= M 2.05e-17) w0 (log1p (expm1 w0))))
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
double tmp;
if (M <= 2.05e-17) {
tmp = w0;
} else {
tmp = log1p(expm1(w0));
}
return tmp;
}
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
double tmp;
if (M <= 2.05e-17) {
tmp = w0;
} else {
tmp = Math.log1p(Math.expm1(w0));
}
return tmp;
}
D_m = math.fabs(D) d_m = math.fabs(d) [w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m]) def code(w0, M, D_m, h, l, d_m): tmp = 0 if M <= 2.05e-17: tmp = w0 else: tmp = math.log1p(math.expm1(w0)) return tmp
D_m = abs(D) d_m = abs(d) w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m]) function code(w0, M, D_m, h, l, d_m) tmp = 0.0 if (M <= 2.05e-17) tmp = w0; else tmp = log1p(expm1(w0)); end return tmp end
D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := If[LessEqual[M, 2.05e-17], w0, N[Log[1 + N[(Exp[w0] - 1), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.05 \cdot 10^{-17}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\right)\right)\\
\end{array}
\end{array}
if M < 2.05e-17Initial program 82.7%
Simplified81.7%
Taylor expanded in D around 0 73.7%
if 2.05e-17 < M Initial program 75.7%
Simplified84.5%
add-sqr-sqrt43.0%
sqrt-unprod37.3%
*-commutative37.3%
*-commutative37.3%
swap-sqr35.1%
Applied egg-rr35.2%
Taylor expanded in h around 0 33.5%
sqrt-pow152.7%
metadata-eval52.7%
pow152.7%
log1p-expm1-u37.6%
Applied egg-rr37.6%
Final simplification67.5%
D_m = (fabs.f64 D) d_m = (fabs.f64 d) NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M D_m h l d_m) :precision binary64 w0)
D_m = fabs(D);
d_m = fabs(d);
assert(w0 < M && M < D_m && D_m < h && h < l && l < d_m);
double code(double w0, double M, double D_m, double h, double l, double d_m) {
return w0;
}
D_m = abs(D)
d_m = abs(d)
NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_m_1
code = w0
end function
D_m = Math.abs(D);
d_m = Math.abs(d);
assert w0 < M && M < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0, double M, double D_m, double h, double l, double d_m) {
return w0;
}
D_m = math.fabs(D) d_m = math.fabs(d) [w0, M, D_m, h, l, d_m] = sort([w0, M, D_m, h, l, d_m]) def code(w0, M, D_m, h, l, d_m): return w0
D_m = abs(D) d_m = abs(d) w0, M, D_m, h, l, d_m = sort([w0, M, D_m, h, l, d_m]) function code(w0, M, D_m, h, l, d_m) return w0 end
D_m = abs(D);
d_m = abs(d);
w0, M, D_m, h, l, d_m = num2cell(sort([w0, M, D_m, h, l, d_m])){:}
function tmp = code(w0, M, D_m, h, l, d_m)
tmp = w0;
end
D_m = N[Abs[D], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M, D_m, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M_, D$95$m_, h_, l_, d$95$m_] := w0
\begin{array}{l}
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
[w0, M, D_m, h, l, d_m] = \mathsf{sort}([w0, M, D_m, h, l, d_m])\\
\\
w0
\end{array}
Initial program 81.5%
Simplified82.2%
Taylor expanded in D around 0 70.1%
Final simplification70.1%
herbie shell --seed 2024019
(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))))))