
(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: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(if (<= h -2e-309)
(* w0 (sqrt (+ 1.0 (/ -1.0 (/ l (* h (pow (* (* D M) (/ 0.5 d)) 2.0)))))))
(*
w0
(sqrt
(+ 1.0 (/ -1.0 (/ l (pow (* (* D (* M (/ 0.5 d))) (sqrt h)) 2.0))))))))M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -2e-309) {
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * sqrt((1.0 + (-1.0 / (l / pow(((D * (M * (0.5 / d))) * sqrt(h)), 2.0)))));
}
return tmp;
}
NOTE: M 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) :: tmp
if (h <= (-2d-309)) then
tmp = w0 * sqrt((1.0d0 + ((-1.0d0) / (l / (h * (((d * m) * (0.5d0 / d_1)) ** 2.0d0))))))
else
tmp = w0 * sqrt((1.0d0 + ((-1.0d0) / (l / (((d * (m * (0.5d0 / d_1))) * sqrt(h)) ** 2.0d0)))))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -2e-309) {
tmp = w0 * Math.sqrt((1.0 + (-1.0 / (l / (h * Math.pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * Math.sqrt((1.0 + (-1.0 / (l / Math.pow(((D * (M * (0.5 / d))) * Math.sqrt(h)), 2.0)))));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if h <= -2e-309: tmp = w0 * math.sqrt((1.0 + (-1.0 / (l / (h * math.pow(((D * M) * (0.5 / d)), 2.0)))))) else: tmp = w0 * math.sqrt((1.0 + (-1.0 / (l / math.pow(((D * (M * (0.5 / d))) * math.sqrt(h)), 2.0))))) return tmp
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (h <= -2e-309) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-1.0 / Float64(l / Float64(h * (Float64(Float64(D * M) * Float64(0.5 / d)) ^ 2.0))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-1.0 / Float64(l / (Float64(Float64(D * Float64(M * Float64(0.5 / d))) * sqrt(h)) ^ 2.0)))))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (h <= -2e-309)
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * (((D * M) * (0.5 / d)) ^ 2.0))))));
else
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (((D * (M * (0.5 / d))) * sqrt(h)) ^ 2.0)))));
end
tmp_2 = tmp;
end
NOTE: M 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[h, -2e-309], N[(w0 * N[Sqrt[N[(1.0 + N[(-1.0 / N[(l / N[(h * N[Power[N[(N[(D * M), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 + N[(-1.0 / N[(l / N[Power[N[(N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -2 \cdot 10^{-309}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot {\left(\left(D \cdot M\right) \cdot \frac{0.5}{d}\right)}^{2}}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{{\left(\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right) \cdot \sqrt{h}\right)}^{2}}}}\\
\end{array}
\end{array}
if h < -1.9999999999999988e-309Initial program 86.3%
Simplified87.1%
associate-*r/93.3%
frac-times92.5%
*-commutative92.5%
clear-num92.5%
*-commutative92.5%
*-commutative92.5%
frac-times93.3%
frac-times92.5%
*-commutative92.5%
div-inv92.5%
*-commutative92.5%
associate-/r*92.5%
metadata-eval92.5%
Applied egg-rr92.5%
if -1.9999999999999988e-309 < h Initial program 79.3%
Simplified78.5%
associate-*r/81.4%
frac-times82.0%
*-commutative82.0%
clear-num82.0%
*-commutative82.0%
*-commutative82.0%
frac-times81.4%
frac-times82.0%
*-commutative82.0%
div-inv82.0%
*-commutative82.0%
associate-/r*82.0%
metadata-eval82.0%
Applied egg-rr82.0%
add-sqr-sqrt82.0%
pow282.0%
*-commutative82.0%
sqrt-prod82.0%
unpow282.0%
sqrt-prod53.1%
add-sqr-sqrt86.5%
associate-*l*85.4%
Applied egg-rr85.4%
Final simplification89.0%
NOTE: M 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 -1e-308) (* w0 (sqrt (+ 1.0 (/ -1.0 (/ l (* h (pow (* (* D M) (/ 0.5 d)) 2.0))))))) (* w0 (sqrt (- 1.0 (/ (pow (* 0.5 (* (sqrt h) (/ (* D M) d))) 2.0) l))))))
M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -1e-308) {
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * sqrt((1.0 - (pow((0.5 * (sqrt(h) * ((D * M) / d))), 2.0) / l)));
}
return tmp;
}
NOTE: M 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) :: tmp
if (h <= (-1d-308)) then
tmp = w0 * sqrt((1.0d0 + ((-1.0d0) / (l / (h * (((d * m) * (0.5d0 / d_1)) ** 2.0d0))))))
else
tmp = w0 * sqrt((1.0d0 - (((0.5d0 * (sqrt(h) * ((d * m) / d_1))) ** 2.0d0) / l)))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -1e-308) {
tmp = w0 * Math.sqrt((1.0 + (-1.0 / (l / (h * Math.pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((0.5 * (Math.sqrt(h) * ((D * M) / d))), 2.0) / l)));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if h <= -1e-308: tmp = w0 * math.sqrt((1.0 + (-1.0 / (l / (h * math.pow(((D * M) * (0.5 / d)), 2.0)))))) else: tmp = w0 * math.sqrt((1.0 - (math.pow((0.5 * (math.sqrt(h) * ((D * M) / d))), 2.0) / l))) return tmp
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (h <= -1e-308) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-1.0 / Float64(l / Float64(h * (Float64(Float64(D * M) * Float64(0.5 / d)) ^ 2.0))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(0.5 * Float64(sqrt(h) * Float64(Float64(D * M) / d))) ^ 2.0) / l)))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (h <= -1e-308)
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * (((D * M) * (0.5 / d)) ^ 2.0))))));
else
tmp = w0 * sqrt((1.0 - (((0.5 * (sqrt(h) * ((D * M) / d))) ^ 2.0) / l)));
end
tmp_2 = tmp;
end
NOTE: M 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[h, -1e-308], N[(w0 * N[Sqrt[N[(1.0 + N[(-1.0 / N[(l / N[(h * N[Power[N[(N[(D * M), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(0.5 * N[(N[Sqrt[h], $MachinePrecision] * N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1 \cdot 10^{-308}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot {\left(\left(D \cdot M\right) \cdot \frac{0.5}{d}\right)}^{2}}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(0.5 \cdot \left(\sqrt{h} \cdot \frac{D \cdot M}{d}\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -9.9999999999999991e-309Initial program 86.3%
Simplified87.1%
associate-*r/93.3%
frac-times92.5%
*-commutative92.5%
clear-num92.5%
*-commutative92.5%
*-commutative92.5%
frac-times93.3%
frac-times92.5%
*-commutative92.5%
div-inv92.5%
*-commutative92.5%
associate-/r*92.5%
metadata-eval92.5%
Applied egg-rr92.5%
if -9.9999999999999991e-309 < h Initial program 79.3%
Simplified78.5%
*-commutative78.5%
frac-times79.3%
*-commutative79.3%
associate-*l/82.0%
*-commutative82.0%
frac-times81.4%
frac-times82.0%
*-commutative82.0%
div-inv82.0%
*-commutative82.0%
associate-/r*82.0%
metadata-eval82.0%
Applied egg-rr82.0%
add-sqr-sqrt82.0%
pow282.0%
*-commutative82.0%
sqrt-prod82.0%
unpow282.0%
sqrt-prod53.1%
add-sqr-sqrt86.5%
associate-*l*85.4%
Applied egg-rr85.4%
associate-*l*85.4%
Simplified85.4%
Taylor expanded in D around 0 86.5%
Final simplification89.5%
NOTE: M 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 -1e-308) (* w0 (sqrt (+ 1.0 (/ -1.0 (/ l (* h (pow (* (* D M) (/ 0.5 d)) 2.0))))))) (* w0 (sqrt (- 1.0 (/ (pow (* D (* (sqrt h) (/ M (/ d 0.5)))) 2.0) l))))))
M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -1e-308) {
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * sqrt((1.0 - (pow((D * (sqrt(h) * (M / (d / 0.5)))), 2.0) / l)));
}
return tmp;
}
NOTE: M 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) :: tmp
if (h <= (-1d-308)) then
tmp = w0 * sqrt((1.0d0 + ((-1.0d0) / (l / (h * (((d * m) * (0.5d0 / d_1)) ** 2.0d0))))))
else
tmp = w0 * sqrt((1.0d0 - (((d * (sqrt(h) * (m / (d_1 / 0.5d0)))) ** 2.0d0) / l)))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -1e-308) {
tmp = w0 * Math.sqrt((1.0 + (-1.0 / (l / (h * Math.pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((D * (Math.sqrt(h) * (M / (d / 0.5)))), 2.0) / l)));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if h <= -1e-308: tmp = w0 * math.sqrt((1.0 + (-1.0 / (l / (h * math.pow(((D * M) * (0.5 / d)), 2.0)))))) else: tmp = w0 * math.sqrt((1.0 - (math.pow((D * (math.sqrt(h) * (M / (d / 0.5)))), 2.0) / l))) return tmp
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (h <= -1e-308) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-1.0 / Float64(l / Float64(h * (Float64(Float64(D * M) * Float64(0.5 / d)) ^ 2.0))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(D * Float64(sqrt(h) * Float64(M / Float64(d / 0.5)))) ^ 2.0) / l)))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (h <= -1e-308)
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * (((D * M) * (0.5 / d)) ^ 2.0))))));
else
tmp = w0 * sqrt((1.0 - (((D * (sqrt(h) * (M / (d / 0.5)))) ^ 2.0) / l)));
end
tmp_2 = tmp;
end
NOTE: M 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[h, -1e-308], N[(w0 * N[Sqrt[N[(1.0 + N[(-1.0 / N[(l / N[(h * N[Power[N[(N[(D * M), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(D * N[(N[Sqrt[h], $MachinePrecision] * N[(M / N[(d / 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1 \cdot 10^{-308}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot {\left(\left(D \cdot M\right) \cdot \frac{0.5}{d}\right)}^{2}}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(D \cdot \left(\sqrt{h} \cdot \frac{M}{\frac{d}{0.5}}\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -9.9999999999999991e-309Initial program 86.3%
Simplified87.1%
associate-*r/93.3%
frac-times92.5%
*-commutative92.5%
clear-num92.5%
*-commutative92.5%
*-commutative92.5%
frac-times93.3%
frac-times92.5%
*-commutative92.5%
div-inv92.5%
*-commutative92.5%
associate-/r*92.5%
metadata-eval92.5%
Applied egg-rr92.5%
if -9.9999999999999991e-309 < h Initial program 79.3%
Simplified78.5%
*-commutative78.5%
frac-times79.3%
*-commutative79.3%
associate-*l/82.0%
*-commutative82.0%
frac-times81.4%
frac-times82.0%
*-commutative82.0%
div-inv82.0%
*-commutative82.0%
associate-/r*82.0%
metadata-eval82.0%
Applied egg-rr82.0%
add-sqr-sqrt82.0%
pow282.0%
*-commutative82.0%
sqrt-prod82.0%
unpow282.0%
sqrt-prod53.1%
add-sqr-sqrt86.5%
associate-*l*85.4%
Applied egg-rr85.4%
associate-*l*85.4%
Simplified85.4%
expm1-log1p-u67.6%
expm1-udef64.5%
Applied egg-rr64.5%
expm1-def67.6%
expm1-log1p85.4%
*-commutative85.4%
associate-/l*85.4%
Simplified85.4%
Final simplification89.0%
NOTE: M 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 -1e-308) (* w0 (sqrt (+ 1.0 (/ -1.0 (/ l (* h (pow (* (* D M) (/ 0.5 d)) 2.0))))))) (* w0 (sqrt (- 1.0 (/ (pow (* D (* (* M (/ 0.5 d)) (sqrt h))) 2.0) l))))))
M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -1e-308) {
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * sqrt((1.0 - (pow((D * ((M * (0.5 / d)) * sqrt(h))), 2.0) / l)));
}
return tmp;
}
NOTE: M 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) :: tmp
if (h <= (-1d-308)) then
tmp = w0 * sqrt((1.0d0 + ((-1.0d0) / (l / (h * (((d * m) * (0.5d0 / d_1)) ** 2.0d0))))))
else
tmp = w0 * sqrt((1.0d0 - (((d * ((m * (0.5d0 / d_1)) * sqrt(h))) ** 2.0d0) / l)))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -1e-308) {
tmp = w0 * Math.sqrt((1.0 + (-1.0 / (l / (h * Math.pow(((D * M) * (0.5 / d)), 2.0))))));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow((D * ((M * (0.5 / d)) * Math.sqrt(h))), 2.0) / l)));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if h <= -1e-308: tmp = w0 * math.sqrt((1.0 + (-1.0 / (l / (h * math.pow(((D * M) * (0.5 / d)), 2.0)))))) else: tmp = w0 * math.sqrt((1.0 - (math.pow((D * ((M * (0.5 / d)) * math.sqrt(h))), 2.0) / l))) return tmp
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (h <= -1e-308) tmp = Float64(w0 * sqrt(Float64(1.0 + Float64(-1.0 / Float64(l / Float64(h * (Float64(Float64(D * M) * Float64(0.5 / d)) ^ 2.0))))))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(D * Float64(Float64(M * Float64(0.5 / d)) * sqrt(h))) ^ 2.0) / l)))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (h <= -1e-308)
tmp = w0 * sqrt((1.0 + (-1.0 / (l / (h * (((D * M) * (0.5 / d)) ^ 2.0))))));
else
tmp = w0 * sqrt((1.0 - (((D * ((M * (0.5 / d)) * sqrt(h))) ^ 2.0) / l)));
end
tmp_2 = tmp;
end
NOTE: M 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[h, -1e-308], N[(w0 * N[Sqrt[N[(1.0 + N[(-1.0 / N[(l / N[(h * N[Power[N[(N[(D * M), $MachinePrecision] * N[(0.5 / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(D * N[(N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1 \cdot 10^{-308}:\\
\;\;\;\;w0 \cdot \sqrt{1 + \frac{-1}{\frac{\ell}{h \cdot {\left(\left(D \cdot M\right) \cdot \frac{0.5}{d}\right)}^{2}}}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(D \cdot \left(\left(M \cdot \frac{0.5}{d}\right) \cdot \sqrt{h}\right)\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -9.9999999999999991e-309Initial program 86.3%
Simplified87.1%
associate-*r/93.3%
frac-times92.5%
*-commutative92.5%
clear-num92.5%
*-commutative92.5%
*-commutative92.5%
frac-times93.3%
frac-times92.5%
*-commutative92.5%
div-inv92.5%
*-commutative92.5%
associate-/r*92.5%
metadata-eval92.5%
Applied egg-rr92.5%
if -9.9999999999999991e-309 < h Initial program 79.3%
Simplified78.5%
*-commutative78.5%
frac-times79.3%
*-commutative79.3%
associate-*l/82.0%
*-commutative82.0%
frac-times81.4%
frac-times82.0%
*-commutative82.0%
div-inv82.0%
*-commutative82.0%
associate-/r*82.0%
metadata-eval82.0%
Applied egg-rr82.0%
add-sqr-sqrt82.0%
pow282.0%
*-commutative82.0%
sqrt-prod82.0%
unpow282.0%
sqrt-prod53.1%
add-sqr-sqrt86.5%
associate-*l*85.4%
Applied egg-rr85.4%
associate-*l*85.4%
Simplified85.4%
Final simplification89.0%
NOTE: M 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 (/ M (* d (/ 2.0 D))) 2.0) l))))))
M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (h * (pow((M / (d * (2.0 / D))), 2.0) / l))));
}
NOTE: M 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 * (((m / (d_1 * (2.0d0 / d))) ** 2.0d0) / l))))
end function
M = Math.abs(M);
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((M / (d * (2.0 / D))), 2.0) / l))));
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (h * (math.pow((M / (d * (2.0 / D))), 2.0) / l))))
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64((Float64(M / Float64(d * Float64(2.0 / D))) ^ 2.0) / l))))) end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0 * sqrt((1.0 - (h * (((M / (d * (2.0 / D))) ^ 2.0) / l))));
end
NOTE: M 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[(h * N[(N[Power[N[(M / N[(d * N[(2.0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0 \cdot \sqrt{1 - h \cdot \frac{{\left(\frac{M}{d \cdot \frac{2}{D}}\right)}^{2}}{\ell}}
\end{array}
Initial program 82.8%
Simplified82.9%
frac-times82.8%
*-commutative82.8%
clear-num82.8%
un-div-inv84.0%
*-commutative84.0%
frac-times84.0%
frac-times84.0%
*-commutative84.0%
div-inv84.0%
*-commutative84.0%
associate-/r*84.0%
metadata-eval84.0%
Applied egg-rr84.0%
associate-/r/87.6%
*-commutative87.6%
*-commutative87.6%
associate-*r*87.8%
associate-*r/87.8%
associate-*r/87.7%
/-rgt-identity87.7%
associate-/l*87.7%
metadata-eval87.7%
associate-*r/87.7%
associate-/l*87.6%
associate-/l/87.5%
Simplified87.5%
Final simplification87.5%
NOTE: M 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 (<= D 520000.0) w0 (+ w0 (* -0.125 (* (/ (* (* D M) (* D M)) l) (* (/ h d) (/ w0 d)))))))
M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 520000.0) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((((D * M) * (D * M)) / l) * ((h / d) * (w0 / d))));
}
return tmp;
}
NOTE: M 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) :: tmp
if (d <= 520000.0d0) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * ((((d * m) * (d * m)) / l) * ((h / d_1) * (w0 / d_1))))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 520000.0) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * ((((D * M) * (D * M)) / l) * ((h / d) * (w0 / d))));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if D <= 520000.0: tmp = w0 else: tmp = w0 + (-0.125 * ((((D * M) * (D * M)) / l) * ((h / d) * (w0 / d)))) return tmp
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 520000.0) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(Float64(D * M) * Float64(D * M)) / l) * Float64(Float64(h / d) * Float64(w0 / d))))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (D <= 520000.0)
tmp = w0;
else
tmp = w0 + (-0.125 * ((((D * M) * (D * M)) / l) * ((h / d) * (w0 / d))));
end
tmp_2 = tmp;
end
NOTE: M 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[D, 520000.0], w0, N[(w0 + N[(-0.125 * N[(N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(h / d), $MachinePrecision] * N[(w0 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;D \leq 520000:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\ell} \cdot \left(\frac{h}{d} \cdot \frac{w0}{d}\right)\right)\\
\end{array}
\end{array}
if D < 5.2e5Initial program 86.5%
Simplified85.6%
Taylor expanded in D around 0 75.8%
if 5.2e5 < D Initial program 70.5%
Simplified73.8%
Taylor expanded in D around 0 42.5%
expm1-log1p-u25.3%
expm1-udef24.9%
associate-*r*21.6%
pow-prod-down28.8%
*-commutative28.8%
*-commutative28.8%
Applied egg-rr28.8%
expm1-def29.1%
expm1-log1p48.2%
times-frac49.5%
*-commutative49.5%
Simplified49.5%
*-commutative49.5%
unpow249.5%
times-frac59.0%
Applied egg-rr59.0%
unpow259.0%
Applied egg-rr59.0%
Final simplification71.9%
NOTE: M 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 (<= D 4.2e-51) w0 (+ w0 (* -0.125 (/ (* (* D M) (* w0 (/ h d))) (* d (/ l (* D M))))))))
M = abs(M);
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 4.2e-51) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((D * M) * (w0 * (h / d))) / (d * (l / (D * M)))));
}
return tmp;
}
NOTE: M 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) :: tmp
if (d <= 4.2d-51) then
tmp = w0
else
tmp = w0 + ((-0.125d0) * (((d * m) * (w0 * (h / d_1))) / (d_1 * (l / (d * m)))))
end if
code = tmp
end function
M = Math.abs(M);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (D <= 4.2e-51) {
tmp = w0;
} else {
tmp = w0 + (-0.125 * (((D * M) * (w0 * (h / d))) / (d * (l / (D * M)))));
}
return tmp;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if D <= 4.2e-51: tmp = w0 else: tmp = w0 + (-0.125 * (((D * M) * (w0 * (h / d))) / (d * (l / (D * M))))) return tmp
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (D <= 4.2e-51) tmp = w0; else tmp = Float64(w0 + Float64(-0.125 * Float64(Float64(Float64(D * M) * Float64(w0 * Float64(h / d))) / Float64(d * Float64(l / Float64(D * M)))))); end return tmp end
M = abs(M)
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (D <= 4.2e-51)
tmp = w0;
else
tmp = w0 + (-0.125 * (((D * M) * (w0 * (h / d))) / (d * (l / (D * M)))));
end
tmp_2 = tmp;
end
NOTE: M 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[D, 4.2e-51], w0, N[(w0 + N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] * N[(w0 * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * N[(l / N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M = |M|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;D \leq 4.2 \cdot 10^{-51}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 + -0.125 \cdot \frac{\left(D \cdot M\right) \cdot \left(w0 \cdot \frac{h}{d}\right)}{d \cdot \frac{\ell}{D \cdot M}}\\
\end{array}
\end{array}
if D < 4.20000000000000003e-51Initial program 87.0%
Simplified86.0%
Taylor expanded in D around 0 75.3%
if 4.20000000000000003e-51 < D Initial program 71.1%
Simplified74.1%
Taylor expanded in D around 0 45.0%
expm1-log1p-u29.9%
expm1-udef29.5%
associate-*r*26.6%
pow-prod-down32.9%
*-commutative32.9%
*-commutative32.9%
Applied egg-rr32.9%
expm1-def33.2%
expm1-log1p50.1%
times-frac51.2%
*-commutative51.2%
Simplified51.2%
*-commutative51.2%
unpow251.2%
times-frac61.0%
Applied egg-rr61.0%
*-commutative61.0%
associate-*l/61.0%
pow261.0%
associate-/l*62.5%
frac-times65.7%
Applied egg-rr65.7%
Final simplification72.8%
NOTE: M 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);
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: 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);
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
M = abs(M) [M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0
M = abs(M) M, D = sort([M, D]) function code(w0, M, D, h, l, d) return w0 end
M = abs(M)
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: 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|\\
[M, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Initial program 82.8%
Simplified82.9%
Taylor expanded in D around 0 65.5%
Final simplification65.5%
herbie shell --seed 2023306
(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))))))