
(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) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= l 5e-67) (* w0 (sqrt (+ 1.0 (* (* h (pow (* (/ (/ D d) 2.0) M_m) 2.0)) (/ -1.0 l))))) (* w0 (sqrt (- 1.0 (* h (pow (/ (* (/ D 2.0) (/ M_m d)) (sqrt l)) 2.0)))))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (l <= 5e-67) {
tmp = w0 * sqrt((1.0 + ((h * pow((((D / d) / 2.0) * M_m), 2.0)) * (-1.0 / l))));
} else {
tmp = w0 * sqrt((1.0 - (h * pow((((D / 2.0) * (M_m / d)) / sqrt(l)), 2.0))));
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 5d-67) then
tmp = w0 * sqrt((1.0d0 + ((h * ((((d / d_1) / 2.0d0) * m_m) ** 2.0d0)) * ((-1.0d0) / l))))
else
tmp = w0 * sqrt((1.0d0 - (h * ((((d / 2.0d0) * (m_m / d_1)) / sqrt(l)) ** 2.0d0))))
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (l <= 5e-67) {
tmp = w0 * Math.sqrt((1.0 + ((h * Math.pow((((D / d) / 2.0) * M_m), 2.0)) * (-1.0 / l))));
} else {
tmp = w0 * Math.sqrt((1.0 - (h * Math.pow((((D / 2.0) * (M_m / d)) / Math.sqrt(l)), 2.0))));
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if l <= 5e-67: tmp = w0 * math.sqrt((1.0 + ((h * math.pow((((D / d) / 2.0) * M_m), 2.0)) * (-1.0 / l)))) else: tmp = w0 * math.sqrt((1.0 - (h * math.pow((((D / 2.0) * (M_m / d)) / math.sqrt(l)), 2.0)))) return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (l <= 5e-67) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(h * (Float64(Float64(Float64(D / d) / 2.0) * M_m) ^ 2.0)) * Float64(-1.0 / l))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(h * (Float64(Float64(Float64(D / 2.0) * Float64(M_m / d)) / sqrt(l)) ^ 2.0))))); end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (l <= 5e-67)
tmp = w0 * sqrt((1.0 + ((h * ((((D / d) / 2.0) * M_m) ^ 2.0)) * (-1.0 / l))));
else
tmp = w0 * sqrt((1.0 - (h * ((((D / 2.0) * (M_m / d)) / sqrt(l)) ^ 2.0))));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[l, 5e-67], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(h * N[Power[N[(N[(N[(D / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[Power[N[(N[(N[(D / 2.0), $MachinePrecision] * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{-67}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \left(h \cdot {\left(\frac{\frac{D}{d}}{2} \cdot M\_m\right)}^{2}\right) \cdot \frac{-1}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - h \cdot {\left(\frac{\frac{D}{2} \cdot \frac{M\_m}{d}}{\sqrt{\ell}}\right)}^{2}}\\
\end{array}
\end{array}
if l < 4.9999999999999999e-67Initial program 80.4%
Simplified79.8%
unpow279.8%
unpow279.8%
associate-/r*79.8%
associate-*r/80.4%
*-commutative80.4%
associate-*r/88.4%
clear-num88.4%
*-commutative88.4%
associate-*l/88.4%
associate-/r*88.4%
clear-num88.4%
associate-*l/88.4%
*-un-lft-identity88.4%
associate-/r/88.4%
Applied egg-rr88.4%
associate-/r/88.4%
associate-*l/88.4%
*-commutative88.4%
associate-*l/88.4%
associate-/l/87.9%
associate-/r/87.9%
Simplified87.9%
if 4.9999999999999999e-67 < l Initial program 84.3%
Simplified85.6%
clear-num85.5%
un-div-inv86.8%
clear-num86.7%
un-div-inv86.7%
associate-/r/86.7%
Applied egg-rr86.7%
associate-/r/87.0%
associate-*l/87.0%
*-commutative87.0%
associate-/l*87.0%
associate-*l/87.0%
*-commutative87.0%
associate-*l/87.0%
associate-/l/85.8%
associate-/r/85.8%
associate-*l/85.8%
*-commutative85.8%
associate-*r/85.9%
*-commutative85.9%
associate-/l/85.9%
associate-/l*87.0%
Simplified87.0%
add-sqr-sqrt87.0%
sqrt-div87.0%
sqrt-pow184.5%
metadata-eval84.5%
pow184.5%
sqrt-div84.5%
sqrt-pow190.6%
metadata-eval90.6%
pow190.6%
Applied egg-rr90.6%
unpow290.6%
associate-*r/88.3%
times-frac90.6%
Simplified90.6%
Final simplification88.8%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (let* ((t_0 (* (/ h l) (pow (/ (* D M_m) (* d 2.0)) 2.0)))) (if (<= t_0 0.0004) (* w0 (sqrt (- 1.0 t_0))) w0)))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double t_0 = (h / l) * pow(((D * M_m) / (d * 2.0)), 2.0);
double tmp;
if (t_0 <= 0.0004) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (h / l) * (((d * m_m) / (d_1 * 2.0d0)) ** 2.0d0)
if (t_0 <= 0.0004d0) then
tmp = w0 * sqrt((1.0d0 - t_0))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double t_0 = (h / l) * Math.pow(((D * M_m) / (d * 2.0)), 2.0);
double tmp;
if (t_0 <= 0.0004) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): t_0 = (h / l) * math.pow(((D * M_m) / (d * 2.0)), 2.0) tmp = 0 if t_0 <= 0.0004: tmp = w0 * math.sqrt((1.0 - t_0)) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) t_0 = Float64(Float64(h / l) * (Float64(Float64(D * M_m) / Float64(d * 2.0)) ^ 2.0)) tmp = 0.0 if (t_0 <= 0.0004) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
t_0 = (h / l) * (((D * M_m) / (d * 2.0)) ^ 2.0);
tmp = 0.0;
if (t_0 <= 0.0004)
tmp = w0 * sqrt((1.0 - t_0));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D * M$95$m), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0004], N[(w0 * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
t_0 := \frac{h}{\ell} \cdot {\left(\frac{D \cdot M\_m}{d \cdot 2}\right)}^{2}\\
\mathbf{if}\;t\_0 \leq 0.0004:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 4.00000000000000019e-4Initial program 91.3%
if 4.00000000000000019e-4 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 0.0%
Simplified7.6%
Taylor expanded in D around 0 69.3%
Final simplification88.9%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= (/ h l) -5e-251) (* w0 (sqrt (+ 1.0 (* (* h (pow (* (/ (/ D d) 2.0) M_m) 2.0)) (/ -1.0 l))))) w0))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -5e-251) {
tmp = w0 * sqrt((1.0 + ((h * pow((((D / d) / 2.0) * M_m), 2.0)) * (-1.0 / l))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if ((h / l) <= (-5d-251)) then
tmp = w0 * sqrt((1.0d0 + ((h * ((((d / d_1) / 2.0d0) * m_m) ** 2.0d0)) * ((-1.0d0) / l))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -5e-251) {
tmp = w0 * Math.sqrt((1.0 + ((h * Math.pow((((D / d) / 2.0) * M_m), 2.0)) * (-1.0 / l))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if (h / l) <= -5e-251: tmp = w0 * math.sqrt((1.0 + ((h * math.pow((((D / d) / 2.0) * M_m), 2.0)) * (-1.0 / l)))) else: tmp = w0 return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -5e-251) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(Float64(h * (Float64(Float64(Float64(D / d) / 2.0) * M_m) ^ 2.0)) * Float64(-1.0 / l))))); else tmp = w0; end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if ((h / l) <= -5e-251)
tmp = w0 * sqrt((1.0 + ((h * ((((D / d) / 2.0) * M_m) ^ 2.0)) * (-1.0 / l))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -5e-251], N[(w0 * N[Sqrt[N[(1.0 + N[(N[(h * N[Power[N[(N[(N[(D / d), $MachinePrecision] / 2.0), $MachinePrecision] * M$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -5 \cdot 10^{-251}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \left(h \cdot {\left(\frac{\frac{D}{d}}{2} \cdot M\_m\right)}^{2}\right) \cdot \frac{-1}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -5.0000000000000003e-251Initial program 80.2%
Simplified80.3%
unpow280.3%
unpow280.3%
associate-/r*80.3%
associate-*r/80.2%
*-commutative80.2%
associate-*r/86.8%
clear-num86.8%
*-commutative86.8%
associate-*l/87.5%
associate-/r*87.5%
clear-num87.5%
associate-*l/87.5%
*-un-lft-identity87.5%
associate-/r/87.5%
Applied egg-rr87.5%
associate-/r/87.4%
associate-*l/87.4%
*-commutative87.4%
associate-*l/87.4%
associate-/l/86.0%
associate-/r/86.0%
Simplified86.0%
if -5.0000000000000003e-251 < (/.f64 h l) Initial program 83.2%
Simplified83.3%
Taylor expanded in D around 0 91.7%
Final simplification88.7%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* h (/ (pow (* D (/ M_m (* d 2.0))) 2.0) l))))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (h * (pow((D * (M_m / (d * 2.0))), 2.0) / l))));
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_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 - (h * (((d * (m_m / (d_1 * 2.0d0))) ** 2.0d0) / l))))
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (h * (Math.pow((D * (M_m / (d * 2.0))), 2.0) / l))));
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((D * (M_m / (d * 2.0))), 2.0) / l))))
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(D * Float64(M_m / Float64(d * 2.0))) ^ 2.0) / l))))) end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0 * sqrt((1.0 - (h * (((D * (M_m / (d * 2.0))) ^ 2.0) / l))));
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[Power[N[(D * N[(M$95$m / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(D \cdot \frac{M\_m}{d \cdot 2}\right)}^{2}}{\ell}}
\end{array}
Initial program 81.6%
Simplified81.7%
clear-num81.6%
un-div-inv82.2%
clear-num82.2%
un-div-inv82.2%
associate-/r/82.2%
Applied egg-rr82.2%
associate-/r/86.9%
associate-*l/88.0%
*-commutative88.0%
associate-/l*86.9%
associate-*l/86.9%
*-commutative86.9%
associate-*l/86.9%
associate-/l/86.1%
associate-/r/86.1%
associate-*l/86.1%
*-commutative86.1%
associate-*r/86.5%
*-commutative86.5%
associate-/l/86.5%
associate-/l*86.9%
Simplified86.9%
Final simplification86.9%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 (if (<= M_m 1.6e+65) w0 (log (exp w0))))
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (M_m <= 1.6e+65) {
tmp = w0;
} else {
tmp = log(exp(w0));
}
return tmp;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
real(8) :: tmp
if (m_m <= 1.6d+65) then
tmp = w0
else
tmp = log(exp(w0))
end if
code = tmp
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
double tmp;
if (M_m <= 1.6e+65) {
tmp = w0;
} else {
tmp = Math.log(Math.exp(w0));
}
return tmp;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): tmp = 0 if M_m <= 1.6e+65: tmp = w0 else: tmp = math.log(math.exp(w0)) return tmp
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) tmp = 0.0 if (M_m <= 1.6e+65) tmp = w0; else tmp = log(exp(w0)); end return tmp end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp_2 = code(w0, M_m, D, h, l, d)
tmp = 0.0;
if (M_m <= 1.6e+65)
tmp = w0;
else
tmp = log(exp(w0));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := If[LessEqual[M$95$m, 1.6e+65], w0, N[Log[N[Exp[w0], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \leq 1.6 \cdot 10^{+65}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{w0}\right)\\
\end{array}
\end{array}
if M < 1.60000000000000003e65Initial program 83.8%
Simplified83.8%
Taylor expanded in D around 0 77.4%
if 1.60000000000000003e65 < M Initial program 71.1%
Simplified71.1%
add-sqr-sqrt46.6%
sqrt-unprod36.5%
*-commutative36.5%
*-commutative36.5%
swap-sqr36.2%
Applied egg-rr36.2%
associate-*l/36.2%
*-commutative36.2%
associate-*l/36.2%
associate-/l/36.3%
associate-/r/36.3%
Simplified36.3%
Taylor expanded in h around 0 32.7%
sqrt-pow143.0%
metadata-eval43.0%
pow143.0%
add-log-exp31.5%
Applied egg-rr31.5%
Final simplification69.7%
M_m = (fabs.f64 M) NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d) :precision binary64 w0)
M_m = fabs(M);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d);
double code(double w0, double M_m, double D, double h, double l, double d) {
return w0;
}
M_m = abs(m)
NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m_m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0
end function
M_m = Math.abs(M);
assert w0 < M_m && M_m < D && D < h && h < l && l < d;
public static double code(double w0, double M_m, double D, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) [w0, M_m, D, h, l, d] = sort([w0, M_m, D, h, l, d]) def code(w0, M_m, D, h, l, d): return w0
M_m = abs(M) w0, M_m, D, h, l, d = sort([w0, M_m, D, h, l, d]) function code(w0, M_m, D, h, l, d) return w0 end
M_m = abs(M);
w0, M_m, D, h, l, d = num2cell(sort([w0, M_m, D, h, l, d])){:}
function tmp = code(w0, M_m, D, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
[w0, M_m, D, h, l, d] = \mathsf{sort}([w0, M_m, D, h, l, d])\\
\\
w0
\end{array}
Initial program 81.6%
Simplified81.7%
Taylor expanded in D around 0 71.6%
Final simplification71.6%
herbie shell --seed 2024096
(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))))))