
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (+ 1.0 (* h (* (pow (/ (* M 0.5) (/ d D)) 2.0) (/ -0.5 l))))))
(if (<= d -1e-310)
(* (/ (sqrt (- d)) (sqrt (- l))) (* (sqrt (/ d h)) t_0))
(* (sqrt (/ d l)) (* t_0 (/ (sqrt d) (sqrt h)))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 + (h * (pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)));
double tmp;
if (d <= -1e-310) {
tmp = (sqrt(-d) / sqrt(-l)) * (sqrt((d / h)) * t_0);
} else {
tmp = sqrt((d / l)) * (t_0 * (sqrt(d) / sqrt(h)));
}
return tmp;
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (h * ((((m * 0.5d0) / (d / d_1)) ** 2.0d0) * ((-0.5d0) / l)))
if (d <= (-1d-310)) then
tmp = (sqrt(-d) / sqrt(-l)) * (sqrt((d / h)) * t_0)
else
tmp = sqrt((d / l)) * (t_0 * (sqrt(d) / sqrt(h)))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 + (h * (Math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)));
double tmp;
if (d <= -1e-310) {
tmp = (Math.sqrt(-d) / Math.sqrt(-l)) * (Math.sqrt((d / h)) * t_0);
} else {
tmp = Math.sqrt((d / l)) * (t_0 * (Math.sqrt(d) / Math.sqrt(h)));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = 1.0 + (h * (math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l))) tmp = 0 if d <= -1e-310: tmp = (math.sqrt(-d) / math.sqrt(-l)) * (math.sqrt((d / h)) * t_0) else: tmp = math.sqrt((d / l)) * (t_0 * (math.sqrt(d) / math.sqrt(h))) return tmp
function code(d, h, l, M, D) t_0 = Float64(1.0 + Float64(h * Float64((Float64(Float64(M * 0.5) / Float64(d / D)) ^ 2.0) * Float64(-0.5 / l)))) tmp = 0.0 if (d <= -1e-310) tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * Float64(sqrt(Float64(d / h)) * t_0)); else tmp = Float64(sqrt(Float64(d / l)) * Float64(t_0 * Float64(sqrt(d) / sqrt(h)))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = 1.0 + (h * ((((M * 0.5) / (d / D)) ^ 2.0) * (-0.5 / l))); tmp = 0.0; if (d <= -1e-310) tmp = (sqrt(-d) / sqrt(-l)) * (sqrt((d / h)) * t_0); else tmp = sqrt((d / l)) * (t_0 * (sqrt(d) / sqrt(h))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 + N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + h \cdot \left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2} \cdot \frac{-0.5}{\ell}\right)\\
\mathbf{if}\;d \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\end{array}
\end{array}
if d < -9.999999999999969e-311Initial program 70.1%
Simplified71.5%
*-commutative71.5%
clear-num70.8%
un-div-inv71.6%
*-commutative71.6%
associate-/r*71.6%
associate-*r/70.2%
*-commutative70.2%
associate-/l*70.9%
div-inv70.9%
associate-/r*70.9%
metadata-eval70.9%
Applied egg-rr70.9%
associate-/r/72.5%
*-commutative72.5%
*-commutative72.5%
associate-/l*72.5%
*-commutative72.5%
associate-*l*73.1%
associate-*r/73.1%
associate-/r/73.0%
Simplified73.0%
frac-2neg73.0%
sqrt-div79.4%
Applied egg-rr79.4%
if -9.999999999999969e-311 < d Initial program 65.3%
Simplified66.1%
*-commutative66.1%
clear-num65.2%
un-div-inv65.2%
*-commutative65.2%
associate-/r*65.2%
associate-*r/64.5%
*-commutative64.5%
associate-/l*64.5%
div-inv64.5%
associate-/r*64.5%
metadata-eval64.5%
Applied egg-rr64.5%
associate-/r/67.1%
*-commutative67.1%
*-commutative67.1%
associate-/l*67.1%
*-commutative67.1%
associate-*l*67.9%
associate-*r/67.9%
associate-/r/67.1%
Simplified67.1%
sqrt-div79.0%
div-inv78.9%
Applied egg-rr78.9%
associate-*r/79.0%
*-rgt-identity79.0%
Simplified79.0%
Final simplification79.2%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ d l))))
(if (<= h -4e-311)
(*
(* t_0 (/ (sqrt (- d)) (sqrt (- h))))
(- 1.0 (* 0.5 (* (pow (* (/ M 2.0) (/ D d)) 2.0) (/ h l)))))
(*
t_0
(*
(+ 1.0 (* h (* (pow (/ (* M 0.5) (/ d D)) 2.0) (/ -0.5 l))))
(/ (sqrt d) (sqrt h)))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l));
double tmp;
if (h <= -4e-311) {
tmp = (t_0 * (sqrt(-d) / sqrt(-h))) * (1.0 - (0.5 * (pow(((M / 2.0) * (D / d)), 2.0) * (h / l))));
} else {
tmp = t_0 * ((1.0 + (h * (pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)))) * (sqrt(d) / sqrt(h)));
}
return tmp;
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((d / l))
if (h <= (-4d-311)) then
tmp = (t_0 * (sqrt(-d) / sqrt(-h))) * (1.0d0 - (0.5d0 * ((((m / 2.0d0) * (d_1 / d)) ** 2.0d0) * (h / l))))
else
tmp = t_0 * ((1.0d0 + (h * ((((m * 0.5d0) / (d / d_1)) ** 2.0d0) * ((-0.5d0) / l)))) * (sqrt(d) / sqrt(h)))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / l));
double tmp;
if (h <= -4e-311) {
tmp = (t_0 * (Math.sqrt(-d) / Math.sqrt(-h))) * (1.0 - (0.5 * (Math.pow(((M / 2.0) * (D / d)), 2.0) * (h / l))));
} else {
tmp = t_0 * ((1.0 + (h * (Math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)))) * (Math.sqrt(d) / Math.sqrt(h)));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = math.sqrt((d / l)) tmp = 0 if h <= -4e-311: tmp = (t_0 * (math.sqrt(-d) / math.sqrt(-h))) * (1.0 - (0.5 * (math.pow(((M / 2.0) * (D / d)), 2.0) * (h / l)))) else: tmp = t_0 * ((1.0 + (h * (math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)))) * (math.sqrt(d) / math.sqrt(h))) return tmp
function code(d, h, l, M, D) t_0 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -4e-311) tmp = Float64(Float64(t_0 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * Float64(1.0 - Float64(0.5 * Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * Float64(h / l))))); else tmp = Float64(t_0 * Float64(Float64(1.0 + Float64(h * Float64((Float64(Float64(M * 0.5) / Float64(d / D)) ^ 2.0) * Float64(-0.5 / l)))) * Float64(sqrt(d) / sqrt(h)))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = sqrt((d / l)); tmp = 0.0; if (h <= -4e-311) tmp = (t_0 * (sqrt(-d) / sqrt(-h))) * (1.0 - (0.5 * ((((M / 2.0) * (D / d)) ^ 2.0) * (h / l)))); else tmp = t_0 * ((1.0 + (h * ((((M * 0.5) / (d / D)) ^ 2.0) * (-0.5 / l)))) * (sqrt(d) / sqrt(h))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -4e-311], N[(N[(t$95$0 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(1.0 + N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -4 \cdot 10^{-311}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(1 + h \cdot \left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2} \cdot \frac{-0.5}{\ell}\right)\right) \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\end{array}
\end{array}
if h < -3.99999999999979e-311Initial program 70.2%
Simplified70.9%
frac-2neg70.9%
sqrt-div77.5%
Applied egg-rr77.5%
if -3.99999999999979e-311 < h Initial program 65.4%
Simplified66.1%
*-commutative66.1%
clear-num65.2%
un-div-inv65.3%
*-commutative65.3%
associate-/r*65.3%
associate-*r/64.5%
*-commutative64.5%
associate-/l*64.6%
div-inv64.6%
associate-/r*64.6%
metadata-eval64.6%
Applied egg-rr64.6%
associate-/r/67.1%
*-commutative67.1%
*-commutative67.1%
associate-/l*67.1%
*-commutative67.1%
associate-*l*67.9%
associate-*r/67.9%
associate-/r/67.1%
Simplified67.1%
sqrt-div77.2%
div-inv77.1%
Applied egg-rr77.1%
associate-*r/77.2%
*-rgt-identity77.2%
Simplified77.2%
Final simplification77.4%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ d l)))
(t_1 (+ 1.0 (* h (* (pow (/ (* M 0.5) (/ d D)) 2.0) (/ -0.5 l))))))
(if (<= d -4e-309)
(* (* (sqrt (/ d h)) t_1) t_0)
(* t_0 (* t_1 (/ (sqrt d) (sqrt h)))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l));
double t_1 = 1.0 + (h * (pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)));
double tmp;
if (d <= -4e-309) {
tmp = (sqrt((d / h)) * t_1) * t_0;
} else {
tmp = t_0 * (t_1 * (sqrt(d) / sqrt(h)));
}
return tmp;
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((d / l))
t_1 = 1.0d0 + (h * ((((m * 0.5d0) / (d / d_1)) ** 2.0d0) * ((-0.5d0) / l)))
if (d <= (-4d-309)) then
tmp = (sqrt((d / h)) * t_1) * t_0
else
tmp = t_0 * (t_1 * (sqrt(d) / sqrt(h)))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / l));
double t_1 = 1.0 + (h * (Math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l)));
double tmp;
if (d <= -4e-309) {
tmp = (Math.sqrt((d / h)) * t_1) * t_0;
} else {
tmp = t_0 * (t_1 * (Math.sqrt(d) / Math.sqrt(h)));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = math.sqrt((d / l)) t_1 = 1.0 + (h * (math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l))) tmp = 0 if d <= -4e-309: tmp = (math.sqrt((d / h)) * t_1) * t_0 else: tmp = t_0 * (t_1 * (math.sqrt(d) / math.sqrt(h))) return tmp
function code(d, h, l, M, D) t_0 = sqrt(Float64(d / l)) t_1 = Float64(1.0 + Float64(h * Float64((Float64(Float64(M * 0.5) / Float64(d / D)) ^ 2.0) * Float64(-0.5 / l)))) tmp = 0.0 if (d <= -4e-309) tmp = Float64(Float64(sqrt(Float64(d / h)) * t_1) * t_0); else tmp = Float64(t_0 * Float64(t_1 * Float64(sqrt(d) / sqrt(h)))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = sqrt((d / l)); t_1 = 1.0 + (h * ((((M * 0.5) / (d / D)) ^ 2.0) * (-0.5 / l))); tmp = 0.0; if (d <= -4e-309) tmp = (sqrt((d / h)) * t_1) * t_0; else tmp = t_0 * (t_1 * (sqrt(d) / sqrt(h))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4e-309], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := 1 + h \cdot \left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2} \cdot \frac{-0.5}{\ell}\right)\\
\mathbf{if}\;d \leq -4 \cdot 10^{-309}:\\
\;\;\;\;\left(\sqrt{\frac{d}{h}} \cdot t\_1\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right)\\
\end{array}
\end{array}
if d < -3.9999999999999977e-309Initial program 70.1%
Simplified71.5%
*-commutative71.5%
clear-num70.8%
un-div-inv71.6%
*-commutative71.6%
associate-/r*71.6%
associate-*r/70.2%
*-commutative70.2%
associate-/l*70.9%
div-inv70.9%
associate-/r*70.9%
metadata-eval70.9%
Applied egg-rr70.9%
associate-/r/72.5%
*-commutative72.5%
*-commutative72.5%
associate-/l*72.5%
*-commutative72.5%
associate-*l*73.1%
associate-*r/73.1%
associate-/r/73.0%
Simplified73.0%
if -3.9999999999999977e-309 < d Initial program 65.3%
Simplified66.1%
*-commutative66.1%
clear-num65.2%
un-div-inv65.2%
*-commutative65.2%
associate-/r*65.2%
associate-*r/64.5%
*-commutative64.5%
associate-/l*64.5%
div-inv64.5%
associate-/r*64.5%
metadata-eval64.5%
Applied egg-rr64.5%
associate-/r/67.1%
*-commutative67.1%
*-commutative67.1%
associate-/l*67.1%
*-commutative67.1%
associate-*l*67.9%
associate-*r/67.9%
associate-/r/67.1%
Simplified67.1%
sqrt-div79.0%
div-inv78.9%
Applied egg-rr78.9%
associate-*r/79.0%
*-rgt-identity79.0%
Simplified79.0%
Final simplification76.0%
(FPCore (d h l M D) :precision binary64 (* (* (sqrt (/ d h)) (+ 1.0 (* h (* (pow (/ (* M 0.5) (/ d D)) 2.0) (/ -0.5 l))))) (sqrt (/ d l))))
double code(double d, double h, double l, double M, double D) {
return (sqrt((d / h)) * (1.0 + (h * (pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l))))) * sqrt((d / l));
}
real(8) function code(d, h, l, m, d_1)
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (sqrt((d / h)) * (1.0d0 + (h * ((((m * 0.5d0) / (d / d_1)) ** 2.0d0) * ((-0.5d0) / l))))) * sqrt((d / l))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.sqrt((d / h)) * (1.0 + (h * (Math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l))))) * Math.sqrt((d / l));
}
def code(d, h, l, M, D): return (math.sqrt((d / h)) * (1.0 + (h * (math.pow(((M * 0.5) / (d / D)), 2.0) * (-0.5 / l))))) * math.sqrt((d / l))
function code(d, h, l, M, D) return Float64(Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(h * Float64((Float64(Float64(M * 0.5) / Float64(d / D)) ^ 2.0) * Float64(-0.5 / l))))) * sqrt(Float64(d / l))) end
function tmp = code(d, h, l, M, D) tmp = (sqrt((d / h)) * (1.0 + (h * ((((M * 0.5) / (d / D)) ^ 2.0) * (-0.5 / l))))) * sqrt((d / l)); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(N[Power[N[(N[(M * 0.5), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(-0.5 / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt{\frac{d}{h}} \cdot \left(1 + h \cdot \left({\left(\frac{M \cdot 0.5}{\frac{d}{D}}\right)}^{2} \cdot \frac{-0.5}{\ell}\right)\right)\right) \cdot \sqrt{\frac{d}{\ell}}
\end{array}
Initial program 67.8%
Simplified68.9%
*-commutative68.9%
clear-num68.0%
un-div-inv68.5%
*-commutative68.5%
associate-/r*68.5%
associate-*r/67.4%
*-commutative67.4%
associate-/l*67.8%
div-inv67.8%
associate-/r*67.8%
metadata-eval67.8%
Applied egg-rr67.8%
associate-/r/69.9%
*-commutative69.9%
*-commutative69.9%
associate-/l*69.9%
*-commutative69.9%
associate-*l*70.6%
associate-*r/70.6%
associate-/r/70.1%
Simplified70.1%
Final simplification70.1%
herbie shell --seed 2024066
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))