Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.4% → 75.6%
Time: 35.3s
Alternatives: 29
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 29 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.4% 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: 75.6% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq 7.2 \cdot 10^{-208}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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


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

    1. Initial program 69.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. Simplified68.8%

      \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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. unpow268.8%

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

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

        \[\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. clear-num72.6%

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 7.1999999999999997e-208

    1. Initial program 22.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. Simplified22.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. Taylor expanded in d around 0 44.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u44.4%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval58.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/58.4%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down68.3%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr68.3%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def68.3%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p69.1%

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

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

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

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

    if 7.1999999999999997e-208 < d

    1. Initial program 68.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. Simplified68.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. Applied egg-rr36.6%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 70.6% accurate, 0.5× 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)\\ \mathbf{if}\;t\_0 \leq \infty:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5} \cdot \frac{d}{{\left(D \cdot M\right)}^{2}}}\\ \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)))))))
   (if (<= t_0 INFINITY)
     t_0
     (* -0.125 (/ (sqrt h) (* (pow l 1.5) (/ d (pow (* D M) 2.0))))))))
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 tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = -0.125 * (sqrt(h) / (pow(l, 1.5) * (d / pow((D * M), 2.0))));
	}
	return tmp;
}
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 tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = -0.125 * (Math.sqrt(h) / (Math.pow(l, 1.5) * (d / Math.pow((D * M), 2.0))));
	}
	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))))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = -0.125 * (math.sqrt(h) / (math.pow(l, 1.5) * (d / math.pow((D * M), 2.0))))
	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)))))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = Float64(-0.125 * Float64(sqrt(h) / Float64((l ^ 1.5) * Float64(d / (Float64(D * M) ^ 2.0)))));
	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))));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = -0.125 * (sqrt(h) / ((l ^ 1.5) * (d / ((D * M) ^ 2.0))));
	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]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(-0.125 * N[(N[Sqrt[h], $MachinePrecision] / N[(N[Power[l, 1.5], $MachinePrecision] * N[(d / N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]), $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)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5} \cdot \frac{d}{{\left(D \cdot M\right)}^{2}}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l)))) < +inf.0

    1. Initial program 80.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. Add Preprocessing

    if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 1 2)) (pow.f64 (/.f64 d l) (/.f64 1 2))) (-.f64 1 (*.f64 (*.f64 (/.f64 1 2) (pow.f64 (/.f64 (*.f64 M D) (*.f64 2 d)) 2)) (/.f64 h l))))

    1. Initial program 0.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. Simplified0.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 0 17.5%

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

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

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

        \[\leadsto -0.125 \cdot \color{blue}{\frac{1 \cdot \sqrt{h}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}}} \]
      4. metadata-eval19.5%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\sqrt{1}} \cdot \sqrt{h}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}} \]
      5. sqrt-prod19.5%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\sqrt{1 \cdot h}}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}} \]
      6. *-un-lft-identity19.5%

        \[\leadsto -0.125 \cdot \frac{\sqrt{\color{blue}{h}}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}} \]
      7. pow-prod-down25.4%

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

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

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

      \[\leadsto -0.125 \cdot \color{blue}{\frac{\sqrt{h}}{\frac{d}{{\left(D \cdot M\right)}^{2}} \cdot {\ell}^{1.5}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.6%

    \[\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 \infty:\\ \;\;\;\;\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}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5} \cdot \frac{d}{{\left(D \cdot M\right)}^{2}}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 78.9% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq 1.45 \cdot 10^{-207}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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


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

    1. Initial program 69.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. Simplified69.6%

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

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

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

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

    if -4.999999999999985e-310 < d < 1.45000000000000006e-207

    1. Initial program 22.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. Simplified22.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. Taylor expanded in d around 0 44.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u44.4%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval58.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/58.4%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down68.3%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr68.3%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def68.3%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p69.1%

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

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

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

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

    if 1.45000000000000006e-207 < d

    1. Initial program 68.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. Simplified68.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. Applied egg-rr36.6%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq 1.7 \cdot 10^{-229}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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


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

    1. Initial program 69.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. Simplified68.8%

      \[\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. associate-*r/70.6%

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 1.7e-229

    1. Initial program 20.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. Simplified20.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 d around 0 39.6%

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

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      2. expm1-udef39.6%

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval51.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/51.6%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down68.8%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr68.8%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def68.8%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p70.3%

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

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

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

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

    if 1.7e-229 < d

    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.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. Applied egg-rr32.8%

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

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

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

Alternative 5: 74.1% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq 1.35 \cdot 10^{-207}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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


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

    1. Initial program 69.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. Simplified68.8%

      \[\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. associate-*r/70.6%

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

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

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

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

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

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

    if 4.999999999999985e-310 < d < 1.35e-207

    1. Initial program 22.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. Simplified22.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. Taylor expanded in d around 0 44.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u44.4%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval58.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/58.4%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down68.3%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr68.3%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def68.3%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p69.1%

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

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

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

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

    if 1.35e-207 < d

    1. Initial program 68.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. Simplified68.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. Applied egg-rr36.6%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 74.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq 1.12 \cdot 10^{-207}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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


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

    1. Initial program 69.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. Simplified68.8%

      \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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. unpow268.8%

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

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

        \[\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. clear-num72.6%

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 1.12000000000000001e-207

    1. Initial program 22.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. Simplified22.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. Taylor expanded in d around 0 44.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u44.4%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval58.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/58.4%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down68.3%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr68.3%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def68.3%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p69.1%

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

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

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

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

    if 1.12000000000000001e-207 < d

    1. Initial program 68.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. Simplified68.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. Applied egg-rr36.6%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 74.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq 7.6 \cdot 10^{-208}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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


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

    1. Initial program 69.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. Simplified68.8%

      \[\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.8%

        \[\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.8%

        \[\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.8%

        \[\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. unpow268.8%

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

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

        \[\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. clear-num72.6%

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

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

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

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

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

    if -4.999999999999985e-310 < d < 7.60000000000000023e-208

    1. Initial program 22.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. Simplified22.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. Taylor expanded in d around 0 44.4%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u44.4%

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

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

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

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval58.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/58.4%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down68.3%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr68.3%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def68.3%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p69.1%

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

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

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

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

    if 7.60000000000000023e-208 < d

    1. Initial program 68.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. Simplified68.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. Applied egg-rr36.6%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 67.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 6 \cdot 10^{-124}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

\mathbf{elif}\;d \leq 7 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.999999999999985e-310 or 6e-124 < d < 7e67

    1. Initial program 72.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. Simplified71.7%

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

    if -4.999999999999985e-310 < d < 6e-124

    1. Initial program 31.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. Simplified31.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 0 34.2%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u34.0%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      2. expm1-udef34.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} - 1\right) \]
      4. *-commutative32.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{h}}{\sqrt{{\ell}^{3}}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      6. sqrt-pow147.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval47.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/49.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down59.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr59.0%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def59.6%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p60.8%

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

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

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

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

    if 7e67 < d

    1. Initial program 65.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. Simplified65.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 70.9%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div83.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr83.8%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.1%

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

Alternative 9: 67.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 1.4 \cdot 10^{-121}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

\mathbf{elif}\;d \leq 4.8 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.999999999999985e-310 or 1.4000000000000001e-121 < d < 4.80000000000000004e67

    1. Initial program 72.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. Simplified72.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

    if -4.999999999999985e-310 < d < 1.4000000000000001e-121

    1. Initial program 31.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. Simplified31.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 0 34.2%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u34.0%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      2. expm1-udef34.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} - 1\right) \]
      4. *-commutative32.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{h}}{\sqrt{{\ell}^{3}}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      6. sqrt-pow147.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval47.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/49.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down59.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr59.0%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def59.6%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p60.8%

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

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

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

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

    if 4.80000000000000004e67 < d

    1. Initial program 65.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. Simplified65.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 70.9%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div83.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr83.8%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.5%

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

Alternative 10: 68.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 1.2 \cdot 10^{-120}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

\mathbf{elif}\;d \leq 7 \cdot 10^{+67}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.999999999999985e-310 or 1.2e-120 < d < 7e67

    1. Initial program 72.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. Simplified72.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. frac-times72.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 \cdot D}{2 \cdot d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      2. associate-/r*72.9%

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

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

    if -4.999999999999985e-310 < d < 1.2e-120

    1. Initial program 31.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. Simplified31.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 0 34.2%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u34.0%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      2. expm1-udef34.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} - 1\right) \]
      4. *-commutative32.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{h}}{\sqrt{{\ell}^{3}}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      6. sqrt-pow147.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval47.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/49.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down59.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr59.0%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def59.6%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p60.8%

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

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

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

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

    if 7e67 < d

    1. Initial program 65.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. Simplified65.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 70.9%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div83.8%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr83.8%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.9%

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

Alternative 11: 69.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;d \leq 5.3 \cdot 10^{-166}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

\mathbf{elif}\;d \leq 1.46 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.999999999999985e-310 or 5.29999999999999996e-166 < d < 1.46e110

    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.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. associate-*r/73.8%

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

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

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

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

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

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

    if -4.999999999999985e-310 < d < 5.29999999999999996e-166

    1. Initial program 29.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. Simplified29.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 d around 0 37.6%

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

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      2. expm1-udef37.6%

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

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\sqrt{\frac{h}{{\ell}^{3}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)}\right)} - 1\right) \]
      5. sqrt-div40.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval52.5%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/52.8%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down62.1%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr62.1%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def62.1%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p63.1%

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

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

        \[\leadsto -0.125 \cdot \color{blue}{\frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}} \]
    8. Simplified63.0%

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

    if 1.46e110 < d

    1. Initial program 62.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. Simplified62.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 d around inf 72.0%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div84.0%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr84.0%

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

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

Alternative 12: 56.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.12 \cdot 10^{-178}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-125}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5} \cdot \frac{d}{{\left(D \cdot M\right)}^{2}}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{+65}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -1.12e-178)
   (* (sqrt (/ d h)) (/ (sqrt (- d)) (sqrt (- l))))
   (if (<= d -5e-310)
     (* d (log1p (expm1 (pow (* h l) -0.5))))
     (if (<= d 1.9e-125)
       (* -0.125 (/ (sqrt h) (* (pow l 1.5) (/ d (pow (* D M) 2.0)))))
       (if (<= d 7.8e+65)
         (*
          (/ d (sqrt (* h l)))
          (+ 1.0 (* -0.125 (* (/ h l) (pow (/ (* D M) d) 2.0)))))
         (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.12e-178) {
		tmp = sqrt((d / h)) * (sqrt(-d) / sqrt(-l));
	} else if (d <= -5e-310) {
		tmp = d * log1p(expm1(pow((h * l), -0.5)));
	} else if (d <= 1.9e-125) {
		tmp = -0.125 * (sqrt(h) / (pow(l, 1.5) * (d / pow((D * M), 2.0))));
	} else if (d <= 7.8e+65) {
		tmp = (d / sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * pow(((D * M) / d), 2.0))));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.12e-178) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt(-d) / Math.sqrt(-l));
	} else if (d <= -5e-310) {
		tmp = d * Math.log1p(Math.expm1(Math.pow((h * l), -0.5)));
	} else if (d <= 1.9e-125) {
		tmp = -0.125 * (Math.sqrt(h) / (Math.pow(l, 1.5) * (d / Math.pow((D * M), 2.0))));
	} else if (d <= 7.8e+65) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * Math.pow(((D * M) / d), 2.0))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -1.12e-178:
		tmp = math.sqrt((d / h)) * (math.sqrt(-d) / math.sqrt(-l))
	elif d <= -5e-310:
		tmp = d * math.log1p(math.expm1(math.pow((h * l), -0.5)))
	elif d <= 1.9e-125:
		tmp = -0.125 * (math.sqrt(h) / (math.pow(l, 1.5) * (d / math.pow((D * M), 2.0))))
	elif d <= 7.8e+65:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * math.pow(((D * M) / d), 2.0))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -1.12e-178)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))));
	elseif (d <= -5e-310)
		tmp = Float64(d * log1p(expm1((Float64(h * l) ^ -0.5))));
	elseif (d <= 1.9e-125)
		tmp = Float64(-0.125 * Float64(sqrt(h) / Float64((l ^ 1.5) * Float64(d / (Float64(D * M) ^ 2.0)))));
	elseif (d <= 7.8e+65)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(Float64(D * M) / d) ^ 2.0)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -1.12e-178], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Log[1 + N[(Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e-125], N[(-0.125 * N[(N[Sqrt[h], $MachinePrecision] / N[(N[Power[l, 1.5], $MachinePrecision] * N[(d / N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.8e+65], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\

\mathbf{elif}\;d \leq 1.9 \cdot 10^{-125}:\\
\;\;\;\;-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5} \cdot \frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.12e-178

    1. Initial program 74.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. Simplified74.6%

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

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

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

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

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

    if -1.12e-178 < d < -4.999999999999985e-310

    1. Initial program 49.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. Simplified49.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. Taylor expanded in d around inf 18.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. log1p-expm1-u34.8%

        \[\leadsto d \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \]
      2. inv-pow34.8%

        \[\leadsto d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \]
      3. sqrt-pow134.8%

        \[\leadsto d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)\right) \]
      4. metadata-eval34.8%

        \[\leadsto d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)\right) \]
    6. Applied egg-rr34.8%

      \[\leadsto d \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]

    if -4.999999999999985e-310 < d < 1.9000000000000001e-125

    1. Initial program 31.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. Simplified31.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 0 34.2%

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

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

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

        \[\leadsto -0.125 \cdot \color{blue}{\frac{1 \cdot \sqrt{h}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}}} \]
      4. metadata-eval38.7%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\sqrt{1}} \cdot \sqrt{h}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}} \]
      5. sqrt-prod38.7%

        \[\leadsto -0.125 \cdot \frac{\color{blue}{\sqrt{1 \cdot h}}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}} \]
      6. *-un-lft-identity38.7%

        \[\leadsto -0.125 \cdot \frac{\sqrt{\color{blue}{h}}}{\frac{d}{{D}^{2} \cdot {M}^{2}} \cdot \sqrt{{\ell}^{3}}} \]
      7. pow-prod-down45.4%

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

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

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

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

    if 1.9000000000000001e-125 < d < 7.7999999999999996e65

    1. Initial program 84.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. Simplified84.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. add-sqr-sqrt84.2%

        \[\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. pow284.2%

        \[\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-prod84.2%

        \[\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. unpow284.2%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt84.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. clear-num84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.7999999999999996e65 < d

    1. Initial program 66.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. Simplified66.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 70.2%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div84.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr84.4%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification61.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.12 \cdot 10^{-178}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-125}:\\ \;\;\;\;-0.125 \cdot \frac{\sqrt{h}}{{\ell}^{1.5} \cdot \frac{d}{{\left(D \cdot M\right)}^{2}}}\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{+65}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 56.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -2.15 \cdot 10^{-166}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-125}:\\ \;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{+64}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -2.15e-166)
   (* (sqrt (/ d h)) (/ (sqrt (- d)) (sqrt (- l))))
   (if (<= d -5e-310)
     (* d (log1p (expm1 (pow (* h l) -0.5))))
     (if (<= d 1.9e-125)
       (* -0.125 (/ (/ (sqrt h) (pow l 1.5)) (/ d (pow (* D M) 2.0))))
       (if (<= d 5.5e+64)
         (*
          (/ d (sqrt (* h l)))
          (+ 1.0 (* -0.125 (* (/ h l) (pow (/ (* D M) d) 2.0)))))
         (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.15e-166) {
		tmp = sqrt((d / h)) * (sqrt(-d) / sqrt(-l));
	} else if (d <= -5e-310) {
		tmp = d * log1p(expm1(pow((h * l), -0.5)));
	} else if (d <= 1.9e-125) {
		tmp = -0.125 * ((sqrt(h) / pow(l, 1.5)) / (d / pow((D * M), 2.0)));
	} else if (d <= 5.5e+64) {
		tmp = (d / sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * pow(((D * M) / d), 2.0))));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -2.15e-166) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt(-d) / Math.sqrt(-l));
	} else if (d <= -5e-310) {
		tmp = d * Math.log1p(Math.expm1(Math.pow((h * l), -0.5)));
	} else if (d <= 1.9e-125) {
		tmp = -0.125 * ((Math.sqrt(h) / Math.pow(l, 1.5)) / (d / Math.pow((D * M), 2.0)));
	} else if (d <= 5.5e+64) {
		tmp = (d / Math.sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * Math.pow(((D * M) / d), 2.0))));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -2.15e-166:
		tmp = math.sqrt((d / h)) * (math.sqrt(-d) / math.sqrt(-l))
	elif d <= -5e-310:
		tmp = d * math.log1p(math.expm1(math.pow((h * l), -0.5)))
	elif d <= 1.9e-125:
		tmp = -0.125 * ((math.sqrt(h) / math.pow(l, 1.5)) / (d / math.pow((D * M), 2.0)))
	elif d <= 5.5e+64:
		tmp = (d / math.sqrt((h * l))) * (1.0 + (-0.125 * ((h / l) * math.pow(((D * M) / d), 2.0))))
	else:
		tmp = d * (math.sqrt((1.0 / h)) / math.sqrt(l))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -2.15e-166)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-l))));
	elseif (d <= -5e-310)
		tmp = Float64(d * log1p(expm1((Float64(h * l) ^ -0.5))));
	elseif (d <= 1.9e-125)
		tmp = Float64(-0.125 * Float64(Float64(sqrt(h) / (l ^ 1.5)) / Float64(d / (Float64(D * M) ^ 2.0))));
	elseif (d <= 5.5e+64)
		tmp = Float64(Float64(d / sqrt(Float64(h * l))) * Float64(1.0 + Float64(-0.125 * Float64(Float64(h / l) * (Float64(Float64(D * M) / d) ^ 2.0)))));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -2.15e-166], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Log[1 + N[(Exp[N[Power[N[(h * l), $MachinePrecision], -0.5], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e-125], N[(-0.125 * N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] / N[(d / N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e+64], N[(N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(-0.125 * N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\

\mathbf{elif}\;d \leq 1.9 \cdot 10^{-125}:\\
\;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -2.15e-166

    1. Initial program 74.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. Simplified74.6%

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

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

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

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

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

    if -2.15e-166 < d < -4.999999999999985e-310

    1. Initial program 49.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. Simplified49.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. Taylor expanded in d around inf 18.6%

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. log1p-expm1-u34.8%

        \[\leadsto d \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \]
      2. inv-pow34.8%

        \[\leadsto d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}\right)\right) \]
      3. sqrt-pow134.8%

        \[\leadsto d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)\right) \]
      4. metadata-eval34.8%

        \[\leadsto d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)\right) \]
    6. Applied egg-rr34.8%

      \[\leadsto d \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)} \]

    if -4.999999999999985e-310 < d < 1.9000000000000001e-125

    1. Initial program 31.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. Simplified31.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 0 34.2%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u34.0%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\right)} \]
      2. expm1-udef34.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} - 1\right) \]
      4. *-commutative32.0%

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

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{h}}{\sqrt{{\ell}^{3}}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      6. sqrt-pow147.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{\color{blue}{{\ell}^{\left(\frac{3}{2}\right)}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      7. metadata-eval47.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{\color{blue}{1.5}}} \cdot \left(\frac{{D}^{2}}{d} \cdot {M}^{2}\right)\right)} - 1\right) \]
      8. associate-*l/49.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{d}}\right)} - 1\right) \]
      9. pow-prod-down59.0%

        \[\leadsto -0.125 \cdot \left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{\color{blue}{{\left(D \cdot M\right)}^{2}}}{d}\right)} - 1\right) \]
    6. Applied egg-rr59.0%

      \[\leadsto -0.125 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def59.6%

        \[\leadsto -0.125 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right)\right)} \]
      2. expm1-log1p60.8%

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

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

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

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

    if 1.9000000000000001e-125 < d < 5.4999999999999996e64

    1. Initial program 84.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. Simplified84.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. add-sqr-sqrt84.2%

        \[\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. pow284.2%

        \[\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-prod84.2%

        \[\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. unpow284.2%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt84.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. clear-num84.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.4999999999999996e64 < d

    1. Initial program 66.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. Simplified66.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 70.2%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div84.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr84.4%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification61.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.15 \cdot 10^{-166}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \mathsf{log1p}\left(\mathsf{expm1}\left({\left(h \cdot \ell\right)}^{-0.5}\right)\right)\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-125}:\\ \;\;\;\;-0.125 \cdot \frac{\frac{\sqrt{h}}{{\ell}^{1.5}}}{\frac{d}{{\left(D \cdot M\right)}^{2}}}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{+64}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 59.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
t_1 := \sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;\ell \leq -4.6 \cdot 10^{-238}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-302}:\\
\;\;\;\;\frac{d}{\log \left(e^{t\_0}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -7.1999999999999999e140 or -9.0000000000000005e-151 < l < -4.60000000000000009e-238

    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.1%

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

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

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

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

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

    if -7.1999999999999999e140 < l < -9.0000000000000005e-151

    1. Initial program 69.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. Simplified67.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. clear-num67.3%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div68.8%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval68.8%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr68.8%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around -inf 53.4%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*53.4%

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

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

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

    if -4.60000000000000009e-238 < l < 6.8e-302

    1. Initial program 82.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. Simplified82.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. expm1-log1p-u18.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \]
      3. expm1-udef18.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1} \]
      4. sqrt-div5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1 \]
      5. sqrt-div5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right)} - 1 \]
      6. frac-times5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}}\right)} - 1 \]
      7. add-sqr-sqrt5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod6.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    6. Applied egg-rr6.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def6.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p48.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Simplified48.6%

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

        \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}} \]
    10. Applied egg-rr77.0%

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

    if 6.8e-302 < l < 2.65e215

    1. Initial program 60.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. Simplified60.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-sqrt60.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. pow260.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-prod60.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. unpow260.6%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt62.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. clear-num62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.65e215 < l

    1. Initial program 51.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.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 d around inf 41.8%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div65.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr65.6%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification63.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.2 \cdot 10^{+140}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;\ell \leq -9 \cdot 10^{-151}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq -4.6 \cdot 10^{-238}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \frac{\sqrt{-d}}{\sqrt{-\ell}}\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-302}:\\ \;\;\;\;\frac{d}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 2.65 \cdot 10^{+215}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 57.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;\ell \leq -7.4 \cdot 10^{+143}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\

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

\mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-302}:\\
\;\;\;\;\frac{d}{\log \left(e^{t\_0}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -7.4000000000000003e143

    1. Initial program 68.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. Simplified68.5%

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

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

    if -7.4000000000000003e143 < l < -5.60000000000000008e-238

    1. Initial program 66.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. Simplified65.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. clear-num64.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div65.2%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval65.2%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr65.2%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around -inf 49.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*49.3%

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

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

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

    if -5.60000000000000008e-238 < l < 6.8e-302

    1. Initial program 82.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. Simplified82.2%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. expm1-log1p-u18.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \]
      3. expm1-udef18.4%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1} \]
      4. sqrt-div5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1 \]
      5. sqrt-div5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right)} - 1 \]
      6. frac-times5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}}\right)} - 1 \]
      7. add-sqr-sqrt5.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod6.2%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    6. Applied egg-rr6.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def6.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p48.6%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Simplified48.6%

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

        \[\leadsto \frac{d}{\color{blue}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}} \]
    10. Applied egg-rr77.0%

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

    if 6.8e-302 < l < 5.4e215

    1. Initial program 60.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. Simplified60.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-sqrt60.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. pow260.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-prod60.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. unpow260.6%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt62.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. clear-num62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.4e215 < l

    1. Initial program 51.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.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 d around inf 41.8%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div65.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr65.6%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification62.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -7.4 \cdot 10^{+143}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -5.6 \cdot 10^{-238}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-302}:\\ \;\;\;\;\frac{d}{\log \left(e^{\sqrt{h \cdot \ell}}\right)}\\ \mathbf{elif}\;\ell \leq 5.4 \cdot 10^{+215}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 57.0% accurate, 1.4× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -6.0000000000000001e143

    1. Initial program 68.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. Simplified68.5%

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

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

    if -6.0000000000000001e143 < l < -2.64999999999999984e-238

    1. Initial program 66.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. Simplified65.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. clear-num64.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div65.2%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval65.2%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr65.2%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around -inf 49.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*49.3%

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

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

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

    if -2.64999999999999984e-238 < l < 6.8e-302

    1. Initial program 82.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. Simplified82.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. clear-num82.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div82.3%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval82.3%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr82.3%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 48.6%

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr48.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-square48.6%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt48.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-sqr48.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-sqrt48.6%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr48.6%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. pow-prod-down59.9%

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

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

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

    if 6.8e-302 < l < 2.65e215

    1. Initial program 60.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. Simplified60.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-sqrt60.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. pow260.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-prod60.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. unpow260.6%

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

        \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \cdot \left(1 - 0.5 \cdot {\left(\color{blue}{\left(\sqrt{\frac{M}{2} \cdot \frac{D}{d}} \cdot \sqrt{\frac{M}{2} \cdot \frac{D}{d}}\right)} \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right) \]
      6. add-sqr-sqrt62.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. clear-num62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.65e215 < l

    1. Initial program 51.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.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 d around inf 41.8%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div65.6%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr65.6%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification61.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6 \cdot 10^{+143}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -2.65 \cdot 10^{-238}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-302}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 2.65 \cdot 10^{+215}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}} \cdot \left(1 + -0.125 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{D \cdot M}{d}\right)}^{2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 47.7% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;\ell \leq 1.82 \cdot 10^{-109}:\\
\;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(M \cdot \frac{D}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if l < -4.7e142

    1. Initial program 68.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. Simplified68.5%

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

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

    if -4.7e142 < l < -3e-238

    1. Initial program 66.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. Simplified65.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. clear-num64.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div65.2%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval65.2%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr65.2%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around -inf 49.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*49.3%

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

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

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

    if -3e-238 < l < 6.8e-302

    1. Initial program 82.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. Simplified82.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. clear-num82.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div82.3%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval82.3%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr82.3%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 48.6%

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr48.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-square48.6%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt48.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-sqr48.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-sqrt48.6%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr48.6%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. pow-prod-down59.9%

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

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

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

    if 6.8e-302 < l < 1.8200000000000001e-109

    1. Initial program 60.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. Simplified60.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 d around 0 46.1%

      \[\leadsto \color{blue}{-0.125 \cdot \left(\frac{{D}^{2} \cdot {M}^{2}}{d} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)} \]
    5. Step-by-step derivation
      1. pow-prod-down52.1%

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

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

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

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

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

      \[\leadsto -0.125 \cdot \left(\color{blue}{\left(\frac{D \cdot M}{1} \cdot \frac{D}{\frac{d}{M}}\right)} \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right) \]
    7. Step-by-step derivation
      1. /-rgt-identity52.2%

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

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

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

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

    if 1.8200000000000001e-109 < l

    1. Initial program 58.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. Simplified58.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 52.0%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div58.1%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr58.1%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification54.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.7 \cdot 10^{+142}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -3 \cdot 10^{-238}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq 6.8 \cdot 10^{-302}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{elif}\;\ell \leq 1.82 \cdot 10^{-109}:\\ \;\;\;\;-0.125 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(M \cdot \frac{D}{d}\right)\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 50.2% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;d \leq 2.6 \cdot 10^{+64}:\\
\;\;\;\;-0.125 \cdot \frac{\sqrt{h} \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}{d \cdot {\ell}^{1.5}}\\

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


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

    1. Initial program 69.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval69.6%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*69.6%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times68.8%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt68.8%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow268.8%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr74.8%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval74.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in41.9%

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

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

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

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

    if -4.999999999999985e-310 < d < 2.59999999999999997e64

    1. Initial program 53.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. Simplified53.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 d around 0 34.7%

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

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

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

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

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

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

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

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

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

    if 2.59999999999999997e64 < d

    1. Initial program 66.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. Simplified66.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 70.2%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div84.4%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr84.4%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification54.6%

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

Alternative 19: 46.4% accurate, 1.5× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -5.4999999999999997e143

    1. Initial program 68.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. Simplified68.5%

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

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

    if -5.4999999999999997e143 < l < -4.7999999999999997e-238

    1. Initial program 66.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. Simplified65.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. clear-num64.1%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div65.2%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval65.2%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr65.2%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around -inf 49.3%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Step-by-step derivation
      1. associate-*r*49.3%

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

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

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

    if -4.7999999999999997e-238 < l < -4.999999999999985e-310

    1. Initial program 87.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. Simplified87.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. clear-num87.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div87.4%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval87.4%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr87.4%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 45.4%

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

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

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

        \[\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.4%

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

        \[\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.4%

        \[\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.4%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr45.4%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. pow-prod-down57.4%

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 58.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. Simplified58.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. Taylor expanded in d around inf 43.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div50.5%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr50.5%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification51.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5.5 \cdot 10^{+143}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\\ \mathbf{elif}\;\ell \leq -4.8 \cdot 10^{-238}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 20: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1.3 \cdot 10^{-238}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \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.3e-238)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -5e-310)
     (* d (cbrt (pow (* h l) -1.5)))
     (* 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.3e-238) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * cbrt(pow((h * l), -1.5));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1.3e-238) {
		tmp = d * -Math.sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * Math.cbrt(Math.pow((h * l), -1.5));
	} 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.3e-238)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	elseif (l <= -5e-310)
		tmp = Float64(d * cbrt((Float64(h * l) ^ -1.5)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -1.3e-238], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], -1.5], $MachinePrecision], 1/3], $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.3 \cdot 10^{-238}:\\
\;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\

\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.3000000000000001e-238

    1. Initial program 67.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval67.0%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*67.0%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times66.1%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt66.1%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow266.1%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr73.0%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval73.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg46.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.2%

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

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

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

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

    if -1.3000000000000001e-238 < l < -4.999999999999985e-310

    1. Initial program 87.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. Simplified87.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. clear-num87.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div87.4%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval87.4%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr87.4%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 45.4%

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

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

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

        \[\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.4%

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

        \[\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.4%

        \[\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.4%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr45.4%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. add-cbrt-cube45.4%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \]
      2. add-cbrt-cube45.4%

        \[\leadsto d \cdot \left(\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}} \cdot \color{blue}{\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}}}\right) \]
      3. cbrt-unprod51.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}} \]
      4. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.25 + -0.25\right)}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      5. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\left(-0.25 + -0.25\right) + -0.25\right)}} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      6. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\left(\color{blue}{-0.5} + -0.25\right)} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      7. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-0.75}} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      8. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot \left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.25 + -0.25\right)}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      9. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\left(-0.25 + -0.25\right) + -0.25\right)}}} \]
      10. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{\left(\color{blue}{-0.5} + -0.25\right)}} \]
      11. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.75}}} \]
    12. Applied egg-rr51.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{-0.75}}} \]
    13. Step-by-step derivation
      1. pow-sqr51.3%

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

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-1.5}}} \]
    14. Simplified51.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}} \]

    if -4.999999999999985e-310 < l

    1. Initial program 58.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. Simplified58.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. clear-num58.7%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div58.6%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval58.6%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr58.6%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 43.4%

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

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

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

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

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

        \[\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-sqr43.2%

        \[\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-sqrt43.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.3 \cdot 10^{-238}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 21: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \cdot 10^{-238}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -2.6e-238)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -5e-310)
     (* d (cbrt (pow (* h l) -1.5)))
     (* d (/ (sqrt (/ 1.0 h)) (sqrt l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2.6e-238) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * cbrt(pow((h * l), -1.5));
	} else {
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2.6e-238) {
		tmp = d * -Math.sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * Math.cbrt(Math.pow((h * l), -1.5));
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -2.6e-238)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	elseif (l <= -5e-310)
		tmp = Float64(d * cbrt((Float64(h * l) ^ -1.5)));
	else
		tmp = Float64(d * Float64(sqrt(Float64(1.0 / h)) / sqrt(l)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -2.6e-238], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], -1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Sqrt[N[(1.0 / h), $MachinePrecision]], $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\

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


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

    1. Initial program 67.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval67.0%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*67.0%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times66.1%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt66.1%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow266.1%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr73.0%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval73.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg46.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.2%

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

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

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

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

    if -2.6000000000000001e-238 < l < -4.999999999999985e-310

    1. Initial program 87.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. Simplified87.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. clear-num87.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div87.4%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval87.4%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr87.4%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 45.4%

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

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

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

        \[\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.4%

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

        \[\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.4%

        \[\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.4%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr45.4%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. add-cbrt-cube45.4%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \]
      2. add-cbrt-cube45.4%

        \[\leadsto d \cdot \left(\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}} \cdot \color{blue}{\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}}}\right) \]
      3. cbrt-unprod51.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}} \]
      4. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.25 + -0.25\right)}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      5. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\left(-0.25 + -0.25\right) + -0.25\right)}} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      6. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\left(\color{blue}{-0.5} + -0.25\right)} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      7. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-0.75}} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      8. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot \left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.25 + -0.25\right)}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      9. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\left(-0.25 + -0.25\right) + -0.25\right)}}} \]
      10. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{\left(\color{blue}{-0.5} + -0.25\right)}} \]
      11. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.75}}} \]
    12. Applied egg-rr51.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{-0.75}}} \]
    13. Step-by-step derivation
      1. pow-sqr51.3%

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

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-1.5}}} \]
    14. Simplified51.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}} \]

    if -4.999999999999985e-310 < l

    1. Initial program 58.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. Simplified58.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. Taylor expanded in d around inf 43.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div50.5%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr50.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -2.6 \cdot 10^{-238}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 22: 47.0% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 67.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval67.0%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*67.0%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times66.1%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt66.1%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow266.1%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr73.0%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval73.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg46.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.2%

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

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

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

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

    if -4.7999999999999997e-238 < l < -4.999999999999985e-310

    1. Initial program 87.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. Simplified87.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. clear-num87.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div87.4%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval87.4%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr87.4%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 45.4%

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

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

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

        \[\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.4%

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

        \[\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.4%

        \[\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.4%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr45.4%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. pow-prod-down57.4%

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

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

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

    if -4.999999999999985e-310 < l

    1. Initial program 58.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. Simplified58.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. Taylor expanded in d around inf 43.4%

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

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
      2. sqrt-div50.5%

        \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
    6. Applied egg-rr50.5%

      \[\leadsto d \cdot \color{blue}{\frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -4.8 \cdot 10^{-238}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot {\left({\left(h \cdot \ell\right)}^{2}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 23: 46.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -8 \cdot 10^{-239}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= l -8e-239)
   (* d (- (sqrt (/ (/ 1.0 l) h))))
   (if (<= l -5e-310)
     (* d (cbrt (pow (* h l) -1.5)))
     (/ d (* (sqrt h) (sqrt l))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -8e-239) {
		tmp = d * -sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * cbrt(pow((h * l), -1.5));
	} else {
		tmp = d / (sqrt(h) * sqrt(l));
	}
	return tmp;
}
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (l <= -8e-239) {
		tmp = d * -Math.sqrt(((1.0 / l) / h));
	} else if (l <= -5e-310) {
		tmp = d * Math.cbrt(Math.pow((h * l), -1.5));
	} else {
		tmp = d / (Math.sqrt(h) * Math.sqrt(l));
	}
	return tmp;
}
function code(d, h, l, M, D)
	tmp = 0.0
	if (l <= -8e-239)
		tmp = Float64(d * Float64(-sqrt(Float64(Float64(1.0 / l) / h))));
	elseif (l <= -5e-310)
		tmp = Float64(d * cbrt((Float64(h * l) ^ -1.5)));
	else
		tmp = Float64(d / Float64(sqrt(h) * sqrt(l)));
	end
	return tmp
end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, -8e-239], N[(d * (-N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], If[LessEqual[l, -5e-310], N[(d * N[Power[N[Power[N[(h * l), $MachinePrecision], -1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(d / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 67.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval67.0%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*67.0%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times66.1%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt66.1%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow266.1%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr73.0%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval73.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg46.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.2%

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

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

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

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

    if -8.0000000000000006e-239 < l < -4.999999999999985e-310

    1. Initial program 87.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. Simplified87.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. clear-num87.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div87.4%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval87.4%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr87.4%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 45.4%

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

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

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

        \[\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.4%

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

        \[\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.4%

        \[\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.4%

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

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

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

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

        \[\leadsto d \cdot \left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.25}}\right) \]
    10. Applied egg-rr45.4%

      \[\leadsto d \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
    11. Step-by-step derivation
      1. add-cbrt-cube45.4%

        \[\leadsto d \cdot \left(\color{blue}{\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \]
      2. add-cbrt-cube45.4%

        \[\leadsto d \cdot \left(\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}} \cdot \color{blue}{\sqrt[3]{\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}}}\right) \]
      3. cbrt-unprod51.3%

        \[\leadsto d \cdot \color{blue}{\sqrt[3]{\left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)}} \]
      4. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.25 + -0.25\right)}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      5. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\left(-0.25 + -0.25\right) + -0.25\right)}} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      6. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\left(\color{blue}{-0.5} + -0.25\right)} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      7. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-0.75}} \cdot \left(\left({\left(h \cdot \ell\right)}^{-0.25} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right) \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      8. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot \left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(-0.25 + -0.25\right)}} \cdot {\left(h \cdot \ell\right)}^{-0.25}\right)} \]
      9. pow-prod-up51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{\left(\left(-0.25 + -0.25\right) + -0.25\right)}}} \]
      10. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{\left(\color{blue}{-0.5} + -0.25\right)}} \]
      11. metadata-eval51.3%

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{\color{blue}{-0.75}}} \]
    12. Applied egg-rr51.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{-0.75} \cdot {\left(h \cdot \ell\right)}^{-0.75}}} \]
    13. Step-by-step derivation
      1. pow-sqr51.3%

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

        \[\leadsto d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{\color{blue}{-1.5}}} \]
    14. Simplified51.3%

      \[\leadsto d \cdot \color{blue}{\sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}} \]

    if -4.999999999999985e-310 < l

    1. Initial program 58.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. Simplified57.4%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. expm1-log1p-u38.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \]
      3. expm1-udef24.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1} \]
      4. sqrt-div29.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1 \]
      5. sqrt-div32.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}}\right)} - 1 \]
      7. add-sqr-sqrt32.3%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod28.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    6. Applied egg-rr28.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def41.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p43.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Simplified43.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. pow1/243.4%

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

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

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

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

        \[\leadsto \frac{d}{{\ell}^{\color{blue}{0.5}} \cdot {h}^{\left(\frac{1}{2}\right)}} \]
      6. pow1/250.4%

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot {h}^{\color{blue}{0.5}}} \]
      8. pow1/250.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
    10. Applied egg-rr50.4%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification48.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -8 \cdot 10^{-239}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt[3]{{\left(h \cdot \ell\right)}^{-1.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 24: 46.3% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\

\mathbf{else}:\\
\;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\


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

    1. Initial program 67.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval67.0%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*67.0%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times66.1%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt66.1%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow266.1%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr73.0%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval73.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg46.2%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in46.2%

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

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

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

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

    if -3.2000000000000002e-238 < l < -4.999999999999985e-310

    1. Initial program 87.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. Simplified87.3%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. expm1-log1p-u13.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \]
      3. expm1-udef13.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1 \]
      5. sqrt-div0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right)} - 1 \]
      6. frac-times0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}}\right)} - 1 \]
      7. add-sqr-sqrt0.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod0.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    6. Applied egg-rr0.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def0.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p45.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Simplified45.4%

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

    if -4.999999999999985e-310 < l

    1. Initial program 58.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. Simplified57.4%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. expm1-log1p-u38.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \]
      3. expm1-udef24.6%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1} \]
      4. sqrt-div29.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1 \]
      5. sqrt-div32.3%

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

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}}\right)} - 1 \]
      7. add-sqr-sqrt32.3%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}}\right)} - 1 \]
      8. sqrt-prod28.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
    6. Applied egg-rr28.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def41.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
      2. expm1-log1p43.4%

        \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    8. Simplified43.4%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
    9. Step-by-step derivation
      1. pow1/243.4%

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

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

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

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

        \[\leadsto \frac{d}{{\ell}^{\color{blue}{0.5}} \cdot {h}^{\left(\frac{1}{2}\right)}} \]
      6. pow1/250.4%

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot {h}^{\color{blue}{0.5}}} \]
      8. pow1/250.4%

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
    10. Applied egg-rr50.4%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification48.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -3.2 \cdot 10^{-238}:\\ \;\;\;\;d \cdot \left(-\sqrt{\frac{\frac{1}{\ell}}{h}}\right)\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{d}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{h} \cdot \sqrt{\ell}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 25: 41.9% accurate, 2.9× speedup?

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

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

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


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

    1. Initial program 68.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. Add Preprocessing
    3. Step-by-step derivation
      1. metadata-eval68.9%

        \[\leadsto \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(\color{blue}{0.5} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. associate-*l*68.9%

        \[\leadsto \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 - \color{blue}{0.5 \cdot \left({\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right) \]
      3. frac-times68.0%

        \[\leadsto \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 - 0.5 \cdot \left({\color{blue}{\left(\frac{M}{2} \cdot \frac{D}{d}\right)}}^{2} \cdot \frac{h}{\ell}\right)\right) \]
      4. add-sqr-sqrt68.0%

        \[\leadsto \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 - \color{blue}{\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)} \cdot \sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}}\right) \]
      5. pow268.0%

        \[\leadsto \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 - \color{blue}{{\left(\sqrt{0.5 \cdot \left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot \frac{h}{\ell}\right)}\right)}^{2}}\right) \]
    4. Applied egg-rr74.2%

      \[\leadsto \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 - \color{blue}{{\left(\sqrt{\frac{h}{\ell}} \cdot \left(\frac{D}{d \cdot \frac{2}{M}} \cdot \sqrt{0.5}\right)\right)}^{2}}\right) \]
    5. Step-by-step derivation
      1. metadata-eval74.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg42.1%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. distribute-rgt-neg-in42.1%

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

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

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

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

    if -7.4999999999999999e-280 < h

    1. Initial program 59.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. Simplified59.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. clear-num59.6%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div59.5%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval59.5%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr59.5%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 43.9%

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr43.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-square43.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt43.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-sqr43.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-sqrt43.9%

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

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

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

Alternative 26: 37.4% accurate, 3.0× speedup?

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

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

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


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

    1. Initial program 67.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. Simplified67.1%

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
      2. *-commutative45.2%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}} \]
      3. sqrt-unprod36.4%

        \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
    6. Applied egg-rr36.4%

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

    if -1.4199999999999999e-238 < l

    1. Initial program 61.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. Simplified61.8%

      \[\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. clear-num61.8%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div61.7%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval61.7%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr61.7%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 43.6%

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr43.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-square43.6%

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

        \[\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-sqr43.4%

        \[\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-sqrt43.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.42 \cdot 10^{-238}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 27: 41.8% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(h \cdot \ell\right)}^{-0.5}\\ \mathbf{if}\;h \leq -7.5 \cdot 10^{-280}:\\ \;\;\;\;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 (<= h -7.5e-280) (* 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 (h <= -7.5e-280) {
		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 (h <= (-7.5d-280)) 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 (h <= -7.5e-280) {
		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 h <= -7.5e-280:
		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 (h <= -7.5e-280)
		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 (h <= -7.5e-280)
		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[h, -7.5e-280], 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}\;h \leq -7.5 \cdot 10^{-280}:\\
\;\;\;\;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 h < -7.4999999999999999e-280

    1. Initial program 68.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. Simplified68.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. clear-num67.2%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div67.9%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval67.9%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr67.9%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around -inf 42.1%

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg42.1%

        \[\leadsto \color{blue}{-d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      2. unpow-142.1%

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

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

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

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

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

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

        \[\leadsto -d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      9. distribute-rgt-neg-in42.1%

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

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

    if -7.4999999999999999e-280 < h

    1. Initial program 59.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. Simplified59.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. clear-num59.6%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
      2. sqrt-div59.5%

        \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval59.5%

        \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
    5. Applied egg-rr59.5%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
    6. Taylor expanded in d around inf 43.9%

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

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

        \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
      3. pow-sqr43.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-square43.9%

        \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      5. rem-square-sqrt43.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-sqr43.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-sqrt43.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;h \leq -7.5 \cdot 10^{-280}:\\ \;\;\;\;d \cdot \left(-{\left(h \cdot \ell\right)}^{-0.5}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot {\left(h \cdot \ell\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 28: 26.6% 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 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. Simplified63.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. clear-num63.2%

      \[\leadsto \left(\sqrt{\color{blue}{\frac{1}{\frac{h}{d}}}} \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) \]
    2. sqrt-div63.6%

      \[\leadsto \left(\color{blue}{\frac{\sqrt{1}}{\sqrt{\frac{h}{d}}}} \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. metadata-eval63.6%

      \[\leadsto \left(\frac{\color{blue}{1}}{\sqrt{\frac{h}{d}}} \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) \]
  5. Applied egg-rr63.6%

    \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{\frac{h}{d}}}} \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) \]
  6. Taylor expanded in d around inf 27.2%

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

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

      \[\leadsto d \cdot \sqrt{{\left(h \cdot \ell\right)}^{\color{blue}{\left(2 \cdot -0.5\right)}}} \]
    3. pow-sqr27.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-square26.8%

      \[\leadsto d \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    5. rem-square-sqrt26.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-sqr26.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-sqrt26.8%

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

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

    \[\leadsto d \cdot {\left(h \cdot \ell\right)}^{-0.5} \]
  10. Add Preprocessing

Alternative 29: 26.6% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \frac{d}{\sqrt{h \cdot \ell}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (/ d (sqrt (* h l))))
double code(double d, double h, double l, double M, double D) {
	return d / sqrt((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 / sqrt((h * l))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d / Math.sqrt((h * l));
}
def code(d, h, l, M, D):
	return d / math.sqrt((h * l))
function code(d, h, l, M, D)
	return Float64(d / sqrt(Float64(h * l)))
end
function tmp = code(d, h, l, M, D)
	tmp = d / sqrt((h * l));
end
code[d_, h_, l_, M_, D_] := N[(d / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{d}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  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. Simplified63.4%

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

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

      \[\leadsto \sqrt{\frac{d}{h}} \cdot \color{blue}{\sqrt{\frac{d}{\ell}}} \]
    2. expm1-log1p-u39.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)} \]
    3. expm1-udef25.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1} \]
    4. sqrt-div15.1%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \cdot \sqrt{\frac{d}{\ell}}\right)} - 1 \]
    5. sqrt-div16.4%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\sqrt{d}}{\sqrt{h}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{\ell}}}\right)} - 1 \]
    6. frac-times16.4%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{h} \cdot \sqrt{\ell}}}\right)} - 1 \]
    7. add-sqr-sqrt16.4%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{d}}{\sqrt{h} \cdot \sqrt{\ell}}\right)} - 1 \]
    8. sqrt-prod15.5%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{d}{\color{blue}{\sqrt{h \cdot \ell}}}\right)} - 1 \]
  6. Applied egg-rr15.5%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)} - 1} \]
  7. Step-by-step derivation
    1. expm1-def22.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{d}{\sqrt{h \cdot \ell}}\right)\right)} \]
    2. expm1-log1p26.8%

      \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  8. Simplified26.8%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  9. Final simplification26.8%

    \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024027 
(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)))))