
(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)
d_m = (fabs.f64 d)
w0\_m = (fabs.f64 w0)
w0\_s = (copysign.f64 #s(literal 1 binary64) w0)
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(let* ((t_0 (* (* M_m 0.5) (/ D_m d_m))))
(*
w0_s
(if (<= (/ (* M_m D_m) (* 2.0 d_m)) 1e+140)
(* w0_m (sqrt (- 1.0 (* h (/ (pow (/ (* D_m (/ M_m 2.0)) d_m) 2.0) l)))))
(exp
(pow
(cbrt (log (* w0_m (sqrt (- 1.0 (* h (* t_0 (/ t_0 l))))))))
3.0))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (M_m * 0.5) * (D_m / d_m);
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 1e+140) {
tmp = w0_m * sqrt((1.0 - (h * (pow(((D_m * (M_m / 2.0)) / d_m), 2.0) / l))));
} else {
tmp = exp(pow(cbrt(log((w0_m * sqrt((1.0 - (h * (t_0 * (t_0 / l)))))))), 3.0));
}
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);
public static double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double t_0 = (M_m * 0.5) * (D_m / d_m);
double tmp;
if (((M_m * D_m) / (2.0 * d_m)) <= 1e+140) {
tmp = w0_m * Math.sqrt((1.0 - (h * (Math.pow(((D_m * (M_m / 2.0)) / d_m), 2.0) / l))));
} else {
tmp = Math.exp(Math.pow(Math.cbrt(Math.log((w0_m * Math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))))))), 3.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) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) t_0 = Float64(Float64(M_m * 0.5) * Float64(D_m / d_m)) tmp = 0.0 if (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) <= 1e+140) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(Float64(D_m * Float64(M_m / 2.0)) / d_m) ^ 2.0) / l))))); else tmp = exp((cbrt(log(Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l)))))))) ^ 3.0)); 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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[(M$95$m * 0.5), $MachinePrecision] * N[(D$95$m / d$95$m), $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 1e+140], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(N[(D$95$m * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision] / d$95$m), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[Power[N[Power[N[Log[N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $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)
\\
\begin{array}{l}
t_0 := \left(M\_m \cdot 0.5\right) \cdot \frac{D\_m}{d\_m}\\
w0\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{M\_m \cdot D\_m}{2 \cdot d\_m} \leq 10^{+140}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(\frac{D\_m \cdot \frac{M\_m}{2}}{d\_m}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;e^{{\left(\sqrt[3]{\log \left(w0\_m \cdot \sqrt{1 - h \cdot \left(t\_0 \cdot \frac{t\_0}{\ell}\right)}\right)}\right)}^{3}}\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) < 1.00000000000000006e140Initial program 84.1%
Simplified83.7%
clear-num83.2%
un-div-inv84.1%
clear-num84.1%
un-div-inv84.1%
associate-/r/84.1%
Applied egg-rr84.1%
associate-/r/90.1%
associate-*l/89.3%
*-commutative89.3%
associate-/l*90.1%
associate-*l/90.1%
*-commutative90.1%
associate-*l/90.1%
associate-/l/89.7%
associate-/r/89.7%
associate-*l/89.7%
*-commutative89.7%
associate-*r/90.6%
*-commutative90.6%
associate-/l/90.6%
associate-/l*90.1%
Simplified90.1%
Taylor expanded in D around 0 90.6%
metadata-eval90.6%
metadata-eval90.6%
associate-*l/89.7%
associate-/r/90.1%
times-frac90.1%
distribute-lft-neg-in90.1%
neg-mul-190.1%
times-frac90.1%
metadata-eval90.1%
associate-/l/90.1%
associate-/r/89.7%
associate-*l/90.6%
associate-/l*90.1%
associate-*l/90.1%
times-frac90.6%
associate-*r/90.1%
*-lft-identity90.1%
associate-/r*90.1%
associate-*r/90.6%
Simplified90.6%
if 1.00000000000000006e140 < (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) Initial program 41.3%
Simplified45.6%
unpow245.6%
unpow245.6%
associate-/r*45.6%
associate-*r/41.3%
*-commutative41.3%
associate-*r/41.6%
clear-num41.6%
*-commutative41.6%
associate-*l/45.9%
associate-/r*45.9%
clear-num45.9%
associate-*l/45.9%
*-un-lft-identity45.9%
associate-/r/45.9%
Applied egg-rr45.9%
associate-/r/45.9%
associate-*l/45.9%
*-commutative45.9%
associate-*l/45.9%
associate-/l/45.9%
associate-/r/45.9%
Simplified45.9%
add-exp-log19.3%
associate-*l/19.3%
*-un-lft-identity19.3%
*-commutative19.3%
associate-/l/19.3%
Applied egg-rr19.3%
add-cube-cbrt19.3%
pow319.3%
associate-/l*19.3%
associate-*r/19.3%
Applied egg-rr19.3%
unpow219.3%
*-un-lft-identity19.3%
times-frac19.3%
times-frac19.3%
div-inv19.3%
metadata-eval19.3%
times-frac26.5%
div-inv26.5%
metadata-eval26.5%
Applied egg-rr26.5%
Final simplification84.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)
(FPCore (w0_s w0_m M_m D_m h l d_m)
:precision binary64
(*
w0_s
(if (<= l 4e-289)
(* w0_m (sqrt (- 1.0 (* h (/ (pow (* D_m (/ M_m (* 2.0 d_m))) 2.0) l)))))
(*
w0_m
(sqrt
(- 1.0 (* h (pow (* D_m (* (/ M_m (sqrt l)) (/ 0.5 d_m))) 2.0))))))))M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (l <= 4e-289) {
tmp = w0_m * sqrt((1.0 - (h * (pow((D_m * (M_m / (2.0 * d_m))), 2.0) / l))));
} else {
tmp = w0_m * sqrt((1.0 - (h * pow((D_m * ((M_m / sqrt(l)) * (0.5 / d_m))), 2.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)
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 (l <= 4d-289) then
tmp = w0_m * sqrt((1.0d0 - (h * (((d_m * (m_m / (2.0d0 * d_m_1))) ** 2.0d0) / l))))
else
tmp = w0_m * sqrt((1.0d0 - (h * ((d_m * ((m_m / sqrt(l)) * (0.5d0 / d_m_1))) ** 2.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);
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 (l <= 4e-289) {
tmp = w0_m * Math.sqrt((1.0 - (h * (Math.pow((D_m * (M_m / (2.0 * d_m))), 2.0) / l))));
} else {
tmp = w0_m * Math.sqrt((1.0 - (h * Math.pow((D_m * ((M_m / Math.sqrt(l)) * (0.5 / d_m))), 2.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) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if l <= 4e-289: tmp = w0_m * math.sqrt((1.0 - (h * (math.pow((D_m * (M_m / (2.0 * d_m))), 2.0) / l)))) else: tmp = w0_m * math.sqrt((1.0 - (h * math.pow((D_m * ((M_m / math.sqrt(l)) * (0.5 / d_m))), 2.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) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (l <= 4e-289) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D_m * Float64(M_m / Float64(2.0 * d_m))) ^ 2.0) / l))))); else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(h * (Float64(D_m * Float64(Float64(M_m / sqrt(l)) * Float64(0.5 / d_m))) ^ 2.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); function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0; if (l <= 4e-289) tmp = w0_m * sqrt((1.0 - (h * (((D_m * (M_m / (2.0 * d_m))) ^ 2.0) / l)))); else tmp = w0_m * sqrt((1.0 - (h * ((D_m * ((M_m / sqrt(l)) * (0.5 / d_m))) ^ 2.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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[l, 4e-289], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(h * N[Power[N[(D$95$m * N[(N[(M$95$m / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * N[(0.5 / d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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\_s \cdot \begin{array}{l}
\mathbf{if}\;\ell \leq 4 \cdot 10^{-289}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{2 \cdot d\_m}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0\_m \cdot \sqrt{1 - h \cdot {\left(D\_m \cdot \left(\frac{M\_m}{\sqrt{\ell}} \cdot \frac{0.5}{d\_m}\right)\right)}^{2}}\\
\end{array}
\end{array}
if l < 4e-289Initial program 76.7%
Simplified76.7%
clear-num76.7%
un-div-inv77.6%
clear-num77.5%
un-div-inv77.5%
associate-/r/77.5%
Applied egg-rr77.5%
associate-/r/83.5%
associate-*l/83.5%
*-commutative83.5%
associate-/l*83.5%
associate-*l/83.5%
*-commutative83.5%
associate-*l/83.5%
associate-/l/83.6%
associate-/r/83.6%
associate-*l/83.6%
*-commutative83.6%
associate-*r/83.6%
*-commutative83.6%
associate-/l/83.6%
associate-/l*83.5%
Simplified83.5%
if 4e-289 < l Initial program 83.2%
Simplified83.2%
clear-num82.5%
un-div-inv83.2%
clear-num83.2%
un-div-inv83.2%
associate-/r/83.2%
Applied egg-rr83.2%
associate-/r/88.4%
associate-*l/87.0%
*-commutative87.0%
associate-/l*88.4%
associate-*l/88.4%
*-commutative88.4%
associate-*l/88.4%
associate-/l/87.7%
associate-/r/87.7%
associate-*l/87.7%
*-commutative87.7%
associate-*r/88.4%
*-commutative88.4%
associate-/l/88.4%
associate-/l*88.4%
Simplified88.4%
Taylor expanded in D around 0 88.4%
metadata-eval88.4%
metadata-eval88.4%
associate-*l/87.7%
associate-/r/88.4%
times-frac88.4%
distribute-lft-neg-in88.4%
neg-mul-188.4%
times-frac88.4%
metadata-eval88.4%
associate-/l/88.4%
associate-/r/87.7%
associate-*l/88.4%
associate-/l*88.4%
associate-*l/88.4%
times-frac88.4%
associate-*r/88.4%
*-lft-identity88.4%
associate-/r*88.4%
associate-*r/88.4%
Simplified88.4%
add-sqr-sqrt88.4%
sqrt-div88.4%
sqrt-pow176.6%
metadata-eval76.6%
pow176.6%
associate-/l*76.6%
div-inv76.6%
metadata-eval76.6%
sqrt-div76.6%
sqrt-pow190.4%
metadata-eval90.4%
pow190.4%
associate-/l*91.7%
div-inv91.7%
metadata-eval91.7%
Applied egg-rr91.7%
unpow291.7%
associate-/l*91.7%
Simplified91.7%
associate-/l/91.1%
times-frac91.0%
Applied egg-rr91.0%
Final simplification87.6%
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) (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 (* 2.0 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);
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 / (2.0 * 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)
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 / (2.0d0 * 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);
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 / (2.0 * 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) 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 / (2.0 * 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) 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(2.0 * 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); 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 / (2.0 * 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]
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[(2.0 * 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\_s \cdot \left(w0\_m \cdot \sqrt{1 - h \cdot \frac{{\left(D\_m \cdot \frac{M\_m}{2 \cdot d\_m}\right)}^{2}}{\ell}}\right)
\end{array}
Initial program 80.3%
Simplified80.2%
clear-num79.9%
un-div-inv80.6%
clear-num80.6%
un-div-inv80.6%
associate-/r/80.6%
Applied egg-rr80.6%
associate-/r/86.2%
associate-*l/85.4%
*-commutative85.4%
associate-/l*86.2%
associate-*l/86.2%
*-commutative86.2%
associate-*l/86.2%
associate-/l/85.8%
associate-/r/85.8%
associate-*l/85.8%
*-commutative85.8%
associate-*r/86.2%
*-commutative86.2%
associate-/l/86.2%
associate-/l*86.2%
Simplified86.2%
Final simplification86.2%
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) (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s (if (<= M_m 4.2e+79) 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);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (M_m <= 4.2e+79) {
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)
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 <= 4.2d+79) 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);
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 (M_m <= 4.2e+79) {
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) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if M_m <= 4.2e+79: 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) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (M_m <= 4.2e+79) 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); function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0; if (M_m <= 4.2e+79) 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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[M$95$m, 4.2e+79], 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\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \leq 4.2 \cdot 10^{+79}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0\_m}\right)\\
\end{array}
\end{array}
if M < 4.20000000000000016e79Initial program 81.7%
Simplified81.7%
Taylor expanded in D around 0 74.3%
if 4.20000000000000016e79 < M Initial program 70.4%
Simplified70.4%
add-sqr-sqrt33.8%
sqrt-unprod29.1%
*-commutative29.1%
*-commutative29.1%
swap-sqr28.7%
Applied egg-rr28.7%
Taylor expanded in h around 0 23.8%
sqrt-pow131.4%
metadata-eval31.4%
pow131.4%
add-log-exp30.7%
Applied egg-rr30.7%
Final simplification68.7%
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) (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s (if (<= D_m 7.5e+171) 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);
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 <= 7.5e+171) {
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);
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 <= 7.5e+171) {
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) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if D_m <= 7.5e+171: 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) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (D_m <= 7.5e+171) 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]
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, 7.5e+171], 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\_s \cdot \begin{array}{l}
\mathbf{if}\;D\_m \leq 7.5 \cdot 10^{+171}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(w0\_m\right)\right)\\
\end{array}
\end{array}
if D < 7.4999999999999998e171Initial program 80.2%
Simplified80.2%
Taylor expanded in D around 0 71.6%
if 7.4999999999999998e171 < D Initial program 80.5%
Simplified80.5%
unpow280.5%
unpow280.5%
associate-/r*80.5%
associate-*r/80.5%
*-commutative80.5%
associate-*r/85.5%
clear-num85.4%
*-commutative85.4%
associate-*l/85.4%
associate-/r*85.4%
clear-num85.4%
associate-*l/85.4%
*-un-lft-identity85.4%
associate-/r/85.4%
Applied egg-rr85.4%
associate-/r/85.5%
associate-*l/85.5%
*-commutative85.5%
associate-*l/85.4%
associate-/l/85.5%
associate-/r/85.5%
Simplified85.5%
add-exp-log44.5%
associate-*l/44.5%
*-un-lft-identity44.5%
*-commutative44.5%
associate-/l/44.5%
Applied egg-rr44.5%
Taylor expanded in h around 0 21.0%
rem-exp-log35.4%
log1p-expm1-u52.3%
Applied egg-rr52.3%
Final simplification70.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) (FPCore (w0_s w0_m M_m D_m h l d_m) :precision binary64 (* w0_s (if (<= M_m 2.4e+91) w0_m (/ (- 1.0 (pow (+ w0_m 1.0) 2.0)) (- -2.0 w0_m)))))
M_m = fabs(M);
D_m = fabs(D);
d_m = fabs(d);
w0\_m = fabs(w0);
w0\_s = copysign(1.0, w0);
double code(double w0_s, double w0_m, double M_m, double D_m, double h, double l, double d_m) {
double tmp;
if (M_m <= 2.4e+91) {
tmp = w0_m;
} else {
tmp = (1.0 - pow((w0_m + 1.0), 2.0)) / (-2.0 - 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)
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 <= 2.4d+91) then
tmp = w0_m
else
tmp = (1.0d0 - ((w0_m + 1.0d0) ** 2.0d0)) / ((-2.0d0) - 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);
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 (M_m <= 2.4e+91) {
tmp = w0_m;
} else {
tmp = (1.0 - Math.pow((w0_m + 1.0), 2.0)) / (-2.0 - 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) def code(w0_s, w0_m, M_m, D_m, h, l, d_m): tmp = 0 if M_m <= 2.4e+91: tmp = w0_m else: tmp = (1.0 - math.pow((w0_m + 1.0), 2.0)) / (-2.0 - 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) function code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0 if (M_m <= 2.4e+91) tmp = w0_m; else tmp = Float64(Float64(1.0 - (Float64(w0_m + 1.0) ^ 2.0)) / Float64(-2.0 - 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); function tmp_2 = code(w0_s, w0_m, M_m, D_m, h, l, d_m) tmp = 0.0; if (M_m <= 2.4e+91) tmp = w0_m; else tmp = (1.0 - ((w0_m + 1.0) ^ 2.0)) / (-2.0 - 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]
code[w0$95$s_, w0$95$m_, M$95$m_, D$95$m_, h_, l_, d$95$m_] := N[(w0$95$s * If[LessEqual[M$95$m, 2.4e+91], w0$95$m, N[(N[(1.0 - N[Power[N[(w0$95$m + 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(-2.0 - 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\_s \cdot \begin{array}{l}
\mathbf{if}\;M\_m \leq 2.4 \cdot 10^{+91}:\\
\;\;\;\;w0\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - {\left(w0\_m + 1\right)}^{2}}{-2 - w0\_m}\\
\end{array}
\end{array}
if M < 2.39999999999999983e91Initial program 81.5%
Simplified81.5%
Taylor expanded in D around 0 74.2%
if 2.39999999999999983e91 < M Initial program 70.8%
Simplified70.7%
unpow270.7%
unpow270.7%
associate-/r*70.7%
associate-*r/70.8%
*-commutative70.8%
associate-*r/71.4%
clear-num71.4%
*-commutative71.4%
associate-*l/71.4%
associate-/r*71.4%
clear-num71.4%
associate-*l/71.4%
*-un-lft-identity71.4%
associate-/r/71.4%
Applied egg-rr71.4%
associate-/r/71.4%
associate-*l/71.4%
*-commutative71.4%
associate-*l/71.3%
associate-/l/71.3%
associate-/r/71.4%
Simplified71.4%
add-exp-log33.4%
associate-*l/33.4%
*-un-lft-identity33.4%
*-commutative33.4%
associate-/l/33.4%
Applied egg-rr33.4%
Taylor expanded in h around 0 8.2%
rem-exp-log27.7%
expm1-log1p-u22.4%
expm1-define9.6%
flip--25.7%
frac-2neg25.7%
metadata-eval25.7%
sub-neg25.7%
pow225.7%
log1p-undefine25.7%
rem-exp-log25.7%
metadata-eval25.7%
log1p-undefine25.7%
rem-exp-log33.1%
Applied egg-rr33.1%
neg-sub033.1%
+-commutative33.1%
associate--r+33.1%
metadata-eval33.1%
+-commutative33.1%
neg-sub033.1%
+-commutative33.1%
associate-+r+33.1%
metadata-eval33.1%
associate--r+33.1%
metadata-eval33.1%
Simplified33.1%
Final simplification69.4%
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) (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);
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)
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);
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) 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) 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); 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]
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\_s \cdot w0\_m
\end{array}
Initial program 80.3%
Simplified80.2%
Taylor expanded in D around 0 68.8%
Final simplification68.8%
herbie shell --seed 2024077
(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))))))