
(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}
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (let* ((t_0 (* 0.5 (* D_m (/ M_m d))))) (* w0 (sqrt (- 1.0 (* h (* t_0 (/ t_0 l))))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = 0.5 * (D_m * (M_m / d));
return w0 * sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
real(8) :: t_0
t_0 = 0.5d0 * (d_m * (m_m / d))
code = w0 * sqrt((1.0d0 - (h * (t_0 * (t_0 / l)))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = 0.5 * (D_m * (M_m / d));
return w0 * Math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): t_0 = 0.5 * (D_m * (M_m / d)) return w0 * math.sqrt((1.0 - (h * (t_0 * (t_0 / l)))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(0.5 * Float64(D_m * Float64(M_m / d))) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(t_0 * Float64(t_0 / l)))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
t_0 = 0.5 * (D_m * (M_m / d));
tmp = w0 * sqrt((1.0 - (h * (t_0 * (t_0 / l)))));
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(0.5 * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\\
w0 \cdot \sqrt{1 - h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right)}
\end{array}
\end{array}
Initial program 78.3%
Simplified77.7%
expm1-log1p-u55.5%
expm1-udef55.5%
log1p-udef55.5%
add-exp-log77.7%
+-commutative77.7%
associate-*l/78.3%
div-inv78.3%
associate-*l*78.2%
associate-/r*78.2%
metadata-eval78.2%
Applied egg-rr78.2%
associate--l+78.2%
metadata-eval78.2%
+-rgt-identity78.2%
associate-*r/85.4%
associate-*l/86.9%
*-commutative86.9%
associate-*r*86.9%
*-commutative86.9%
associate-*l/86.9%
*-commutative86.9%
associate-*r/86.9%
associate-*r/86.3%
Simplified86.3%
Taylor expanded in D around 0 86.9%
unpow286.9%
*-un-lft-identity86.9%
times-frac89.1%
associate-*r/87.8%
associate-*r/88.2%
Applied egg-rr88.2%
Final simplification88.2%
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
(FPCore (w0 M_m D_m h l d)
:precision binary64
(*
w0
(sqrt
(-
1.0
(* h (* (* 0.5 (* D_m (/ M_m d))) (* (* M_m (/ D_m d)) (/ 0.5 l))))))))M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * sqrt((1.0 - (h * ((0.5 * (D_m * (M_m / d))) * ((M_m * (D_m / d)) * (0.5 / l))))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
code = w0 * sqrt((1.0d0 - (h * ((0.5d0 * (d_m * (m_m / d))) * ((m_m * (d_m / d)) * (0.5d0 / l))))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (h * ((0.5 * (D_m * (M_m / d))) * ((M_m * (D_m / d)) * (0.5 / l))))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 * math.sqrt((1.0 - (h * ((0.5 * (D_m * (M_m / d))) * ((M_m * (D_m / d)) * (0.5 / l))))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(h * Float64(Float64(0.5 * Float64(D_m * Float64(M_m / d))) * Float64(Float64(M_m * Float64(D_m / d)) * Float64(0.5 / l))))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 * sqrt((1.0 - (h * ((0.5 * (D_m * (M_m / d))) * ((M_m * (D_m / d)) * (0.5 / l))))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(h * N[(N[(0.5 * N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision] * N[(0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 \cdot \sqrt{1 - h \cdot \left(\left(0.5 \cdot \left(D_m \cdot \frac{M_m}{d}\right)\right) \cdot \left(\left(M_m \cdot \frac{D_m}{d}\right) \cdot \frac{0.5}{\ell}\right)\right)}
\end{array}
Initial program 78.3%
Simplified77.7%
expm1-log1p-u55.5%
expm1-udef55.5%
log1p-udef55.5%
add-exp-log77.7%
+-commutative77.7%
associate-*l/78.3%
div-inv78.3%
associate-*l*78.2%
associate-/r*78.2%
metadata-eval78.2%
Applied egg-rr78.2%
associate--l+78.2%
metadata-eval78.2%
+-rgt-identity78.2%
associate-*r/85.4%
associate-*l/86.9%
*-commutative86.9%
associate-*r*86.9%
*-commutative86.9%
associate-*l/86.9%
*-commutative86.9%
associate-*r/86.9%
associate-*r/86.3%
Simplified86.3%
Taylor expanded in D around 0 86.9%
unpow286.9%
*-un-lft-identity86.9%
times-frac89.1%
associate-*r/87.8%
associate-*r/88.2%
Applied egg-rr88.2%
Taylor expanded in D around 0 83.5%
associate-/r*87.8%
associate-*r/88.2%
associate-*r/88.2%
*-commutative88.2%
associate-*r/88.2%
associate-*r/87.8%
associate-*l/87.4%
Simplified87.4%
Final simplification87.4%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (let* ((t_0 (* D_m (/ M_m d)))) (* w0 (fma (* h (* t_0 (/ t_0 l))) -0.125 1.0))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * (M_m / d);
return w0 * fma((h * (t_0 * (t_0 / l))), -0.125, 1.0);
}
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(D_m * Float64(M_m / d)) return Float64(w0 * fma(Float64(h * Float64(t_0 * Float64(t_0 / l))), -0.125, 1.0)) end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, N[(w0 * N[(N[(h * N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D_m \cdot \frac{M_m}{d}\\
w0 \cdot \mathsf{fma}\left(h \cdot \left(t_0 \cdot \frac{t_0}{\ell}\right), -0.125, 1\right)
\end{array}
\end{array}
Initial program 78.3%
Simplified77.7%
expm1-log1p-u55.5%
expm1-udef55.5%
log1p-udef55.5%
add-exp-log77.7%
+-commutative77.7%
associate-*l/78.3%
div-inv78.3%
associate-*l*78.2%
associate-/r*78.2%
metadata-eval78.2%
Applied egg-rr78.2%
associate--l+78.2%
metadata-eval78.2%
+-rgt-identity78.2%
associate-*r/85.4%
associate-*l/86.9%
*-commutative86.9%
associate-*r*86.9%
*-commutative86.9%
associate-*l/86.9%
*-commutative86.9%
associate-*r/86.9%
associate-*r/86.3%
Simplified86.3%
Taylor expanded in h around 0 54.2%
+-commutative54.2%
*-commutative54.2%
fma-def54.2%
Simplified80.1%
associate-*r/80.9%
pow280.9%
*-un-lft-identity80.9%
times-frac82.1%
associate-*r/81.3%
associate-*r/81.3%
Applied egg-rr81.3%
Final simplification81.3%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= M_m 1.42) w0 (* -0.125 (* h (* (/ w0 l) (pow (* M_m (/ D_m d)) 2.0))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 1.42) {
tmp = w0;
} else {
tmp = -0.125 * (h * ((w0 / l) * pow((M_m * (D_m / d)), 2.0)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
real(8) :: tmp
if (m_m <= 1.42d0) then
tmp = w0
else
tmp = (-0.125d0) * (h * ((w0 / l) * ((m_m * (d_m / d)) ** 2.0d0)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 1.42) {
tmp = w0;
} else {
tmp = -0.125 * (h * ((w0 / l) * Math.pow((M_m * (D_m / d)), 2.0)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if M_m <= 1.42: tmp = w0 else: tmp = -0.125 * (h * ((w0 / l) * math.pow((M_m * (D_m / d)), 2.0))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (M_m <= 1.42) tmp = w0; else tmp = Float64(-0.125 * Float64(h * Float64(Float64(w0 / l) * (Float64(M_m * Float64(D_m / d)) ^ 2.0)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (M_m <= 1.42)
tmp = w0;
else
tmp = -0.125 * (h * ((w0 / l) * ((M_m * (D_m / d)) ^ 2.0)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 1.42], w0, N[(-0.125 * N[(h * N[(N[(w0 / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 1.42:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(h \cdot \left(\frac{w0}{\ell} \cdot {\left(M_m \cdot \frac{D_m}{d}\right)}^{2}\right)\right)\\
\end{array}
\end{array}
if M < 1.4199999999999999Initial program 80.9%
Simplified80.7%
Taylor expanded in M around 0 74.0%
if 1.4199999999999999 < M Initial program 68.6%
Simplified66.7%
expm1-log1p-u29.1%
expm1-udef29.1%
log1p-udef29.1%
add-exp-log66.7%
+-commutative66.7%
associate-*l/68.6%
div-inv68.6%
associate-*l*70.3%
associate-/r*70.3%
metadata-eval70.3%
Applied egg-rr70.3%
associate--l+70.3%
metadata-eval70.3%
+-rgt-identity70.3%
associate-*r/70.5%
associate-*l/75.7%
*-commutative75.7%
associate-*r*74.0%
*-commutative74.0%
associate-*l/74.0%
*-commutative74.0%
associate-*r/74.0%
associate-*r/72.1%
Simplified72.1%
Taylor expanded in h around 0 44.6%
+-commutative44.6%
*-commutative44.6%
fma-def44.6%
Simplified62.0%
Taylor expanded in D around inf 25.0%
associate-*r*25.0%
times-frac25.3%
unpow225.3%
unpow225.3%
unpow225.3%
swap-sqr27.5%
times-frac30.0%
associate-*r/29.9%
associate-*r/30.0%
unpow230.0%
*-commutative30.0%
associate-*l/30.0%
associate-*r/30.1%
associate-*r/30.2%
Simplified30.2%
expm1-log1p-u14.9%
expm1-udef14.9%
*-commutative14.9%
associate-*r/14.8%
*-commutative14.8%
associate-*r/14.7%
Applied egg-rr14.7%
expm1-def14.7%
expm1-log1p30.0%
associate-*l*30.2%
associate-*r/30.2%
associate-*l/30.3%
Simplified30.3%
Final simplification64.6%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (if (<= M_m 0.83) w0 (* -0.125 (* (/ (* w0 h) l) (pow (* M_m (/ D_m d)) 2.0)))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 0.83) {
tmp = w0;
} else {
tmp = -0.125 * (((w0 * h) / l) * pow((M_m * (D_m / d)), 2.0));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
real(8) :: tmp
if (m_m <= 0.83d0) then
tmp = w0
else
tmp = (-0.125d0) * (((w0 * h) / l) * ((m_m * (d_m / d)) ** 2.0d0))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double tmp;
if (M_m <= 0.83) {
tmp = w0;
} else {
tmp = -0.125 * (((w0 * h) / l) * Math.pow((M_m * (D_m / d)), 2.0));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): tmp = 0 if M_m <= 0.83: tmp = w0 else: tmp = -0.125 * (((w0 * h) / l) * math.pow((M_m * (D_m / d)), 2.0)) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) tmp = 0.0 if (M_m <= 0.83) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(Float64(w0 * h) / l) * (Float64(M_m * Float64(D_m / d)) ^ 2.0))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
tmp = 0.0;
if (M_m <= 0.83)
tmp = w0;
else
tmp = -0.125 * (((w0 * h) / l) * ((M_m * (D_m / d)) ^ 2.0));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := If[LessEqual[M$95$m, 0.83], w0, N[(-0.125 * N[(N[(N[(w0 * h), $MachinePrecision] / l), $MachinePrecision] * N[Power[N[(M$95$m * N[(D$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
\mathbf{if}\;M_m \leq 0.83:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\frac{w0 \cdot h}{\ell} \cdot {\left(M_m \cdot \frac{D_m}{d}\right)}^{2}\right)\\
\end{array}
\end{array}
if M < 0.82999999999999996Initial program 80.9%
Simplified80.7%
Taylor expanded in M around 0 74.0%
if 0.82999999999999996 < M Initial program 68.6%
Simplified66.7%
expm1-log1p-u29.1%
expm1-udef29.1%
log1p-udef29.1%
add-exp-log66.7%
+-commutative66.7%
associate-*l/68.6%
div-inv68.6%
associate-*l*70.3%
associate-/r*70.3%
metadata-eval70.3%
Applied egg-rr70.3%
associate--l+70.3%
metadata-eval70.3%
+-rgt-identity70.3%
associate-*r/70.5%
associate-*l/75.7%
*-commutative75.7%
associate-*r*74.0%
*-commutative74.0%
associate-*l/74.0%
*-commutative74.0%
associate-*r/74.0%
associate-*r/72.1%
Simplified72.1%
Taylor expanded in h around 0 44.6%
+-commutative44.6%
*-commutative44.6%
fma-def44.6%
Simplified62.0%
Taylor expanded in D around inf 25.0%
associate-*r*25.0%
times-frac25.3%
unpow225.3%
unpow225.3%
unpow225.3%
swap-sqr27.5%
times-frac30.0%
associate-*r/29.9%
associate-*r/30.0%
unpow230.0%
*-commutative30.0%
associate-*l/30.0%
associate-*r/30.1%
associate-*r/30.2%
Simplified30.2%
Taylor expanded in h around 0 30.1%
Final simplification64.6%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (+ w0 (* w0 (* -0.125 (* h (/ (pow (* D_m (/ M_m d)) 2.0) l))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 + (w0 * (-0.125 * (h * (pow((D_m * (M_m / d)), 2.0) / l))));
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
code = w0 + (w0 * ((-0.125d0) * (h * (((d_m * (m_m / d)) ** 2.0d0) / l))))
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0 + (w0 * (-0.125 * (h * (Math.pow((D_m * (M_m / d)), 2.0) / l))));
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0 + (w0 * (-0.125 * (h * (math.pow((D_m * (M_m / d)), 2.0) / l))))
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return Float64(w0 + Float64(w0 * Float64(-0.125 * Float64(h * Float64((Float64(D_m * Float64(M_m / d)) ^ 2.0) / l))))) end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0 + (w0 * (-0.125 * (h * (((D_m * (M_m / d)) ^ 2.0) / l))));
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := N[(w0 + N[(w0 * N[(-0.125 * N[(h * N[(N[Power[N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0 + w0 \cdot \left(-0.125 \cdot \left(h \cdot \frac{{\left(D_m \cdot \frac{M_m}{d}\right)}^{2}}{\ell}\right)\right)
\end{array}
Initial program 78.3%
Simplified77.7%
expm1-log1p-u55.5%
expm1-udef55.5%
log1p-udef55.5%
add-exp-log77.7%
+-commutative77.7%
associate-*l/78.3%
div-inv78.3%
associate-*l*78.2%
associate-/r*78.2%
metadata-eval78.2%
Applied egg-rr78.2%
associate--l+78.2%
metadata-eval78.2%
+-rgt-identity78.2%
associate-*r/85.4%
associate-*l/86.9%
*-commutative86.9%
associate-*r*86.9%
*-commutative86.9%
associate-*l/86.9%
*-commutative86.9%
associate-*r/86.9%
associate-*r/86.3%
Simplified86.3%
Taylor expanded in h around 0 54.2%
+-commutative54.2%
*-commutative54.2%
fma-def54.2%
Simplified80.1%
fma-udef80.1%
distribute-rgt-in80.1%
*-commutative80.1%
*-un-lft-identity80.1%
Applied egg-rr80.1%
Final simplification80.1%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 (let* ((t_0 (* D_m (/ M_m d)))) (if (<= M_m 1.55) w0 (* -0.125 (* (* t_0 t_0) (* h (/ w0 l)))))))
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * (M_m / d);
double tmp;
if (M_m <= 1.55) {
tmp = w0;
} else {
tmp = -0.125 * ((t_0 * t_0) * (h * (w0 / l)));
}
return tmp;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
real(8) :: t_0
real(8) :: tmp
t_0 = d_m * (m_m / d)
if (m_m <= 1.55d0) then
tmp = w0
else
tmp = (-0.125d0) * ((t_0 * t_0) * (h * (w0 / l)))
end if
code = tmp
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
double t_0 = D_m * (M_m / d);
double tmp;
if (M_m <= 1.55) {
tmp = w0;
} else {
tmp = -0.125 * ((t_0 * t_0) * (h * (w0 / l)));
}
return tmp;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): t_0 = D_m * (M_m / d) tmp = 0 if M_m <= 1.55: tmp = w0 else: tmp = -0.125 * ((t_0 * t_0) * (h * (w0 / l))) return tmp
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) t_0 = Float64(D_m * Float64(M_m / d)) tmp = 0.0 if (M_m <= 1.55) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(t_0 * t_0) * Float64(h * Float64(w0 / l)))); end return tmp end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp_2 = code(w0, M_m, D_m, h, l, d)
t_0 = D_m * (M_m / d);
tmp = 0.0;
if (M_m <= 1.55)
tmp = w0;
else
tmp = -0.125 * ((t_0 * t_0) * (h * (w0 / l)));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := Block[{t$95$0 = N[(D$95$m * N[(M$95$m / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M$95$m, 1.55], w0, N[(-0.125 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(h * N[(w0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
\begin{array}{l}
t_0 := D_m \cdot \frac{M_m}{d}\\
\mathbf{if}\;M_m \leq 1.55:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\left(t_0 \cdot t_0\right) \cdot \left(h \cdot \frac{w0}{\ell}\right)\right)\\
\end{array}
\end{array}
if M < 1.55000000000000004Initial program 80.9%
Simplified80.7%
Taylor expanded in M around 0 74.0%
if 1.55000000000000004 < M Initial program 68.6%
Simplified66.7%
expm1-log1p-u29.1%
expm1-udef29.1%
log1p-udef29.1%
add-exp-log66.7%
+-commutative66.7%
associate-*l/68.6%
div-inv68.6%
associate-*l*70.3%
associate-/r*70.3%
metadata-eval70.3%
Applied egg-rr70.3%
associate--l+70.3%
metadata-eval70.3%
+-rgt-identity70.3%
associate-*r/70.5%
associate-*l/75.7%
*-commutative75.7%
associate-*r*74.0%
*-commutative74.0%
associate-*l/74.0%
*-commutative74.0%
associate-*r/74.0%
associate-*r/72.1%
Simplified72.1%
Taylor expanded in h around 0 44.6%
+-commutative44.6%
*-commutative44.6%
fma-def44.6%
Simplified62.0%
Taylor expanded in D around inf 25.0%
associate-*r*25.0%
times-frac25.3%
unpow225.3%
unpow225.3%
unpow225.3%
swap-sqr27.5%
times-frac30.0%
associate-*r/29.9%
associate-*r/30.0%
unpow230.0%
*-commutative30.0%
associate-*l/30.0%
associate-*r/30.1%
associate-*r/30.2%
Simplified30.2%
associate-*r/30.1%
*-commutative30.1%
associate-*r/30.0%
unpow230.0%
Applied egg-rr30.0%
Final simplification64.6%
M_m = (fabs.f64 M) D_m = (fabs.f64 D) NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. (FPCore (w0 M_m D_m h l d) :precision binary64 w0)
M_m = fabs(M);
D_m = fabs(D);
assert(w0 < M_m && M_m < D_m && D_m < h && h < l && l < d);
double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = abs(M)
D_m = abs(D)
NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function.
real(8) function code(w0, m_m, d_m, h, l, d)
real(8), intent (in) :: w0
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
code = w0
end function
M_m = Math.abs(M);
D_m = Math.abs(D);
assert w0 < M_m && M_m < D_m && D_m < h && h < l && l < d;
public static double code(double w0, double M_m, double D_m, double h, double l, double d) {
return w0;
}
M_m = math.fabs(M) D_m = math.fabs(D) [w0, M_m, D_m, h, l, d] = sort([w0, M_m, D_m, h, l, d]) def code(w0, M_m, D_m, h, l, d): return w0
M_m = abs(M) D_m = abs(D) w0, M_m, D_m, h, l, d = sort([w0, M_m, D_m, h, l, d]) function code(w0, M_m, D_m, h, l, d) return w0 end
M_m = abs(M);
D_m = abs(D);
w0, M_m, D_m, h, l, d = num2cell(sort([w0, M_m, D_m, h, l, d])){:}
function tmp = code(w0, M_m, D_m, h, l, d)
tmp = w0;
end
M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] NOTE: w0, M_m, D_m, h, l, and d should be sorted in increasing order before calling this function. code[w0_, M$95$m_, D$95$m_, h_, l_, d_] := w0
\begin{array}{l}
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[w0, M_m, D_m, h, l, d] = \mathsf{sort}([w0, M_m, D_m, h, l, d])\\
\\
w0
\end{array}
Initial program 78.3%
Simplified77.7%
Taylor expanded in M around 0 66.5%
Final simplification66.5%
herbie shell --seed 2023314
(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))))))