
(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}
(FPCore (w0 M D h l d)
:precision binary64
(let* ((t_0 (* (* D (* 0.5 (/ M d))) (sqrt h))))
(if (<= h -4e-310)
(* w0 (sqrt (- 1.0 (/ (* h (pow (/ D (* (/ d M) 2.0)) 2.0)) l))))
(* w0 (sqrt (- 1.0 (* t_0 (/ t_0 l))))))))
double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (D * (0.5 * (M / d))) * sqrt(h);
double tmp;
if (h <= -4e-310) {
tmp = w0 * sqrt((1.0 - ((h * pow((D / ((d / M) * 2.0)), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (t_0 * (t_0 / l))));
}
return tmp;
}
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 = (d * (0.5d0 * (m / d_1))) * sqrt(h)
if (h <= (-4d-310)) then
tmp = w0 * sqrt((1.0d0 - ((h * ((d / ((d_1 / m) * 2.0d0)) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - (t_0 * (t_0 / l))))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double t_0 = (D * (0.5 * (M / d))) * Math.sqrt(h);
double tmp;
if (h <= -4e-310) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((D / ((d / M) * 2.0)), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (t_0 * (t_0 / l))));
}
return tmp;
}
def code(w0, M, D, h, l, d): t_0 = (D * (0.5 * (M / d))) * math.sqrt(h) tmp = 0 if h <= -4e-310: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((D / ((d / M) * 2.0)), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (t_0 * (t_0 / l)))) return tmp
function code(w0, M, D, h, l, d) t_0 = Float64(Float64(D * Float64(0.5 * Float64(M / d))) * sqrt(h)) tmp = 0.0 if (h <= -4e-310) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D / Float64(Float64(d / M) * 2.0)) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(t_0 * Float64(t_0 / l))))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) t_0 = (D * (0.5 * (M / d))) * sqrt(h); tmp = 0.0; if (h <= -4e-310) tmp = w0 * sqrt((1.0 - ((h * ((D / ((d / M) * 2.0)) ^ 2.0)) / l))); else tmp = w0 * sqrt((1.0 - (t_0 * (t_0 / l)))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := Block[{t$95$0 = N[(N[(D * N[(0.5 * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4e-310], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D / N[(N[(d / M), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(t$95$0 * N[(t$95$0 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{h}\\
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D}{\frac{d}{M} \cdot 2}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - t\_0 \cdot \frac{t\_0}{\ell}}\\
\end{array}
\end{array}
if h < -3.999999999999988e-310Initial program 74.8%
Simplified77.3%
unpow277.3%
unpow277.3%
associate-/r*77.3%
associate-*r/74.8%
*-commutative74.8%
associate-*r/79.8%
*-commutative79.8%
associate-*l/81.4%
associate-/r*81.4%
clear-num81.4%
associate-*l/81.4%
*-un-lft-identity81.4%
associate-/r/81.4%
Applied egg-rr81.4%
if -3.999999999999988e-310 < h Initial program 74.7%
Simplified74.7%
unpow274.7%
unpow274.7%
associate-/r*74.7%
associate-*r/74.7%
*-commutative74.7%
associate-*r/81.7%
*-commutative81.7%
associate-*l/81.7%
associate-/r*81.7%
clear-num81.7%
associate-*l/81.7%
*-un-lft-identity81.7%
associate-/r/81.7%
Applied egg-rr81.7%
add-sqr-sqrt81.7%
*-un-lft-identity81.7%
times-frac81.6%
Applied egg-rr86.6%
Final simplification84.1%
(FPCore (w0 M D h l d) :precision binary64 (if (<= (* (pow (/ (* D M) (* d 2.0)) 2.0) (/ h l)) -2e-13) (* w0 (sqrt (- 1.0 (* (/ h l) (pow (* D (/ (/ M 2.0) d)) 2.0))))) w0))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((pow(((D * M) / (d * 2.0)), 2.0) * (h / l)) <= -2e-13) {
tmp = w0 * sqrt((1.0 - ((h / l) * pow((D * ((M / 2.0) / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
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 * m) / (d_1 * 2.0d0)) ** 2.0d0) * (h / l)) <= (-2d-13)) then
tmp = w0 * sqrt((1.0d0 - ((h / l) * ((d * ((m / 2.0d0) / d_1)) ** 2.0d0))))
else
tmp = w0
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if ((Math.pow(((D * M) / (d * 2.0)), 2.0) * (h / l)) <= -2e-13) {
tmp = w0 * Math.sqrt((1.0 - ((h / l) * Math.pow((D * ((M / 2.0) / d)), 2.0))));
} else {
tmp = w0;
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if (math.pow(((D * M) / (d * 2.0)), 2.0) * (h / l)) <= -2e-13: tmp = w0 * math.sqrt((1.0 - ((h / l) * math.pow((D * ((M / 2.0) / d)), 2.0)))) else: tmp = w0 return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (Float64((Float64(Float64(D * M) / Float64(d * 2.0)) ^ 2.0) * Float64(h / l)) <= -2e-13) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h / l) * (Float64(D * Float64(Float64(M / 2.0) / d)) ^ 2.0))))); else tmp = w0; end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (((((D * M) / (d * 2.0)) ^ 2.0) * (h / l)) <= -2e-13) tmp = w0 * sqrt((1.0 - ((h / l) * ((D * ((M / 2.0) / d)) ^ 2.0)))); else tmp = w0; end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[N[(N[Power[N[(N[(D * M), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision], -2e-13], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], w0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell} \leq -2 \cdot 10^{-13}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h}{\ell} \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;w0\\
\end{array}
\end{array}
if (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) < -2.0000000000000001e-13Initial program 57.1%
Simplified58.1%
if -2.0000000000000001e-13 < (*.f64 (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2) (/.f64 h l)) Initial program 84.3%
Simplified85.5%
Taylor expanded in D around 0 94.3%
Final simplification81.6%
(FPCore (w0 M D h l d) :precision binary64 (if (<= h -4e-310) (* w0 (sqrt (- 1.0 (/ (* h (pow (/ D (* (/ d M) 2.0)) 2.0)) l)))) (* w0 (sqrt (- 1.0 (/ (pow (* (* D (* 0.5 (/ M d))) (sqrt h)) 2.0) l))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -4e-310) {
tmp = w0 * sqrt((1.0 - ((h * pow((D / ((d / M) * 2.0)), 2.0)) / l)));
} else {
tmp = w0 * sqrt((1.0 - (pow(((D * (0.5 * (M / d))) * sqrt(h)), 2.0) / l)));
}
return tmp;
}
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 <= (-4d-310)) then
tmp = w0 * sqrt((1.0d0 - ((h * ((d / ((d_1 / m) * 2.0d0)) ** 2.0d0)) / l)))
else
tmp = w0 * sqrt((1.0d0 - ((((d * (0.5d0 * (m / d_1))) * sqrt(h)) ** 2.0d0) / l)))
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (h <= -4e-310) {
tmp = w0 * Math.sqrt((1.0 - ((h * Math.pow((D / ((d / M) * 2.0)), 2.0)) / l)));
} else {
tmp = w0 * Math.sqrt((1.0 - (Math.pow(((D * (0.5 * (M / d))) * Math.sqrt(h)), 2.0) / l)));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if h <= -4e-310: tmp = w0 * math.sqrt((1.0 - ((h * math.pow((D / ((d / M) * 2.0)), 2.0)) / l))) else: tmp = w0 * math.sqrt((1.0 - (math.pow(((D * (0.5 * (M / d))) * math.sqrt(h)), 2.0) / l))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (h <= -4e-310) tmp = Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D / Float64(Float64(d / M) * 2.0)) ^ 2.0)) / l)))); else tmp = Float64(w0 * sqrt(Float64(1.0 - Float64((Float64(Float64(D * Float64(0.5 * Float64(M / d))) * sqrt(h)) ^ 2.0) / l)))); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (h <= -4e-310) tmp = w0 * sqrt((1.0 - ((h * ((D / ((d / M) * 2.0)) ^ 2.0)) / l))); else tmp = w0 * sqrt((1.0 - ((((D * (0.5 * (M / d))) * sqrt(h)) ^ 2.0) / l))); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[h, -4e-310], N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D / N[(N[(d / M), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(w0 * N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(D * N[(0.5 * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \leq -4 \cdot 10^{-310}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D}{\frac{d}{M} \cdot 2}\right)}^{2}}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;w0 \cdot \sqrt{1 - \frac{{\left(\left(D \cdot \left(0.5 \cdot \frac{M}{d}\right)\right) \cdot \sqrt{h}\right)}^{2}}{\ell}}\\
\end{array}
\end{array}
if h < -3.999999999999988e-310Initial program 74.8%
Simplified77.3%
unpow277.3%
unpow277.3%
associate-/r*77.3%
associate-*r/74.8%
*-commutative74.8%
associate-*r/79.8%
*-commutative79.8%
associate-*l/81.4%
associate-/r*81.4%
clear-num81.4%
associate-*l/81.4%
*-un-lft-identity81.4%
associate-/r/81.4%
Applied egg-rr81.4%
if -3.999999999999988e-310 < h Initial program 74.7%
Simplified74.7%
unpow274.7%
unpow274.7%
associate-/r*74.7%
associate-*r/74.7%
*-commutative74.7%
associate-*r/81.7%
*-commutative81.7%
associate-*l/81.7%
associate-/r*81.7%
clear-num81.7%
associate-*l/81.7%
*-un-lft-identity81.7%
associate-/r/81.7%
Applied egg-rr81.7%
add-sqr-sqrt81.7%
pow281.7%
*-commutative81.7%
div-inv81.7%
associate-*l/81.7%
*-commutative81.7%
clear-num81.7%
sqrt-prod81.7%
unpow281.7%
sqrt-prod54.3%
add-sqr-sqrt85.2%
*-un-lft-identity85.2%
times-frac85.2%
metadata-eval85.2%
Applied egg-rr85.2%
Final simplification83.4%
(FPCore (w0 M D h l d) :precision binary64 (* w0 (sqrt (- 1.0 (/ (* h (pow (/ D (* (/ d M) 2.0)) 2.0)) l)))))
double code(double w0, double M, double D, double h, double l, double d) {
return w0 * sqrt((1.0 - ((h * pow((D / ((d / M) * 2.0)), 2.0)) / 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 - ((h * ((d / ((d_1 / m) * 2.0d0)) ** 2.0d0)) / 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 - ((h * Math.pow((D / ((d / M) * 2.0)), 2.0)) / l)));
}
def code(w0, M, D, h, l, d): return w0 * math.sqrt((1.0 - ((h * math.pow((D / ((d / M) * 2.0)), 2.0)) / l)))
function code(w0, M, D, h, l, d) return Float64(w0 * sqrt(Float64(1.0 - Float64(Float64(h * (Float64(D / Float64(Float64(d / M) * 2.0)) ^ 2.0)) / l)))) end
function tmp = code(w0, M, D, h, l, d) tmp = w0 * sqrt((1.0 - ((h * ((D / ((d / M) * 2.0)) ^ 2.0)) / l))); end
code[w0_, M_, D_, h_, l_, d_] := N[(w0 * N[Sqrt[N[(1.0 - N[(N[(h * N[Power[N[(D / N[(N[(d / M), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
w0 \cdot \sqrt{1 - \frac{h \cdot {\left(\frac{D}{\frac{d}{M} \cdot 2}\right)}^{2}}{\ell}}
\end{array}
Initial program 74.7%
Simplified75.9%
unpow275.9%
unpow275.9%
associate-/r*75.9%
associate-*r/74.7%
*-commutative74.7%
associate-*r/80.8%
*-commutative80.8%
associate-*l/81.5%
associate-/r*81.5%
clear-num81.5%
associate-*l/81.5%
*-un-lft-identity81.5%
associate-/r/81.5%
Applied egg-rr81.5%
Final simplification81.5%
(FPCore (w0 M D h l d) :precision binary64 (if (<= M 3000000000000.0) w0 (expm1 (* w0 (+ 1.0 (* w0 (- (* w0 0.3333333333333333) 0.5)))))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3000000000000.0) {
tmp = w0;
} else {
tmp = expm1((w0 * (1.0 + (w0 * ((w0 * 0.3333333333333333) - 0.5)))));
}
return tmp;
}
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3000000000000.0) {
tmp = w0;
} else {
tmp = Math.expm1((w0 * (1.0 + (w0 * ((w0 * 0.3333333333333333) - 0.5)))));
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if M <= 3000000000000.0: tmp = w0 else: tmp = math.expm1((w0 * (1.0 + (w0 * ((w0 * 0.3333333333333333) - 0.5))))) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 3000000000000.0) tmp = w0; else tmp = expm1(Float64(w0 * Float64(1.0 + Float64(w0 * Float64(Float64(w0 * 0.3333333333333333) - 0.5))))); end return tmp end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3000000000000.0], w0, N[(Exp[N[(w0 * N[(1.0 + N[(w0 * N[(N[(w0 * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3000000000000:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(w0 \cdot \left(1 + w0 \cdot \left(w0 \cdot 0.3333333333333333 - 0.5\right)\right)\right)\\
\end{array}
\end{array}
if M < 3e12Initial program 76.5%
Simplified77.5%
Taylor expanded in D around 0 68.5%
if 3e12 < M Initial program 68.4%
Simplified70.2%
Applied egg-rr21.1%
expm1-define43.3%
*-commutative43.3%
associate-*l/43.7%
associate-/l*47.2%
associate-*l/47.2%
*-commutative47.2%
associate-*l/47.2%
associate-/l/47.2%
associate-/r/47.2%
associate-*l/47.2%
*-commutative47.2%
associate-*r/45.4%
*-commutative45.4%
associate-/l/45.4%
associate-/l*47.2%
Simplified47.2%
Taylor expanded in h around 0 8.0%
log1p-define30.6%
Simplified30.6%
Taylor expanded in w0 around 0 37.6%
Final simplification61.8%
(FPCore (w0 M D h l d) :precision binary64 (if (<= M 3.2e+95) w0 (/ (+ 1.0 (* (+ w0 -1.0) (- 1.0 w0))) (- 2.0 w0))))
double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3.2e+95) {
tmp = w0;
} else {
tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0);
}
return tmp;
}
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.2d+95) then
tmp = w0
else
tmp = (1.0d0 + ((w0 + (-1.0d0)) * (1.0d0 - w0))) / (2.0d0 - w0)
end if
code = tmp
end function
public static double code(double w0, double M, double D, double h, double l, double d) {
double tmp;
if (M <= 3.2e+95) {
tmp = w0;
} else {
tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0);
}
return tmp;
}
def code(w0, M, D, h, l, d): tmp = 0 if M <= 3.2e+95: tmp = w0 else: tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0) return tmp
function code(w0, M, D, h, l, d) tmp = 0.0 if (M <= 3.2e+95) tmp = w0; else tmp = Float64(Float64(1.0 + Float64(Float64(w0 + -1.0) * Float64(1.0 - w0))) / Float64(2.0 - w0)); end return tmp end
function tmp_2 = code(w0, M, D, h, l, d) tmp = 0.0; if (M <= 3.2e+95) tmp = w0; else tmp = (1.0 + ((w0 + -1.0) * (1.0 - w0))) / (2.0 - w0); end tmp_2 = tmp; end
code[w0_, M_, D_, h_, l_, d_] := If[LessEqual[M, 3.2e+95], w0, N[(N[(1.0 + N[(N[(w0 + -1.0), $MachinePrecision] * N[(1.0 - w0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 - w0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.2 \cdot 10^{+95}:\\
\;\;\;\;w0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(w0 + -1\right) \cdot \left(1 - w0\right)}{2 - w0}\\
\end{array}
\end{array}
if M < 3.2000000000000001e95Initial program 74.9%
Simplified75.8%
Taylor expanded in D around 0 66.9%
if 3.2000000000000001e95 < M Initial program 73.5%
Simplified76.5%
Applied egg-rr24.8%
expm1-define44.9%
*-commutative44.9%
associate-*l/45.3%
associate-/l*51.1%
associate-*l/51.1%
*-commutative51.1%
associate-*l/51.1%
associate-/l/51.1%
associate-/r/51.1%
associate-*l/51.1%
*-commutative51.1%
associate-*r/48.0%
*-commutative48.0%
associate-/l/48.0%
associate-/l*51.1%
Simplified51.1%
Taylor expanded in h around 0 8.2%
log1p-define28.6%
Simplified28.6%
expm1-undefine8.2%
log1p-undefine8.2%
rem-exp-log19.1%
Applied egg-rr19.1%
associate--l+19.1%
flip-+19.2%
metadata-eval19.2%
sub-neg19.2%
metadata-eval19.2%
sub-neg19.2%
metadata-eval19.2%
sub-neg19.2%
metadata-eval19.2%
Applied egg-rr19.2%
sub-neg19.2%
distribute-rgt-neg-in19.2%
+-commutative19.2%
+-commutative19.2%
distribute-neg-in19.2%
metadata-eval19.2%
sub-neg19.2%
+-commutative19.2%
associate--r+19.2%
metadata-eval19.2%
Simplified19.2%
Final simplification60.7%
(FPCore (w0 M D h l d) :precision binary64 w0)
double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
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
public static double code(double w0, double M, double D, double h, double l, double d) {
return w0;
}
def code(w0, M, D, h, l, d): return w0
function code(w0, M, D, h, l, d) return w0 end
function tmp = code(w0, M, D, h, l, d) tmp = w0; end
code[w0_, M_, D_, h_, l_, d_] := w0
\begin{array}{l}
\\
w0
\end{array}
Initial program 74.7%
Simplified75.9%
Taylor expanded in D around 0 63.4%
Final simplification63.4%
herbie shell --seed 2024054
(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))))))