Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.8% → 44.7%
Time: 9.5s
Alternatives: 9
Speedup: 0.7×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(c0, w, h, d, d_1, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
    code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
end
function tmp = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}

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 9 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: 24.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(c0, w, h, d, d_1, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
    code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
end
function tmp = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}

Alternative 1: 44.7% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} \mathbf{if}\;w \leq 2 \cdot 10^{+206}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\_m\right) + \frac{\frac{d}{D} \cdot \frac{d}{D}}{h} \cdot \frac{c0}{w}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (if (<= w 2e+206)
   (*
    (/ c0 (* 2.0 w))
    (+
     (hypot (* (/ (pow (/ d D) 2.0) h) (/ c0 w)) M_m)
     (* (/ (* (/ d D) (/ d D)) h) (/ c0 w))))
   (* 0.5 (/ (* M_m c0) w))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if (w <= 2e+206) {
		tmp = (c0 / (2.0 * w)) * (hypot(((pow((d / D), 2.0) / h) * (c0 / w)), M_m) + ((((d / D) * (d / D)) / h) * (c0 / w)));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double tmp;
	if (w <= 2e+206) {
		tmp = (c0 / (2.0 * w)) * (Math.hypot(((Math.pow((d / D), 2.0) / h) * (c0 / w)), M_m) + ((((d / D) * (d / D)) / h) * (c0 / w)));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	tmp = 0
	if w <= 2e+206:
		tmp = (c0 / (2.0 * w)) * (math.hypot(((math.pow((d / D), 2.0) / h) * (c0 / w)), M_m) + ((((d / D) * (d / D)) / h) * (c0 / w)))
	else:
		tmp = 0.5 * ((M_m * c0) / w)
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	tmp = 0.0
	if (w <= 2e+206)
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(hypot(Float64(Float64((Float64(d / D) ^ 2.0) / h) * Float64(c0 / w)), M_m) + Float64(Float64(Float64(Float64(d / D) * Float64(d / D)) / h) * Float64(c0 / w))));
	else
		tmp = Float64(0.5 * Float64(Float64(M_m * c0) / w));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	tmp = 0.0;
	if (w <= 2e+206)
		tmp = (c0 / (2.0 * w)) * (hypot(((((d / D) ^ 2.0) / h) * (c0 / w)), M_m) + ((((d / D) * (d / D)) / h) * (c0 / w)));
	else
		tmp = 0.5 * ((M_m * c0) / w);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := If[LessEqual[w, 2e+206], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / h), $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision] ^ 2 + M$95$m ^ 2], $MachinePrecision] + N[(N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(M$95$m * c0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
\mathbf{if}\;w \leq 2 \cdot 10^{+206}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\_m\right) + \frac{\frac{d}{D} \cdot \frac{d}{D}}{h} \cdot \frac{c0}{w}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w < 2.0000000000000001e206

    1. Initial program 25.2%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right)} \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. associate-*l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      8. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w}} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      11. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \color{blue}{\frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      15. lower-*.f6423.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      16. lift--.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}}\right) \]
    3. Applied rewrites37.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites43.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      3. associate-*l/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{h \cdot w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{\color{blue}{h \cdot w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      5. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      6. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \color{blue}{\frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      7. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      8. lower-/.f6440.2

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      9. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0}\right) \]
      10. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0\right) \]
      11. associate-*l/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{h \cdot w}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{\color{blue}{h \cdot w}}\right) \]
      13. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}\right) \]
      14. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \color{blue}{\frac{c0}{w}}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}\right) \]
      16. lower-/.f6445.3

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot \frac{c0}{w}\right) \]
    6. Applied rewrites45.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right)} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\color{blue}{\left(\frac{d}{D}\right)}}^{2}}{h} \cdot \frac{c0}{w}\right) \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}{h} \cdot \frac{c0}{w}\right) \]
      3. unpow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h} \cdot \frac{c0}{w}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h} \cdot \frac{c0}{w}\right) \]
      5. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{\color{blue}{\frac{d}{D}} \cdot \frac{d}{D}}{h} \cdot \frac{c0}{w}\right) \]
      6. lift-/.f6445.3

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{\frac{d}{D} \cdot \color{blue}{\frac{d}{D}}}{h} \cdot \frac{c0}{w}\right) \]
    8. Applied rewrites45.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h} \cdot \frac{c0}{w}\right) \]

    if 2.0000000000000001e206 < w

    1. Initial program 17.2%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites22.1%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites18.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6418.7

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites18.7%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{M \cdot c0}{w}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{M \cdot c0}{w}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{M \cdot c0}{\color{blue}{w}} \]
      3. lower-*.f6433.7

        \[\leadsto 0.5 \cdot \frac{M \cdot c0}{w} \]
    9. Applied rewrites33.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 42.5% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;M\_m \cdot M\_m \leq 10^{-209}:\\ \;\;\;\;t\_1 \cdot \left(\mathsf{hypot}\left(\frac{t\_0}{h \cdot w} \cdot c0, M\_m\right) + \frac{\frac{d}{D} \cdot \frac{d}{D}}{h \cdot w} \cdot c0\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \left(-1 \cdot M\_m + \frac{t\_0}{h} \cdot \frac{c0}{w}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0)) (t_1 (/ c0 (* 2.0 w))))
   (if (<= (* M_m M_m) 1e-209)
     (*
      t_1
      (+
       (hypot (* (/ t_0 (* h w)) c0) M_m)
       (* (/ (* (/ d D) (/ d D)) (* h w)) c0)))
     (* t_1 (+ (* -1.0 M_m) (* (/ t_0 h) (/ c0 w)))))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = pow((d / D), 2.0);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if ((M_m * M_m) <= 1e-209) {
		tmp = t_1 * (hypot(((t_0 / (h * w)) * c0), M_m) + ((((d / D) * (d / D)) / (h * w)) * c0));
	} else {
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)));
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = Math.pow((d / D), 2.0);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if ((M_m * M_m) <= 1e-209) {
		tmp = t_1 * (Math.hypot(((t_0 / (h * w)) * c0), M_m) + ((((d / D) * (d / D)) / (h * w)) * c0));
	} else {
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = math.pow((d / D), 2.0)
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if (M_m * M_m) <= 1e-209:
		tmp = t_1 * (math.hypot(((t_0 / (h * w)) * c0), M_m) + ((((d / D) * (d / D)) / (h * w)) * c0))
	else:
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)))
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(d / D) ^ 2.0
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (Float64(M_m * M_m) <= 1e-209)
		tmp = Float64(t_1 * Float64(hypot(Float64(Float64(t_0 / Float64(h * w)) * c0), M_m) + Float64(Float64(Float64(Float64(d / D) * Float64(d / D)) / Float64(h * w)) * c0)));
	else
		tmp = Float64(t_1 * Float64(Float64(-1.0 * M_m) + Float64(Float64(t_0 / h) * Float64(c0 / w))));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = (d / D) ^ 2.0;
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if ((M_m * M_m) <= 1e-209)
		tmp = t_1 * (hypot(((t_0 / (h * w)) * c0), M_m) + ((((d / D) * (d / D)) / (h * w)) * c0));
	else
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * M$95$m), $MachinePrecision], 1e-209], N[(t$95$1 * N[(N[Sqrt[N[(N[(t$95$0 / N[(h * w), $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision] ^ 2 + M$95$m ^ 2], $MachinePrecision] + N[(N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] / N[(h * w), $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(-1.0 * M$95$m), $MachinePrecision] + N[(N[(t$95$0 / h), $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;M\_m \cdot M\_m \leq 10^{-209}:\\
\;\;\;\;t\_1 \cdot \left(\mathsf{hypot}\left(\frac{t\_0}{h \cdot w} \cdot c0, M\_m\right) + \frac{\frac{d}{D} \cdot \frac{d}{D}}{h \cdot w} \cdot c0\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(-1 \cdot M\_m + \frac{t\_0}{h} \cdot \frac{c0}{w}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M M) < 1e-209

    1. Initial program 30.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right)} \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. associate-*l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      8. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w}} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      11. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \color{blue}{\frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      15. lower-*.f6428.2

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      16. lift--.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}}\right) \]
    3. Applied rewrites38.1%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites46.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right)} \]
    5. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}{h \cdot w} \cdot c0\right) \]
      2. unpow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h \cdot w} \cdot c0\right) \]
      3. lower-*.f6446.8

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h \cdot w} \cdot c0\right) \]
    6. Applied rewrites46.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h \cdot w} \cdot c0\right) \]

    if 1e-209 < (*.f64 M M)

    1. Initial program 20.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right)} \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. associate-*l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      8. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w}} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      11. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \color{blue}{\frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      15. lower-*.f6419.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      16. lift--.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}}\right) \]
    3. Applied rewrites35.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites39.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      3. associate-*l/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{h \cdot w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{\color{blue}{h \cdot w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      5. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      6. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \color{blue}{\frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      7. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      8. lower-/.f6438.3

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      9. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0}\right) \]
      10. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0\right) \]
      11. associate-*l/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{h \cdot w}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{\color{blue}{h \cdot w}}\right) \]
      13. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}\right) \]
      14. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \color{blue}{\frac{c0}{w}}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}\right) \]
      16. lower-/.f6441.0

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot \frac{c0}{w}\right) \]
    6. Applied rewrites41.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right)} \]
    7. Taylor expanded in M around -inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{-1 \cdot M} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right) \]
    8. Step-by-step derivation
      1. lower-*.f6439.4

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-1 \cdot \color{blue}{M} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right) \]
    9. Applied rewrites39.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{-1 \cdot M} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 41.6% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := {\left(\frac{d}{D}\right)}^{2}\\ t_1 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;M\_m \cdot M\_m \leq 10^{-209}:\\ \;\;\;\;t\_1 \cdot \left(\mathsf{hypot}\left(\frac{t\_0}{h \cdot w} \cdot c0, M\_m\right) + \left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{h \cdot w}\right) \cdot c0\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \left(-1 \cdot M\_m + \frac{t\_0}{h} \cdot \frac{c0}{w}\right)\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (pow (/ d D) 2.0)) (t_1 (/ c0 (* 2.0 w))))
   (if (<= (* M_m M_m) 1e-209)
     (*
      t_1
      (+
       (hypot (* (/ t_0 (* h w)) c0) M_m)
       (* (* (/ d D) (/ (/ d D) (* h w))) c0)))
     (* t_1 (+ (* -1.0 M_m) (* (/ t_0 h) (/ c0 w)))))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = pow((d / D), 2.0);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if ((M_m * M_m) <= 1e-209) {
		tmp = t_1 * (hypot(((t_0 / (h * w)) * c0), M_m) + (((d / D) * ((d / D) / (h * w))) * c0));
	} else {
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)));
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = Math.pow((d / D), 2.0);
	double t_1 = c0 / (2.0 * w);
	double tmp;
	if ((M_m * M_m) <= 1e-209) {
		tmp = t_1 * (Math.hypot(((t_0 / (h * w)) * c0), M_m) + (((d / D) * ((d / D) / (h * w))) * c0));
	} else {
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)));
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = math.pow((d / D), 2.0)
	t_1 = c0 / (2.0 * w)
	tmp = 0
	if (M_m * M_m) <= 1e-209:
		tmp = t_1 * (math.hypot(((t_0 / (h * w)) * c0), M_m) + (((d / D) * ((d / D) / (h * w))) * c0))
	else:
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)))
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(d / D) ^ 2.0
	t_1 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (Float64(M_m * M_m) <= 1e-209)
		tmp = Float64(t_1 * Float64(hypot(Float64(Float64(t_0 / Float64(h * w)) * c0), M_m) + Float64(Float64(Float64(d / D) * Float64(Float64(d / D) / Float64(h * w))) * c0)));
	else
		tmp = Float64(t_1 * Float64(Float64(-1.0 * M_m) + Float64(Float64(t_0 / h) * Float64(c0 / w))));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = (d / D) ^ 2.0;
	t_1 = c0 / (2.0 * w);
	tmp = 0.0;
	if ((M_m * M_m) <= 1e-209)
		tmp = t_1 * (hypot(((t_0 / (h * w)) * c0), M_m) + (((d / D) * ((d / D) / (h * w))) * c0));
	else
		tmp = t_1 * ((-1.0 * M_m) + ((t_0 / h) * (c0 / w)));
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * M$95$m), $MachinePrecision], 1e-209], N[(t$95$1 * N[(N[Sqrt[N[(N[(t$95$0 / N[(h * w), $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision] ^ 2 + M$95$m ^ 2], $MachinePrecision] + N[(N[(N[(d / D), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[(h * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(-1.0 * M$95$m), $MachinePrecision] + N[(N[(t$95$0 / h), $MachinePrecision] * N[(c0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := {\left(\frac{d}{D}\right)}^{2}\\
t_1 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;M\_m \cdot M\_m \leq 10^{-209}:\\
\;\;\;\;t\_1 \cdot \left(\mathsf{hypot}\left(\frac{t\_0}{h \cdot w} \cdot c0, M\_m\right) + \left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{h \cdot w}\right) \cdot c0\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(-1 \cdot M\_m + \frac{t\_0}{h} \cdot \frac{c0}{w}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M M) < 1e-209

    1. Initial program 30.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right)} \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. associate-*l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      8. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w}} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      11. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \color{blue}{\frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      15. lower-*.f6428.2

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      16. lift--.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}}\right) \]
    3. Applied rewrites38.1%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites46.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right)} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0\right) \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}{h \cdot w} \cdot c0\right) \]
      3. unpow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{h \cdot w} \cdot c0\right) \]
      4. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \color{blue}{\left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{h \cdot w}\right)} \cdot c0\right) \]
      5. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \color{blue}{\left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{h \cdot w}\right)} \cdot c0\right) \]
      6. lower-/.f6444.7

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \left(\frac{d}{D} \cdot \color{blue}{\frac{\frac{d}{D}}{h \cdot w}}\right) \cdot c0\right) \]
    6. Applied rewrites44.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \color{blue}{\left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{h \cdot w}\right)} \cdot c0\right) \]

    if 1e-209 < (*.f64 M M)

    1. Initial program 20.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{\left(w \cdot h\right)} \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. associate-*l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left(c0 \cdot d\right) \cdot d}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      8. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot d}{w}} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      11. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{d \cdot c0}}{w} \cdot \frac{d}{h \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \color{blue}{\frac{d}{h \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      14. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      15. lower-*.f6419.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\color{blue}{\left(D \cdot D\right) \cdot h}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      16. lift--.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}}\right) \]
    3. Applied rewrites35.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h} + \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites39.7%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      3. associate-*l/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{h \cdot w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{\color{blue}{h \cdot w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      5. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      6. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \color{blue}{\frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      7. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      8. lower-/.f6438.3

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      9. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0}\right) \]
      10. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}} \cdot c0\right) \]
      11. associate-*l/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{h \cdot w}}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2} \cdot c0}{\color{blue}{h \cdot w}}\right) \]
      13. times-fracN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}\right) \]
      14. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \color{blue}{\frac{c0}{w}}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}}\right) \]
      16. lower-/.f6441.0

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \color{blue}{\frac{{\left(\frac{d}{D}\right)}^{2}}{h}} \cdot \frac{c0}{w}\right) \]
    6. Applied rewrites41.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\mathsf{hypot}\left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}, M\right) + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right)} \]
    7. Taylor expanded in M around -inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{-1 \cdot M} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right) \]
    8. Step-by-step derivation
      1. lower-*.f6439.4

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-1 \cdot \color{blue}{M} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right) \]
    9. Applied rewrites39.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{-1 \cdot M} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h} \cdot \frac{c0}{w}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 41.4% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_1 := t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot t\_1 \leq \infty:\\ \;\;\;\;\frac{c0}{w + w} \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
        (t_1 (+ t_0 (sqrt (- (* t_0 t_0) (* M_m M_m))))))
   (if (<= (* (/ c0 (* 2.0 w)) t_1) INFINITY)
     (* (/ c0 (+ w w)) t_1)
     (* 0.5 (/ (* M_m c0) w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_1 = t_0 + sqrt(((t_0 * t_0) - (M_m * M_m)));
	double tmp;
	if (((c0 / (2.0 * w)) * t_1) <= ((double) INFINITY)) {
		tmp = (c0 / (w + w)) * t_1;
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_1 = t_0 + Math.sqrt(((t_0 * t_0) - (M_m * M_m)));
	double tmp;
	if (((c0 / (2.0 * w)) * t_1) <= Double.POSITIVE_INFINITY) {
		tmp = (c0 / (w + w)) * t_1;
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	t_1 = t_0 + math.sqrt(((t_0 * t_0) - (M_m * M_m)))
	tmp = 0
	if ((c0 / (2.0 * w)) * t_1) <= math.inf:
		tmp = (c0 / (w + w)) * t_1
	else:
		tmp = 0.5 * ((M_m * c0) / w)
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_1 = Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M_m * M_m))))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * t_1) <= Inf)
		tmp = Float64(Float64(c0 / Float64(w + w)) * t_1);
	else
		tmp = Float64(0.5 * Float64(Float64(M_m * c0) / w));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	t_1 = t_0 + sqrt(((t_0 * t_0) - (M_m * M_m)));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * t_1) <= Inf)
		tmp = (c0 / (w + w)) * t_1;
	else
		tmp = 0.5 * ((M_m * c0) / w);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], Infinity], N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(0.5 * N[(N[(M$95$m * c0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_1 := t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot t\_1 \leq \infty:\\
\;\;\;\;\frac{c0}{w + w} \cdot t\_1\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 75.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lower-+.f6475.0

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    3. Applied rewrites75.0%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites16.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites10.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6410.2

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites10.2%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{M \cdot c0}{w}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{M \cdot c0}{w}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{M \cdot c0}{\color{blue}{w}} \]
      3. lower-*.f6424.9

        \[\leadsto 0.5 \cdot \frac{M \cdot c0}{w} \]
    9. Applied rewrites24.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 38.2% accurate, 0.5× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\right) \leq \infty:\\ \;\;\;\;\frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M_m M_m)))))
        INFINITY)
     (/ (pow (* c0 d) 2.0) (* (* D D) (* h (* w w))))
     (* 0.5 (/ (* M_m c0) w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M_m * M_m))))) <= ((double) INFINITY)) {
		tmp = pow((c0 * d), 2.0) / ((D * D) * (h * (w * w)));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M_m * M_m))))) <= Double.POSITIVE_INFINITY) {
		tmp = Math.pow((c0 * d), 2.0) / ((D * D) * (h * (w * w)));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M_m * M_m))))) <= math.inf:
		tmp = math.pow((c0 * d), 2.0) / ((D * D) * (h * (w * w)))
	else:
		tmp = 0.5 * ((M_m * c0) / w)
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M_m * M_m))))) <= Inf)
		tmp = Float64((Float64(c0 * d) ^ 2.0) / Float64(Float64(D * D) * Float64(h * Float64(w * w))));
	else
		tmp = Float64(0.5 * Float64(Float64(M_m * c0) / w));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M_m * M_m))))) <= Inf)
		tmp = ((c0 * d) ^ 2.0) / ((D * D) * (h * (w * w)));
	else
		tmp = 0.5 * ((M_m * c0) / w);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[(c0 * d), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(M$95$m * c0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;\frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 75.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites69.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites62.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6462.8

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites62.8%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    8. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      2. pow-prod-downN/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      3. lower-pow.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{{\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2} \cdot \color{blue}{\left(h \cdot {w}^{2}\right)}} \]
      6. pow2N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(\color{blue}{h} \cdot {w}^{2}\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(\color{blue}{h} \cdot {w}^{2}\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
      9. unpow2N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot \color{blue}{w}\right)\right)} \]
      10. lower-*.f6465.2

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot \color{blue}{w}\right)\right)} \]
    9. Applied rewrites65.2%

      \[\leadsto \color{blue}{\frac{{\left(c0 \cdot d\right)}^{2}}{\left(D \cdot D\right) \cdot \left(h \cdot \left(w \cdot w\right)\right)}} \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites16.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites10.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6410.2

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites10.2%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{M \cdot c0}{w}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{M \cdot c0}{w}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{M \cdot c0}{\color{blue}{w}} \]
      3. lower-*.f6424.9

        \[\leadsto 0.5 \cdot \frac{M \cdot c0}{w} \]
    9. Applied rewrites24.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 41.0% accurate, 0.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := c0 \cdot \left(d \cdot d\right)\\ t_1 := \frac{t\_0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq \infty:\\ \;\;\;\;\frac{c0}{w + w} \cdot \left(2 \cdot \frac{t\_0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (* c0 (* d d))) (t_1 (/ t_0 (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M_m M_m)))))
        INFINITY)
     (* (/ c0 (+ w w)) (* 2.0 (/ t_0 (* (* D D) (* h w)))))
     (* 0.5 (/ (* M_m c0) w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = c0 * (d * d);
	double t_1 = t_0 / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= ((double) INFINITY)) {
		tmp = (c0 / (w + w)) * (2.0 * (t_0 / ((D * D) * (h * w))));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = c0 * (d * d);
	double t_1 = t_0 / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Double.POSITIVE_INFINITY) {
		tmp = (c0 / (w + w)) * (2.0 * (t_0 / ((D * D) * (h * w))));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = c0 * (d * d)
	t_1 = t_0 / ((w * h) * (D * D))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= math.inf:
		tmp = (c0 / (w + w)) * (2.0 * (t_0 / ((D * D) * (h * w))))
	else:
		tmp = 0.5 * ((M_m * c0) / w)
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(c0 * Float64(d * d))
	t_1 = Float64(t_0 / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M_m * M_m))))) <= Inf)
		tmp = Float64(Float64(c0 / Float64(w + w)) * Float64(2.0 * Float64(t_0 / Float64(Float64(D * D) * Float64(h * w)))));
	else
		tmp = Float64(0.5 * Float64(Float64(M_m * c0) / w));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = c0 * (d * d);
	t_1 = t_0 / ((w * h) * (D * D));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Inf)
		tmp = (c0 / (w + w)) * (2.0 * (t_0 / ((D * D) * (h * w))));
	else
		tmp = 0.5 * ((M_m * c0) / w);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(t$95$0 / N[(N[(D * D), $MachinePrecision] * N[(h * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(M$95$m * c0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := c0 \cdot \left(d \cdot d\right)\\
t_1 := \frac{t\_0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;\frac{c0}{w + w} \cdot \left(2 \cdot \frac{t\_0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 75.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites69.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites62.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6462.8

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites62.8%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around inf

      \[\leadsto \frac{c0}{w + w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)}\right) \]
      4. pow2N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{{D}^{2} \cdot \color{blue}{\left(h \cdot w\right)}}\right) \]
      7. pow2N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(\color{blue}{h} \cdot w\right)}\right) \]
      8. lift-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(\color{blue}{h} \cdot w\right)}\right) \]
      9. lift-*.f6473.8

        \[\leadsto \frac{c0}{w + w} \cdot \left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(h \cdot \color{blue}{w}\right)}\right) \]
    9. Applied rewrites73.8%

      \[\leadsto \frac{c0}{w + w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}\right)} \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites16.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites10.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6410.2

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites10.2%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{M \cdot c0}{w}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{M \cdot c0}{w}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{M \cdot c0}{\color{blue}{w}} \]
      3. lower-*.f6424.9

        \[\leadsto 0.5 \cdot \frac{M \cdot c0}{w} \]
    9. Applied rewrites24.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 38.5% accurate, 0.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := c0 \cdot \left(d \cdot d\right)\\ t_1 := \frac{t\_0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq \infty:\\ \;\;\;\;\frac{c0}{w + w} \cdot \left(M\_m + \frac{t\_0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (* c0 (* d d))) (t_1 (/ t_0 (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M_m M_m)))))
        INFINITY)
     (* (/ c0 (+ w w)) (+ M_m (/ t_0 (* (* D D) (* h w)))))
     (* 0.5 (/ (* M_m c0) w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = c0 * (d * d);
	double t_1 = t_0 / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= ((double) INFINITY)) {
		tmp = (c0 / (w + w)) * (M_m + (t_0 / ((D * D) * (h * w))));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = Math.abs(M);
public static double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = c0 * (d * d);
	double t_1 = t_0 / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Double.POSITIVE_INFINITY) {
		tmp = (c0 / (w + w)) * (M_m + (t_0 / ((D * D) * (h * w))));
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = math.fabs(M)
def code(c0, w, h, D, d, M_m):
	t_0 = c0 * (d * d)
	t_1 = t_0 / ((w * h) * (D * D))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M_m * M_m))))) <= math.inf:
		tmp = (c0 / (w + w)) * (M_m + (t_0 / ((D * D) * (h * w))))
	else:
		tmp = 0.5 * ((M_m * c0) / w)
	return tmp
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(c0 * Float64(d * d))
	t_1 = Float64(t_0 / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M_m * M_m))))) <= Inf)
		tmp = Float64(Float64(c0 / Float64(w + w)) * Float64(M_m + Float64(t_0 / Float64(Float64(D * D) * Float64(h * w)))));
	else
		tmp = Float64(0.5 * Float64(Float64(M_m * c0) / w));
	end
	return tmp
end
M_m = abs(M);
function tmp_2 = code(c0, w, h, D, d, M_m)
	t_0 = c0 * (d * d);
	t_1 = t_0 / ((w * h) * (D * D));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M_m * M_m))))) <= Inf)
		tmp = (c0 / (w + w)) * (M_m + (t_0 / ((D * D) * (h * w))));
	else
		tmp = 0.5 * ((M_m * c0) / w);
	end
	tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(M$95$m + N[(t$95$0 / N[(N[(D * D), $MachinePrecision] * N[(h * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(M$95$m * c0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := c0 \cdot \left(d \cdot d\right)\\
t_1 := \frac{t\_0}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;\frac{c0}{w + w} \cdot \left(M\_m + \frac{t\_0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 75.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites69.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites62.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6462.8

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites62.8%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \frac{c0}{w + w} \cdot \color{blue}{\left(M + \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    8. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot {d}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)}\right) \]
      4. pow2N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot \left(d \cdot d\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot \left(d \cdot d\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot \left(d \cdot d\right)}{{D}^{2} \cdot \color{blue}{\left(h \cdot w\right)}}\right) \]
      7. pow2N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(\color{blue}{h} \cdot w\right)}\right) \]
      8. lift-*.f64N/A

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(\color{blue}{h} \cdot w\right)}\right) \]
      9. lift-*.f6466.1

        \[\leadsto \frac{c0}{w + w} \cdot \left(M + \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(h \cdot \color{blue}{w}\right)}\right) \]
    9. Applied rewrites66.1%

      \[\leadsto \frac{c0}{w + w} \cdot \color{blue}{\left(M + \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}\right)} \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites16.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites10.2%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6410.2

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites10.2%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{M \cdot c0}{w}} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{M \cdot c0}{w}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \frac{M \cdot c0}{\color{blue}{w}} \]
      3. lower-*.f6424.9

        \[\leadsto 0.5 \cdot \frac{M \cdot c0}{w} \]
    9. Applied rewrites24.9%

      \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 38.5% accurate, 0.7× speedup?

\[\begin{array}{l} M_m = \left|M\right| \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\right) \leq \infty:\\ \;\;\;\;\frac{c0}{w + w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, M\_m\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\ \end{array} \end{array} \]
M_m = (fabs.f64 M)
(FPCore (c0 w h D d M_m)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M_m M_m)))))
        INFINITY)
     (* (/ c0 (+ w w)) (fma (* d c0) (/ d (* (* (* D D) w) h)) M_m))
     (* 0.5 (/ (* M_m c0) w)))))
M_m = fabs(M);
double code(double c0, double w, double h, double D, double d, double M_m) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M_m * M_m))))) <= ((double) INFINITY)) {
		tmp = (c0 / (w + w)) * fma((d * c0), (d / (((D * D) * w) * h)), M_m);
	} else {
		tmp = 0.5 * ((M_m * c0) / w);
	}
	return tmp;
}
M_m = abs(M)
function code(c0, w, h, D, d, M_m)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M_m * M_m))))) <= Inf)
		tmp = Float64(Float64(c0 / Float64(w + w)) * fma(Float64(d * c0), Float64(d / Float64(Float64(Float64(D * D) * w) * h)), M_m));
	else
		tmp = Float64(0.5 * Float64(Float64(M_m * c0) / w));
	end
	return tmp
end
M_m = N[Abs[M], $MachinePrecision]
code[c0_, w_, h_, D_, d_, M$95$m_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(N[(d * c0), $MachinePrecision] * N[(d / N[(N[(N[(D * D), $MachinePrecision] * w), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] + M$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(M$95$m * c0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M\_m \cdot M\_m}\right) \leq \infty:\\
\;\;\;\;\frac{c0}{w + w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, M\_m\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{M\_m \cdot c0}{w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 75.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites69.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites62.8%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6462.8

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites62.8%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \frac{c0}{w + w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \color{blue}{M}\right) \]
    8. Step-by-step derivation
      1. Applied rewrites66.3%

        \[\leadsto \frac{c0}{w + w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \color{blue}{M}\right) \]

      if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

      1. Initial program 0.0%

        \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      2. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
        3. lift-*.f64N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
        4. lift-*.f64N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
        5. associate-*r*N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
        6. associate-/l*N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
        7. lower-fma.f64N/A

          \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      3. Applied rewrites16.3%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
      4. Applied rewrites10.2%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
        2. count-2-revN/A

          \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
        3. lower-+.f6410.2

          \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      6. Applied rewrites10.2%

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      7. Taylor expanded in c0 around 0

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{M \cdot c0}{w}} \]
      8. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{M \cdot c0}{w}} \]
        2. lower-/.f64N/A

          \[\leadsto \frac{1}{2} \cdot \frac{M \cdot c0}{\color{blue}{w}} \]
        3. lower-*.f6424.9

          \[\leadsto 0.5 \cdot \frac{M \cdot c0}{w} \]
      9. Applied rewrites24.9%

        \[\leadsto \color{blue}{0.5 \cdot \frac{M \cdot c0}{w}} \]
    9. Recombined 2 regimes into one program.
    10. Add Preprocessing

    Alternative 9: 23.9% accurate, 7.8× speedup?

    \[\begin{array}{l} M_m = \left|M\right| \\ \frac{c0}{w + w} \cdot M\_m \end{array} \]
    M_m = (fabs.f64 M)
    (FPCore (c0 w h D d M_m) :precision binary64 (* (/ c0 (+ w w)) M_m))
    M_m = fabs(M);
    double code(double c0, double w, double h, double D, double d, double M_m) {
    	return (c0 / (w + w)) * M_m;
    }
    
    M_m =     private
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(8) function code(c0, w, h, d, d_1, m_m)
    use fmin_fmax_functions
        real(8), intent (in) :: c0
        real(8), intent (in) :: w
        real(8), intent (in) :: h
        real(8), intent (in) :: d
        real(8), intent (in) :: d_1
        real(8), intent (in) :: m_m
        code = (c0 / (w + w)) * m_m
    end function
    
    M_m = Math.abs(M);
    public static double code(double c0, double w, double h, double D, double d, double M_m) {
    	return (c0 / (w + w)) * M_m;
    }
    
    M_m = math.fabs(M)
    def code(c0, w, h, D, d, M_m):
    	return (c0 / (w + w)) * M_m
    
    M_m = abs(M)
    function code(c0, w, h, D, d, M_m)
    	return Float64(Float64(c0 / Float64(w + w)) * M_m)
    end
    
    M_m = abs(M);
    function tmp = code(c0, w, h, D, d, M_m)
    	tmp = (c0 / (w + w)) * M_m;
    end
    
    M_m = N[Abs[M], $MachinePrecision]
    code[c0_, w_, h_, D_, d_, M$95$m_] := N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]
    
    \begin{array}{l}
    M_m = \left|M\right|
    
    \\
    \frac{c0}{w + w} \cdot M\_m
    \end{array}
    
    Derivation
    1. Initial program 24.8%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{c0 \cdot \left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      5. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\color{blue}{\left(c0 \cdot d\right) \cdot d}}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      6. associate-/l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(c0 \cdot d\right) \cdot \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(c0 \cdot d, \frac{d}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}, \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)} \]
    3. Applied rewrites34.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(-M, M, {\left(\frac{d \cdot c0}{w} \cdot \frac{d}{\left(D \cdot D\right) \cdot h}\right)}^{2}\right)}\right)} \]
    4. Applied rewrites27.6%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\color{blue}{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}}\right) \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
      3. lower-+.f6427.6

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    6. Applied rewrites27.6%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \mathsf{fma}\left(d \cdot c0, \frac{d}{\left(\left(D \cdot D\right) \cdot w\right) \cdot h}, \sqrt{\mathsf{fma}\left(\frac{d \cdot d}{\left(D \cdot D\right) \cdot w}, \frac{\left(\left(d \cdot d\right) \cdot c0\right) \cdot c0}{\left(\left(\left(D \cdot D\right) \cdot w\right) \cdot h\right) \cdot h}, M \cdot M\right)}\right) \]
    7. Taylor expanded in c0 around 0

      \[\leadsto \frac{c0}{w + w} \cdot \color{blue}{M} \]
    8. Step-by-step derivation
      1. Applied rewrites23.9%

        \[\leadsto \frac{c0}{w + w} \cdot \color{blue}{M} \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025107 
      (FPCore (c0 w h D d M)
        :name "Henrywood and Agarwal, Equation (13)"
        :precision binary64
        (* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))