Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.5% → 79.0%
Time: 24.2s
Alternatives: 16
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D):
	return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D)
	return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))))
end
function tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 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.5% 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: 79.0% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 42.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. Simplified42.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
    5. Step-by-step derivation
      1. metadata-eval48.8%

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

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

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

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

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

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

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

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

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

    if -1.5000000000000001e206 < l < -3.999999999999988e-310

    1. Initial program 68.9%

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

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

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

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

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

    if -3.999999999999988e-310 < l

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

Alternative 2: 75.4% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -1.6e-189

    1. Initial program 67.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. Simplified67.8%

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

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

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

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

    if -1.6e-189 < h < 1.10000000000000006e-296

    1. Initial program 53.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. Simplified49.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
    5. Step-by-step derivation
      1. metadata-eval64.5%

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

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

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

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

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

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

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

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

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

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

    if 1.10000000000000006e-296 < h

    1. Initial program 60.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. Simplified60.7%

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

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

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

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

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

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

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

Alternative 3: 74.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 67.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. Simplified66.5%

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

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

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

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

    if -4.00000000000000022e-279 < d

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

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

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

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

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

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

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

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

Alternative 4: 78.9% accurate, 0.8× speedup?

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

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

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


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

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

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

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

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

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

    if -3.999999999999988e-310 < l

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

Alternative 5: 73.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 64.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. Simplified63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.10000000000000006e-296 < h

    1. Initial program 60.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. Simplified60.7%

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

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

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

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

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

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

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

Alternative 6: 74.1% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 64.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. Simplified63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.10000000000000006e-296 < h

    1. Initial program 60.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. Simplified60.7%

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

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

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

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

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

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

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

Alternative 7: 72.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.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. Simplified46.3%

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified59.8%

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

    if -1.15e94 < l < 5.2000000000000001e-235

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.2000000000000001e-235 < l

    1. Initial program 60.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. Simplified61.1%

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

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

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

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

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

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

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

Alternative 8: 72.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.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. Simplified46.3%

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified59.8%

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

    if -1.15e94 < l < 4.99999999999999955e-308

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

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

    if 4.99999999999999955e-308 < l

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

Alternative 9: 73.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 27.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. Simplified27.7%

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

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

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

    if -2.3000000000000001e250 < l < -3.999999999999988e-310

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
    5. Step-by-step derivation
      1. metadata-eval69.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < l

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

Alternative 10: 65.3% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;\ell \leq 3.35 \cdot 10^{+204}:\\
\;\;\;\;\frac{d}{t_0} \cdot \mathsf{fma}\left({\left(\frac{M \cdot D}{d \cdot 2}\right)}^{2}, \frac{h \cdot -0.5}{\ell}, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -5.49999999999999976e89

    1. Initial program 46.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. Simplified46.3%

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified59.8%

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

    if -5.49999999999999976e89 < l < -9.9999999999999991e-309

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
    5. Step-by-step derivation
      1. metadata-eval75.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999991e-309 < l < 3.35000000000000021e204

    1. Initial program 60.2%

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

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

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

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

    if 3.35000000000000021e204 < l

    1. Initial program 56.9%

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

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

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

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

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

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

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

Alternative 11: 68.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 46.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. Simplified46.3%

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified59.8%

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

    if -2.0000000000000001e92 < l < -3.999999999999988e-310

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
    5. Step-by-step derivation
      1. metadata-eval75.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.999999999999988e-310 < l

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

Alternative 12: 58.6% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\ell \leq 8.8 \cdot 10^{-187} \lor \neg \left(\ell \leq 1.85 \cdot 10^{-134}\right) \land \ell \leq 2.2 \cdot 10^{+28}:\\
\;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)\\

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


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

    1. Initial program 46.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. Simplified46.3%

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified59.8%

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

    if -1.05000000000000004e91 < l < 8.80000000000000032e-187 or 1.85e-134 < l < 2.19999999999999986e28

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \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) \]
    5. Step-by-step derivation
      1. metadata-eval75.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.80000000000000032e-187 < l < 1.85e-134 or 2.19999999999999986e28 < l

    1. Initial program 48.9%

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

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

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

      \[\leadsto \color{blue}{d \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
    5. Step-by-step derivation
      1. rem-exp-log43.5%

        \[\leadsto \color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow-143.5%

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

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

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

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

        \[\leadsto e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr43.5%

        \[\leadsto e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow43.5%

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

        \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      10. exp-to-pow43.4%

        \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      11. metadata-eval43.4%

        \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      12. distribute-rgt-neg-in43.4%

        \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      13. exp-neg43.4%

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

        \[\leadsto e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      15. exp-to-pow43.4%

        \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      16. unpow1/243.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -1.05 \cdot 10^{+91}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 8.8 \cdot 10^{-187} \lor \neg \left(\ell \leq 1.85 \cdot 10^{-134}\right) \land \ell \leq 2.2 \cdot 10^{+28}:\\ \;\;\;\;\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \cdot \left(1 + \left(\frac{h}{\ell} \cdot -0.5\right) \cdot {\left(\left(0.5 \cdot M\right) \cdot \frac{D}{d}\right)}^{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 13: 47.0% accurate, 1.6× speedup?

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

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

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


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

    1. Initial program 64.5%

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

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.1%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.1%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.1%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.1%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.1%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.1%

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

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.1%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.1%

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

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.1%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.1%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified45.2%

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

    if 2.2999999999999999e-307 < l

    1. Initial program 60.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. Simplified60.7%

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

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

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

        \[\leadsto \color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow-141.4%

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

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

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

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

        \[\leadsto e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr41.4%

        \[\leadsto e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow41.4%

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

        \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      10. exp-to-pow41.2%

        \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      11. metadata-eval41.2%

        \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      12. distribute-rgt-neg-in41.2%

        \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      13. exp-neg41.2%

        \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      14. log-rec41.2%

        \[\leadsto e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      15. exp-to-pow41.2%

        \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      16. unpow1/241.2%

        \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      17. exp-sum41.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 2.3 \cdot 10^{-307}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \]

Alternative 14: 43.0% accurate, 3.0× speedup?

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

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


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

    1. Initial program 68.1%

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

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified49.7%

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

    if -1.00000000000000002e-194 < d

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{-194}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;d \cdot \sqrt{\frac{\frac{1}{\ell}}{h}}\\ \end{array} \]

Alternative 15: 43.0% accurate, 3.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;d \leq -9.5 \cdot 10^{-195}:\\ \;\;\;\;\frac{-d}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{t_0}\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h)))) (if (<= d -9.5e-195) (/ (- d) t_0) (/ d t_0))))
double code(double d, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (d <= -9.5e-195) {
		tmp = -d / t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
real(8) function code(d, h, l, m, d_1)
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (d <= (-9.5d-195)) then
        tmp = -d / t_0
    else
        tmp = d / t_0
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = Math.sqrt((l * h));
	double tmp;
	if (d <= -9.5e-195) {
		tmp = -d / t_0;
	} else {
		tmp = d / t_0;
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if d <= -9.5e-195:
		tmp = -d / t_0
	else:
		tmp = d / t_0
	return tmp
function code(d, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (d <= -9.5e-195)
		tmp = Float64(Float64(-d) / t_0);
	else
		tmp = Float64(d / t_0);
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (d <= -9.5e-195)
		tmp = -d / t_0;
	else
		tmp = d / t_0;
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -9.5e-195], N[((-d) / t$95$0), $MachinePrecision], N[(d / t$95$0), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{d}{t_0}\\


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

    1. Initial program 68.1%

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

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

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

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

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

        \[\leadsto -\color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      3. unpow-10.0%

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

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

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

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
      7. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      8. fabs-sqr0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      9. sqr-pow0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
      10. rem-exp-log0.0%

        \[\leadsto -e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      11. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      12. metadata-eval0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      13. distribute-rgt-neg-in0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      14. exp-neg0.0%

        \[\leadsto -e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      15. log-rec0.0%

        \[\leadsto -e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      16. exp-to-pow0.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      17. unpow1/20.0%

        \[\leadsto -e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    6. Simplified49.7%

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

    if -9.5000000000000007e-195 < d

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

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

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

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

        \[\leadsto \color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
      2. unpow-137.4%

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

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

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

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

        \[\leadsto e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
      7. fabs-sqr37.4%

        \[\leadsto e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
      8. sqr-pow37.4%

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

        \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
      10. exp-to-pow37.2%

        \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
      11. metadata-eval37.2%

        \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
      12. distribute-rgt-neg-in37.2%

        \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
      13. exp-neg37.2%

        \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
      14. log-rec37.2%

        \[\leadsto e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
      15. exp-to-pow37.2%

        \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
      16. unpow1/237.2%

        \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
      17. exp-sum37.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.5 \cdot 10^{-195}:\\ \;\;\;\;\frac{-d}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell \cdot h}}\\ \end{array} \]

Alternative 16: 26.8% accurate, 3.2× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\log d}} \cdot \sqrt{\frac{1}{h \cdot \ell}} \]
    2. unpow-122.8%

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

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

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

      \[\leadsto e^{\log d} \cdot \color{blue}{\left|{\left(h \cdot \ell\right)}^{-0.5}\right|} \]
    6. sqr-pow22.8%

      \[\leadsto e^{\log d} \cdot \left|\color{blue}{{\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}}\right| \]
    7. fabs-sqr22.8%

      \[\leadsto e^{\log d} \cdot \color{blue}{\left({\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)} \cdot {\left(h \cdot \ell\right)}^{\left(\frac{-0.5}{2}\right)}\right)} \]
    8. sqr-pow22.8%

      \[\leadsto e^{\log d} \cdot \color{blue}{{\left(h \cdot \ell\right)}^{-0.5}} \]
    9. rem-exp-log22.7%

      \[\leadsto e^{\log d} \cdot \color{blue}{e^{\log \left({\left(h \cdot \ell\right)}^{-0.5}\right)}} \]
    10. exp-to-pow22.7%

      \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(e^{\log \left(h \cdot \ell\right) \cdot -0.5}\right)}} \]
    11. metadata-eval22.7%

      \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\log \left(h \cdot \ell\right) \cdot \color{blue}{\left(-0.5\right)}}\right)} \]
    12. distribute-rgt-neg-in22.7%

      \[\leadsto e^{\log d} \cdot e^{\log \left(e^{\color{blue}{-\log \left(h \cdot \ell\right) \cdot 0.5}}\right)} \]
    13. exp-neg22.7%

      \[\leadsto e^{\log d} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(h \cdot \ell\right) \cdot 0.5}}\right)}} \]
    14. log-rec22.7%

      \[\leadsto e^{\log d} \cdot e^{\color{blue}{-\log \left(e^{\log \left(h \cdot \ell\right) \cdot 0.5}\right)}} \]
    15. exp-to-pow22.7%

      \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left({\left(h \cdot \ell\right)}^{0.5}\right)}} \]
    16. unpow1/222.7%

      \[\leadsto e^{\log d} \cdot e^{-\log \color{blue}{\left(\sqrt{h \cdot \ell}\right)}} \]
    17. exp-sum22.7%

      \[\leadsto \color{blue}{e^{\log d + \left(-\log \left(\sqrt{h \cdot \ell}\right)\right)}} \]
  6. Simplified28.2%

    \[\leadsto \color{blue}{\frac{d}{\sqrt{h \cdot \ell}}} \]
  7. Final simplification28.2%

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

Reproduce

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