
(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 8 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}
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(pow
(*
(cbrt w0)
(exp
(*
0.16666666666666666
(+
(log (* -0.25 (/ (* h (pow M 2.0)) l)))
(+ (* -2.0 (log d)) (* 2.0 (log D)))))))
3.0)
(if (<= t_0 0.5) (* w0 (sqrt (- 1.0 t_0))) w0))))M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = pow((cbrt(w0) * exp((0.16666666666666666 * (log((-0.25 * ((h * pow(M, 2.0)) / l))) + ((-2.0 * log(d)) + (2.0 * log(D))))))), 3.0);
} else if (t_0 <= 0.5) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M = Math.abs(M);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.pow((Math.cbrt(w0) * Math.exp((0.16666666666666666 * (Math.log((-0.25 * ((h * Math.pow(M, 2.0)) / l))) + ((-2.0 * Math.log(d)) + (2.0 * Math.log(D))))))), 3.0);
} else if (t_0 <= 0.5) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(cbrt(w0) * exp(Float64(0.16666666666666666 * Float64(log(Float64(-0.25 * Float64(Float64(h * (M ^ 2.0)) / l))) + Float64(Float64(-2.0 * log(d)) + Float64(2.0 * log(D))))))) ^ 3.0; elseif (t_0 <= 0.5) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = w0; end return tmp end
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Power[w0, 1/3], $MachinePrecision] * N[Exp[N[(0.16666666666666666 * N[(N[Log[N[(-0.25 * N[(N[(h * N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(-2.0 * N[Log[d], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Log[D], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $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|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(\log \left(-0.25 \cdot \frac{h \cdot {M}^{2}}{\ell}\right) + \left(-2 \cdot \log d + 2 \cdot \log D\right)\right)}\right)}^{3}\\
\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%
Applied egg-rr57.3%
Taylor expanded in d around 0 24.8%
unpow1/335.0%
*-lft-identity35.0%
exp-prod34.8%
distribute-lft-neg-in34.8%
metadata-eval34.8%
*-commutative34.8%
associate-*r/33.5%
Simplified33.5%
Taylor expanded in D around 0 15.0%
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 D around 0 72.4%
Final simplification78.0%
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))
(if (<= t_0 (- INFINITY))
(pow
(*
(cbrt w0)
(exp
(*
0.16666666666666666
(+
(* -2.0 (log d))
(log (* (/ (* h (pow (* M D) 2.0)) l) (- 0.25)))))))
3.0)
(if (<= t_0 0.5) (* w0 (sqrt (- 1.0 t_0))) w0))))M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = pow((cbrt(w0) * exp((0.16666666666666666 * ((-2.0 * log(d)) + log((((h * pow((M * D), 2.0)) / l) * -0.25)))))), 3.0);
} else if (t_0 <= 0.5) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M = Math.abs(M);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = Math.pow((Math.cbrt(w0) * Math.exp((0.16666666666666666 * ((-2.0 * Math.log(d)) + Math.log((((h * Math.pow((M * D), 2.0)) / l) * -0.25)))))), 3.0);
} else if (t_0 <= 0.5) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(cbrt(w0) * exp(Float64(0.16666666666666666 * Float64(Float64(-2.0 * log(d)) + log(Float64(Float64(Float64(h * (Float64(M * D) ^ 2.0)) / l) * Float64(-0.25))))))) ^ 3.0; elseif (t_0 <= 0.5) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = w0; end return tmp end
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[Power[N[(N[Power[w0, 1/3], $MachinePrecision] * N[Exp[N[(0.16666666666666666 * N[(N[(-2.0 * N[Log[d], $MachinePrecision]), $MachinePrecision] + N[Log[N[(N[(N[(h * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * (-0.25)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $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|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;{\left(\sqrt[3]{w0} \cdot e^{0.16666666666666666 \cdot \left(-2 \cdot \log d + \log \left(\frac{h \cdot {\left(M \cdot D\right)}^{2}}{\ell} \cdot \left(-0.25\right)\right)\right)}\right)}^{3}\\
\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%
Applied egg-rr57.3%
Taylor expanded in d around 0 24.8%
expm1-log1p-u11.5%
expm1-udef9.9%
associate-*r*9.9%
pow-prod-down9.9%
Applied egg-rr9.9%
expm1-def11.9%
expm1-log1p25.2%
*-commutative25.2%
Simplified25.2%
expm1-log1p-u25.2%
expm1-udef20.3%
unpow1/320.5%
*-un-lft-identity20.5%
Applied egg-rr20.5%
expm1-def26.8%
expm1-log1p38.4%
Simplified38.4%
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 D around 0 72.4%
Final simplification83.5%
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))) (if (<= t_0 0.5) (* w0 (sqrt (- 1.0 t_0))) w0)))
M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= 0.5) {
tmp = w0 * sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
real(8) :: t_0
real(8) :: tmp
t_0 = (((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l)
if (t_0 <= 0.5d0) then
tmp = w0 * sqrt((1.0d0 - t_0))
else
tmp = w0
end if
code = tmp
end function
M = Math.abs(M);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l);
double tmp;
if (t_0 <= 0.5) {
tmp = w0 * Math.sqrt((1.0 - t_0));
} else {
tmp = w0;
}
return tmp;
}
M = abs(M) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): t_0 = math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l) tmp = 0 if t_0 <= 0.5: tmp = w0 * math.sqrt((1.0 - t_0)) else: tmp = w0 return tmp
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) t_0 = Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l)) tmp = 0.0 if (t_0 <= 0.5) tmp = Float64(w0 * sqrt(Float64(1.0 - t_0))); else tmp = w0; end return tmp end
M = abs(M)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
t_0 = (((M * D) / (2.0 * d)) ^ 2.0) * (h / l);
tmp = 0.0;
if (t_0 <= 0.5)
tmp = w0 * sqrt((1.0 - t_0));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $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|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\\
\mathbf{if}\;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)) < 0.5Initial program 89.1%
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 D around 0 72.4%
Final simplification87.9%
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(if (<= (/ h l) -2e+288)
(* w0 (fma -0.125 (* h (/ (pow (* M (/ D d)) 2.0) l)) 1.0))
(if (<= (/ h l) -1e-281)
(* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D 2.0) (/ M d)) 2.0)))))
w0)))M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((h / l) <= -2e+288) {
tmp = w0 * fma(-0.125, (h * (pow((M * (D / d)), 2.0) / l)), 1.0);
} else if ((h / l) <= -1e-281) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D / 2.0) * (M / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64(h / l) <= -2e+288) tmp = Float64(w0 * fma(-0.125, Float64(h * Float64((Float64(M * Float64(D / d)) ^ 2.0) / l)), 1.0)); elseif (Float64(h / l) <= -1e-281) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(Float64(D / 2.0) * Float64(M / d)) ^ 2.0))))); else tmp = w0; end return tmp end
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(h / l), $MachinePrecision], -2e+288], N[(w0 * N[(-0.125 * N[(h * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $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[(N[(D / 2.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]]
\begin{array}{l}
M = |M|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{h}{\ell} \leq -2 \cdot 10^{+288}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}, 1\right)\\
\mathbf{elif}\;\frac{h}{\ell} \leq -1 \cdot 10^{-281}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (/.f64 h l) < -2e288Initial program 42.0%
Simplified42.0%
associate-*r/74.7%
frac-times74.7%
*-commutative74.7%
*-un-lft-identity74.7%
times-frac74.7%
metadata-eval74.7%
*-commutative74.7%
Applied egg-rr74.7%
add-sqr-sqrt55.3%
pow255.3%
sqrt-prod40.0%
sqrt-pow144.3%
metadata-eval44.3%
pow144.3%
associate-/l*44.5%
Applied egg-rr44.5%
Taylor expanded in D around 0 41.9%
+-commutative41.9%
fma-def41.9%
times-frac45.5%
associate-/l*30.4%
associate-*r/30.4%
unpow230.4%
unpow230.4%
times-frac41.9%
unpow241.9%
swap-sqr42.2%
unpow242.2%
associate-*l/42.2%
associate-/l*42.2%
Simplified42.2%
associate-/r/64.3%
associate-/r/64.3%
Applied egg-rr64.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 D around 0 93.8%
Final simplification85.9%
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* h (pow (* 0.5 (/ (* M D) d)) 2.0)) l)))))
M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((h * pow((0.5 * ((M * D) / d)), 2.0)) / l)));
}
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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 - ((h * ((0.5d0 * ((m * d) / d_1)) ** 2.0d0)) / l)))
end function
M = Math.abs(M);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - ((h * Math.pow((0.5 * ((M * D) / d)), 2.0)) / l)));
}
M = abs(M) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((h * math.pow((0.5 * ((M * D) / d)), 2.0)) / l)))
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(0.5 * Float64(Float64(M * D) / d)) ^ 2.0)) / l)))) end
M = abs(M)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0 * sqrt((1.0 - ((h * ((0.5 * ((M * D) / d)) ^ 2.0)) / l)));
end
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(0.5 * N[(N[(M * D), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(0.5 \cdot \frac{M \cdot D}{d}\right)}^{2}}{\ell}}
\end{array}
Initial program 82.5%
Simplified81.3%
associate-*r/85.2%
frac-times86.4%
*-commutative86.4%
*-un-lft-identity86.4%
times-frac86.4%
metadata-eval86.4%
*-commutative86.4%
Applied egg-rr86.4%
Final simplification86.4%
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (* w0 (fma -0.125 (* h (/ (pow (* M (/ D d)) 2.0) l)) 1.0)))
M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * fma(-0.125, (h * (pow((M * (D / d)), 2.0) / l)), 1.0);
}
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return Float64(w0 * fma(-0.125, Float64(h * Float64((Float64(M * Float64(D / d)) ^ 2.0) / l)), 1.0)) end
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[(-0.125 * N[(h * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \mathsf{fma}\left(-0.125, h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}, 1\right)
\end{array}
Initial program 82.5%
Simplified81.3%
associate-*r/85.2%
frac-times86.4%
*-commutative86.4%
*-un-lft-identity86.4%
times-frac86.4%
metadata-eval86.4%
*-commutative86.4%
Applied egg-rr86.4%
add-sqr-sqrt67.6%
pow267.6%
sqrt-prod48.0%
sqrt-pow149.2%
metadata-eval49.2%
pow149.2%
associate-/l*49.3%
Applied egg-rr49.3%
Taylor expanded in D around 0 54.2%
+-commutative54.2%
fma-def54.2%
times-frac55.9%
associate-/l*55.2%
associate-*r/55.6%
unpow255.6%
unpow255.6%
times-frac66.5%
unpow266.5%
swap-sqr75.4%
unpow275.4%
associate-*l/75.8%
associate-/l*75.4%
Simplified75.4%
associate-/r/79.3%
associate-/r/79.2%
Applied egg-rr79.2%
Final simplification79.2%
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (let* ((t_0 (* M (/ D d)))) (if (<= D 1.55e+113) w0 (* w0 (fma -0.125 (/ (* t_0 t_0) (/ l h)) 1.0)))))
M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = M * (D / d);
double tmp;
if (D <= 1.55e+113) {
tmp = w0;
} else {
tmp = w0 * fma(-0.125, ((t_0 * t_0) / (l / h)), 1.0);
}
return tmp;
}
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) t_0 = Float64(M * Float64(D / d)) tmp = 0.0 if (D <= 1.55e+113) tmp = w0; else tmp = Float64(w0 * fma(-0.125, Float64(Float64(t_0 * t_0) / Float64(l / h)), 1.0)); end return tmp end
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[D, 1.55e+113], w0, N[(w0 * N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M = |M|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
t_0 := M \cdot \frac{D}{d}\\
\mathbf{if}\;D \leq 1.55 \cdot 10^{+113}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \mathsf{fma}\left(-0.125, \frac{t_0 \cdot t_0}{\frac{\ell}{h}}, 1\right)\\
\end{array}
\end{array}
if D < 1.54999999999999996e113Initial program 84.0%
Simplified82.6%
Taylor expanded in D around 0 73.5%
if 1.54999999999999996e113 < D Initial program 74.1%
Simplified73.5%
associate-*r/73.8%
frac-times74.5%
*-commutative74.5%
*-un-lft-identity74.5%
times-frac74.5%
metadata-eval74.5%
*-commutative74.5%
Applied egg-rr74.5%
add-sqr-sqrt35.6%
pow235.6%
sqrt-prod32.6%
sqrt-pow135.3%
metadata-eval35.3%
pow135.3%
associate-/l*35.3%
Applied egg-rr35.3%
Taylor expanded in D around 0 41.8%
+-commutative41.8%
fma-def41.8%
times-frac44.7%
associate-/l*44.6%
associate-*r/41.9%
unpow241.9%
unpow241.9%
times-frac56.0%
unpow256.0%
swap-sqr61.5%
unpow261.5%
associate-*l/61.7%
associate-/l*61.7%
Simplified61.7%
unpow261.7%
associate-/r/61.5%
associate-/r/61.5%
Applied egg-rr61.5%
Final simplification71.8%
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 w0)
M = abs(M);
d = abs(d);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
NOTE: M should be positive before calling this function
NOTE: d should be positive before calling this function
NOTE: M and D should be sorted in increasing order before calling this function.
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
end function
M = Math.abs(M);
d = Math.abs(d);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
M = abs(M) d = abs(d) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0
M = abs(M) d = abs(d) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return w0 end
M = abs(M)
d = abs(d)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0;
end
NOTE: M should be positive before calling this function NOTE: d should be positive before calling this function NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
M = |M|\\
d = |d|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Initial program 82.5%
Simplified81.3%
Taylor expanded in D 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))))))