Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.3% → 82.7%
Time: 27.1s
Alternatives: 19
Speedup: 0.8×

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 19 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.3% 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: 82.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 73.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. Simplified73.0%

      \[\leadsto \color{blue}{\sqrt{\frac{d}{\ell}} \cdot \left(\sqrt{\frac{d}{h}} \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. Step-by-step derivation
      1. frac-2neg73.0%

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

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

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

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

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

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

    if -4.9999999999999995e-309 < l < 1.00000000000000005e117

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*69.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv69.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e117 < l

    1. Initial program 59.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. Simplified59.4%

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

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

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

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

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

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

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

Alternative 2: 78.1% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \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{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
t_2 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-203}:\\
\;\;\;\;\left(t_0 \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{0.5 \cdot \left(M \cdot D\right)}{d}\right)}^{2}\right)\right)\right) \cdot t_2\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-260} \lor \neg \left(t_1 \leq 2 \cdot 10^{+268}\right):\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot \left(t_0 \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 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)))) < -1e-203

    1. Initial program 91.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. Simplified90.2%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*91.3%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv91.3%

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

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

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

    if -1e-203 < (*.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)))) < 5.0000000000000003e-260 or 1.9999999999999999e268 < (*.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 30.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. Simplified30.0%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr29.5%

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

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt38.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified63.1%

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

    if 5.0000000000000003e-260 < (*.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.9999999999999999e268

    1. Initial program 99.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. Simplified99.4%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*99.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv99.4%

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

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

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

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

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

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

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

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

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

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

    \[\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{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right) \leq -1 \cdot 10^{-203}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{0.5 \cdot \left(M \cdot D\right)}{d}\right)}^{2}\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \mathbf{elif}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right) \leq 5 \cdot 10^{-260} \lor \neg \left(\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{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right) \leq 2 \cdot 10^{+268}\right):\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\ \end{array} \]

Alternative 3: 79.0% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \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{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right)\\
t_2 := \sqrt{\frac{d}{h}}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-203}:\\
\;\;\;\;t_2 \cdot \left(t_0 \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot -0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-260} \lor \neg \left(t_1 \leq 2 \cdot 10^{+268}\right):\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot \left(t_0 \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 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)))) < -1e-203

    1. Initial program 91.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. Simplified90.2%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. pow290.1%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
    4. Applied egg-rr92.2%

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

    if -1e-203 < (*.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)))) < 5.0000000000000003e-260 or 1.9999999999999999e268 < (*.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 30.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. Simplified30.0%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr29.5%

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

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt38.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified63.1%

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

    if 5.0000000000000003e-260 < (*.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.9999999999999999e268

    1. Initial program 99.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. Simplified99.4%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*99.4%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv99.4%

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

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

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

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

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

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

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

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

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

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

    \[\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{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right) \leq -1 \cdot 10^{-203}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot {\left(\left(\frac{D}{d} \cdot \left(M \cdot -0.5\right)\right) \cdot \sqrt{\frac{h}{\ell}}\right)}^{2}\right)\right)\\ \mathbf{elif}\;\left({\left(\frac{d}{h}\right)}^{0.5} \cdot {\left(\frac{d}{\ell}\right)}^{0.5}\right) \cdot \left(1 - \frac{h}{\ell} \cdot \left(0.5 \cdot {\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right) \leq 5 \cdot 10^{-260} \lor \neg \left(\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{M \cdot D}{d \cdot 2}\right)}^{2}\right)\right) \leq 2 \cdot 10^{+268}\right):\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\ \end{array} \]

Alternative 4: 79.4% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 73.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. Simplified73.0%

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

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

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

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

    if -4.9999999999999995e-309 < l < 4.99999999999999983e117

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*69.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv69.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999983e117 < l

    1. Initial program 59.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. Simplified59.4%

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

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

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

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

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

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

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

Alternative 5: 79.4% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 73.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. Simplified73.0%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*73.0%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv73.0%

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

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

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

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

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

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

    if -4.9999999999999995e-309 < l < 3.05000000000000009e116

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

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*69.7%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv69.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.05000000000000009e116 < l

    1. Initial program 59.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. Simplified59.4%

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

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

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

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

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

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

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

Alternative 6: 53.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 1.45 \cdot 10^{-8}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.4500000000000001e-8

    1. Initial program 68.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. Simplified67.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow19.0%

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)} - 1\right) \]
      5. metadata-eval19.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr19.0%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def29.2%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt28.3%

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

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

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

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

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

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

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

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

    if 1.4500000000000001e-8 < D

    1. Initial program 73.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.9%

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

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      2. associate-/r*73.9%

        \[\leadsto \sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \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)\right) \]
      3. div-inv73.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 1.45 \cdot 10^{-8}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 + -0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{d} \cdot \frac{D}{2}\right)}^{2}\right)\right)\right)\\ \end{array} \]

Alternative 7: 53.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 1.42 \cdot 10^{-8}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.41999999999999998e-8

    1. Initial program 68.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. Simplified67.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow19.0%

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)} - 1\right) \]
      5. metadata-eval19.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr19.0%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def29.2%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt28.3%

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

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

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

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

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

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

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

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

    if 1.41999999999999998e-8 < D

    1. Initial program 73.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 1.42 \cdot 10^{-8}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2}\right)\right)\right) \cdot \sqrt{\frac{d}{h}}\\ \end{array} \]

Alternative 8: 53.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 1.42 \cdot 10^{-8}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 1.41999999999999998e-8

    1. Initial program 68.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. Simplified67.2%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow19.0%

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)} - 1\right) \]
      5. metadata-eval19.0%

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr19.0%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def29.2%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt28.3%

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

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

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

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

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

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

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

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

    if 1.41999999999999998e-8 < D

    1. Initial program 73.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 1.42 \cdot 10^{-8}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - 0.5 \cdot \left(\frac{h}{\ell} \cdot {\left(\frac{M \cdot -0.5}{\frac{d}{D}}\right)}^{2}\right)\right)\right)\\ \end{array} \]

Alternative 9: 50.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 8.6 \cdot 10^{+25}:\\ \;\;\;\;\frac{-0.125 \cdot {\left(M \cdot D\right)}^{2}}{d} \cdot \sqrt{h \cdot {\ell}^{-3}}\\ \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 -6e-84)
   (fabs (* d (pow (* l h) -0.5)))
   (if (<= d 1.95e-306)
     (* d (sqrt (log (exp (/ (/ 1.0 h) l)))))
     (if (<= d 8.6e+25)
       (* (/ (* -0.125 (pow (* M D) 2.0)) 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 (d <= -6e-84) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	} else if (d <= 8.6e+25) {
		tmp = ((-0.125 * pow((M * D), 2.0)) / 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 (d <= (-6d-84)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    else if (d <= 1.95d-306) then
        tmp = d * sqrt(log(exp(((1.0d0 / h) / l))))
    else if (d <= 8.6d+25) then
        tmp = (((-0.125d0) * ((m * d_1) ** 2.0d0)) / 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 (d <= -6e-84) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * Math.sqrt(Math.log(Math.exp(((1.0 / h) / l))));
	} else if (d <= 8.6e+25) {
		tmp = ((-0.125 * Math.pow((M * D), 2.0)) / 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 d <= -6e-84:
		tmp = math.fabs((d * math.pow((l * h), -0.5)))
	elif d <= 1.95e-306:
		tmp = d * math.sqrt(math.log(math.exp(((1.0 / h) / l))))
	elif d <= 8.6e+25:
		tmp = ((-0.125 * math.pow((M * D), 2.0)) / 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 (d <= -6e-84)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = Float64(d * sqrt(log(exp(Float64(Float64(1.0 / h) / l)))));
	elseif (d <= 8.6e+25)
		tmp = Float64(Float64(Float64(-0.125 * (Float64(M * D) ^ 2.0)) / 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 (d <= -6e-84)
		tmp = abs((d * ((l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	elseif (d <= 8.6e+25)
		tmp = ((-0.125 * ((M * D) ^ 2.0)) / 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[d, -6e-84], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 1.95e-306], N[(d * N[Sqrt[N[Log[N[Exp[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8.6e+25], N[(N[(N[(-0.125 * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * N[Sqrt[N[(h * N[Power[l, -3.0], $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 -6 \cdot 10^{-84}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -6.0000000000000002e-84

    1. Initial program 76.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow5.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def5.5%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified62.0%

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

    if -6.0000000000000002e-84 < d < 1.95e-306

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

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

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

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

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

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

    if 1.95e-306 < d < 8.59999999999999996e25

    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 \mathsf{fma}\left({\left(\frac{-0.5 \cdot M}{d} \cdot D\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
    3. Taylor expanded in d around 0 39.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{h}{{\ell}^{3}}\right)}^{0.5}} \cdot \frac{-0.125 \cdot {\left(D \cdot M\right)}^{2}}{d} \]
      2. add-sqr-sqrt46.3%

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

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

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

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

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

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

        \[\leadsto \left({\left(h \cdot {\ell}^{-3}\right)}^{0.25} \cdot \color{blue}{{\left(\frac{h}{{\ell}^{3}}\right)}^{\left(\frac{0.5}{2}\right)}}\right) \cdot \frac{-0.125 \cdot {\left(D \cdot M\right)}^{2}}{d} \]
      9. div-inv46.3%

        \[\leadsto \left({\left(h \cdot {\ell}^{-3}\right)}^{0.25} \cdot {\color{blue}{\left(h \cdot \frac{1}{{\ell}^{3}}\right)}}^{\left(\frac{0.5}{2}\right)}\right) \cdot \frac{-0.125 \cdot {\left(D \cdot M\right)}^{2}}{d} \]
      10. pow-flip46.3%

        \[\leadsto \left({\left(h \cdot {\ell}^{-3}\right)}^{0.25} \cdot {\left(h \cdot \color{blue}{{\ell}^{\left(-3\right)}}\right)}^{\left(\frac{0.5}{2}\right)}\right) \cdot \frac{-0.125 \cdot {\left(D \cdot M\right)}^{2}}{d} \]
      11. metadata-eval46.3%

        \[\leadsto \left({\left(h \cdot {\ell}^{-3}\right)}^{0.25} \cdot {\left(h \cdot {\ell}^{\color{blue}{-3}}\right)}^{\left(\frac{0.5}{2}\right)}\right) \cdot \frac{-0.125 \cdot {\left(D \cdot M\right)}^{2}}{d} \]
      12. metadata-eval46.3%

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

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

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

        \[\leadsto {\left(h \cdot {\ell}^{-3}\right)}^{\color{blue}{0.5}} \cdot \frac{-0.125 \cdot {\left(D \cdot M\right)}^{2}}{d} \]
      3. unpow1/246.3%

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

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

    if 8.59999999999999996e25 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 8.6 \cdot 10^{+25}:\\ \;\;\;\;\frac{-0.125 \cdot {\left(M \cdot D\right)}^{2}}{d} \cdot \sqrt{h \cdot {\ell}^{-3}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 10: 50.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 5.3 \cdot 10^{+26}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot {\left(M \cdot D\right)}^{2}}{d}\\ \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.9e-84)
   (fabs (* d (pow (* l h) -0.5)))
   (if (<= d 1.95e-306)
     (* d (sqrt (log (exp (/ (/ 1.0 h) l)))))
     (if (<= d 5.3e+26)
       (* (sqrt (/ h (pow l 3.0))) (/ (* -0.125 (pow (* M D) 2.0)) d))
       (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -1.9e-84) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	} else if (d <= 5.3e+26) {
		tmp = sqrt((h / pow(l, 3.0))) * ((-0.125 * pow((M * D), 2.0)) / d);
	} 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 <= (-1.9d-84)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    else if (d <= 1.95d-306) then
        tmp = d * sqrt(log(exp(((1.0d0 / h) / l))))
    else if (d <= 5.3d+26) then
        tmp = sqrt((h / (l ** 3.0d0))) * (((-0.125d0) * ((m * d_1) ** 2.0d0)) / d)
    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 <= -1.9e-84) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * Math.sqrt(Math.log(Math.exp(((1.0 / h) / l))));
	} else if (d <= 5.3e+26) {
		tmp = Math.sqrt((h / Math.pow(l, 3.0))) * ((-0.125 * Math.pow((M * D), 2.0)) / d);
	} 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.9e-84:
		tmp = math.fabs((d * math.pow((l * h), -0.5)))
	elif d <= 1.95e-306:
		tmp = d * math.sqrt(math.log(math.exp(((1.0 / h) / l))))
	elif d <= 5.3e+26:
		tmp = math.sqrt((h / math.pow(l, 3.0))) * ((-0.125 * math.pow((M * D), 2.0)) / d)
	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.9e-84)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = Float64(d * sqrt(log(exp(Float64(Float64(1.0 / h) / l)))));
	elseif (d <= 5.3e+26)
		tmp = Float64(sqrt(Float64(h / (l ^ 3.0))) * Float64(Float64(-0.125 * (Float64(M * D) ^ 2.0)) / d));
	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 <= -1.9e-84)
		tmp = abs((d * ((l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	elseif (d <= 5.3e+26)
		tmp = sqrt((h / (l ^ 3.0))) * ((-0.125 * ((M * D) ^ 2.0)) / d);
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -1.9e-84], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 1.95e-306], N[(d * N[Sqrt[N[Log[N[Exp[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.3e+26], N[(N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-0.125 * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / d), $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.9 \cdot 10^{-84}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.89999999999999993e-84

    1. Initial program 76.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow5.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def5.5%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified62.0%

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

    if -1.89999999999999993e-84 < d < 1.95e-306

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

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

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

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

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

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

    if 1.95e-306 < d < 5.29999999999999969e26

    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 \mathsf{fma}\left({\left(\frac{-0.5 \cdot M}{d} \cdot D\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
    3. Taylor expanded in d around 0 39.3%

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

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

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

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

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

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

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

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

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

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

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

    if 5.29999999999999969e26 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.9 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 5.3 \cdot 10^{+26}:\\ \;\;\;\;\sqrt{\frac{h}{{\ell}^{3}}} \cdot \frac{-0.125 \cdot {\left(M \cdot D\right)}^{2}}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 11: 53.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -8.5 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 2.95 \cdot 10^{+26}:\\ \;\;\;\;\frac{\sqrt{h} \cdot -0.125}{{\ell}^{1.5} \cdot \frac{d}{{\left(M \cdot D\right)}^{2}}}\\ \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 -8.5e-84)
   (fabs (* d (pow (* l h) -0.5)))
   (if (<= d 1.95e-306)
     (* d (sqrt (log (exp (/ (/ 1.0 h) l)))))
     (if (<= d 2.95e+26)
       (/ (* (sqrt h) -0.125) (* (pow l 1.5) (/ d (pow (* 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 <= -8.5e-84) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	} else if (d <= 2.95e+26) {
		tmp = (sqrt(h) * -0.125) / (pow(l, 1.5) * (d / pow((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 (d <= (-8.5d-84)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    else if (d <= 1.95d-306) then
        tmp = d * sqrt(log(exp(((1.0d0 / h) / l))))
    else if (d <= 2.95d+26) then
        tmp = (sqrt(h) * (-0.125d0)) / ((l ** 1.5d0) * (d / ((m * d_1) ** 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 (d <= -8.5e-84) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * Math.sqrt(Math.log(Math.exp(((1.0 / h) / l))));
	} else if (d <= 2.95e+26) {
		tmp = (Math.sqrt(h) * -0.125) / (Math.pow(l, 1.5) * (d / Math.pow((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 <= -8.5e-84:
		tmp = math.fabs((d * math.pow((l * h), -0.5)))
	elif d <= 1.95e-306:
		tmp = d * math.sqrt(math.log(math.exp(((1.0 / h) / l))))
	elif d <= 2.95e+26:
		tmp = (math.sqrt(h) * -0.125) / (math.pow(l, 1.5) * (d / math.pow((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 <= -8.5e-84)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = Float64(d * sqrt(log(exp(Float64(Float64(1.0 / h) / l)))));
	elseif (d <= 2.95e+26)
		tmp = Float64(Float64(sqrt(h) * -0.125) / Float64((l ^ 1.5) * Float64(d / (Float64(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 (d <= -8.5e-84)
		tmp = abs((d * ((l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	elseif (d <= 2.95e+26)
		tmp = (sqrt(h) * -0.125) / ((l ^ 1.5) * (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[d, -8.5e-84], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 1.95e-306], N[(d * N[Sqrt[N[Log[N[Exp[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.95e+26], N[(N[(N[Sqrt[h], $MachinePrecision] * -0.125), $MachinePrecision] / N[(N[Power[l, 1.5], $MachinePrecision] * N[(d / N[Power[N[(M * D), $MachinePrecision], 2.0], $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 -8.5 \cdot 10^{-84}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -8.4999999999999994e-84

    1. Initial program 76.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow5.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def5.5%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified62.0%

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

    if -8.4999999999999994e-84 < d < 1.95e-306

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

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

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

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

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

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

    if 1.95e-306 < d < 2.95000000000000015e26

    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 \mathsf{fma}\left({\left(\frac{-0.5 \cdot M}{d} \cdot D\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
    3. Taylor expanded in d around 0 39.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.95000000000000015e26 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8.5 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 2.95 \cdot 10^{+26}:\\ \;\;\;\;\frac{\sqrt{h} \cdot -0.125}{{\ell}^{1.5} \cdot \frac{d}{{\left(M \cdot D\right)}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 12: 53.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -6.6 \cdot 10^{-83}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{+26}:\\ \;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot {\left(M \cdot D\right)}^{2}\right)}{d}\\ \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 -6.6e-83)
   (fabs (* d (pow (* l h) -0.5)))
   (if (<= d 1.95e-306)
     (* d (sqrt (log (exp (/ (/ 1.0 h) l)))))
     (if (<= d 4.7e+26)
       (/ (* (/ (sqrt h) (pow l 1.5)) (* -0.125 (pow (* M D) 2.0))) d)
       (* d (/ (sqrt (/ 1.0 h)) (sqrt l)))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -6.6e-83) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	} else if (d <= 4.7e+26) {
		tmp = ((sqrt(h) / pow(l, 1.5)) * (-0.125 * pow((M * D), 2.0))) / d;
	} 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 <= (-6.6d-83)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    else if (d <= 1.95d-306) then
        tmp = d * sqrt(log(exp(((1.0d0 / h) / l))))
    else if (d <= 4.7d+26) then
        tmp = ((sqrt(h) / (l ** 1.5d0)) * ((-0.125d0) * ((m * d_1) ** 2.0d0))) / d
    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 <= -6.6e-83) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else if (d <= 1.95e-306) {
		tmp = d * Math.sqrt(Math.log(Math.exp(((1.0 / h) / l))));
	} else if (d <= 4.7e+26) {
		tmp = ((Math.sqrt(h) / Math.pow(l, 1.5)) * (-0.125 * Math.pow((M * D), 2.0))) / d;
	} else {
		tmp = d * (Math.sqrt((1.0 / h)) / Math.sqrt(l));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -6.6e-83:
		tmp = math.fabs((d * math.pow((l * h), -0.5)))
	elif d <= 1.95e-306:
		tmp = d * math.sqrt(math.log(math.exp(((1.0 / h) / l))))
	elif d <= 4.7e+26:
		tmp = ((math.sqrt(h) / math.pow(l, 1.5)) * (-0.125 * math.pow((M * D), 2.0))) / d
	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 <= -6.6e-83)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = Float64(d * sqrt(log(exp(Float64(Float64(1.0 / h) / l)))));
	elseif (d <= 4.7e+26)
		tmp = Float64(Float64(Float64(sqrt(h) / (l ^ 1.5)) * Float64(-0.125 * (Float64(M * D) ^ 2.0))) / d);
	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 <= -6.6e-83)
		tmp = abs((d * ((l * h) ^ -0.5)));
	elseif (d <= 1.95e-306)
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	elseif (d <= 4.7e+26)
		tmp = ((sqrt(h) / (l ^ 1.5)) * (-0.125 * ((M * D) ^ 2.0))) / d;
	else
		tmp = d * (sqrt((1.0 / h)) / sqrt(l));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -6.6e-83], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, 1.95e-306], N[(d * N[Sqrt[N[Log[N[Exp[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.7e+26], N[(N[(N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision] * N[(-0.125 * N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $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 -6.6 \cdot 10^{-83}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -6.5999999999999999e-83

    1. Initial program 76.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow5.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def5.5%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified62.0%

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

    if -6.5999999999999999e-83 < d < 1.95e-306

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

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

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

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

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

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

    if 1.95e-306 < d < 4.6999999999999998e26

    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 \mathsf{fma}\left({\left(\frac{-0.5 \cdot M}{d} \cdot D\right)}^{2}, -0.5 \cdot \frac{h}{\ell}, 1\right)} \]
    3. Taylor expanded in d around 0 39.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.6999999999999998e26 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.6 \cdot 10^{-83}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq 1.95 \cdot 10^{-306}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{elif}\;d \leq 4.7 \cdot 10^{+26}:\\ \;\;\;\;\frac{\frac{\sqrt{h}}{{\ell}^{1.5}} \cdot \left(-0.125 \cdot {\left(M \cdot D\right)}^{2}\right)}{d}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \frac{\sqrt{\frac{1}{h}}}{\sqrt{\ell}}\\ \end{array} \]

Alternative 13: 47.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -3.4e-84)
   (fabs (* d (pow (* l h) -0.5)))
   (if (<= d -5e-310)
     (* d (sqrt (log (exp (/ (/ 1.0 h) l)))))
     (* d (* (pow l -0.5) (pow h -0.5))))))
double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -3.4e-84) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else if (d <= -5e-310) {
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-3.4d-84)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    else if (d <= (-5d-310)) then
        tmp = d * sqrt(log(exp(((1.0d0 / h) / l))))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -3.4e-84) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else if (d <= -5e-310) {
		tmp = d * Math.sqrt(Math.log(Math.exp(((1.0 / h) / l))));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -3.4e-84:
		tmp = math.fabs((d * math.pow((l * h), -0.5)))
	elif d <= -5e-310:
		tmp = d * math.sqrt(math.log(math.exp(((1.0 / h) / l))))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	tmp = 0.0
	if (d <= -3.4e-84)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	elseif (d <= -5e-310)
		tmp = Float64(d * sqrt(log(exp(Float64(Float64(1.0 / h) / l)))));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= -3.4e-84)
		tmp = abs((d * ((l * h) ^ -0.5)));
	elseif (d <= -5e-310)
		tmp = d * sqrt(log(exp(((1.0 / h) / l))));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -3.4e-84], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Sqrt[N[Log[N[Exp[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.4 \cdot 10^{-84}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\

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


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

    1. Initial program 76.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow5.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def5.5%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified62.0%

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

    if -3.40000000000000021e-84 < d < -4.999999999999985e-310

    1. Initial program 64.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. Simplified64.2%

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

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

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

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

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

    if -4.999999999999985e-310 < d

    1. Initial program 67.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.1%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr26.1%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def43.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \sqrt{\log \left(e^{\frac{\frac{1}{h}}{\ell}}\right)}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 14: 47.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\ \mathbf{if}\;d \leq -1.1 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot t_0\right|\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \log \left(e^{t_0}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (pow (* l h) -0.5)))
   (if (<= d -1.1e-84)
     (fabs (* d t_0))
     (if (<= d -5e-310)
       (* d (log (exp t_0)))
       (* d (* (pow l -0.5) (pow h -0.5)))))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = pow((l * h), -0.5);
	double tmp;
	if (d <= -1.1e-84) {
		tmp = fabs((d * t_0));
	} else if (d <= -5e-310) {
		tmp = d * log(exp(t_0));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (l * h) ** (-0.5d0)
    if (d <= (-1.1d-84)) then
        tmp = abs((d * t_0))
    else if (d <= (-5d-310)) then
        tmp = d * log(exp(t_0))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.pow((l * h), -0.5);
	double tmp;
	if (d <= -1.1e-84) {
		tmp = Math.abs((d * t_0));
	} else if (d <= -5e-310) {
		tmp = d * Math.log(Math.exp(t_0));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.pow((l * h), -0.5)
	tmp = 0
	if d <= -1.1e-84:
		tmp = math.fabs((d * t_0))
	elif d <= -5e-310:
		tmp = d * math.log(math.exp(t_0))
	else:
		tmp = d * (math.pow(l, -0.5) * math.pow(h, -0.5))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(l * h) ^ -0.5
	tmp = 0.0
	if (d <= -1.1e-84)
		tmp = abs(Float64(d * t_0));
	elseif (d <= -5e-310)
		tmp = Float64(d * log(exp(t_0)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = (l * h) ^ -0.5;
	tmp = 0.0;
	if (d <= -1.1e-84)
		tmp = abs((d * t_0));
	elseif (d <= -5e-310)
		tmp = d * log(exp(t_0));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[d, -1.1e-84], N[Abs[N[(d * t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[d, -5e-310], N[(d * N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;d \leq -1.1 \cdot 10^{-84}:\\
\;\;\;\;\left|d \cdot t_0\right|\\

\mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\
\;\;\;\;d \cdot \log \left(e^{t_0}\right)\\

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


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

    1. Initial program 76.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. Simplified73.9%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow5.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr5.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def5.5%

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

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

      \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.2%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|} \]
    11. Simplified62.0%

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

    if -1.0999999999999999e-84 < d < -4.999999999999985e-310

    1. Initial program 64.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. Simplified64.2%

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

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

        \[\leadsto d \cdot \color{blue}{\log \left(e^{\sqrt{\frac{1}{h \cdot \ell}}}\right)} \]
      2. inv-pow40.5%

        \[\leadsto d \cdot \log \left(e^{\sqrt{\color{blue}{{\left(h \cdot \ell\right)}^{-1}}}}\right) \]
      3. sqrt-pow140.5%

        \[\leadsto d \cdot \log \left(e^{\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}}\right) \]
      4. metadata-eval40.5%

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

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

    if -4.999999999999985e-310 < d

    1. Initial program 67.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.1%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr26.1%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def43.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.1 \cdot 10^{-84}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{elif}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;d \cdot \log \left(e^{{\left(\ell \cdot h\right)}^{-0.5}}\right)\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 15: 46.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (if (<= d -5e-310)
   (fabs (* d (pow (* l h) -0.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 (d <= -5e-310) {
		tmp = fabs((d * pow((l * h), -0.5)));
	} else {
		tmp = d * (pow(l, -0.5) * pow(h, -0.5));
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: tmp
    if (d <= (-5d-310)) then
        tmp = abs((d * ((l * h) ** (-0.5d0))))
    else
        tmp = d * ((l ** (-0.5d0)) * (h ** (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double tmp;
	if (d <= -5e-310) {
		tmp = Math.abs((d * Math.pow((l * h), -0.5)));
	} else {
		tmp = d * (Math.pow(l, -0.5) * Math.pow(h, -0.5));
	}
	return tmp;
}
def code(d, h, l, M, D):
	tmp = 0
	if d <= -5e-310:
		tmp = math.fabs((d * math.pow((l * h), -0.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 (d <= -5e-310)
		tmp = abs(Float64(d * (Float64(l * h) ^ -0.5)));
	else
		tmp = Float64(d * Float64((l ^ -0.5) * (h ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	tmp = 0.0;
	if (d <= -5e-310)
		tmp = abs((d * ((l * h) ^ -0.5)));
	else
		tmp = d * ((l ^ -0.5) * (h ^ -0.5));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := If[LessEqual[d, -5e-310], N[Abs[N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(d * N[(N[Power[l, -0.5], $MachinePrecision] * N[Power[h, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

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

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow8.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr8.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def8.6%

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

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

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

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

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

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

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

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

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

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

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

    if -4.999999999999985e-310 < d

    1. Initial program 67.1%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified67.1%

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

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

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

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

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr26.1%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def43.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \left({\ell}^{-0.5} \cdot {h}^{-0.5}\right)\\ \end{array} \]

Alternative 16: 40.6% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.8 \cdot 10^{-29}:\\
\;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 3.79999999999999976e-29

    1. Initial program 69.5%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified69.0%

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

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

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

        \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{\frac{1}{h \cdot \ell}}\right)} - 1\right)} \]
      3. inv-pow18.7%

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

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

        \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
    5. Applied egg-rr18.7%

      \[\leadsto d \cdot \color{blue}{\left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{-0.5}\right)} - 1\right)} \]
    6. Step-by-step derivation
      1. expm1-def29.2%

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

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

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

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

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

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

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

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

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

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

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

    if 3.79999999999999976e-29 < M

    1. Initial program 70.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Simplified68.9%

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

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

        \[\leadsto d \cdot \sqrt{\frac{1}{\color{blue}{\ell \cdot h}}} \]
      2. associate-/r*19.4%

        \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{\ell}}{h}}} \]
    5. Simplified19.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 3.8 \cdot 10^{-29}:\\ \;\;\;\;\left|d \cdot {\left(\ell \cdot h\right)}^{-0.5}\right|\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]

Alternative 17: 26.3% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot \sqrt{\frac{1}{\ell \cdot h}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ 1.0 (* l h)))))
double code(double d, double h, double l, double M, double D) {
	return d * sqrt((1.0 / (l * h)));
}
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((1.0d0 / (l * h)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt((1.0 / (l * h)));
}
def code(d, h, l, M, D):
	return d * math.sqrt((1.0 / (l * h)))
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(1.0 / Float64(l * h))))
end
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt((1.0 / (l * h)));
end
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot \sqrt{\frac{1}{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 69.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. Simplified68.9%

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

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
  4. Final simplification26.7%

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

Alternative 18: 26.4% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (sqrt (/ (/ 1.0 h) l))))
double code(double d, double h, double l, double M, double D) {
	return d * sqrt(((1.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 * sqrt(((1.0d0 / h) / l))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.sqrt(((1.0 / h) / l));
}
def code(d, h, l, M, D):
	return d * math.sqrt(((1.0 / h) / l))
function code(d, h, l, M, D)
	return Float64(d * sqrt(Float64(Float64(1.0 / h) / l)))
end
function tmp = code(d, h, l, M, D)
	tmp = d * sqrt(((1.0 / h) / l));
end
code[d_, h_, l_, M_, D_] := N[(d * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}
\end{array}
Derivation
  1. Initial program 69.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. Simplified68.9%

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

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

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

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

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

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)} - 1\right) \]
    5. metadata-eval17.6%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
  5. Applied egg-rr17.6%

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

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

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

    \[\leadsto d \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
  8. Taylor expanded in d around 0 26.7%

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

      \[\leadsto d \cdot \sqrt{\color{blue}{\frac{\frac{1}{h}}{\ell}}} \]
  10. Simplified27.1%

    \[\leadsto \color{blue}{d \cdot \sqrt{\frac{\frac{1}{h}}{\ell}}} \]
  11. Final simplification27.1%

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

Alternative 19: 26.1% accurate, 3.1× speedup?

\[\begin{array}{l} \\ d \cdot {\left(\ell \cdot h\right)}^{-0.5} \end{array} \]
(FPCore (d h l M D) :precision binary64 (* d (pow (* l h) -0.5)))
double code(double d, double h, double l, double M, double D) {
	return d * pow((l * h), -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 * ((l * h) ** (-0.5d0))
end function
public static double code(double d, double h, double l, double M, double D) {
	return d * Math.pow((l * h), -0.5);
}
def code(d, h, l, M, D):
	return d * math.pow((l * h), -0.5)
function code(d, h, l, M, D)
	return Float64(d * (Float64(l * h) ^ -0.5))
end
function tmp = code(d, h, l, M, D)
	tmp = d * ((l * h) ^ -0.5);
end
code[d_, h_, l_, M_, D_] := N[(d * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d \cdot {\left(\ell \cdot h\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 69.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. Simplified68.9%

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

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

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

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

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

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}}\right)} - 1\right) \]
    5. metadata-eval17.6%

      \[\leadsto d \cdot \left(e^{\mathsf{log1p}\left({\left(h \cdot \ell\right)}^{\color{blue}{-0.5}}\right)} - 1\right) \]
  5. Applied egg-rr17.6%

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

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

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

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

    \[\leadsto d \cdot {\left(\ell \cdot h\right)}^{-0.5} \]

Reproduce

?
herbie shell --seed 2023309 
(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)))))