
(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 4 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)
NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D h l d_m)
:precision binary64
(let* ((t_0 (* (pow (/ (* M_m D) (* 2.0 d_m)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(* w0 (* (/ D d_m) (sqrt (* (/ (pow M_m 2.0) (/ l h)) -0.25))))
(if (<= t_0 0.5) (* w0 (sqrt (- 1.0 t_0))) w0))))M_m = fabs(M);
d_m = fabs(d);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d_m);
double code(double w0, double M_m, double D, double h, double l, double d_m) {
double t_0 = pow(((M_m * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = w0 * ((D / d_m) * sqrt(((pow(M_m, 2.0) / (l / h)) * -0.25)));
} else if (t_0 <= 0.5) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M_m = Math.abs(M);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D && D < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D, double h, double l, double d_m) {
double t_0 = Math.pow(((M_m * D) / (2.0 * d_m)), 2.0) * (h / l);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = w0 * ((D / d_m) * Math.sqrt(((Math.pow(M_m, 2.0) / (l / h)) * -0.25)));
} else if (t_0 <= 0.5) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) d_m = math.fabs(d) [w0, M_m, D, h, l, d_m] = sort([w0, M_m, D, h, l, d_m]) def code(w0, M_m, D, h, l, d_m): t_0 = math.pow(((M_m * D) / (2.0 * d_m)), 2.0) * (h / l) tmp = 0 if t_0 <= -math.inf: tmp = w0 * ((D / d_m) * math.sqrt(((math.pow(M_m, 2.0) / (l / h)) * -0.25))) elif t_0 <= 0.5: tmp = w0 * math.sqrt((1.0 - t_0)) else: tmp = w0 return tmp
M_m = abs(M) d_m = abs(d) w0, M_m, D, h, l, d_m = sort([w0, M_m, D, h, l, d_m]) function code(w0, M_m, D, h, l, d_m) t_0 = Float64((Float64(Float64(M_m * D) / Float64(2.0 * d_m)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(w0 * Float64(Float64(D / d_m) * sqrt(Float64(Float64((M_m ^ 2.0) / Float64(l / h)) * -0.25)))); elseif (t_0 <= 0.5) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = w0; end return tmp end
M_m = abs(M);
d_m = abs(d);
w0, M_m, D, h, l, d_m = num2cell(sort([w0, M_m, D, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D, h, l, d_m)
t_0 = (((M_m * D) / (2.0 * d_m)) ^ 2.0) * (h / l);
tmp = 0.0;
if (t_0 <= -Inf)
tmp = w0 * ((D / d_m) * sqrt((((M_m ^ 2.0) / (l / h)) * -0.25)));
elseif (t_0 <= 0.5)
tmp = w0 * sqrt((1.0 - t_0));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
d_m = N[Abs[d], $MachinePrecision]
NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D_, h_, l_, d$95$m_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(w0 * N[(N[(D / d$95$m), $MachinePrecision] * N[Sqrt[N[(N[(N[Power[M$95$m, 2.0], $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.5], N[(w0 * N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]]
\begin{array}{l}
M_m = \left|M\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D, h, l, d_m] = \mathsf{sort}([w0, M_m, D, h, l, d_m])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M_m \cdot D}{2 \cdot d_m}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;w0 \cdot \left(\frac{D}{d_m} \cdot \sqrt{\frac{{M_m}^{2}}{\frac{\ell}{h}} \cdot -0.25}\right)\\
\mathbf{elif}\;t_0 \leq 0.5:\\
\;\;\;\;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)) < -inf.0Initial program 57.3%
Simplified57.3%
Taylor expanded in D around inf 51.8%
*-commutative51.8%
times-frac51.7%
Simplified51.7%
associate-*l*51.7%
sqrt-prod53.2%
sqrt-div53.2%
unpow253.2%
sqrt-prod24.3%
add-sqr-sqrt24.3%
unpow224.3%
sqrt-prod13.8%
add-sqr-sqrt30.5%
associate-/l*30.5%
Applied egg-rr30.5%
if -inf.0 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < 0.5Initial program 99.9%
if 0.5 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 0.0%
Simplified0.0%
Taylor expanded in M around 0 72.4%
Final simplification81.6%
M_m = (fabs.f64 M)
d_m = (fabs.f64 d)
NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D h l d_m)
:precision binary64
(if (<= (/ h l) -2e+288)
(* w0 (+ 1.0 (* (* h (/ (pow (* M_m (/ D d_m)) 2.0) l)) -0.125)))
(if (<= (/ h l) -1e-281)
(* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D (/ M_m (* 2.0 d_m))) 2.0)))))
w0)))M_m = fabs(M);
d_m = fabs(d);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d_m);
double code(double w0, double M_m, double D, double h, double l, double d_m) {
double tmp;
if ((h / l) <= -2e+288) {
tmp = w0 * (1.0 + ((h * (pow((M_m * (D / d_m)), 2.0) / l)) * -0.125));
} else if ((h / l) <= -1e-281) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D * (M_m / (2.0 * d_m))), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = abs(M)
d_m = abs(d)
NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_m)
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_m
real(8) :: tmp
if ((h / l) <= (-2d+288)) then
tmp = w0 * (1.0d0 + ((h * (((m_m * (d / d_m)) ** 2.0d0) / l)) * (-0.125d0)))
else if ((h / l) <= (-1d-281)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d * (m_m / (2.0d0 * d_m))) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
M_m = Math.abs(M);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D && D < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D, double h, double l, double d_m) {
double tmp;
if ((h / l) <= -2e+288) {
tmp = w0 * (1.0 + ((h * (Math.pow((M_m * (D / d_m)), 2.0) / l)) * -0.125));
} else if ((h / l) <= -1e-281) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D * (M_m / (2.0 * d_m))), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M_m = math.fabs(M) d_m = math.fabs(d) [w0, M_m, D, h, l, d_m] = sort([w0, M_m, D, h, l, d_m]) def code(w0, M_m, D, h, l, d_m): tmp = 0 if (h / l) <= -2e+288: tmp = w0 * (1.0 + ((h * (math.pow((M_m * (D / d_m)), 2.0) / l)) * -0.125)) elif (h / l) <= -1e-281: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D * (M_m / (2.0 * d_m))), 2.0)))) else: tmp = w0 return tmp
M_m = abs(M) d_m = abs(d) w0, M_m, D, h, l, d_m = sort([w0, M_m, D, h, l, d_m]) function code(w0, M_m, D, h, l, d_m) tmp = 0.0 if (Float64(h / l) <= -2e+288) tmp = Float64(w0 * Float64(1.0 + Float64(Float64(h * Float64((Float64(M_m * Float64(D / d_m)) ^ 2.0) / l)) * -0.125))); elseif (Float64(h / l) <= -1e-281) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D * Float64(M_m / Float64(2.0 * d_m))) ^ 2.0))))); else tmp = w0; end return tmp end
M_m = abs(M);
d_m = abs(d);
w0, M_m, D, h, l, d_m = num2cell(sort([w0, M_m, D, h, l, d_m])){:}
function tmp_2 = code(w0, M_m, D, h, l, d_m)
tmp = 0.0;
if ((h / l) <= -2e+288)
tmp = w0 * (1.0 + ((h * (((M_m * (D / d_m)) ^ 2.0) / l)) * -0.125));
elseif ((h / l) <= -1e-281)
tmp = w0 * sqrt((1.0 - ((h / l) * ((D * (M_m / (2.0 * d_m))) ^ 2.0))));
else
tmp = w0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d$95$m_] := If[LessEqual[N[(h / l), $MachinePrecision], -2e+288], N[(w0 * N[(1.0 + N[(N[(h * N[(N[Power[N[(M$95$m * N[(D / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(h / l), $MachinePrecision], -1e-281], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(M$95$m / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
M_m = \left|M\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D, h, l, d_m] = \mathsf{sort}([w0, M_m, D, h, l, d_m])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{+288}:\\
\;\;\;\;w0 \cdot \left(1 + \left(h \cdot \frac{{\left(M_m \cdot \frac{D}{d_m}\right)}^{2}}{\ell}\right) \cdot -0.125\right)\\
\mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-281}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{M_m}{2 \cdot d_m}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -2e288Initial program 42.0%
Simplified42.0%
Taylor expanded in M around 0 41.9%
*-commutative41.9%
times-frac45.5%
Simplified45.5%
add-sqr-sqrt45.5%
sqrt-div45.5%
unpow245.5%
sqrt-prod26.5%
add-sqr-sqrt34.2%
unpow234.2%
sqrt-prod11.1%
add-sqr-sqrt33.7%
sqrt-div33.7%
unpow233.7%
sqrt-prod30.2%
add-sqr-sqrt49.2%
unpow249.2%
sqrt-prod30.5%
add-sqr-sqrt57.3%
Applied egg-rr57.3%
expm1-log1p-u15.5%
expm1-udef15.5%
associate-/l*3.7%
Applied egg-rr3.7%
expm1-def3.7%
expm1-log1p41.9%
Simplified41.9%
expm1-log1p-u14.8%
expm1-udef14.8%
associate-*r/14.8%
pow214.8%
pow-prod-down15.0%
Applied egg-rr15.0%
expm1-def15.0%
expm1-log1p42.2%
associate-/r/64.3%
*-commutative64.3%
Simplified64.3%
if -2e288 < (/.f64 h l) < -1e-281Initial program 86.1%
Simplified84.5%
if -1e-281 < (/.f64 h l) Initial program 88.9%
Simplified87.9%
Taylor expanded in M around 0 93.8%
Final simplification85.9%
M_m = (fabs.f64 M) d_m = (fabs.f64 d) NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d_m) :precision binary64 (* w0 (+ 1.0 (* (* h (/ (pow (* M_m (/ D d_m)) 2.0) l)) -0.125))))
M_m = fabs(M);
d_m = fabs(d);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d_m);
double code(double w0, double M_m, double D, double h, double l, double d_m) {
return w0 * (1.0 + ((h * (pow((M_m * (D / d_m)), 2.0) / l)) * -0.125));
}
M_m = abs(M)
d_m = abs(d)
NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_m)
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_m
code = w0 * (1.0d0 + ((h * (((m_m * (d / d_m)) ** 2.0d0) / l)) * (-0.125d0)))
end function
M_m = Math.abs(M);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D && D < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D, double h, double l, double d_m) {
return w0 * (1.0 + ((h * (Math.pow((M_m * (D / d_m)), 2.0) / l)) * -0.125));
}
M_m = math.fabs(M) d_m = math.fabs(d) [w0, M_m, D, h, l, d_m] = sort([w0, M_m, D, h, l, d_m]) def code(w0, M_m, D, h, l, d_m): return w0 * (1.0 + ((h * (math.pow((M_m * (D / d_m)), 2.0) / l)) * -0.125))
M_m = abs(M) d_m = abs(d) w0, M_m, D, h, l, d_m = sort([w0, M_m, D, h, l, d_m]) function code(w0, M_m, D, h, l, d_m) return Float64(w0 * Float64(1.0 + Float64(Float64(h * Float64((Float64(M_m * Float64(D / d_m)) ^ 2.0) / l)) * -0.125))) end
M_m = abs(M);
d_m = abs(d);
w0, M_m, D, h, l, d_m = num2cell(sort([w0, M_m, D, h, l, d_m])){:}
function tmp = code(w0, M_m, D, h, l, d_m)
tmp = w0 * (1.0 + ((h * (((M_m * (D / d_m)) ^ 2.0) / l)) * -0.125));
end
M_m = N[Abs[M], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d$95$m_] := N[(w0 * N[(1.0 + N[(N[(h * N[(N[Power[N[(M$95$m * N[(D / d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D, h, l, d_m] = \mathsf{sort}([w0, M_m, D, h, l, d_m])\\
\\
w0 \cdot \left(1 + \left(h \cdot \frac{{\left(M_m \cdot \frac{D}{d_m}\right)}^{2}}{\ell}\right) \cdot -0.125\right)
\end{array}
Initial program 82.5%
Simplified81.3%
Taylor expanded in M around 0 54.2%
*-commutative54.2%
times-frac55.9%
Simplified55.9%
add-sqr-sqrt55.9%
sqrt-div55.9%
unpow255.9%
sqrt-prod29.4%
add-sqr-sqrt49.1%
unpow249.1%
sqrt-prod23.1%
add-sqr-sqrt49.7%
sqrt-div49.7%
unpow249.7%
sqrt-prod29.3%
add-sqr-sqrt55.8%
unpow255.8%
sqrt-prod31.6%
add-sqr-sqrt67.2%
Applied egg-rr67.2%
expm1-log1p-u49.4%
expm1-udef47.9%
associate-/l*46.4%
Applied egg-rr46.4%
expm1-def47.9%
expm1-log1p66.1%
Simplified66.1%
expm1-log1p-u52.5%
expm1-udef52.5%
associate-*r/52.9%
pow252.9%
pow-prod-down61.0%
Applied egg-rr61.0%
expm1-def61.0%
expm1-log1p75.4%
associate-/r/79.2%
*-commutative79.2%
Simplified79.2%
Final simplification79.2%
M_m = (fabs.f64 M) d_m = (fabs.f64 d) NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function. (FPCore (w0 M_m D h l d_m) :precision binary64 w0)
M_m = fabs(M);
d_m = fabs(d);
assert(w0 < M_m && M_m < D && D < h && h < l && l < d_m);
double code(double w0, double M_m, double D, double h, double l, double d_m) {
return w0;
}
M_m = abs(M)
d_m = abs(d)
NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d, h, l, d_m)
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_m
code = w0
end function
M_m = Math.abs(M);
d_m = Math.abs(d);
assert w0 < M_m && M_m < D && D < h && h < l && l < d_m;
public static double code(double w0, double M_m, double D, double h, double l, double d_m) {
return w0;
}
M_m = math.fabs(M) d_m = math.fabs(d) [w0, M_m, D, h, l, d_m] = sort([w0, M_m, D, h, l, d_m]) def code(w0, M_m, D, h, l, d_m): return w0
M_m = abs(M) d_m = abs(d) w0, M_m, D, h, l, d_m = sort([w0, M_m, D, h, l, d_m]) function code(w0, M_m, D, h, l, d_m) return w0 end
M_m = abs(M);
d_m = abs(d);
w0, M_m, D, h, l, d_m = num2cell(sort([w0, M_m, D, h, l, d_m])){:}
function tmp = code(w0, M_m, D, h, l, d_m)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] d_m = N[Abs[d], $MachinePrecision] NOTE: w0, M_m, D, h, l, and d_m should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D_, h_, l_, d$95$m_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
d_m = \left|d\right|
\\
[w0, M_m, D, h, l, d_m] = \mathsf{sort}([w0, M_m, D, h, l, d_m])\\
\\
w0
\end{array}
Initial program 82.5%
Simplified81.3%
Taylor expanded in M around 0 67.7%
Final simplification67.7%
herbie shell --seed 2023318
(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))))))