
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l))))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
real(8) function code(w0, m, d, h, l, d_1)
real(8), intent (in) :: w0
real(8), intent (in) :: m
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: d_1
code = w0 * sqrt((1.0d0 - ((((m * d) / (2.0d0 * d_1)) ** 2.0d0) * (h / l))))
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l)))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}}
\end{array}
NOTE: M and D should be sorted in increasing order before calling this function.
(FPCore (w0 M D h l d)
:precision binary64
(if (<=
(* w0 (sqrt (- 1.0 (* (pow (/ (* M D) (* 2.0 d)) 2.0) (/ h l)))))
INFINITY)
(* w0 (sqrt (- 1.0 (* (/ h l) (pow (* (/ D 2.0) (/ M d)) 2.0)))))
w0))assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((w0 * sqrt((1.0 - (pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))) <= ((double) INFINITY)) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow(((D / 2.0) * (M / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((w0 * Math.sqrt((1.0 - (Math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))) <= Double.POSITIVE_INFINITY) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow(((D / 2.0) * (M / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if (w0 * math.sqrt((1.0 - (math.pow(((M * D) / (2.0 * d)), 2.0) * (h / l))))) <= math.inf: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow(((D / 2.0) * (M / d)), 2.0)))) else: tmp = w0 return tmp
M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0) * Float64(h / l))))) <= Inf) 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
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if ((w0 * sqrt((1.0 - ((((M * D) / (2.0 * d)) ^ 2.0) * (h / l))))) <= Inf)
tmp = w0 * sqrt((1.0 - ((h / l) * (((D / 2.0) * (M / d)) ^ 2.0))));
else
tmp = w0;
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[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], Infinity], 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, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;w0 \cdot \sqrt{1 - {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}} \leq \infty:\\
\;\;\;\;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 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) < +inf.0Initial program 86.1%
Simplified86.5%
if +inf.0 < (*.f64 w0 (sqrt.f64 (-.f64 1 (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l))))) Initial program 0.0%
Simplified13.0%
Taylor expanded in D around 0 76.6%
Final simplification85.6%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= M 4.6e-119) w0 (* w0 (sqrt (- 1.0 (* 0.25 (* (* (/ D d) (/ D d)) (/ (* h (* M M)) l))))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 4.6e-119) {
tmp = w0;
} else {
tmp = w0 * sqrt((1.0 - (0.25 * (((D / d) * (D / d)) * ((h * (M * M)) / l)))));
}
return tmp;
}
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 (m <= 4.6d-119) then
tmp = w0
else
tmp = w0 * sqrt((1.0d0 - (0.25d0 * (((d / d_1) * (d / d_1)) * ((h * (m * m)) / l)))))
end if
code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 4.6e-119) {
tmp = w0;
} else {
tmp = w0 * Math.sqrt((1.0 - (0.25 * (((D / d) * (D / d)) * ((h * (M * M)) / l)))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if M <= 4.6e-119: tmp = w0 else: tmp = w0 * math.sqrt((1.0 - (0.25 * (((D / d) * (D / d)) * ((h * (M * M)) / l))))) return tmp
M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 4.6e-119) tmp = w0; else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(Float64(h * Float64(M * M)) / l)))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (M <= 4.6e-119)
tmp = w0;
else
tmp = w0 * sqrt((1.0 - (0.25 * (((D / d) * (D / d)) * ((h * (M * M)) / l)))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 4.6e-119], w0, N[(w0 * N[Sqrt[N[(1.0 - N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 4.6 \cdot 10^{-119}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - 0.25 \cdot \left(\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \frac{h \cdot \left(M \cdot M\right)}{\ell}\right)}\\
\end{array}
\end{array}
if M < 4.59999999999999987e-119Initial program 82.0%
Simplified84.8%
Taylor expanded in D around 0 70.3%
if 4.59999999999999987e-119 < M Initial program 70.8%
Simplified69.6%
Taylor expanded in D around 0 52.0%
times-frac50.9%
unpow250.9%
unpow250.9%
unpow250.9%
Simplified50.9%
Taylor expanded in D around 0 50.9%
unpow250.9%
unpow250.9%
times-frac62.4%
Simplified62.4%
Final simplification67.7%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= M 1.25e-118) w0 (* w0 (+ 1.0 (* -0.125 (* h (* (/ (* M D) (* d d)) (/ (* M D) l))))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 1.25e-118) {
tmp = w0;
} else {
tmp = w0 * (1.0 + (-0.125 * (h * (((M * D) / (d * d)) * ((M * D) / l)))));
}
return tmp;
}
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 (m <= 1.25d-118) then
tmp = w0
else
tmp = w0 * (1.0d0 + ((-0.125d0) * (h * (((m * d) / (d_1 * d_1)) * ((m * d) / l)))))
end if
code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 1.25e-118) {
tmp = w0;
} else {
tmp = w0 * (1.0 + (-0.125 * (h * (((M * D) / (d * d)) * ((M * D) / l)))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if M <= 1.25e-118: tmp = w0 else: tmp = w0 * (1.0 + (-0.125 * (h * (((M * D) / (d * d)) * ((M * D) / l))))) return tmp
M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 1.25e-118) tmp = w0; else tmp = Float64(w0 * Float64(1.0 + Float64(-0.125 * Float64(h * Float64(Float64(Float64(M * D) / Float64(d * d)) * Float64(Float64(M * D) / l)))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (M <= 1.25e-118)
tmp = w0;
else
tmp = w0 * (1.0 + (-0.125 * (h * (((M * D) / (d * d)) * ((M * D) / l)))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 1.25e-118], w0, N[(w0 * N[(1.0 + N[(-0.125 * N[(h * N[(N[(N[(M * D), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.25 \cdot 10^{-118}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(1 + -0.125 \cdot \left(h \cdot \left(\frac{M \cdot D}{d \cdot d} \cdot \frac{M \cdot D}{\ell}\right)\right)\right)\\
\end{array}
\end{array}
if M < 1.25000000000000004e-118Initial program 82.0%
Simplified84.8%
Taylor expanded in D around 0 70.3%
if 1.25000000000000004e-118 < M Initial program 70.8%
Simplified69.6%
Taylor expanded in D around 0 49.2%
*-commutative49.2%
times-frac49.3%
unpow249.3%
unpow249.3%
unpow249.3%
Simplified49.3%
Taylor expanded in D around 0 49.2%
associate-*r*50.4%
unpow250.4%
unpow250.4%
unpow250.4%
associate-*r*55.6%
associate-*l/55.6%
*-commutative55.6%
unswap-sqr62.0%
associate-*r*56.9%
Simplified56.9%
times-frac58.5%
Applied egg-rr58.5%
Final simplification66.5%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= M 5e-119) w0 (* w0 (+ 1.0 (* (/ (* (* (/ D d) (/ D d)) (* h (* M M))) l) -0.125)))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 5e-119) {
tmp = w0;
} else {
tmp = w0 * (1.0 + (((((D / d) * (D / d)) * (h * (M * M))) / l) * -0.125));
}
return tmp;
}
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 (m <= 5d-119) then
tmp = w0
else
tmp = w0 * (1.0d0 + (((((d / d_1) * (d / d_1)) * (h * (m * m))) / l) * (-0.125d0)))
end if
code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 5e-119) {
tmp = w0;
} else {
tmp = w0 * (1.0 + (((((D / d) * (D / d)) * (h * (M * M))) / l) * -0.125));
}
return tmp;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if M <= 5e-119: tmp = w0 else: tmp = w0 * (1.0 + (((((D / d) * (D / d)) * (h * (M * M))) / l) * -0.125)) return tmp
M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 5e-119) tmp = w0; else tmp = Float64(w0 * Float64(1.0 + Float64(Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) * Float64(h * Float64(M * M))) / l) * -0.125))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (M <= 5e-119)
tmp = w0;
else
tmp = w0 * (1.0 + (((((D / d) * (D / d)) * (h * (M * M))) / l) * -0.125));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 5e-119], w0, N[(w0 * N[(1.0 + N[(N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(h * N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 5 \cdot 10^{-119}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \left(1 + \frac{\left(\frac{D}{d} \cdot \frac{D}{d}\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{\ell} \cdot -0.125\right)\\
\end{array}
\end{array}
if M < 4.99999999999999993e-119Initial program 82.0%
Simplified84.8%
Taylor expanded in D around 0 70.3%
if 4.99999999999999993e-119 < M Initial program 70.8%
Simplified69.6%
Taylor expanded in D around 0 49.2%
*-commutative49.2%
times-frac49.3%
unpow249.3%
unpow249.3%
unpow249.3%
Simplified49.3%
associate-*r/49.3%
times-frac56.2%
*-commutative56.2%
Applied egg-rr56.2%
Final simplification65.8%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= M 3.1e-38) w0 (* -0.125 (* (* w0 M) (* (* M h) (* (/ D d) (/ D (* d l))))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3.1e-38) {
tmp = w0;
} else {
tmp = -0.125 * ((w0 * M) * ((M * h) * ((D / d) * (D / (d * l)))));
}
return tmp;
}
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 (m <= 3.1d-38) then
tmp = w0
else
tmp = (-0.125d0) * ((w0 * m) * ((m * h) * ((d / d_1) * (d / (d_1 * l)))))
end if
code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3.1e-38) {
tmp = w0;
} else {
tmp = -0.125 * ((w0 * M) * ((M * h) * ((D / d) * (D / (d * l)))));
}
return tmp;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if M <= 3.1e-38: tmp = w0 else: tmp = -0.125 * ((w0 * M) * ((M * h) * ((D / d) * (D / (d * l))))) return tmp
M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 3.1e-38) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(w0 * M) * Float64(Float64(M * h) * Float64(Float64(D / d) * Float64(D / Float64(d * l)))))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (M <= 3.1e-38)
tmp = w0;
else
tmp = -0.125 * ((w0 * M) * ((M * h) * ((D / d) * (D / (d * l)))));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3.1e-38], w0, N[(-0.125 * N[(N[(w0 * M), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] * N[(N[(D / d), $MachinePrecision] * N[(D / N[(d * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.1 \cdot 10^{-38}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\left(w0 \cdot M\right) \cdot \left(\left(M \cdot h\right) \cdot \left(\frac{D}{d} \cdot \frac{D}{d \cdot \ell}\right)\right)\right)\\
\end{array}
\end{array}
if M < 3.09999999999999983e-38Initial program 82.5%
Simplified85.1%
Taylor expanded in D around 0 70.8%
if 3.09999999999999983e-38 < M Initial program 66.5%
Simplified65.1%
Taylor expanded in D around 0 44.4%
+-commutative44.4%
*-commutative44.4%
fma-def44.4%
associate-*r*45.9%
unpow245.9%
unpow245.9%
swap-sqr53.8%
associate-/l*53.6%
swap-sqr45.7%
unpow245.7%
associate-*l*49.0%
Simplified49.0%
Taylor expanded in D around inf 30.7%
unpow230.7%
associate-*r*32.5%
associate-/l*32.6%
unpow232.6%
associate-*r*30.8%
associate-*r*30.8%
*-commutative30.8%
unpow230.8%
associate-*r*31.2%
Simplified31.2%
pow131.2%
associate-*l*33.1%
Applied egg-rr33.1%
pow133.1%
associate-/r/32.9%
associate-*l*33.1%
*-commutative33.1%
associate-*r*33.2%
times-frac34.0%
Applied egg-rr34.0%
Final simplification61.3%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 (if (<= M 2.12e-38) w0 (* -0.125 (* (/ (* (/ D d) (/ D d)) l) (* (* M h) (* w0 M))))))
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 2.12e-38) {
tmp = w0;
} else {
tmp = -0.125 * ((((D / d) * (D / d)) / l) * ((M * h) * (w0 * M)));
}
return tmp;
}
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 (m <= 2.12d-38) then
tmp = w0
else
tmp = (-0.125d0) * ((((d / d_1) * (d / d_1)) / l) * ((m * h) * (w0 * m)))
end if
code = tmp
end function
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 2.12e-38) {
tmp = w0;
} else {
tmp = -0.125 * ((((D / d) * (D / d)) / l) * ((M * h) * (w0 * M)));
}
return tmp;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): tmp = 0 if M <= 2.12e-38: tmp = w0 else: tmp = -0.125 * ((((D / d) * (D / d)) / l) * ((M * h) * (w0 * M))) return tmp
M, D = sort([M, D]) function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 2.12e-38) tmp = w0; else tmp = Float64(-0.125 * Float64(Float64(Float64(Float64(D / d) * Float64(D / d)) / l) * Float64(Float64(M * h) * Float64(w0 * M)))); end return tmp end
M, D = num2cell(sort([M, D])){:}
function tmp_2 = code(w0, M, D, h, l, d)
tmp = 0.0;
if (M <= 2.12e-38)
tmp = w0;
else
tmp = -0.125 * ((((D / d) * (D / d)) / l) * ((M * h) * (w0 * M)));
end
tmp_2 = tmp;
end
NOTE: M and D should be sorted in increasing order before calling this function. code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 2.12e-38], w0, N[(-0.125 * N[(N[(N[(N[(D / d), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * N[(N[(M * h), $MachinePrecision] * N[(w0 * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[M, D] = \mathsf{sort}([M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.12 \cdot 10^{-38}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \left(\frac{\frac{D}{d} \cdot \frac{D}{d}}{\ell} \cdot \left(\left(M \cdot h\right) \cdot \left(w0 \cdot M\right)\right)\right)\\
\end{array}
\end{array}
if M < 2.12000000000000001e-38Initial program 82.5%
Simplified85.1%
Taylor expanded in D around 0 70.8%
if 2.12000000000000001e-38 < M Initial program 66.5%
Simplified65.1%
Taylor expanded in D around 0 44.4%
+-commutative44.4%
*-commutative44.4%
fma-def44.4%
associate-*r*45.9%
unpow245.9%
unpow245.9%
swap-sqr53.8%
associate-/l*53.6%
swap-sqr45.7%
unpow245.7%
associate-*l*49.0%
Simplified49.0%
Taylor expanded in D around inf 30.7%
unpow230.7%
associate-*r*32.5%
associate-/l*32.6%
unpow232.6%
associate-*r*30.8%
associate-*r*30.8%
*-commutative30.8%
unpow230.8%
associate-*r*31.2%
Simplified31.2%
associate-/r/31.1%
associate-*l*32.9%
associate-*l*33.1%
*-commutative33.1%
Applied egg-rr33.1%
Taylor expanded in D around 0 31.2%
unpow231.2%
associate-/r*29.9%
unpow229.9%
times-frac30.8%
Simplified30.8%
Final simplification60.5%
NOTE: M and D should be sorted in increasing order before calling this function. (FPCore (w0 M D h l d) :precision binary64 w0)
assert(M < D);
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
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
assert M < D;
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
[M, D] = sort([M, D]) def code(w0, M, D, h, l, d): return w0
M, D = sort([M, D]) function code(w0, M, D, h, l, d) return w0 end
M, D = num2cell(sort([M, D])){:}
function tmp = code(w0, M, D, h, l, d)
tmp = w0;
end
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, D] = \mathsf{sort}([M, D])\\
\\
w0
\end{array}
Initial program 78.4%
Simplified79.9%
Taylor expanded in D around 0 61.0%
Final simplification61.0%
herbie shell --seed 2023290
(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))))))