Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.7% → 85.5%
Time: 29.1s
Alternatives: 22
Speedup: 1.0×

Specification

?
\[\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
 (*
  (* (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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 22 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 66.7% accurate, 1.0× speedup?

\[\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
 (*
  (* (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}

Alternative 1: 85.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{-d}\\ \mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{t\_0}{\sqrt{-\ell}} \cdot \left(\frac{t\_0}{\sqrt{-h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (- d))))
   (if (<= h -2e-310)
     (*
      (/ t_0 (sqrt (- l)))
      (*
       (/ t_0 (sqrt (- h)))
       (+ 1.0 (/ (* -0.5 (pow (* D (/ M (* d 2.0))) 2.0)) (/ l h)))))
     (*
      d
      (/
       (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
       (* (sqrt l) (sqrt h)))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(-d);
	double tmp;
	if (h <= -2e-310) {
		tmp = (t_0 / sqrt(-l)) * ((t_0 / sqrt(-h)) * (1.0 + ((-0.5 * pow((D * (M / (d * 2.0))), 2.0)) / (l / h))));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(-d))
	tmp = 0.0
	if (h <= -2e-310)
		tmp = Float64(Float64(t_0 / sqrt(Float64(-l))) * Float64(Float64(t_0 / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(-0.5 * (Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0)) / Float64(l / h)))));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[(-d)], $MachinePrecision]}, If[LessEqual[h, -2e-310], N[(N[(t$95$0 / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$0 / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(-0.5 * N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{-d}\\
\mathbf{if}\;h \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{t\_0}{\sqrt{-\ell}} \cdot \left(\frac{t\_0}{\sqrt{-h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -1.999999999999994e-310

    1. Initial program 72.3%

      \[\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) \]
    2. Simplified70.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \frac{h}{\ell}}\right)\right) \]
      2. clear-num70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}\right)\right) \]
      3. un-div-inv70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5}{\frac{\ell}{h}}}\right)\right) \]
      4. *-commutative70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{\color{blue}{-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      5. add-sqr-sqrt70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}}{\frac{\ell}{h}}\right)\right) \]
      6. pow270.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      7. unpow270.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(\sqrt{\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      8. sqrt-prod44.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(\sqrt{D \cdot \frac{\frac{M}{2}}{d}} \cdot \sqrt{D \cdot \frac{\frac{M}{2}}{d}}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      9. add-sqr-sqrt70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      10. associate-/l/70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    5. Applied egg-rr70.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}}\right)\right) \]
    6. Step-by-step derivation
      1. frac-2neg70.0%

        \[\leadsto \sqrt{\color{blue}{\frac{-d}{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      2. sqrt-div73.1%

        \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    7. Applied egg-rr73.1%

      \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    8. Step-by-step derivation
      1. frac-2neg73.1%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\color{blue}{\frac{-d}{-h}}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      2. sqrt-div84.4%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    9. Applied egg-rr84.4%

      \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]

    if -1.999999999999994e-310 < h

    1. Initial program 64.3%

      \[\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) \]
    2. Simplified64.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg64.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in53.9%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div61.3%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div62.9%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times62.9%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt63.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr75.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity75.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative75.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in81.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/82.3%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*82.3%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified86.2%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 69.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ t_1 := \sqrt{\frac{d}{\ell}}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-193}:\\ \;\;\;\;t\_1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-282}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
          (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* D M) (* d 2.0)) 2.0))))))
        (t_1 (sqrt (/ d l))))
   (if (<= t_0 -1e-193)
     (*
      t_1
      (*
       (sqrt (/ d h))
       (+ 1.0 (* (/ h l) (* -0.5 (pow (* M (/ D (* d 2.0))) 2.0))))))
     (if (<= t_0 1e-282)
       (* d (sqrt (/ (/ 1.0 h) l)))
       (* t_1 (/ 1.0 (sqrt (/ h d))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((D * M) / (d * 2.0)), 2.0))));
	double t_1 = sqrt((d / l));
	double tmp;
	if (t_0 <= -1e-193) {
		tmp = t_1 * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * pow((M * (D / (d * 2.0))), 2.0)))));
	} else if (t_0 <= 1e-282) {
		tmp = d * sqrt(((1.0 / h) / l));
	} else {
		tmp = t_1 * (1.0 / sqrt((h / d)));
	}
	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 = (((d / h) ** 0.5d0) * ((d / l) ** 0.5d0)) * (1.0d0 - ((h / l) * (0.5d0 * (((d_1 * m) / (d * 2.0d0)) ** 2.0d0))))
    t_1 = sqrt((d / l))
    if (t_0 <= (-1d-193)) then
        tmp = t_1 * (sqrt((d / h)) * (1.0d0 + ((h / l) * ((-0.5d0) * ((m * (d_1 / (d * 2.0d0))) ** 2.0d0)))))
    else if (t_0 <= 1d-282) then
        tmp = d * sqrt(((1.0d0 / h) / l))
    else
        tmp = t_1 * (1.0d0 / sqrt((h / d)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = (Math.pow((d / h), 0.5) * Math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * Math.pow(((D * M) / (d * 2.0)), 2.0))));
	double t_1 = Math.sqrt((d / l));
	double tmp;
	if (t_0 <= -1e-193) {
		tmp = t_1 * (Math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * Math.pow((M * (D / (d * 2.0))), 2.0)))));
	} else if (t_0 <= 1e-282) {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = t_1 * (1.0 / Math.sqrt((h / d)));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = (math.pow((d / h), 0.5) * math.pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * math.pow(((D * M) / (d * 2.0)), 2.0))))
	t_1 = math.sqrt((d / l))
	tmp = 0
	if t_0 <= -1e-193:
		tmp = t_1 * (math.sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * math.pow((M * (D / (d * 2.0))), 2.0)))))
	elif t_0 <= 1e-282:
		tmp = d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = t_1 * (1.0 / math.sqrt((h / d)))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(D * M) / Float64(d * 2.0)) ^ 2.0)))))
	t_1 = sqrt(Float64(d / l))
	tmp = 0.0
	if (t_0 <= -1e-193)
		tmp = Float64(t_1 * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(M * Float64(D / Float64(d * 2.0))) ^ 2.0))))));
	elseif (t_0 <= 1e-282)
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(t_1 * Float64(1.0 / sqrt(Float64(h / d))));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = (((d / h) ^ 0.5) * ((d / l) ^ 0.5)) * (1.0 - ((h / l) * (0.5 * (((D * M) / (d * 2.0)) ^ 2.0))));
	t_1 = sqrt((d / l));
	tmp = 0.0;
	if (t_0 <= -1e-193)
		tmp = t_1 * (sqrt((d / h)) * (1.0 + ((h / l) * (-0.5 * ((M * (D / (d * 2.0))) ^ 2.0)))));
	elseif (t_0 <= 1e-282)
		tmp = d * sqrt(((1.0 / h) / l));
	else
		tmp = t_1 * (1.0 / sqrt((h / d)));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(D * M), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -1e-193], N[(t$95$1 * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(M * N[(D / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-282], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(1.0 / N[Sqrt[N[(h / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-193}:\\
\;\;\;\;t\_1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)\\

\mathbf{elif}\;t\_0 \leq 10^{-282}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1e-193

    1. Initial program 82.1%

      \[\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) \]
    2. Simplified80.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. clear-num80.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \color{blue}{\frac{1}{\frac{d}{\frac{M}{2}}}}\right)}^{2} \cdot -0.5\right)\right)\right) \]
      2. un-div-inv80.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\color{blue}{\left(\frac{D}{\frac{d}{\frac{M}{2}}}\right)}}^{2} \cdot -0.5\right)\right)\right) \]
      3. div-inv80.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{\color{blue}{d \cdot \frac{1}{\frac{M}{2}}}}\right)}^{2} \cdot -0.5\right)\right)\right) \]
      4. clear-num80.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{d \cdot \color{blue}{\frac{2}{M}}}\right)}^{2} \cdot -0.5\right)\right)\right) \]
    5. Applied egg-rr80.1%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\color{blue}{\left(\frac{D}{d \cdot \frac{2}{M}}\right)}}^{2} \cdot -0.5\right)\right)\right) \]
    6. Step-by-step derivation
      1. associate-*r/80.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(\frac{D}{\color{blue}{\frac{d \cdot 2}{M}}}\right)}^{2} \cdot -0.5\right)\right)\right) \]
      2. associate-/r/82.2%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\color{blue}{\left(\frac{D}{d \cdot 2} \cdot M\right)}}^{2} \cdot -0.5\right)\right)\right) \]
    7. Simplified82.2%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\color{blue}{\left(\frac{D}{d \cdot 2} \cdot M\right)}}^{2} \cdot -0.5\right)\right)\right) \]

    if -1e-193 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1e-282

    1. Initial program 33.6%

      \[\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) \]
    2. Simplified33.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 63.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*64.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified64.9%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]

    if 1e-282 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l))))

    1. Initial program 63.7%

      \[\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) \]
    2. Simplified63.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 68.4%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. clear-num68.4%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \]
      2. sqrt-div69.7%

        \[\leadsto \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \]
      3. metadata-eval69.7%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \]
    6. Applied egg-rr69.7%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right) \leq -1 \cdot 10^{-193}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(M \cdot \frac{D}{d \cdot 2}\right)}^{2}\right)\right)\right)\\ \mathbf{elif}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right) \leq 10^{-282}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \frac{1}{\sqrt{\frac{h}{d}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 78.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{d}{h}}\\ \mathbf{if}\;d \leq -2.1 \cdot 10^{-21}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t\_0\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\ \mathbf{elif}\;d \leq -5.1 \cdot 10^{-284}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(t\_0 \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ d h))))
   (if (<= d -2.1e-21)
     (*
      (* (sqrt (/ d l)) t_0)
      (- 1.0 (* 0.5 (pow (* (* (/ D d) (* M 0.5)) (sqrt (/ h l))) 2.0))))
     (if (<= d -5.1e-284)
       (*
        (/ (sqrt (- d)) (sqrt (- l)))
        (* t_0 (+ 1.0 (* -0.125 (* (/ h l) (pow (* D (/ M d)) 2.0))))))
       (*
        d
        (/
         (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
         (* (sqrt l) (sqrt h))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((d / h));
	double tmp;
	if (d <= -2.1e-21) {
		tmp = (sqrt((d / l)) * t_0) * (1.0 - (0.5 * pow((((D / d) * (M * 0.5)) * sqrt((h / l))), 2.0)));
	} else if (d <= -5.1e-284) {
		tmp = (sqrt(-d) / sqrt(-l)) * (t_0 * (1.0 + (-0.125 * ((h / l) * pow((D * (M / d)), 2.0)))));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(d / h))
	tmp = 0.0
	if (d <= -2.1e-21)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * t_0) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(D / d) * Float64(M * 0.5)) * sqrt(Float64(h / l))) ^ 2.0))));
	elseif (d <= -5.1e-284)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * Float64(t_0 * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(D * Float64(M / d)) ^ 2.0))))));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -2.1e-21], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.1e-284], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;d \leq -2.1 \cdot 10^{-21}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot t\_0\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\

\mathbf{elif}\;d \leq -5.1 \cdot 10^{-284}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(t\_0 \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.10000000000000013e-21

    1. Initial program 79.2%

      \[\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) \]
    2. Simplified79.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt79.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow279.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod79.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow184.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval84.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow184.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative84.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv84.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval84.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr84.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]

    if -2.10000000000000013e-21 < d < -5.1000000000000002e-284

    1. Initial program 65.5%

      \[\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) \]
    2. Simplified63.7%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \frac{h}{\ell}}\right)\right) \]
      2. clear-num63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}\right)\right) \]
      3. un-div-inv63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5}{\frac{\ell}{h}}}\right)\right) \]
      4. *-commutative63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{\color{blue}{-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      5. add-sqr-sqrt63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}}{\frac{\ell}{h}}\right)\right) \]
      6. pow263.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      7. unpow263.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(\sqrt{\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      8. sqrt-prod39.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(\sqrt{D \cdot \frac{\frac{M}{2}}{d}} \cdot \sqrt{D \cdot \frac{\frac{M}{2}}{d}}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      9. add-sqr-sqrt63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      10. associate-/l/63.7%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    5. Applied egg-rr63.7%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}}\right)\right) \]
    6. Step-by-step derivation
      1. frac-2neg63.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-d}{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      2. sqrt-div71.6%

        \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    7. Applied egg-rr71.6%

      \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    8. Taylor expanded in D around 0 44.4%

      \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r*46.4%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      2. times-frac46.3%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right)\right) \]
      3. unpow246.3%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      4. unpow246.3%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      5. unswap-sqr62.2%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      6. unpow262.2%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      7. times-frac73.5%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      8. unpow273.5%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. *-commutative73.5%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)}\right)\right) \]
      10. associate-/l*71.6%

        \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\color{blue}{\left(D \cdot \frac{M}{d}\right)}}^{2}\right)\right)\right) \]
    10. Simplified71.6%

      \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{-0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)}\right)\right) \]

    if -5.1000000000000002e-284 < d

    1. Initial program 63.3%

      \[\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) \]
    2. Simplified63.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg63.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in53.1%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity53.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative53.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div60.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div62.0%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times62.0%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt62.1%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr74.3%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity74.3%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative74.3%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in80.2%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/81.1%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*81.0%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified84.9%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.1 \cdot 10^{-21}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\ \mathbf{elif}\;d \leq -5.1 \cdot 10^{-284}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(D \cdot \frac{M}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -5e-310)
   (*
    (*
     (/ (sqrt (- d)) (sqrt (- h)))
     (+ 1.0 (/ (* -0.5 (pow (* D (/ M (* d 2.0))) 2.0)) (/ l h))))
    (sqrt (/ d l)))
   (*
    d
    (/
     (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
     (* (sqrt l) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5e-310) {
		tmp = ((sqrt(-d) / sqrt(-h)) * (1.0 + ((-0.5 * pow((D * (M / (d * 2.0))), 2.0)) / (l / h)))) * sqrt((d / l));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(-0.5 * (Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0)) / Float64(l / h)))) * sqrt(Float64(d / l)));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(-0.5 * N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(l / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.999999999999985e-310

    1. Initial program 72.3%

      \[\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) \]
    2. Simplified70.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \frac{h}{\ell}}\right)\right) \]
      2. clear-num70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}\right)\right) \]
      3. un-div-inv70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5}{\frac{\ell}{h}}}\right)\right) \]
      4. *-commutative70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{\color{blue}{-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      5. add-sqr-sqrt70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}}{\frac{\ell}{h}}\right)\right) \]
      6. pow270.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      7. unpow270.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(\sqrt{\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      8. sqrt-prod44.4%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(\sqrt{D \cdot \frac{\frac{M}{2}}{d}} \cdot \sqrt{D \cdot \frac{\frac{M}{2}}{d}}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      9. add-sqr-sqrt70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      10. associate-/l/70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    5. Applied egg-rr70.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}}\right)\right) \]
    6. Step-by-step derivation
      1. frac-2neg70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\color{blue}{\frac{-d}{-h}}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      2. sqrt-div79.6%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    7. Applied egg-rr79.6%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]

    if -4.999999999999985e-310 < l

    1. Initial program 64.3%

      \[\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) \]
    2. Simplified64.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg64.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in53.9%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div61.3%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div62.9%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times62.9%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt63.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr75.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity75.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative75.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in81.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/82.3%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*82.3%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified86.2%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -5e-310)
   (*
    (sqrt (/ d l))
    (*
     (/ (sqrt (- d)) (sqrt (- h)))
     (+ 1.0 (* (/ h l) (* -0.5 (pow (* D (/ (/ M 2.0) d)) 2.0))))))
   (*
    d
    (/
     (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
     (* (sqrt l) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5e-310) {
		tmp = sqrt((d / l)) * ((sqrt(-d) / sqrt(-h)) * (1.0 + ((h / l) * (-0.5 * pow((D * ((M / 2.0) / d)), 2.0)))));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) * Float64(1.0 + Float64(Float64(h / l) * Float64(-0.5 * (Float64(D * Float64(Float64(M / 2.0) / d)) ^ 2.0))))));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-310], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(h / l), $MachinePrecision] * N[(-0.5 * N[Power[N[(D * N[(N[(M / 2.0), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.999999999999985e-310

    1. Initial program 72.3%

      \[\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) \]
    2. Simplified70.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. frac-2neg70.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\color{blue}{\frac{-d}{-h}}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right) \]
      2. sqrt-div79.6%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right) \]
    5. Applied egg-rr79.6%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right) \]

    if -4.999999999999985e-310 < l

    1. Initial program 64.3%

      \[\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) \]
    2. Simplified64.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg64.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in53.9%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div61.3%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div62.9%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times62.9%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt63.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr75.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity75.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative75.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in81.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/82.3%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*82.3%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified86.2%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\frac{\sqrt{-d}}{\sqrt{-h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left(-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 81.8% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{\frac{\sqrt{-d}}{\sqrt{-h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -5e-310)
   (*
    (/ (/ (sqrt (- d)) (sqrt (- h))) (sqrt (/ l d)))
    (+ 1.0 (* (* (/ h l) (pow (* M (/ D d)) 2.0)) -0.125)))
   (*
    d
    (/
     (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
     (* (sqrt l) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -5e-310) {
		tmp = ((sqrt(-d) / sqrt(-h)) / sqrt((l / d))) * (1.0 + (((h / l) * pow((M * (D / d)), 2.0)) * -0.125));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -5e-310)
		tmp = Float64(Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-h))) / sqrt(Float64(l / d))) * Float64(1.0 + Float64(Float64(Float64(h / l) * (Float64(M * Float64(D / d)) ^ 2.0)) * -0.125)));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -5e-310], N[(N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(N[(h / l), $MachinePrecision] * N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\frac{\sqrt{-d}}{\sqrt{-h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < -4.999999999999985e-310

    1. Initial program 72.3%

      \[\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) \]
    2. Simplified71.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt71.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow271.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod71.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow175.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval75.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow175.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative75.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv75.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval75.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr75.5%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. clear-num75.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. sqrt-div75.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. metadata-eval75.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. Applied egg-rr75.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. Step-by-step derivation
      1. pow175.6%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)}^{1}} \]
    9. Applied egg-rr71.6%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right)\right)\right)}^{1}} \]
    10. Step-by-step derivation
      1. unpow171.6%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right)\right)} \]
      2. *-commutative71.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right) \cdot -0.5}\right) \]
      3. associate-*r*71.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right) \cdot 0.25\right)} \cdot -0.5\right) \]
      4. associate-*l*71.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right) \cdot \left(0.25 \cdot -0.5\right)}\right) \]
      5. *-commutative71.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}\right) \cdot \left(0.25 \cdot -0.5\right)\right) \]
      6. metadata-eval71.6%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot \color{blue}{-0.125}\right) \]
    11. Simplified71.6%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right)} \]
    12. Step-by-step derivation
      1. frac-2neg71.6%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-d}{-h}}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right) \]
      2. sqrt-div80.3%

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right) \]
    13. Applied egg-rr80.3%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{-d}}{\sqrt{-h}}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right) \]

    if -4.999999999999985e-310 < l

    1. Initial program 64.3%

      \[\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) \]
    2. Simplified64.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg64.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in53.9%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative53.9%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div61.3%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div62.9%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times62.9%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt63.0%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr75.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity75.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative75.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in81.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/82.3%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*82.3%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified86.2%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 77.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 6 \cdot 10^{-295}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l 6e-295)
   (*
    (* (sqrt (/ d l)) (sqrt (/ d h)))
    (- 1.0 (* 0.5 (pow (* (* (/ D d) (* M 0.5)) (sqrt (/ h l))) 2.0))))
   (*
    d
    (/
     (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
     (* (sqrt l) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 6e-295) {
		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (0.5 * pow((((D / d) * (M * 0.5)) * sqrt((h / l))), 2.0)));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 6e-295)
		tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(0.5 * (Float64(Float64(Float64(D / d) * Float64(M * 0.5)) * sqrt(Float64(h / l))) ^ 2.0))));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 6e-295], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(0.5 * N[Power[N[(N[(N[(D / d), $MachinePrecision] * N[(M * 0.5), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 6 \cdot 10^{-295}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 5.99999999999999993e-295

    1. Initial program 72.5%

      \[\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) \]
    2. Simplified71.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt71.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow271.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod71.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow174.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval74.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow174.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative74.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv74.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval74.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr74.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]

    if 5.99999999999999993e-295 < l

    1. Initial program 64.0%

      \[\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) \]
    2. Simplified64.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg64.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in54.3%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity54.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative54.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div61.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div63.4%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times63.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt63.5%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr76.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity76.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative76.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in82.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/82.9%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*82.9%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified86.1%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 6 \cdot 10^{-295}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 77.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 6 \cdot 10^{-295}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l 6e-295)
   (*
    (* (pow (/ d h) 0.5) (pow (/ d l) 0.5))
    (- 1.0 (* (/ h l) (* 0.5 (pow (/ (* D M) (* d 2.0)) 2.0)))))
   (*
    d
    (/
     (fma -0.5 (* h (/ (pow (* D (* M (/ 0.5 d))) 2.0) l)) 1.0)
     (* (sqrt l) (sqrt h))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 6e-295) {
		tmp = (pow((d / h), 0.5) * pow((d / l), 0.5)) * (1.0 - ((h / l) * (0.5 * pow(((D * M) / (d * 2.0)), 2.0))));
	} else {
		tmp = d * (fma(-0.5, (h * (pow((D * (M * (0.5 / d))), 2.0) / l)), 1.0) / (sqrt(l) * sqrt(h)));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 6e-295)
		tmp = Float64(Float64((Float64(d / h) ^ 0.5) * (Float64(d / l) ^ 0.5)) * Float64(1.0 - Float64(Float64(h / l) * Float64(0.5 * (Float64(Float64(D * M) / Float64(d * 2.0)) ^ 2.0)))));
	else
		tmp = Float64(d * Float64(fma(-0.5, Float64(h * Float64((Float64(D * Float64(M * Float64(0.5 / d))) ^ 2.0) / l)), 1.0) / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 6e-295], N[(N[(N[Power[N[(d / h), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(0.5 * N[Power[N[(N[(D * M), $MachinePrecision] / N[(d * 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[(-0.5 * N[(h * N[(N[Power[N[(D * N[(M * N[(0.5 / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 6 \cdot 10^{-295}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 5.99999999999999993e-295

    1. Initial program 72.5%

      \[\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) \]
    2. Add Preprocessing

    if 5.99999999999999993e-295 < l

    1. Initial program 64.0%

      \[\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) \]
    2. Simplified64.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. sub-neg64.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \color{blue}{\left(1 + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)\right)} \]
      2. distribute-rgt-in54.3%

        \[\leadsto \color{blue}{1 \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} \]
      3. *-un-lft-identity54.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      4. *-commutative54.3%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      5. sqrt-div61.7%

        \[\leadsto \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}} \cdot \sqrt{\frac{d}{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. sqrt-div63.4%

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. frac-times63.4%

        \[\leadsto \color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      8. add-sqr-sqrt63.5%

        \[\leadsto \frac{\color{blue}{d}}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
    5. Applied egg-rr76.0%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    6. Step-by-step derivation
      1. *-rgt-identity76.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1} + \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right) \cdot \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      2. *-commutative76.0%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot 1 + \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(-0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      3. distribute-lft-in82.0%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)} \]
      4. associate-*l/82.9%

        \[\leadsto \color{blue}{\frac{d \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      5. associate-/l*82.9%

        \[\leadsto \color{blue}{d \cdot \frac{1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right)}^{2}\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. Simplified86.1%

      \[\leadsto \color{blue}{d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 6 \cdot 10^{-295}:\\ \;\;\;\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\mathsf{fma}\left(-0.5, h \cdot \frac{{\left(D \cdot \left(M \cdot \frac{0.5}{d}\right)\right)}^{2}}{\ell}, 1\right)}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 69.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 2.8 \cdot 10^{+191}:\\ \;\;\;\;\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l 2.8e+191)
   (*
    (/ (sqrt (/ d h)) (sqrt (/ l d)))
    (+ 1.0 (* -0.125 (/ (* h (pow (/ (* D M) d) 2.0)) l))))
   (* d (* (pow l -0.5) (pow h -0.5)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 2.8e+191) {
		tmp = (sqrt((d / h)) / sqrt((l / d))) * (1.0 + (-0.125 * ((h * pow(((D * M) / d), 2.0)) / l)));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (l <= 2.8d+191) then
        tmp = (sqrt((d / h)) / sqrt((l / d))) * (1.0d0 + ((-0.125d0) * ((h * (((d_1 * m) / d) ** 2.0d0)) / l)))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 2.8e+191) {
		tmp = (Math.sqrt((d / h)) / Math.sqrt((l / d))) * (1.0 + (-0.125 * ((h * Math.pow(((D * M) / d), 2.0)) / l)));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= 2.8e+191:
		tmp = (math.sqrt((d / h)) / math.sqrt((l / d))) * (1.0 + (-0.125 * ((h * math.pow(((D * M) / d), 2.0)) / l)))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 2.8e+191)
		tmp = Float64(Float64(sqrt(Float64(d / h)) / sqrt(Float64(l / d))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h * (Float64(Float64(D * M) / d) ^ 2.0)) / l))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= 2.8e+191)
		tmp = (sqrt((d / h)) / sqrt((l / d))) * (1.0 + (-0.125 * ((h * (((D * M) / d) ^ 2.0)) / l)));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 2.8e+191], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h * N[Power[N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2.8 \cdot 10^{+191}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 2.7999999999999999e191

    1. Initial program 69.2%

      \[\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) \]
    2. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt68.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow268.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod68.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow171.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow171.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr71.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. clear-num71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. sqrt-div71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. metadata-eval71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. Applied egg-rr71.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. Step-by-step derivation
      1. pow171.3%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)}^{1}} \]
    9. Applied egg-rr68.4%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right)\right)\right)}^{1}} \]
    10. Step-by-step derivation
      1. unpow168.4%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right)\right)} \]
      2. *-commutative68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right) \cdot -0.5}\right) \]
      3. associate-*r*68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right) \cdot 0.25\right)} \cdot -0.5\right) \]
      4. associate-*l*68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right) \cdot \left(0.25 \cdot -0.5\right)}\right) \]
      5. *-commutative68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}\right) \cdot \left(0.25 \cdot -0.5\right)\right) \]
      6. metadata-eval68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot \color{blue}{-0.125}\right) \]
    11. Simplified68.4%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right)} \]
    12. Step-by-step derivation
      1. associate-*l/68.1%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\frac{h \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}} \cdot -0.125\right) \]
      2. associate-*r/69.1%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \frac{h \cdot {\color{blue}{\left(\frac{M \cdot D}{d}\right)}}^{2}}{\ell} \cdot -0.125\right) \]
      3. *-commutative69.1%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \frac{h \cdot {\left(\frac{\color{blue}{D \cdot M}}{d}\right)}^{2}}{\ell} \cdot -0.125\right) \]
    13. Applied egg-rr69.1%

      \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\frac{h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}} \cdot -0.125\right) \]

    if 2.7999999999999999e191 < l

    1. Initial program 60.2%

      \[\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) \]
    2. Simplified63.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt63.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow263.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod63.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow169.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow169.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr69.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 54.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-154.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval54.6%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr54.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square54.7%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt54.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr54.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt54.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified54.7%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative54.7%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.8 \cdot 10^{+191}:\\ \;\;\;\;\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.125 \cdot \frac{h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 69.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.22 \cdot 10^{+190}:\\ \;\;\;\;\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l 1.22e+190)
   (*
    (/ (sqrt (/ d h)) (sqrt (/ l d)))
    (+ 1.0 (* -0.125 (* h (/ (pow (* M (/ D d)) 2.0) l)))))
   (* d (* (pow l -0.5) (pow h -0.5)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.22e+190) {
		tmp = (sqrt((d / h)) / sqrt((l / d))) * (1.0 + (-0.125 * (h * (pow((M * (D / d)), 2.0) / l))));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (l <= 1.22d+190) then
        tmp = (sqrt((d / h)) / sqrt((l / d))) * (1.0d0 + ((-0.125d0) * (h * (((m * (d_1 / d)) ** 2.0d0) / l))))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.22e+190) {
		tmp = (Math.sqrt((d / h)) / Math.sqrt((l / d))) * (1.0 + (-0.125 * (h * (Math.pow((M * (D / d)), 2.0) / l))));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= 1.22e+190:
		tmp = (math.sqrt((d / h)) / math.sqrt((l / d))) * (1.0 + (-0.125 * (h * (math.pow((M * (D / d)), 2.0) / l))))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 1.22e+190)
		tmp = Float64(Float64(sqrt(Float64(d / h)) / sqrt(Float64(l / d))) * Float64(1.0 + Float64(-0.125 * Float64(h * Float64((Float64(M * Float64(D / d)) ^ 2.0) / l)))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= 1.22e+190)
		tmp = (sqrt((d / h)) / sqrt((l / d))) * (1.0 + (-0.125 * (h * (((M * (D / d)) ^ 2.0) / l))));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 1.22e+190], N[(N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(h * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.22 \cdot 10^{+190}:\\
\;\;\;\;\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.21999999999999995e190

    1. Initial program 69.2%

      \[\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) \]
    2. Simplified68.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt68.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow268.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod68.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow171.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow171.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr71.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Step-by-step derivation
      1. clear-num71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      2. sqrt-div71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      3. metadata-eval71.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. Applied egg-rr71.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. Step-by-step derivation
      1. pow171.3%

        \[\leadsto \color{blue}{{\left(\left(\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)}^{1}} \]
    9. Applied egg-rr68.4%

      \[\leadsto \color{blue}{{\left(\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right)\right)\right)}^{1}} \]
    10. Step-by-step derivation
      1. unpow168.4%

        \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right)\right)} \]
      2. *-commutative68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot \left({\left(\frac{D}{d} \cdot M\right)}^{2} \cdot 0.25\right)\right) \cdot -0.5}\right) \]
      3. associate-*r*68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right) \cdot 0.25\right)} \cdot -0.5\right) \]
      4. associate-*l*68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot M\right)}^{2}\right) \cdot \left(0.25 \cdot -0.5\right)}\right) \]
      5. *-commutative68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}\right) \cdot \left(0.25 \cdot -0.5\right)\right) \]
      6. metadata-eval68.4%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot \color{blue}{-0.125}\right) \]
    11. Simplified68.4%

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot {\left(M \cdot \frac{D}{d}\right)}^{2}\right) \cdot -0.125\right)} \]
    12. Taylor expanded in h around 0 44.2%

      \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}} \cdot -0.125\right) \]
    13. Step-by-step derivation
      1. associate-*r*45.0%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell} \cdot -0.125\right) \]
      2. times-frac44.2%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)} \cdot -0.125\right) \]
      3. associate-/l*43.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\color{blue}{\left({D}^{2} \cdot \frac{{M}^{2}}{{d}^{2}}\right)} \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      4. unpow243.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot \frac{{M}^{2}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      5. unpow243.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\left(\left(D \cdot D\right) \cdot \frac{\color{blue}{M \cdot M}}{{d}^{2}}\right) \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      6. unpow243.8%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{\color{blue}{d \cdot d}}\right) \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      7. times-frac54.5%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(\frac{M}{d} \cdot \frac{M}{d}\right)}\right) \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      8. swap-sqr67.5%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\color{blue}{\left(\left(D \cdot \frac{M}{d}\right) \cdot \left(D \cdot \frac{M}{d}\right)\right)} \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      9. associate-/l*67.5%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\left(\color{blue}{\frac{D \cdot M}{d}} \cdot \left(D \cdot \frac{M}{d}\right)\right) \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      10. associate-/l*69.3%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\left(\frac{D \cdot M}{d} \cdot \color{blue}{\frac{D \cdot M}{d}}\right) \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      11. unpow269.3%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right) \cdot -0.125\right) \]
      12. *-commutative69.3%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)} \cdot -0.125\right) \]
      13. associate-*l/69.1%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\frac{h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}} \cdot -0.125\right) \]
      14. associate-/l*69.9%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}\right)} \cdot -0.125\right) \]
      15. *-commutative69.9%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{2}}{\ell}\right) \cdot -0.125\right) \]
      16. associate-/l*69.0%

        \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \left(h \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right) \cdot -0.125\right) \]
    14. Simplified69.0%

      \[\leadsto \frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + \color{blue}{\left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)} \cdot -0.125\right) \]

    if 1.21999999999999995e190 < l

    1. Initial program 60.2%

      \[\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) \]
    2. Simplified63.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt63.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow263.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod63.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow169.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow169.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr69.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 54.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-154.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval54.6%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr54.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square54.7%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt54.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr54.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt54.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified54.7%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative54.7%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 1.22 \cdot 10^{+190}:\\ \;\;\;\;\frac{\sqrt{\frac{d}{h}}}{\sqrt{\frac{\ell}{d}}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 69.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 1.72 \cdot 10^{+192}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l 1.72e+192)
   (*
    (sqrt (/ d l))
    (* (sqrt (/ d h)) (+ 1.0 (* -0.125 (* h (/ (pow (* M (/ D d)) 2.0) l))))))
   (* d (* (pow l -0.5) (pow h -0.5)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.72e+192) {
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (-0.125 * (h * (pow((M * (D / d)), 2.0) / l)))));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (l <= 1.72d+192) then
        tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0d0 + ((-0.125d0) * (h * (((m * (d_1 / d)) ** 2.0d0) / l)))))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= 1.72e+192) {
		tmp = Math.sqrt((d / l)) * (Math.sqrt((d / h)) * (1.0 + (-0.125 * (h * (Math.pow((M * (D / d)), 2.0) / l)))));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= 1.72e+192:
		tmp = math.sqrt((d / l)) * (math.sqrt((d / h)) * (1.0 + (-0.125 * (h * (math.pow((M * (D / d)), 2.0) / l)))))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= 1.72e+192)
		tmp = Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(d / h)) * Float64(1.0 + Float64(-0.125 * Float64(h * Float64((Float64(M * Float64(D / d)) ^ 2.0) / l))))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= 1.72e+192)
		tmp = sqrt((d / l)) * (sqrt((d / h)) * (1.0 + (-0.125 * (h * (((M * (D / d)) ^ 2.0) / l)))));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 1.72e+192], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(h * N[(N[Power[N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.72 \cdot 10^{+192}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 1.7199999999999999e192

    1. Initial program 69.2%

      \[\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) \]
    2. Simplified67.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \frac{h}{\ell}}\right)\right) \]
      2. clear-num67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}\right)\right) \]
      3. un-div-inv67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5}{\frac{\ell}{h}}}\right)\right) \]
      4. *-commutative67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{\color{blue}{-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      5. add-sqr-sqrt67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}}{\frac{\ell}{h}}\right)\right) \]
      6. pow267.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      7. unpow267.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(\sqrt{\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      8. sqrt-prod44.2%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(\sqrt{D \cdot \frac{\frac{M}{2}}{d}} \cdot \sqrt{D \cdot \frac{\frac{M}{2}}{d}}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      9. add-sqr-sqrt67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      10. associate-/l/67.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    5. Applied egg-rr67.5%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}}\right)\right) \]
    6. Taylor expanded in D around 0 44.2%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{-0.125 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2} \cdot \ell}}\right)\right) \]
    7. Step-by-step derivation
      1. associate-*r*45.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2} \cdot \ell}\right)\right) \]
      2. times-frac44.2%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\left(\frac{{D}^{2} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)}\right)\right) \]
      3. unpow244.2%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      4. unpow244.2%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      5. unswap-sqr55.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{{d}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      6. unpow255.5%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\color{blue}{d \cdot d}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      7. times-frac69.3%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)} \cdot \frac{h}{\ell}\right)\right)\right) \]
      8. unpow269.3%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(\color{blue}{{\left(\frac{D \cdot M}{d}\right)}^{2}} \cdot \frac{h}{\ell}\right)\right)\right) \]
      9. *-commutative69.3%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)}\right)\right) \]
      10. associate-*l/69.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\frac{h \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}}\right)\right) \]
      11. associate-/l*69.9%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \color{blue}{\left(h \cdot \frac{{\left(\frac{D \cdot M}{d}\right)}^{2}}{\ell}\right)}\right)\right) \]
      12. *-commutative69.9%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\left(\frac{\color{blue}{M \cdot D}}{d}\right)}^{2}}{\ell}\right)\right)\right) \]
      13. associate-/l*68.9%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + -0.125 \cdot \left(h \cdot \frac{{\color{blue}{\left(M \cdot \frac{D}{d}\right)}}^{2}}{\ell}\right)\right)\right) \]
    8. Simplified68.9%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{-0.125 \cdot \left(h \cdot \frac{{\left(M \cdot \frac{D}{d}\right)}^{2}}{\ell}\right)}\right)\right) \]

    if 1.7199999999999999e192 < l

    1. Initial program 60.2%

      \[\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) \]
    2. Simplified63.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt63.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow263.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod63.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow169.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow169.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval69.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr69.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 54.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-154.6%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval54.6%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr54.7%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square54.7%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt54.7%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr54.7%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt54.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified54.7%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative54.7%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down81.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr81.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 60.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{+108}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;\ell \leq 360 \lor \neg \left(\ell \leq 1.05 \cdot 10^{+111}\right) \land \ell \leq 3.8 \cdot 10^{+189}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -1e+108)
   (* (/ (sqrt (- d)) (sqrt (- l))) (sqrt (/ d h)))
   (if (or (<= l 360.0) (and (not (<= l 1.05e+111)) (<= l 3.8e+189)))
     (*
      (sqrt (* (/ d l) (/ d h)))
      (+ 1.0 (* h (* -0.5 (/ (pow (* D (/ M (* d 2.0))) 2.0) l)))))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1e+108) {
		tmp = (sqrt(-d) / sqrt(-l)) * sqrt((d / h));
	} else if ((l <= 360.0) || (!(l <= 1.05e+111) && (l <= 3.8e+189))) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (pow((D * (M / (d * 2.0))), 2.0) / l))));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (l <= (-1d+108)) then
        tmp = (sqrt(-d) / sqrt(-l)) * sqrt((d / h))
    else if ((l <= 360.0d0) .or. (.not. (l <= 1.05d+111)) .and. (l <= 3.8d+189)) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + (h * ((-0.5d0) * (((d_1 * (m / (d * 2.0d0))) ** 2.0d0) / l))))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1e+108) {
		tmp = (Math.sqrt(-d) / Math.sqrt(-l)) * Math.sqrt((d / h));
	} else if ((l <= 360.0) || (!(l <= 1.05e+111) && (l <= 3.8e+189))) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (Math.pow((D * (M / (d * 2.0))), 2.0) / l))));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -1e+108:
		tmp = (math.sqrt(-d) / math.sqrt(-l)) * math.sqrt((d / h))
	elif (l <= 360.0) or (not (l <= 1.05e+111) and (l <= 3.8e+189)):
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (math.pow((D * (M / (d * 2.0))), 2.0) / l))))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -1e+108)
		tmp = Float64(Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))) * sqrt(Float64(d / h)));
	elseif ((l <= 360.0) || (!(l <= 1.05e+111) && (l <= 3.8e+189)))
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(h * Float64(-0.5 * Float64((Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0) / l)))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -1e+108)
		tmp = (sqrt(-d) / sqrt(-l)) * sqrt((d / h));
	elseif ((l <= 360.0) || (~((l <= 1.05e+111)) && (l <= 3.8e+189)))
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (((D * (M / (d * 2.0))) ^ 2.0) / l))));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1e+108], N[(N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 360.0], And[N[Not[LessEqual[l, 1.05e+111]], $MachinePrecision], LessEqual[l, 3.8e+189]]], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.5 * N[(N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{+108}:\\
\;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;\ell \leq 360 \lor \neg \left(\ell \leq 1.05 \cdot 10^{+111}\right) \land \ell \leq 3.8 \cdot 10^{+189}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1e108

    1. Initial program 53.2%

      \[\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) \]
    2. Simplified51.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{h}{\ell} \cdot \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right)\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. *-commutative51.1%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \frac{h}{\ell}}\right)\right) \]
      2. clear-num51.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \left({\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5\right) \cdot \color{blue}{\frac{1}{\frac{\ell}{h}}}\right)\right) \]
      3. un-div-inv51.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2} \cdot -0.5}{\frac{\ell}{h}}}\right)\right) \]
      4. *-commutative51.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{\color{blue}{-0.5 \cdot {\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      5. add-sqr-sqrt51.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}} \cdot \sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}}{\frac{\ell}{h}}\right)\right) \]
      6. pow251.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot \color{blue}{{\left(\sqrt{{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}^{2}}\right)}^{2}}}{\frac{\ell}{h}}\right)\right) \]
      7. unpow251.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(\sqrt{\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right) \cdot \left(D \cdot \frac{\frac{M}{2}}{d}\right)}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      8. sqrt-prod37.2%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(\sqrt{D \cdot \frac{\frac{M}{2}}{d}} \cdot \sqrt{D \cdot \frac{\frac{M}{2}}{d}}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      9. add-sqr-sqrt51.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\color{blue}{\left(D \cdot \frac{\frac{M}{2}}{d}\right)}}^{2}}{\frac{\ell}{h}}\right)\right) \]
      10. associate-/l/51.0%

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \color{blue}{\frac{M}{d \cdot 2}}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    5. Applied egg-rr51.0%

      \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}}\right)\right) \]
    6. Step-by-step derivation
      1. frac-2neg51.0%

        \[\leadsto \sqrt{\color{blue}{\frac{-d}{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
      2. sqrt-div60.0%

        \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    7. Applied egg-rr60.0%

      \[\leadsto \color{blue}{\frac{\sqrt{-d}}{\sqrt{-\ell}}} \cdot \left(\sqrt{\frac{d}{h}} \cdot \left(1 + \frac{-0.5 \cdot {\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\frac{\ell}{h}}\right)\right) \]
    8. Taylor expanded in d around inf 53.2%

      \[\leadsto \frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}} \]

    if -1e108 < l < 360 or 1.04999999999999997e111 < l < 3.7999999999999998e189

    1. Initial program 75.3%

      \[\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) \]
    2. Simplified74.1%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt74.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow274.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod74.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow174.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval74.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow174.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative74.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv74.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval74.1%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr74.1%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Applied egg-rr67.6%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow167.6%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. *-commutative67.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. *-commutative67.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. associate-*l*67.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      5. associate-*r/68.4%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{\left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
      6. associate-*l/69.0%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell} \cdot h}\right) \]
      7. *-commutative69.0%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \frac{-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}}\right) \]
      8. associate-/l*69.0%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \color{blue}{\left(-0.5 \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      9. associate-/l*67.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      10. *-commutative67.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}}{\ell}\right)\right) \]
    8. Simplified67.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}\right)\right)} \]

    if 360 < l < 1.04999999999999997e111 or 3.7999999999999998e189 < l

    1. Initial program 58.8%

      \[\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) \]
    2. Simplified60.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow260.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod60.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow167.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow167.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval67.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr67.6%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 57.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-157.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval57.8%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr57.9%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square57.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt57.6%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr57.6%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt57.9%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified57.9%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative57.9%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down77.2%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr77.2%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification66.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{+108}:\\ \;\;\;\;\frac{\sqrt{-d}}{\sqrt{-\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;\ell \leq 360 \lor \neg \left(\ell \leq 1.05 \cdot 10^{+111}\right) \land \ell \leq 3.8 \cdot 10^{+189}:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 60.3% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -9.5 \cdot 10^{+107}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\\ \mathbf{elif}\;\ell \leq 28500:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -9.5e+107)
   (* (sqrt (/ d h)) (/ 1.0 (sqrt (/ l d))))
   (if (<= l 28500.0)
     (*
      (sqrt (* (/ d l) (/ d h)))
      (+ 1.0 (* h (* -0.5 (/ (pow (* D (/ M (* d 2.0))) 2.0) l)))))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -9.5e+107) {
		tmp = sqrt((d / h)) * (1.0 / sqrt((l / d)));
	} else if (l <= 28500.0) {
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (pow((D * (M / (d * 2.0))), 2.0) / l))));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (l <= (-9.5d+107)) then
        tmp = sqrt((d / h)) * (1.0d0 / sqrt((l / d)))
    else if (l <= 28500.0d0) then
        tmp = sqrt(((d / l) * (d / h))) * (1.0d0 + (h * ((-0.5d0) * (((d_1 * (m / (d * 2.0d0))) ** 2.0d0) / l))))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -9.5e+107) {
		tmp = Math.sqrt((d / h)) * (1.0 / Math.sqrt((l / d)));
	} else if (l <= 28500.0) {
		tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (Math.pow((D * (M / (d * 2.0))), 2.0) / l))));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if l <= -9.5e+107:
		tmp = math.sqrt((d / h)) * (1.0 / math.sqrt((l / d)))
	elif l <= 28500.0:
		tmp = math.sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (math.pow((D * (M / (d * 2.0))), 2.0) / l))))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -9.5e+107)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(1.0 / sqrt(Float64(l / d))));
	elseif (l <= 28500.0)
		tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 + Float64(h * Float64(-0.5 * Float64((Float64(D * Float64(M / Float64(d * 2.0))) ^ 2.0) / l)))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (l <= -9.5e+107)
		tmp = sqrt((d / h)) * (1.0 / sqrt((l / d)));
	elseif (l <= 28500.0)
		tmp = sqrt(((d / l) * (d / h))) * (1.0 + (h * (-0.5 * (((D * (M / (d * 2.0))) ^ 2.0) / l))));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -9.5e+107], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 28500.0], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(h * N[(-0.5 * N[(N[Power[N[(D * N[(M / N[(d * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -9.5 \cdot 10^{+107}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\\

\mathbf{elif}\;\ell \leq 28500:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -9.50000000000000019e107

    1. Initial program 53.2%

      \[\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) \]
    2. Simplified53.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 49.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. clear-num49.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}} \cdot 1\right) \]
      2. sqrt-div49.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}} \cdot 1\right) \]
      3. metadata-eval49.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}} \cdot 1\right) \]
    6. Applied egg-rr49.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}} \cdot 1\right) \]

    if -9.50000000000000019e107 < l < 28500

    1. Initial program 77.7%

      \[\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) \]
    2. Simplified76.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow276.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow176.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow176.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr76.3%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Applied egg-rr69.1%

      \[\leadsto \color{blue}{{\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\right)}^{1}} \]
    7. Step-by-step derivation
      1. unpow169.1%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)} \]
      2. *-commutative69.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \color{blue}{\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. *-commutative69.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left({\left(\frac{\color{blue}{D \cdot M}}{d \cdot 2}\right)}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. associate-*l*69.1%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right) \cdot \frac{h}{\ell}}\right) \]
      5. associate-*r/70.7%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{\left(-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}\right) \cdot h}{\ell}}\right) \]
      6. associate-*l/70.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{\frac{-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell} \cdot h}\right) \]
      7. *-commutative70.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \color{blue}{h \cdot \frac{-0.5 \cdot {\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}}\right) \]
      8. associate-/l*70.6%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \color{blue}{\left(-0.5 \cdot \frac{{\left(\frac{D \cdot M}{d \cdot 2}\right)}^{2}}{\ell}\right)}\right) \]
      9. associate-/l*68.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\color{blue}{\left(D \cdot \frac{M}{d \cdot 2}\right)}}^{2}}{\ell}\right)\right) \]
      10. *-commutative68.5%

        \[\leadsto \sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{\color{blue}{2 \cdot d}}\right)}^{2}}{\ell}\right)\right) \]
    8. Simplified68.5%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{2 \cdot d}\right)}^{2}}{\ell}\right)\right)} \]

    if 28500 < l

    1. Initial program 58.3%

      \[\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) \]
    2. Simplified59.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt59.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow259.5%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod59.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow164.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval64.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow164.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative64.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv64.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval64.8%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr64.8%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 50.4%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-150.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval50.4%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr50.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square50.5%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt50.3%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr50.3%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt50.5%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified50.5%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative50.5%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down64.9%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr64.9%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9.5 \cdot 10^{+107}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\\ \mathbf{elif}\;\ell \leq 28500:\\ \;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 + h \cdot \left(-0.5 \cdot \frac{{\left(D \cdot \frac{M}{d \cdot 2}\right)}^{2}}{\ell}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 47.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{if}\;\ell \leq -1.3 \cdot 10^{-200}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\ell \leq -3.5 \cdot 10^{-288}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-266}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (* (- d) (sqrt (/ (/ 1.0 h) l)))))
   (if (<= l -1.3e-200)
     t_0
     (if (<= l -3.5e-288)
       (* d (pow (pow (* h l) 2.0) -0.25))
       (if (<= l 3.8e-266) t_0 (* d (* (pow l -0.5) (pow h -0.5))))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = -d * sqrt(((1.0 / h) / l));
	double tmp;
	if (l <= -1.3e-200) {
		tmp = t_0;
	} else if (l <= -3.5e-288) {
		tmp = d * pow(pow((h * l), 2.0), -0.25);
	} else if (l <= 3.8e-266) {
		tmp = t_0;
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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 = -d * sqrt(((1.0d0 / h) / l))
    if (l <= (-1.3d-200)) then
        tmp = t_0
    else if (l <= (-3.5d-288)) then
        tmp = d * (((h * l) ** 2.0d0) ** (-0.25d0))
    else if (l <= 3.8d-266) then
        tmp = t_0
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = -d * Math.sqrt(((1.0 / h) / l));
	double tmp;
	if (l <= -1.3e-200) {
		tmp = t_0;
	} else if (l <= -3.5e-288) {
		tmp = d * Math.pow(Math.pow((h * l), 2.0), -0.25);
	} else if (l <= 3.8e-266) {
		tmp = t_0;
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = -d * math.sqrt(((1.0 / h) / l))
	tmp = 0
	if l <= -1.3e-200:
		tmp = t_0
	elif l <= -3.5e-288:
		tmp = d * math.pow(math.pow((h * l), 2.0), -0.25)
	elif l <= 3.8e-266:
		tmp = t_0
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)))
	tmp = 0.0
	if (l <= -1.3e-200)
		tmp = t_0;
	elseif (l <= -3.5e-288)
		tmp = Float64(d * ((Float64(h * l) ^ 2.0) ^ -0.25));
	elseif (l <= 3.8e-266)
		tmp = t_0;
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = -d * sqrt(((1.0 / h) / l));
	tmp = 0.0;
	if (l <= -1.3e-200)
		tmp = t_0;
	elseif (l <= -3.5e-288)
		tmp = d * (((h * l) ^ 2.0) ^ -0.25);
	elseif (l <= 3.8e-266)
		tmp = t_0;
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.3e-200], t$95$0, If[LessEqual[l, -3.5e-288], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], 2.0], $MachinePrecision], -0.25], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.8e-266], t$95$0, N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{if}\;\ell \leq -1.3 \cdot 10^{-200}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;\ell \leq -3.5 \cdot 10^{-288}:\\
\;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\

\mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-266}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -1.29999999999999995e-200 or -3.5000000000000003e-288 < l < 3.79999999999999994e-266

    1. Initial program 71.1%

      \[\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) \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.6%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.6%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.6%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -1.29999999999999995e-200 < l < -3.5000000000000003e-288

    1. Initial program 79.9%

      \[\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) \]
    2. Simplified79.9%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 34.7%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. add-log-exp53.6%

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. pow1/253.6%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(\frac{1}{h \cdot \ell}\right)}^{0.5}}}\right) \]
      3. inv-pow53.6%

        \[\leadsto d \cdot \log \left(e^{{\color{blue}{\left({\left(h \cdot \ell\right)}^{-1}\right)}}^{0.5}}\right) \]
      4. pow-pow53.6%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(-1 \cdot 0.5\right)}}}\right) \]
      5. metadata-eval53.6%

        \[\leadsto d \cdot \log \left(e^{{\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}}\right) \]
    6. Applied egg-rr53.6%

      \[\leadsto d \cdot \color{blue}{\log \left(e^{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. Step-by-step derivation
      1. rem-log-exp34.7%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      2. sqr-pow34.7%

        \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      3. pow-prod-down42.3%

        \[\leadsto d \cdot \color{blue}{{\left(\left(h \cdot \ell\right) \cdot \left(h \cdot \ell\right)\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      4. pow242.3%

        \[\leadsto d \cdot {\color{blue}{\left({\left(h \cdot \ell\right)}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      5. *-commutative42.3%

        \[\leadsto d \cdot {\left({\color{blue}{\left(\ell \cdot h\right)}}^{2}\right)}^{\left(\frac{-0.5}{2}\right)} \]
      6. metadata-eval42.3%

        \[\leadsto d \cdot {\left({\left(\ell \cdot h\right)}^{2}\right)}^{\color{blue}{-0.25}} \]
    8. Applied egg-rr42.3%

      \[\leadsto d \cdot \color{blue}{{\left({\left(\ell \cdot h\right)}^{2}\right)}^{-0.25}} \]

    if 3.79999999999999994e-266 < l

    1. Initial program 63.4%

      \[\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) \]
    2. Simplified64.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt64.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow264.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod64.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow167.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval67.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow167.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative67.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv67.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval67.0%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr67.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 45.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-145.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval45.5%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr45.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square45.5%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt45.3%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr45.3%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt45.5%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified45.5%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative45.5%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down55.7%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr55.7%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.3 \cdot 10^{-200}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{elif}\;\ell \leq -3.5 \cdot 10^{-288}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 3.8 \cdot 10^{-266}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 46.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq -7 \cdot 10^{+107}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 1.4 \cdot 10^{-272}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= h -7e+107)
   (* (sqrt (/ d h)) (/ 1.0 (sqrt (/ l d))))
   (if (<= h 1.4e-272)
     (* (- d) (sqrt (/ (/ 1.0 h) l)))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -7e+107) {
		tmp = sqrt((d / h)) * (1.0 / sqrt((l / d)));
	} else if (h <= 1.4e-272) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (h <= (-7d+107)) then
        tmp = sqrt((d / h)) * (1.0d0 / sqrt((l / d)))
    else if (h <= 1.4d-272) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -7e+107) {
		tmp = Math.sqrt((d / h)) * (1.0 / Math.sqrt((l / d)));
	} else if (h <= 1.4e-272) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if h <= -7e+107:
		tmp = math.sqrt((d / h)) * (1.0 / math.sqrt((l / d)))
	elif h <= 1.4e-272:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= -7e+107)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(1.0 / sqrt(Float64(l / d))));
	elseif (h <= 1.4e-272)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= -7e+107)
		tmp = sqrt((d / h)) * (1.0 / sqrt((l / d)));
	elseif (h <= 1.4e-272)
		tmp = -d * sqrt(((1.0 / h) / l));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, -7e+107], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[Sqrt[N[(l / d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.4e-272], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;h \leq -7 \cdot 10^{+107}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\\

\mathbf{elif}\;h \leq 1.4 \cdot 10^{-272}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -6.9999999999999995e107

    1. Initial program 65.0%

      \[\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) \]
    2. Simplified65.1%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 41.9%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]
    5. Step-by-step derivation
      1. clear-num41.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\color{blue}{\frac{1}{\frac{\ell}{d}}}} \cdot 1\right) \]
      2. sqrt-div41.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{\ell}{d}}}} \cdot 1\right) \]
      3. metadata-eval41.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\frac{\color{blue}{1}}{\sqrt{\frac{\ell}{d}}} \cdot 1\right) \]
    6. Applied egg-rr41.9%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\color{blue}{\frac{1}{\sqrt{\frac{\ell}{d}}}} \cdot 1\right) \]

    if -6.9999999999999995e107 < h < 1.39999999999999997e-272

    1. Initial program 75.0%

      \[\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) \]
    2. Simplified74.0%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.3%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.3%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.3%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if 1.39999999999999997e-272 < h

    1. Initial program 64.5%

      \[\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) \]
    2. Simplified64.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow264.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow167.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow167.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-144.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval44.1%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr44.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square44.2%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt44.0%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr44.0%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt44.2%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified44.2%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative44.2%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down54.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr54.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -7 \cdot 10^{+107}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{1}{\sqrt{\frac{\ell}{d}}}\\ \mathbf{elif}\;h \leq 1.4 \cdot 10^{-272}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 46.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq -7 \cdot 10^{+111}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;h \leq 1.4 \cdot 10^{-272}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= h -7e+111)
   (* (sqrt (/ d l)) (sqrt (/ d h)))
   (if (<= h 1.4e-272)
     (* (- d) (sqrt (/ (/ 1.0 h) l)))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -7e+111) {
		tmp = sqrt((d / l)) * sqrt((d / h));
	} else if (h <= 1.4e-272) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (h <= (-7d+111)) then
        tmp = sqrt((d / l)) * sqrt((d / h))
    else if (h <= 1.4d-272) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= -7e+111) {
		tmp = Math.sqrt((d / l)) * Math.sqrt((d / h));
	} else if (h <= 1.4e-272) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if h <= -7e+111:
		tmp = math.sqrt((d / l)) * math.sqrt((d / h))
	elif h <= 1.4e-272:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= -7e+111)
		tmp = Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h)));
	elseif (h <= 1.4e-272)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= -7e+111)
		tmp = sqrt((d / l)) * sqrt((d / h));
	elseif (h <= 1.4e-272)
		tmp = -d * sqrt(((1.0 / h) / l));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, -7e+111], N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.4e-272], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;h \leq -7 \cdot 10^{+111}:\\
\;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\

\mathbf{elif}\;h \leq 1.4 \cdot 10^{-272}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -7.0000000000000004e111

    1. Initial program 64.1%

      \[\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) \]
    2. Simplified64.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \mathsf{fma}\left({\left(0.5 \cdot \left(M \cdot \frac{D}{d}\right)\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in M around 0 43.0%

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{1}\right) \]

    if -7.0000000000000004e111 < h < 1.39999999999999997e-272

    1. Initial program 75.3%

      \[\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) \]
    2. Simplified74.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt46.7%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-146.7%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified46.7%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if 1.39999999999999997e-272 < h

    1. Initial program 64.5%

      \[\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) \]
    2. Simplified64.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow264.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow167.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow167.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-144.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval44.1%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr44.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square44.2%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt44.0%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr44.0%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt44.2%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified44.2%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative44.2%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down54.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr54.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -7 \cdot 10^{+111}:\\ \;\;\;\;\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;h \leq 1.4 \cdot 10^{-272}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 45.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;h \leq 1.4 \cdot 10^{-272}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= h 1.4e-272)
   (* (- d) (sqrt (/ (/ 1.0 h) l)))
   (* d (* (pow l -0.5) (pow h -0.5)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.4e-272) {
		tmp = -d * sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	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) :: tmp
    if (h <= 1.4d-272) then
        tmp = -d * sqrt(((1.0d0 / h) / l))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (h <= 1.4e-272) {
		tmp = -d * Math.sqrt(((1.0 / h) / l));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if h <= 1.4e-272:
		tmp = -d * math.sqrt(((1.0 / h) / l))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (h <= 1.4e-272)
		tmp = Float64(Float64(-d) * sqrt(Float64(Float64(1.0 / h) / l)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (h <= 1.4e-272)
		tmp = -d * sqrt(((1.0 / h) / l));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 1.4e-272], N[((-d) * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.4 \cdot 10^{-272}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\

\mathbf{else}:\\
\;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < 1.39999999999999997e-272

    1. Initial program 72.0%

      \[\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) \]
    2. Simplified71.2%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt40.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-140.5%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified40.5%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if 1.39999999999999997e-272 < h

    1. Initial program 64.5%

      \[\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) \]
    2. Simplified64.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt64.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow264.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod64.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow167.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow167.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval67.2%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr67.2%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 44.1%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-144.1%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval44.1%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr44.2%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square44.2%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt44.0%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr44.0%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt44.2%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified44.2%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
    9. Step-by-step derivation
      1. *-commutative44.2%

        \[\leadsto d \cdot {\color{blue}{\left(\ell \cdot h\right)}}^{-0.5} \]
      2. unpow-prod-down54.0%

        \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
    10. Applied egg-rr54.0%

      \[\leadsto d \cdot \color{blue}{\left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification47.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq 1.4 \cdot 10^{-272}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 42.7% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{if}\;d \leq -3.1 \cdot 10^{-139}:\\ \;\;\;\;\left(-d\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (/ (/ 1.0 h) l))))
   (if (<= d -3.1e-139) (* (- d) t_0) (* d t_0))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt(((1.0 / h) / l));
	double tmp;
	if (d <= -3.1e-139) {
		tmp = -d * t_0;
	} else {
		tmp = d * t_0;
	}
	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(((1.0d0 / h) / l))
    if (d <= (-3.1d-139)) then
        tmp = -d * t_0
    else
        tmp = d * t_0
    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(((1.0 / h) / l));
	double tmp;
	if (d <= -3.1e-139) {
		tmp = -d * t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.sqrt(((1.0 / h) / l))
	tmp = 0
	if d <= -3.1e-139:
		tmp = -d * t_0
	else:
		tmp = d * t_0
	return tmp
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(Float64(1.0 / h) / l))
	tmp = 0.0
	if (d <= -3.1e-139)
		tmp = Float64(Float64(-d) * t_0);
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt(((1.0 / h) / l));
	tmp = 0.0;
	if (d <= -3.1e-139)
		tmp = -d * t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -3.1e-139], N[((-d) * t$95$0), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\frac{\frac{1}{h}}{\ell}}\\
\mathbf{if}\;d \leq -3.1 \cdot 10^{-139}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.0999999999999999e-139

    1. Initial program 77.3%

      \[\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) \]
    2. Simplified76.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. *-commutative0.0%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right)} \]
      2. associate-/r*0.0%

        \[\leadsto \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \cdot \left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \]
      3. *-commutative0.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot d\right)} \]
      4. unpow20.0%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot d\right) \]
      5. rem-square-sqrt47.2%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(\color{blue}{-1} \cdot d\right) \]
      6. neg-mul-147.2%

        \[\leadsto \sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \color{blue}{\left(-d\right)} \]
    6. Simplified47.2%

      \[\leadsto \color{blue}{\sqrt{\frac{\frac{1}{h}}{\ell}} \cdot \left(-d\right)} \]

    if -3.0999999999999999e-139 < d

    1. Initial program 62.7%

      \[\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) \]
    2. Simplified62.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 40.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*41.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified41.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.1 \cdot 10^{-139}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 19: 42.7% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -8.2 \cdot 10^{-145}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -8.2e-145)
   (* d (- (pow (* h l) -0.5)))
   (* d (sqrt (/ (/ 1.0 h) l)))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -8.2e-145) {
		tmp = d * -pow((h * l), -0.5);
	} else {
		tmp = d * sqrt(((1.0 / h) / l));
	}
	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) :: tmp
    if (d <= (-8.2d-145)) then
        tmp = d * -((h * l) ** (-0.5d0))
    else
        tmp = d * sqrt(((1.0d0 / h) / l))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -8.2e-145) {
		tmp = d * -Math.pow((h * l), -0.5);
	} else {
		tmp = d * Math.sqrt(((1.0 / h) / l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -8.2e-145:
		tmp = d * -math.pow((h * l), -0.5)
	else:
		tmp = d * math.sqrt(((1.0 / h) / l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -8.2e-145)
		tmp = Float64(d * Float64(-(Float64(h * l) ^ -0.5)));
	else
		tmp = Float64(d * sqrt(Float64(Float64(1.0 / h) / l)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= -8.2e-145)
		tmp = d * -((h * l) ^ -0.5);
	else
		tmp = d * sqrt(((1.0 / h) / l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -8.2e-145], N[(d * (-N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{-145}:\\
\;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.1999999999999995e-145

    1. Initial program 77.3%

      \[\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) \]
    2. Simplified76.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt76.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow276.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow181.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow181.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr81.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.9%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. neg-mul-146.9%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow-146.9%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \]
      6. metadata-eval46.9%

        \[\leadsto d \cdot \left(-\sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \]
      7. pow-sqr46.9%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      8. rem-sqrt-square46.9%

        \[\leadsto d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \]
      9. rem-square-sqrt46.7%

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      10. fabs-sqr46.7%

        \[\leadsto d \cdot \left(-\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      11. rem-square-sqrt46.9%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    8. Simplified46.9%

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -8.1999999999999995e-145 < d

    1. Initial program 62.7%

      \[\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) \]
    2. Simplified62.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 40.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. associate-/r*41.5%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
    6. Simplified41.5%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 20: 42.6% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{-144}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -1.9e-144)
   (* d (- (pow (* h l) -0.5)))
   (* d (sqrt (/ 1.0 (* h l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.9e-144) {
		tmp = d * -pow((h * l), -0.5);
	} else {
		tmp = d * sqrt((1.0 / (h * l)));
	}
	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) :: tmp
    if (d <= (-1.9d-144)) then
        tmp = d * -((h * l) ** (-0.5d0))
    else
        tmp = d * sqrt((1.0d0 / (h * l)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.9e-144) {
		tmp = d * -Math.pow((h * l), -0.5);
	} else {
		tmp = d * Math.sqrt((1.0 / (h * l)));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -1.9e-144:
		tmp = d * -math.pow((h * l), -0.5)
	else:
		tmp = d * math.sqrt((1.0 / (h * l)))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1.9e-144)
		tmp = Float64(d * Float64(-(Float64(h * l) ^ -0.5)));
	else
		tmp = Float64(d * sqrt(Float64(1.0 / Float64(h * l))));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= -1.9e-144)
		tmp = d * -((h * l) ^ -0.5);
	else
		tmp = d * sqrt((1.0 / (h * l)));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -1.9e-144], N[(d * (-N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision])), $MachinePrecision], N[(d * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.9 \cdot 10^{-144}:\\
\;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot \sqrt{\frac{1}{h \cdot \ell}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.89999999999999996e-144

    1. Initial program 77.3%

      \[\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) \]
    2. Simplified76.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt76.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow276.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow181.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow181.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr81.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.9%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. neg-mul-146.9%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow-146.9%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \]
      6. metadata-eval46.9%

        \[\leadsto d \cdot \left(-\sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \]
      7. pow-sqr46.9%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      8. rem-sqrt-square46.9%

        \[\leadsto d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \]
      9. rem-square-sqrt46.7%

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      10. fabs-sqr46.7%

        \[\leadsto d \cdot \left(-\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      11. rem-square-sqrt46.9%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    8. Simplified46.9%

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -1.89999999999999996e-144 < d

    1. Initial program 62.7%

      \[\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) \]
    2. Simplified62.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in d around inf 40.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 21: 42.7% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;d \leq -2.1 \cdot 10^{-144}:\\ \;\;\;\;d \cdot \left(-t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (pow (* h l) -0.5)))
   (if (<= d -2.1e-144) (* d (- t_0)) (* d t_0))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((h * l), -0.5);
	double tmp;
	if (d <= -2.1e-144) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	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 = (h * l) ** (-0.5d0)
    if (d <= (-2.1d-144)) then
        tmp = d * -t_0
    else
        tmp = d * t_0
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.pow((h * l), -0.5);
	double tmp;
	if (d <= -2.1e-144) {
		tmp = d * -t_0;
	} else {
		tmp = d * t_0;
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.pow((h * l), -0.5)
	tmp = 0
	if d <= -2.1e-144:
		tmp = d * -t_0
	else:
		tmp = d * t_0
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(h * l) ^ -0.5
	tmp = 0.0
	if (d <= -2.1e-144)
		tmp = Float64(d * Float64(-t_0));
	else
		tmp = Float64(d * t_0);
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = (h * l) ^ -0.5;
	tmp = 0.0;
	if (d <= -2.1e-144)
		tmp = d * -t_0;
	else
		tmp = d * t_0;
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, -2.1e-144], N[(d * (-t$95$0)), $MachinePrecision], N[(d * t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(h \cdot \ell\right)}^{-0.5}\\
\mathbf{if}\;d \leq -2.1 \cdot 10^{-144}:\\
\;\;\;\;d \cdot \left(-t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;d \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.1000000000000001e-144

    1. Initial program 77.3%

      \[\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) \]
    2. Simplified76.4%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt76.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow276.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod76.3%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow181.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow181.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval81.4%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr81.4%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in l around -inf 0.0%

      \[\leadsto \color{blue}{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. associate-*l*0.0%

        \[\leadsto \color{blue}{d \cdot \left({\left(\sqrt{-1}\right)}^{2} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      2. unpow20.0%

        \[\leadsto d \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. rem-square-sqrt46.9%

        \[\leadsto d \cdot \left(\color{blue}{-1} \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. neg-mul-146.9%

        \[\leadsto d \cdot \color{blue}{\left(-\sqrt{\frac{1}{h \cdot \ell}}\right)} \]
      5. unpow-146.9%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right) \]
      6. metadata-eval46.9%

        \[\leadsto d \cdot \left(-\sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}}\right) \]
      7. pow-sqr46.9%

        \[\leadsto d \cdot \left(-\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      8. rem-sqrt-square46.9%

        \[\leadsto d \cdot \left(-\color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|}\right) \]
      9. rem-square-sqrt46.7%

        \[\leadsto d \cdot \left(-\left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right|\right) \]
      10. fabs-sqr46.7%

        \[\leadsto d \cdot \left(-\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right) \]
      11. rem-square-sqrt46.9%

        \[\leadsto d \cdot \left(-\color{blue}{{\left(h \cdot \ell\right)}^{-0.5}}\right) \]
    8. Simplified46.9%

      \[\leadsto \color{blue}{d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)} \]

    if -2.1000000000000001e-144 < d

    1. Initial program 62.7%

      \[\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) \]
    2. Simplified62.6%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. add-sqr-sqrt62.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
      2. pow262.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
      3. sqrt-prod62.6%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
      4. sqrt-pow164.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      5. metadata-eval64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. pow164.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      7. *-commutative64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      8. div-inv64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      9. metadata-eval64.9%

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. Applied egg-rr64.9%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
    6. Taylor expanded in d around inf 40.8%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    7. Step-by-step derivation
      1. unpow-140.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
      2. metadata-eval40.8%

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr40.8%

        \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
      4. rem-sqrt-square40.2%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt40.0%

        \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
      6. fabs-sqr40.0%

        \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
      7. rem-square-sqrt40.2%

        \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Simplified40.2%

      \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 22: 27.3% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot {\left(h \cdot \ell\right)}^{-0.5} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (pow (* h l) -0.5)))
double code(double d, double h, double l, double M, double D) {
	return d * pow((h * l), -0.5);
}
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 * l) ** (-0.5d0))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((h * l), -0.5);
}
def code(d, h, l, M, D):
	return d * math.pow((h * l), -0.5)
function code(d, h, l, M, D)
	return Float64(d * (Float64(h * l) ^ -0.5))
end
function tmp = code(d, h, l, M, D)
	tmp = d * ((h * l) ^ -0.5);
end
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot {\left(h \cdot \ell\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 68.1%

    \[\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) \]
  2. Simplified67.7%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)\right)} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. add-sqr-sqrt67.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}} \cdot \sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}\right) \]
    2. pow267.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}}\right)}^{2}}\right) \]
    3. sqrt-prod67.7%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\color{blue}{\left(\sqrt{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}} \cdot \sqrt{\frac{h}{\ell}}\right)}}^{2}\right) \]
    4. sqrt-pow171.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\left(\frac{2}{2}\right)}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    5. metadata-eval71.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{\color{blue}{1}} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    6. pow171.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    7. *-commutative71.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\frac{D}{d} \cdot \frac{M}{2}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    8. div-inv71.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \color{blue}{\left(M \cdot \frac{1}{2}\right)}\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
    9. metadata-eval71.0%

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot \color{blue}{0.5}\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
  5. Applied egg-rr71.0%

    \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot \color{blue}{{\left(\left(\frac{D}{d} \cdot \left(M \cdot 0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}}\right) \]
  6. Taylor expanded in d around inf 28.6%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  7. Step-by-step derivation
    1. unpow-128.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}} \]
    2. metadata-eval28.6%

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr28.6%

      \[\leadsto d \cdot \sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-0.5} \cdot {\left(h \cdot \ell\right)}^{-0.5}}} \]
    4. rem-sqrt-square28.2%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    5. rem-square-sqrt28.1%

      \[\leadsto d \cdot \left|\color{blue}{\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}}\right| \]
    6. fabs-sqr28.1%

      \[\leadsto d \cdot \color{blue}{\left(\sqrt{{\left(h \cdot \ell\right)}^{-0.5}} \cdot \sqrt{{\left(h \cdot \ell\right)}^{-0.5}}\right)} \]
    7. rem-square-sqrt28.2%

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  8. Simplified28.2%

    \[\leadsto \color{blue}{d \cdot {\left(h \cdot \ell\right)}^{-0.5}} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024102 
(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)))))