
(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 1 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)) -2e+259)
(pow
(*
(sqrt w0_m)
(pow
(exp 0.25)
(+
(log (* -0.25 (* h (/ (pow (* M_m D_m) 2.0) l))))
(* -2.0 (log d_m)))))
2.0)
(*
w0_m
(sqrt (- 1.0 (/ (* h (pow (* (/ M_m d_m) (/ D_m 2.0)) 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)) <= -2e+259) {
tmp = pow((sqrt(w0_m) * pow(exp(0.25), (log((-0.25 * (h * (pow((M_m * D_m), 2.0) / l)))) + (-2.0 * log(d_m))))), 2.0);
} else {
tmp = w0_m * sqrt((1.0 - ((h * pow(((M_m / d_m) * (D_m / 2.0)), 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)) <= (-2d+259)) then
tmp = (sqrt(w0_m) * (exp(0.25d0) ** (log(((-0.25d0) * (h * (((m_m * d_m) ** 2.0d0) / l)))) + ((-2.0d0) * log(d_m_1))))) ** 2.0d0
else
tmp = w0_m * sqrt((1.0d0 - ((h * (((m_m / d_m_1) * (d_m / 2.0d0)) ** 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)) <= -2e+259) {
tmp = Math.pow((Math.sqrt(w0_m) * Math.pow(Math.exp(0.25), (Math.log((-0.25 * (h * (Math.pow((M_m * D_m), 2.0) / l)))) + (-2.0 * Math.log(d_m))))), 2.0);
} else {
tmp = w0_m * Math.sqrt((1.0 - ((h * Math.pow(((M_m / d_m) * (D_m / 2.0)), 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)) <= -2e+259: tmp = math.pow((math.sqrt(w0_m) * math.pow(math.exp(0.25), (math.log((-0.25 * (h * (math.pow((M_m * D_m), 2.0) / l)))) + (-2.0 * math.log(d_m))))), 2.0) else: tmp = w0_m * math.sqrt((1.0 - ((h * math.pow(((M_m / d_m) * (D_m / 2.0)), 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)) <= -2e+259) tmp = Float64(sqrt(w0_m) * (exp(0.25) ^ Float64(log(Float64(-0.25 * Float64(h * Float64((Float64(M_m * D_m) ^ 2.0) / l)))) + Float64(-2.0 * log(d_m))))) ^ 2.0; else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m / d_m) * Float64(D_m / 2.0)) ^ 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)) <= -2e+259)
tmp = (sqrt(w0_m) * (exp(0.25) ^ (log((-0.25 * (h * (((M_m * D_m) ^ 2.0) / l)))) + (-2.0 * log(d_m))))) ^ 2.0;
else
tmp = w0_m * sqrt((1.0 - ((h * (((M_m / d_m) * (D_m / 2.0)) ^ 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], -2e+259], N[Power[N[(N[Sqrt[w0$95$m], $MachinePrecision] * N[Power[N[Exp[0.25], $MachinePrecision], N[(N[Log[N[(-0.25 * N[(h * N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(-2.0 * N[Log[d$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m / d$95$m), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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 -2 \cdot 10^{+259}:\\
\;\;\;\;{\left(\sqrt{w0_m} \cdot {\left(e^{0.25}\right)}^{\left(\log \left(-0.25 \cdot \left(h \cdot \frac{{\left(M_m \cdot D_m\right)}^{2}}{\ell}\right)\right) + -2 \cdot \log d_m\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M_m}{d_m} \cdot \frac{D_m}{2}\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -2e259Initial program 53.3%
Simplified53.4%
*-commutative53.4%
frac-times53.3%
associate-*l/53.3%
associate-*l/56.1%
associate-*l/57.4%
*-commutative57.4%
times-frac56.1%
Applied egg-rr56.1%
add-sqr-sqrt29.9%
pow229.9%
*-commutative29.9%
sqrt-prod29.8%
unpow229.8%
sqrt-prod17.9%
add-sqr-sqrt31.2%
div-inv31.2%
metadata-eval31.2%
Applied egg-rr31.2%
associate-*l*31.2%
*-commutative31.2%
Simplified31.2%
add-sqr-sqrt16.0%
pow216.0%
Applied egg-rr25.0%
Taylor expanded in d around 0 8.9%
exp-prod8.9%
Simplified11.7%
if -2e259 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 90.2%
Simplified90.2%
*-commutative90.2%
frac-times90.2%
associate-*l/90.8%
associate-*l/97.4%
associate-*l/96.9%
*-commutative96.9%
times-frac97.4%
Applied egg-rr97.4%
Final simplification73.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 1 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
(let* ((t_0 (* (* (/ M_m d_m) (* D_m 0.5)) (sqrt h))))
(*
w0_s
(if (<= h 1.5e-295)
(* w0_m (sqrt (- 1.0 (/ (* h (pow (* (/ M_m d_m) (/ D_m 2.0)) 2.0)) l))))
(pow (sqrt (* w0_m (sqrt (- 1.0 (* t_0 (/ t_0 l)))))) 2.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 t_0 = ((M_m / d_m) * (D_m * 0.5)) * sqrt(h);
double tmp;
if (h <= 1.5e-295) {
tmp = w0_m * sqrt((1.0 - ((h * pow(((M_m / d_m) * (D_m / 2.0)), 2.0)) / l)));
} else {
tmp = pow(sqrt((w0_m * sqrt((1.0 - (t_0 * (t_0 / l)))))), 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)
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) :: t_0
real(8) :: tmp
t_0 = ((m_m / d_m_1) * (d_m * 0.5d0)) * sqrt(h)
if (h <= 1.5d-295) then
tmp = w0_m * sqrt((1.0d0 - ((h * (((m_m / d_m_1) * (d_m / 2.0d0)) ** 2.0d0)) / l)))
else
tmp = sqrt((w0_m * sqrt((1.0d0 - (t_0 * (t_0 / l)))))) ** 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);
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 t_0 = ((M_m / d_m) * (D_m * 0.5)) * Math.sqrt(h);
double tmp;
if (h <= 1.5e-295) {
tmp = w0_m * Math.sqrt((1.0 - ((h * Math.pow(((M_m / d_m) * (D_m / 2.0)), 2.0)) / l)));
} else {
tmp = Math.pow(Math.sqrt((w0_m * Math.sqrt((1.0 - (t_0 * (t_0 / l)))))), 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) [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): t_0 = ((M_m / d_m) * (D_m * 0.5)) * math.sqrt(h) tmp = 0 if h <= 1.5e-295: tmp = w0_m * math.sqrt((1.0 - ((h * math.pow(((M_m / d_m) * (D_m / 2.0)), 2.0)) / l))) else: tmp = math.pow(math.sqrt((w0_m * math.sqrt((1.0 - (t_0 * (t_0 / l)))))), 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) 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) t_0 = Float64(Float64(Float64(M_m / d_m) * Float64(D_m * 0.5)) * sqrt(h)) tmp = 0.0 if (h <= 1.5e-295) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(Float64(M_m / d_m) * Float64(D_m / 2.0)) ^ 2.0)) / l)))); else tmp = sqrt(Float64(w0_m * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_0 / l)))))) ^ 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);
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)
t_0 = ((M_m / d_m) * (D_m * 0.5)) * sqrt(h);
tmp = 0.0;
if (h <= 1.5e-295)
tmp = w0_m * sqrt((1.0 - ((h * (((M_m / d_m) * (D_m / 2.0)) ^ 2.0)) / l)));
else
tmp = sqrt((w0_m * sqrt((1.0 - (t_0 * (t_0 / l)))))) ^ 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]
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_] := Block[{t$95$0 = N[(N[(N[(M$95$m / d$95$m), $MachinePrecision] * N[(D$95$m * 0.5), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, N[(w0$95$s * If[LessEqual[h, 1.5e-295], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(N[(M$95$m / d$95$m), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Sqrt[N[(w0$95$m * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $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])\\
\\
\begin{array}{l}
t_0 := \left(\frac{M_m}{d_m} \cdot \left(D_m \cdot 0.5\right)\right) \cdot \sqrt{h}\\
w0_s \cdot \begin{array}{l}
\mathbf{if}\;h \leq 1.5 \cdot 10^{-295}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{M_m}{d_m} \cdot \frac{D_m}{2}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{w0_m \cdot \sqrt{1 - t_0 \cdot \frac{t_0}{\ell}}}\right)}^{2}\\
\end{array}
\end{array}
\end{array}
if h < 1.49999999999999998e-295Initial program 81.2%
Simplified80.4%
*-commutative80.4%
frac-times81.2%
associate-*l/82.0%
associate-*l/90.4%
associate-*l/90.3%
*-commutative90.3%
times-frac90.4%
Applied egg-rr90.4%
if 1.49999999999999998e-295 < h Initial program 78.9%
Simplified79.7%
*-commutative79.7%
frac-times78.9%
associate-*l/79.0%
associate-*l/82.1%
associate-*l/82.1%
*-commutative82.1%
times-frac82.1%
Applied egg-rr82.1%
add-sqr-sqrt82.1%
pow282.1%
*-commutative82.1%
sqrt-prod82.1%
unpow282.1%
sqrt-prod61.8%
add-sqr-sqrt84.8%
div-inv84.8%
metadata-eval84.8%
Applied egg-rr84.8%
associate-*l*83.3%
*-commutative83.3%
Simplified83.3%
add-sqr-sqrt45.2%
pow245.2%
Applied egg-rr43.9%
add-sqr-sqrt43.9%
*-un-lft-identity43.9%
times-frac43.9%
sqrt-prod43.9%
unpow243.9%
sqrt-prod30.7%
add-sqr-sqrt37.5%
sqrt-prod37.5%
unpow237.5%
sqrt-prod32.0%
add-sqr-sqrt46.6%
Applied egg-rr46.6%
Final simplification67.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 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)) 2e-10)
(* w0_m (sqrt (- 1.0 (* (/ h l) (pow (* D_m (/ M_m (* 2.0 d_m))) 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);
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)) <= 2e-10) {
tmp = w0_m * sqrt((1.0 - ((h / l) * pow((D_m * (M_m / (2.0 * d_m))), 2.0))));
} else {
tmp = 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 (((((m_m * d_m) / (2.0d0 * d_m_1)) ** 2.0d0) * (h / l)) <= 2d-10) then
tmp = w0_m * sqrt((1.0d0 - ((h / l) * ((d_m * (m_m / (2.0d0 * d_m_1))) ** 2.0d0))))
else
tmp = 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 ((Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= 2e-10) {
tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow((D_m * (M_m / (2.0 * d_m))), 2.0))));
} else {
tmp = 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 (math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0) * (h / l)) <= 2e-10: tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow((D_m * (M_m / (2.0 * d_m))), 2.0)))) else: tmp = 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 (Float64((Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) <= 2e-10) tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D_m * Float64(M_m / Float64(2.0 * d_m))) ^ 2.0))))); else tmp = 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 (((((M_m * D_m) / (2.0 * d_m)) ^ 2.0) * (h / l)) <= 2e-10)
tmp = w0_m * sqrt((1.0 - ((h / l) * ((D_m * (M_m / (2.0 * d_m))) ^ 2.0))));
else
tmp = 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[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], 2e-10], N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D$95$m * N[(M$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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 \begin{array}{l}
\mathbf{if}\;{\left(\frac{M_m \cdot D_m}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D_m \cdot \frac{M_m}{2 \cdot d_m}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0_m\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 2.00000000000000007e-10Initial program 86.0%
Simplified85.6%
if 2.00000000000000007e-10 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 0.0%
Simplified11.1%
Taylor expanded in M around 0 69.2%
Final simplification84.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 1 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 (<= (* M_m D_m) 1e-31)
w0_m
(*
w0_m
(sqrt (- 1.0 (* (/ h l) (pow (* (/ M_m 2.0) (/ D_m 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);
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 ((M_m * D_m) <= 1e-31) {
tmp = w0_m;
} else {
tmp = w0_m * sqrt((1.0 - ((h / l) * pow(((M_m / 2.0) * (D_m / 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)
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) <= 1d-31) then
tmp = w0_m
else
tmp = w0_m * sqrt((1.0d0 - ((h / l) * (((m_m / 2.0d0) * (d_m / 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);
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 ((M_m * D_m) <= 1e-31) {
tmp = w0_m;
} else {
tmp = w0_m * Math.sqrt((1.0 - ((h / l) * Math.pow(((M_m / 2.0) * (D_m / 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) [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 (M_m * D_m) <= 1e-31: tmp = w0_m else: tmp = w0_m * math.sqrt((1.0 - ((h / l) * math.pow(((M_m / 2.0) * (D_m / 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) 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(M_m * D_m) <= 1e-31) tmp = w0_m; else tmp = Float64(w0_m * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(M_m / 2.0) * Float64(D_m / 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);
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) <= 1e-31)
tmp = w0_m;
else
tmp = w0_m * sqrt((1.0 - ((h / l) * (((M_m / 2.0) * (D_m / 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]
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[(M$95$m * D$95$m), $MachinePrecision], 1e-31], w0$95$m, N[(w0$95$m * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D$95$m / d$95$m), $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_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}\;M_m \cdot D_m \leq 10^{-31}:\\
\;\;\;\;w0_m\\
\mathbf{else}:\\
\;\;\;\;w0_m \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{M_m}{2} \cdot \frac{D_m}{d_m}\right)}^{2}}\\
\end{array}
\end{array}
if (*.f64 M D) < 1e-31Initial program 80.8%
Simplified80.8%
Taylor expanded in M around 0 75.3%
if 1e-31 < (*.f64 M D) Initial program 77.6%
Simplified77.7%
Final simplification75.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 1 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 (* (/ M_m d_m) (/ D_m 2.0)) 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(((M_m / d_m) * (D_m / 2.0)), 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 * (((m_m / d_m_1) * (d_m / 2.0d0)) ** 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(((M_m / d_m) * (D_m / 2.0)), 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(((M_m / d_m) * (D_m / 2.0)), 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(Float64(h * (Float64(Float64(M_m / d_m) * Float64(D_m / 2.0)) ^ 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 * (((M_m / d_m) * (D_m / 2.0)) ^ 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[(N[(h * N[Power[N[(N[(M$95$m / d$95$m), $MachinePrecision] * N[(D$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $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 - \frac{h \cdot {\left(\frac{M_m}{d_m} \cdot \frac{D_m}{2}\right)}^{2}}{\ell}}\right)
\end{array}
Initial program 80.0%
Simplified80.0%
*-commutative80.0%
frac-times80.0%
associate-*l/80.4%
associate-*l/86.0%
associate-*l/85.9%
*-commutative85.9%
times-frac86.0%
Applied egg-rr86.0%
Final simplification86.0%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
d_m = (fabs.f64 d)
w0_m = (fabs.f64 w0)
w0_s = (copysign.f64 1 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 (<= (* M_m D_m) 2e+172)
w0_m
(* -0.125 (* (/ (pow (* M_m D_m) 2.0) l) (* (/ w0_m d_m) (/ h d_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 ((M_m * D_m) <= 2e+172) {
tmp = w0_m;
} else {
tmp = -0.125 * ((pow((M_m * D_m), 2.0) / l) * ((w0_m / d_m) * (h / d_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 ((m_m * d_m) <= 2d+172) then
tmp = w0_m
else
tmp = (-0.125d0) * ((((m_m * d_m) ** 2.0d0) / l) * ((w0_m / d_m_1) * (h / d_m_1)))
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 ((M_m * D_m) <= 2e+172) {
tmp = w0_m;
} else {
tmp = -0.125 * ((Math.pow((M_m * D_m), 2.0) / l) * ((w0_m / d_m) * (h / d_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 (M_m * D_m) <= 2e+172: tmp = w0_m else: tmp = -0.125 * ((math.pow((M_m * D_m), 2.0) / l) * ((w0_m / d_m) * (h / d_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 (Float64(M_m * D_m) <= 2e+172) tmp = w0_m; else tmp = Float64(-0.125 * Float64(Float64((Float64(M_m * D_m) ^ 2.0) / l) * Float64(Float64(w0_m / d_m) * Float64(h / d_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 ((M_m * D_m) <= 2e+172)
tmp = w0_m;
else
tmp = -0.125 * ((((M_m * D_m) ^ 2.0) / l) * ((w0_m / d_m) * (h / d_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[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+172], w0$95$m, N[(-0.125 * N[(N[(N[Power[N[(M$95$m * D$95$m), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision] * N[(N[(w0$95$m / d$95$m), $MachinePrecision] * N[(h / d$95$m), $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}\;M_m \cdot D_m \leq 2 \cdot 10^{+172}:\\
\;\;\;\;w0_m\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\frac{{\left(M_m \cdot D_m\right)}^{2}}{\ell} \cdot \left(\frac{w0_m}{d_m} \cdot \frac{h}{d_m}\right)\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 2.0000000000000002e172Initial program 80.5%
Simplified80.1%
Taylor expanded in M around 0 72.0%
if 2.0000000000000002e172 < (*.f64 M D) Initial program 75.4%
Simplified79.1%
Taylor expanded in M around 0 60.2%
add-sqr-sqrt26.2%
pow226.2%
sqrt-prod26.2%
unpow226.2%
sqrt-prod18.8%
add-sqr-sqrt26.2%
sqrt-prod26.2%
unpow226.2%
sqrt-prod22.5%
add-sqr-sqrt29.9%
Applied egg-rr29.9%
Taylor expanded in D around inf 56.3%
associate-*r*56.2%
*-commutative56.2%
times-frac56.2%
unpow256.2%
unpow256.2%
swap-sqr56.2%
unpow256.2%
Simplified56.2%
*-commutative56.2%
unpow256.2%
times-frac56.8%
Applied egg-rr56.8%
Final simplification70.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 1 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 80.0%
Simplified80.0%
Taylor expanded in M around 0 67.2%
Final simplification67.2%
herbie shell --seed 2023322
(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))))))