
(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}
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(*
w0_s
(if (<= (* (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0) (/ h l)) -1e+237)
(pow (sqrt (* w0_m (* (sqrt (* h (/ -0.25 l))) (* D_m (/ M_m d_m))))) 2.0)
(*
w0_m
(sqrt (- 1.0 (* h (/ (pow (* D_m (* M_m (/ 0.5 d_m))) 2.0) l))))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -1e+237) {
tmp = pow(sqrt((w0_m * (sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))), 2.0);
} else {
tmp = w0_m * sqrt((1.0 - (h * (pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))));
}
return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
real(8) :: tmp
if (((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) * (h / l)) <= (-1d+237)) then
tmp = sqrt((w0_m * (sqrt((h * ((-0.25d0) / l))) * (d_m * (m_m / d_m_1))))) ** 2.0d0
else
tmp = w0_m * sqrt((1.0d0 - (h * (((d_m * (m_m * (0.5d0 / d_m_1))) ** 2.0d0) / l))))
end if
code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -1e+237) {
tmp = Math.pow(Math.sqrt((w0_m * (Math.sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))), 2.0);
} else {
tmp = w0_m * Math.sqrt((1.0 - (h * (Math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l))));
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= -1e+237: tmp = math.pow(math.sqrt((w0_m * (math.sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))), 2.0) else: tmp = w0_m * math.sqrt((1.0 - (h * (math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= -1e+237) tmp = sqrt(Float64(w0_m * Float64(sqrt(Float64(h * Float64(-0.25 / l))) * Float64(D_m * Float64(M_m / d_m))))) ^ 2.0; else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d_m))) ^ 2.0) / l))))); end return Float64(w0_s * tmp) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= -1e+237)
tmp = sqrt((w0_m * (sqrt((h * (-0.25 / l))) * (D_m * (M_m / d_m))))) ^ 2.0;
else
tmp = w0_m * sqrt((1.0 - (h * (((D_m * (M_m * (0.5 / d_m))) ^ 2.0) / l))));
end
tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[N[(N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -1e+237], N[Power[N[Sqrt[N[(w0$95$m * N[(N[Sqrt[N[(h * N[(-0.25 / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(D$95$m * N[(M$95$m / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;{\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2} \cdot \frac{h}{\ell} \leq -1 \cdot 10^{+237}:\\
\;\;\;\;{\left(\sqrt{w0\_m \cdot \left(\sqrt{h \cdot \frac{-0.25}{\ell}} \cdot \left(D\_m \cdot \frac{M\_m}{d\_m}\right)\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\\
\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)) < -9.9999999999999994e236Initial program 64.3%
Simplified65.5%
add-sqr-sqrt26.8%
pow226.8%
*-commutative26.8%
*-commutative26.8%
associate-*l/25.6%
associate-*r/26.8%
div-inv26.8%
metadata-eval26.8%
Applied egg-rr26.8%
add-cube-cbrt26.7%
pow326.7%
associate-*l*26.7%
Applied egg-rr26.7%
Taylor expanded in h around -inf 0.0%
mul-1-neg0.0%
distribute-rgt-neg-in0.0%
associate-/l*0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt16.0%
mul-1-neg16.0%
rem-cube-cbrt16.0%
associate-/l*16.0%
Simplified16.0%
if -9.9999999999999994e236 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64)) (/.f64 h l)) Initial program 88.8%
Simplified88.2%
clear-num88.2%
un-div-inv88.2%
*-commutative88.2%
associate-*l/88.8%
associate-*r/87.7%
div-inv87.7%
metadata-eval87.7%
Applied egg-rr87.7%
associate-/r/94.0%
associate-*r/95.1%
*-commutative95.1%
associate-/l*94.5%
associate-*r/94.6%
Simplified94.6%
Final simplification70.9%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(*
w0_s
(if (or (<= D_m 2.6e+251) (and (not (<= D_m 5.6e+269)) (<= D_m 2.6e+284)))
w0_m
(log (exp w0_m)))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((D_m <= 2.6e+251) || (!(D_m <= 5.6e+269) && (D_m <= 2.6e+284))) {
tmp = w0_m;
} else {
tmp = log(exp(w0_m));
}
return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
real(8) :: tmp
if ((d_m <= 2.6d+251) .or. (.not. (d_m <= 5.6d+269)) .and. (d_m <= 2.6d+284)) then
tmp = w0_m
else
tmp = log(exp(w0_m))
end if
code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if ((D_m <= 2.6e+251) || (!(D_m <= 5.6e+269) && (D_m <= 2.6e+284))) {
tmp = w0_m;
} else {
tmp = Math.log(Math.exp(w0_m));
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if (D_m <= 2.6e+251) or (not (D_m <= 5.6e+269) and (D_m <= 2.6e+284)): tmp = w0_m else: tmp = math.log(math.exp(w0_m)) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if ((D_m <= 2.6e+251) || (!(D_m <= 5.6e+269) && (D_m <= 2.6e+284))) tmp = w0_m; else tmp = log(exp(w0_m)); end return Float64(w0_s * tmp) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = 0.0;
if ((D_m <= 2.6e+251) || (~((D_m <= 5.6e+269)) && (D_m <= 2.6e+284)))
tmp = w0_m;
else
tmp = log(exp(w0_m));
end
tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[Or[LessEqual[D$95$m, 2.6e+251], And[N[Not[LessEqual[D$95$m, 5.6e+269]], $MachinePrecision], LessEqual[D$95$m, 2.6e+284]]], w0$95$m, N[Log[N[Exp[w0$95$m], $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;D\_m \leq 2.6 \cdot 10^{+251} \lor \neg \left(D\_m \leq 5.6 \cdot 10^{+269}\right) \land D\_m \leq 2.6 \cdot 10^{+284}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0\_m}\right)\\
\end{array}
\end{array}
if D < 2.6000000000000002e251 or 5.59999999999999956e269 < D < 2.5999999999999998e284Initial program 81.4%
Simplified81.4%
Taylor expanded in D around 0 67.7%
if 2.6000000000000002e251 < D < 5.59999999999999956e269 or 2.5999999999999998e284 < D Initial program 81.1%
Simplified81.3%
add-sqr-sqrt50.6%
pow250.6%
*-commutative50.6%
*-commutative50.6%
associate-*l/50.6%
associate-*r/50.6%
div-inv50.6%
metadata-eval50.6%
Applied egg-rr50.6%
Taylor expanded in h around 0 4.2%
unpow24.2%
add-sqr-sqrt5.8%
add-log-exp60.8%
Applied egg-rr60.8%
Final simplification67.5%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) w0\_m = (fabs.f64 w0) w0\_s = (copysign.f64 #s(literal 1 binary64) w0) NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s (* w0_m (sqrt (- 1.0 (* h (/ (pow (* D_m (* M_m (/ 0.5 d_m))) 2.0) l)))))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
return w0_s * (w0_m * sqrt((1.0 - (h * (pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))));
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
code = w0_s * (w0_m * sqrt((1.0d0 - (h * (((d_m * (m_m * (0.5d0 / d_m_1))) ** 2.0d0) / l)))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
return w0_s * (w0_m * Math.sqrt((1.0 - (h * (Math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))));
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): return w0_s * (w0_m * math.sqrt((1.0 - (h * (math.pow((D_m * (M_m * (0.5 / d_m))), 2.0) / l)))))
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) return Float64(w0_s * Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M_m * Float64(0.5 / d_m))) ^ 2.0) / l)))))) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = w0_s * (w0_m * sqrt((1.0 - (h * (((D_m * (M_m * (0.5 / d_m))) ^ 2.0) / l)))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \left(M\_m \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}{\ell}}\right)
\end{array}
Initial program 81.4%
Simplified81.4%
clear-num81.0%
un-div-inv81.0%
*-commutative81.0%
associate-*l/81.0%
associate-*r/80.6%
div-inv80.6%
metadata-eval80.6%
Applied egg-rr80.6%
associate-/r/86.2%
associate-*r/86.9%
*-commutative86.9%
associate-/l*86.9%
associate-*r/86.9%
Simplified86.9%
Final simplification86.9%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) w0\_m = (fabs.f64 w0) w0\_s = (copysign.f64 #s(literal 1 binary64) w0) NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s (if (<= D_m 9e+211) w0_m (log1p (expm1 w0_m)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 9e+211) {
tmp = w0_m;
} else {
tmp = log1p(expm1(w0_m));
}
return w0_s * tmp;
}
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 9e+211) {
tmp = w0_m;
} else {
tmp = Math.log1p(Math.expm1(w0_m));
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if D_m <= 9e+211: tmp = w0_m else: tmp = math.log1p(math.expm1(w0_m)) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (D_m <= 9e+211) tmp = w0_m; else tmp = log1p(expm1(w0_m)); end return Float64(w0_s * tmp) end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[D$95$m, 9e+211], w0$95$m, N[Log[1 + N[(Exp[w0$95$m] - 1), $MachinePrecision]], $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;D\_m \leq 9 \cdot 10^{+211}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\_m\right)\right)\\
\end{array}
\end{array}
if D < 9e211Initial program 81.5%
Simplified81.5%
Taylor expanded in D around 0 67.6%
if 9e211 < D Initial program 79.8%
Simplified79.9%
add-sqr-sqrt43.2%
pow243.2%
*-commutative43.2%
*-commutative43.2%
associate-*l/43.2%
associate-*r/43.2%
div-inv43.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in h around 0 10.0%
unpow210.0%
add-sqr-sqrt25.9%
add-exp-log9.5%
Applied egg-rr9.5%
rem-exp-log25.9%
log1p-expm1-u58.8%
Applied egg-rr58.8%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(*
w0_s
(if (<= D_m 2.3e+251)
w0_m
(/ (+ (pow (+ w0_m 1.0) 2.0) -1.0) (+ 1.0 (+ w0_m 1.0))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 2.3e+251) {
tmp = w0_m;
} else {
tmp = (pow((w0_m + 1.0), 2.0) + -1.0) / (1.0 + (w0_m + 1.0));
}
return w0_s * tmp;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
real(8) :: tmp
if (d_m <= 2.3d+251) then
tmp = w0_m
else
tmp = (((w0_m + 1.0d0) ** 2.0d0) + (-1.0d0)) / (1.0d0 + (w0_m + 1.0d0))
end if
code = w0_s * tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (D_m <= 2.3e+251) {
tmp = w0_m;
} else {
tmp = (Math.pow((w0_m + 1.0), 2.0) + -1.0) / (1.0 + (w0_m + 1.0));
}
return w0_s * tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if D_m <= 2.3e+251: tmp = w0_m else: tmp = (math.pow((w0_m + 1.0), 2.0) + -1.0) / (1.0 + (w0_m + 1.0)) return w0_s * tmp
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (D_m <= 2.3e+251) tmp = w0_m; else tmp = Float64(Float64((Float64(w0_m + 1.0) ^ 2.0) + -1.0) / Float64(1.0 + Float64(w0_m + 1.0))); end return Float64(w0_s * tmp) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = 0.0;
if (D_m <= 2.3e+251)
tmp = w0_m;
else
tmp = (((w0_m + 1.0) ^ 2.0) + -1.0) / (1.0 + (w0_m + 1.0));
end
tmp_2 = w0_s * tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[D$95$m, 2.3e+251], w0$95$m, N[(N[(N[Power[N[(w0$95$m + 1.0), $MachinePrecision], 2.0], $MachinePrecision] + -1.0), $MachinePrecision] / N[(1.0 + N[(w0$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;D\_m \leq 2.3 \cdot 10^{+251}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(w0\_m + 1\right)}^{2} + -1}{1 + \left(w0\_m + 1\right)}\\
\end{array}
\end{array}
if D < 2.29999999999999988e251Initial program 81.3%
Simplified81.3%
Taylor expanded in D around 0 67.5%
if 2.29999999999999988e251 < D Initial program 84.3%
Simplified84.4%
add-sqr-sqrt50.4%
pow250.4%
*-commutative50.4%
*-commutative50.4%
associate-*l/50.4%
associate-*r/50.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr50.4%
Taylor expanded in h around 0 11.7%
unpow211.7%
add-sqr-sqrt21.5%
add-exp-log11.1%
Applied egg-rr11.1%
rem-exp-log21.5%
expm1-log1p-u20.2%
expm1-define11.8%
flip--50.3%
pow250.3%
log1p-undefine50.3%
rem-exp-log50.3%
metadata-eval50.3%
log1p-undefine50.3%
rem-exp-log59.4%
Applied egg-rr59.4%
Final simplification67.1%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) d_m = (fabs.f64 d) w0\_m = (fabs.f64 w0) w0\_s = (copysign.f64 #s(literal 1 binary64) w0) NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s w0_m))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
assert(w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
return w0_s * w0_m;
}
M_m = abs(m)
D_m = abs(d)
d_m = abs(d)
w0\_m = abs(w0)
w0\_s = copysign(1.0d0, w0)
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0_s, w0_m, m_m, d_m, h, l, d_m_1)
real(8), intent (in) :: w0_s
real(8), intent (in) :: w0_m
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_m_1
code = w0_s * w0_m
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
d_m = Math.abs(d);
w0\_m = Math.abs(w0);
w0\_s = Math.copySign(1.0, w0);
assert w0_m < M_m && M_m < D_m && D_m < h && h < l && l < d_m;
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
return w0_s * w0_m;
}
M_m = math.fabs(M) D_m = math.fabs(D) d_m = math.fabs(d) w0\_m = math.fabs(w0) w0\_s = math.copysign(1.0, w0) [w0_m, M_m, D_m, h, l, d_m] = sort([w0_m, M_m, D_m, h, l, d_m]) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): return w0_s * w0_m
M_m = abs(M) D_m = abs(D) d_m = abs(d) w0\_m = abs(w0) w0\_s = copysign(1.0, w0) w0_m, M_m, D_m, h, l, d_m = sort([w0_m, M_m, D_m, h, l, d_m]) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) return Float64(w0_s * w0_m) end
M_m = abs(M);
D_m = abs(D);
d_m = abs(d);
w0\_m = abs(w0);
w0\_s = sign(w0) * abs(1.0);
w0_m, M_m, D_m, h, l, d_m = num2cell(sort([w0_m, M_m, D_m, h, l, d_m])){:}
function tmp = code(w0_s, w0_m, M_m, D_m, h, l, d_m)
tmp = w0_s * w0_m;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
w0\_m = N[Abs[w0], $MachinePrecision]
w0\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[w0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: w0_m, M_m, D_m, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * w0$95$m), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
d_m = \left|d\right|
\\
w0\_m = \left|w0\right|
\\
w0\_s = \mathsf{copysign}\left(1, w0\right)
\\
[w0_m, M_m, D_m, h, l, d_m] = \mathsf{sort}([w0_m, M_m, D_m, h, l, d_m])\\
\\
w0\_s \cdot w0\_m
\end{array}
Initial program 81.4%
Simplified81.4%
Taylor expanded in D around 0 65.3%
herbie shell --seed 2024085
(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))))))