a parameter of renormalized beta distribution

Percentage Accurate: 99.8% → 99.9%
Time: 8.1s
Alternatives: 12
Speedup: 1.0×

Specification

?
\[\left(0 < m \land 0 < v\right) \land v < 0.25\]
\[\begin{array}{l} \\ \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \end{array} \]
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) m))
double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * m;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    code = (((m * (1.0d0 - m)) / v) - 1.0d0) * m
end function
public static double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * m;
}
def code(m, v):
	return (((m * (1.0 - m)) / v) - 1.0) * m
function code(m, v)
	return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * m)
end
function tmp = code(m, v)
	tmp = (((m * (1.0 - m)) / v) - 1.0) * m;
end
code[m_, v_] := N[(N[(N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * m), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \end{array} \]
(FPCore (m v) :precision binary64 (* (- (/ (* m (- 1.0 m)) v) 1.0) m))
double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * m;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    code = (((m * (1.0d0 - m)) / v) - 1.0d0) * m
end function
public static double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * m;
}
def code(m, v):
	return (((m * (1.0 - m)) / v) - 1.0) * m
function code(m, v)
	return Float64(Float64(Float64(Float64(m * Float64(1.0 - m)) / v) - 1.0) * m)
end
function tmp = code(m, v)
	tmp = (((m * (1.0 - m)) / v) - 1.0) * m;
end
code[m_, v_] := N[(N[(N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1.0), $MachinePrecision] * m), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{m \cdot \left(1 - m\right)}{\frac{v}{m}} - m \end{array} \]
(FPCore (m v) :precision binary64 (- (/ (* m (- 1.0 m)) (/ v m)) m))
double code(double m, double v) {
	return ((m * (1.0 - m)) / (v / m)) - m;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    code = ((m * (1.0d0 - m)) / (v / m)) - m
end function
public static double code(double m, double v) {
	return ((m * (1.0 - m)) / (v / m)) - m;
}
def code(m, v):
	return ((m * (1.0 - m)) / (v / m)) - m
function code(m, v)
	return Float64(Float64(Float64(m * Float64(1.0 - m)) / Float64(v / m)) - m)
end
function tmp = code(m, v)
	tmp = ((m * (1.0 - m)) / (v / m)) - m;
end
code[m_, v_] := N[(N[(N[(m * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]
\begin{array}{l}

\\
\frac{m \cdot \left(1 - m\right)}{\frac{v}{m}} - m
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
    2. sub-negN/A

      \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
    3. distribute-rgt-inN/A

      \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot m} \]
    4. metadata-evalN/A

      \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + -1 \cdot m \]
    5. neg-mul-1N/A

      \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \left(\mathsf{neg}\left(m\right)\right) \]
    6. unsub-negN/A

      \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m - \color{blue}{m} \]
    7. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v} \cdot m\right), \color{blue}{m}\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{v} \cdot m\right), m\right) \]
    9. associate-/l*N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot \frac{m}{v}\right) \cdot m\right), m\right) \]
    10. associate-*l*N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(1 - m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
    12. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\left(\frac{m}{v}\right), m\right)\right), m\right) \]
    14. /-lowering-/.f6499.8%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, v\right), m\right)\right), m\right) \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right) - m} \]
  5. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(m \cdot \frac{m}{v}\right)\right), m\right) \]
    2. associate-*r*N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{m}{v}\right), m\right) \]
    3. clear-numN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{1}{\frac{v}{m}}\right), m\right) \]
    4. un-div-invN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{\frac{v}{m}}\right), m\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(1 - m\right) \cdot m\right), \left(\frac{v}{m}\right)\right), m\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
    8. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
    9. /-lowering-/.f6499.8%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{m}}} - m \]
  7. Add Preprocessing

Alternative 2: 61.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 2.6 \cdot 10^{-166}:\\ \;\;\;\;0 - m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 2.6e-166)
   (- 0.0 m)
   (if (<= m 1.0) (/ m (/ v m)) (* (* m m) (/ -1.0 m)))))
double code(double m, double v) {
	double tmp;
	if (m <= 2.6e-166) {
		tmp = 0.0 - m;
	} else if (m <= 1.0) {
		tmp = m / (v / m);
	} else {
		tmp = (m * m) * (-1.0 / m);
	}
	return tmp;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if (m <= 2.6d-166) then
        tmp = 0.0d0 - m
    else if (m <= 1.0d0) then
        tmp = m / (v / m)
    else
        tmp = (m * m) * ((-1.0d0) / m)
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 2.6e-166) {
		tmp = 0.0 - m;
	} else if (m <= 1.0) {
		tmp = m / (v / m);
	} else {
		tmp = (m * m) * (-1.0 / m);
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 2.6e-166:
		tmp = 0.0 - m
	elif m <= 1.0:
		tmp = m / (v / m)
	else:
		tmp = (m * m) * (-1.0 / m)
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 2.6e-166)
		tmp = Float64(0.0 - m);
	elseif (m <= 1.0)
		tmp = Float64(m / Float64(v / m));
	else
		tmp = Float64(Float64(m * m) * Float64(-1.0 / m));
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 2.6e-166)
		tmp = 0.0 - m;
	elseif (m <= 1.0)
		tmp = m / (v / m);
	else
		tmp = (m * m) * (-1.0 / m);
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 2.6e-166], N[(0.0 - m), $MachinePrecision], If[LessEqual[m, 1.0], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], N[(N[(m * m), $MachinePrecision] * N[(-1.0 / m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.6 \cdot 10^{-166}:\\
\;\;\;\;0 - m\\

\mathbf{elif}\;m \leq 1:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\

\mathbf{else}:\\
\;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if m < 2.59999999999999989e-166

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around 0

      \[\leadsto \color{blue}{-1 \cdot m} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{m} \]
      3. --lowering--.f6481.7%

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
    5. Simplified81.7%

      \[\leadsto \color{blue}{0 - m} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-lowering-neg.f6481.7%

        \[\leadsto \mathsf{neg.f64}\left(m\right) \]
    7. Applied egg-rr81.7%

      \[\leadsto \color{blue}{-m} \]

    if 2.59999999999999989e-166 < m < 1

    1. Initial program 99.5%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({m}^{2} \cdot \left(\frac{1}{m \cdot v} - \frac{1}{v}\right)\right)}, m\right) \]
    4. Step-by-step derivation
      1. distribute-lft-out--N/A

        \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{1}{m \cdot v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      2. associate-/r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{\frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{{m}^{2} \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(m \cdot m\right) \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(m \cdot \frac{1}{m}\right)}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      6. rgt-mult-inverseN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      8. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      9. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - \left(m \cdot m\right) \cdot \frac{1}{v}\right), m\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \left(m \cdot \frac{1}{v}\right)\right), m\right) \]
      12. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m \cdot 1}{v}\right), m\right) \]
      13. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m}{v}\right), m\right) \]
      14. distribute-lft-out--N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \left(\frac{1}{v} - \frac{m}{v}\right)\right), m\right) \]
      15. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), m\right) \]
      16. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v}\right), m\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), v\right), m\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), v\right), m\right) \]
      19. --lowering--.f6477.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), v\right), m\right) \]
    5. Simplified77.4%

      \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} \cdot m \]
    6. Taylor expanded in m around 0

      \[\leadsto \color{blue}{\frac{{m}^{2}}{v}} \]
    7. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left({m}^{2}\right), \color{blue}{v}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(m \cdot m\right), v\right) \]
      3. *-lowering-*.f6471.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(m, m\right), v\right) \]
    8. Simplified71.6%

      \[\leadsto \color{blue}{\frac{m \cdot m}{v}} \]
    9. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto m \cdot \color{blue}{\frac{m}{v}} \]
      2. clear-numN/A

        \[\leadsto m \cdot \frac{1}{\color{blue}{\frac{v}{m}}} \]
      3. un-div-invN/A

        \[\leadsto \frac{m}{\color{blue}{\frac{v}{m}}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(m, \color{blue}{\left(\frac{v}{m}\right)}\right) \]
      5. /-lowering-/.f6473.7%

        \[\leadsto \mathsf{/.f64}\left(m, \mathsf{/.f64}\left(v, \color{blue}{m}\right)\right) \]
    10. Applied egg-rr73.7%

      \[\leadsto \color{blue}{\frac{m}{\frac{v}{m}}} \]

    if 1 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around 0

      \[\leadsto \color{blue}{-1 \cdot m} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{m} \]
      3. --lowering--.f645.7%

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
    5. Simplified5.7%

      \[\leadsto \color{blue}{0 - m} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-lowering-neg.f645.7%

        \[\leadsto \mathsf{neg.f64}\left(m\right) \]
    7. Applied egg-rr5.7%

      \[\leadsto \color{blue}{-m} \]
    8. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto \mathsf{neg}\left(\left(0 + m\right)\right) \]
      2. flip-+N/A

        \[\leadsto \mathsf{neg}\left(\frac{0 \cdot 0 - m \cdot m}{0 - m}\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{neg}\left(\frac{0 - m \cdot m}{0 - m}\right) \]
      4. neg-sub0N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(m \cdot m\right)}{0 - m}\right) \]
      5. neg-sub0N/A

        \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(m \cdot m\right)}{\mathsf{neg}\left(m\right)}\right) \]
      6. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(m \cdot m\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(m\right)}} \]
      7. div-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(m \cdot m\right)\right)\right)\right) \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(m\right)}} \]
      8. remove-double-negN/A

        \[\leadsto \left(m \cdot m\right) \cdot \frac{\color{blue}{1}}{\mathsf{neg}\left(m\right)} \]
      9. neg-sub0N/A

        \[\leadsto \left(m \cdot m\right) \cdot \frac{1}{0 - \color{blue}{m}} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot m\right), \color{blue}{\left(\frac{1}{0 - m}\right)}\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\color{blue}{1}}{0 - m}\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{0} - m}\right)\right) \]
      13. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(m\right)}\right)\right) \]
      14. frac-2negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{-1}{\color{blue}{m}}\right)\right) \]
      15. /-lowering-/.f6456.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \mathsf{/.f64}\left(-1, \color{blue}{m}\right)\right) \]
    9. Applied egg-rr56.8%

      \[\leadsto \color{blue}{\left(m \cdot m\right) \cdot \frac{-1}{m}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 2.6 \cdot 10^{-166}:\\ \;\;\;\;0 - m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 38.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 2.55 \cdot 10^{-166}:\\ \;\;\;\;0 - m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;0 - m\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 2.55e-166) (- 0.0 m) (if (<= m 1.0) (/ m (/ v m)) (- 0.0 m))))
double code(double m, double v) {
	double tmp;
	if (m <= 2.55e-166) {
		tmp = 0.0 - m;
	} else if (m <= 1.0) {
		tmp = m / (v / m);
	} else {
		tmp = 0.0 - m;
	}
	return tmp;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if (m <= 2.55d-166) then
        tmp = 0.0d0 - m
    else if (m <= 1.0d0) then
        tmp = m / (v / m)
    else
        tmp = 0.0d0 - m
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 2.55e-166) {
		tmp = 0.0 - m;
	} else if (m <= 1.0) {
		tmp = m / (v / m);
	} else {
		tmp = 0.0 - m;
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 2.55e-166:
		tmp = 0.0 - m
	elif m <= 1.0:
		tmp = m / (v / m)
	else:
		tmp = 0.0 - m
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 2.55e-166)
		tmp = Float64(0.0 - m);
	elseif (m <= 1.0)
		tmp = Float64(m / Float64(v / m));
	else
		tmp = Float64(0.0 - m);
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 2.55e-166)
		tmp = 0.0 - m;
	elseif (m <= 1.0)
		tmp = m / (v / m);
	else
		tmp = 0.0 - m;
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 2.55e-166], N[(0.0 - m), $MachinePrecision], If[LessEqual[m, 1.0], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], N[(0.0 - m), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.55 \cdot 10^{-166}:\\
\;\;\;\;0 - m\\

\mathbf{elif}\;m \leq 1:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\

\mathbf{else}:\\
\;\;\;\;0 - m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < 2.5500000000000001e-166 or 1 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around 0

      \[\leadsto \color{blue}{-1 \cdot m} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{m} \]
      3. --lowering--.f6432.9%

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
    5. Simplified32.9%

      \[\leadsto \color{blue}{0 - m} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-lowering-neg.f6432.9%

        \[\leadsto \mathsf{neg.f64}\left(m\right) \]
    7. Applied egg-rr32.9%

      \[\leadsto \color{blue}{-m} \]

    if 2.5500000000000001e-166 < m < 1

    1. Initial program 99.5%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({m}^{2} \cdot \left(\frac{1}{m \cdot v} - \frac{1}{v}\right)\right)}, m\right) \]
    4. Step-by-step derivation
      1. distribute-lft-out--N/A

        \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{1}{m \cdot v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      2. associate-/r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{\frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{{m}^{2} \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(m \cdot m\right) \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(m \cdot \frac{1}{m}\right)}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      6. rgt-mult-inverseN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      8. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      9. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - \left(m \cdot m\right) \cdot \frac{1}{v}\right), m\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \left(m \cdot \frac{1}{v}\right)\right), m\right) \]
      12. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m \cdot 1}{v}\right), m\right) \]
      13. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m}{v}\right), m\right) \]
      14. distribute-lft-out--N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \left(\frac{1}{v} - \frac{m}{v}\right)\right), m\right) \]
      15. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), m\right) \]
      16. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v}\right), m\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), v\right), m\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), v\right), m\right) \]
      19. --lowering--.f6477.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), v\right), m\right) \]
    5. Simplified77.4%

      \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} \cdot m \]
    6. Taylor expanded in m around 0

      \[\leadsto \color{blue}{\frac{{m}^{2}}{v}} \]
    7. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left({m}^{2}\right), \color{blue}{v}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(m \cdot m\right), v\right) \]
      3. *-lowering-*.f6471.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(m, m\right), v\right) \]
    8. Simplified71.6%

      \[\leadsto \color{blue}{\frac{m \cdot m}{v}} \]
    9. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto m \cdot \color{blue}{\frac{m}{v}} \]
      2. clear-numN/A

        \[\leadsto m \cdot \frac{1}{\color{blue}{\frac{v}{m}}} \]
      3. un-div-invN/A

        \[\leadsto \frac{m}{\color{blue}{\frac{v}{m}}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(m, \color{blue}{\left(\frac{v}{m}\right)}\right) \]
      5. /-lowering-/.f6473.7%

        \[\leadsto \mathsf{/.f64}\left(m, \mathsf{/.f64}\left(v, \color{blue}{m}\right)\right) \]
    10. Applied egg-rr73.7%

      \[\leadsto \color{blue}{\frac{m}{\frac{v}{m}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 2.55 \cdot 10^{-166}:\\ \;\;\;\;0 - m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;0 - m\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 38.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 2.6 \cdot 10^{-166}:\\ \;\;\;\;0 - m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;m \cdot \frac{m}{v}\\ \mathbf{else}:\\ \;\;\;\;0 - m\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 2.6e-166) (- 0.0 m) (if (<= m 1.0) (* m (/ m v)) (- 0.0 m))))
double code(double m, double v) {
	double tmp;
	if (m <= 2.6e-166) {
		tmp = 0.0 - m;
	} else if (m <= 1.0) {
		tmp = m * (m / v);
	} else {
		tmp = 0.0 - m;
	}
	return tmp;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if (m <= 2.6d-166) then
        tmp = 0.0d0 - m
    else if (m <= 1.0d0) then
        tmp = m * (m / v)
    else
        tmp = 0.0d0 - m
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 2.6e-166) {
		tmp = 0.0 - m;
	} else if (m <= 1.0) {
		tmp = m * (m / v);
	} else {
		tmp = 0.0 - m;
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 2.6e-166:
		tmp = 0.0 - m
	elif m <= 1.0:
		tmp = m * (m / v)
	else:
		tmp = 0.0 - m
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 2.6e-166)
		tmp = Float64(0.0 - m);
	elseif (m <= 1.0)
		tmp = Float64(m * Float64(m / v));
	else
		tmp = Float64(0.0 - m);
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 2.6e-166)
		tmp = 0.0 - m;
	elseif (m <= 1.0)
		tmp = m * (m / v);
	else
		tmp = 0.0 - m;
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 2.6e-166], N[(0.0 - m), $MachinePrecision], If[LessEqual[m, 1.0], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], N[(0.0 - m), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.6 \cdot 10^{-166}:\\
\;\;\;\;0 - m\\

\mathbf{elif}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v}\\

\mathbf{else}:\\
\;\;\;\;0 - m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < 2.59999999999999989e-166 or 1 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around 0

      \[\leadsto \color{blue}{-1 \cdot m} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{m} \]
      3. --lowering--.f6432.9%

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
    5. Simplified32.9%

      \[\leadsto \color{blue}{0 - m} \]
    6. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(m\right) \]
      2. neg-lowering-neg.f6432.9%

        \[\leadsto \mathsf{neg.f64}\left(m\right) \]
    7. Applied egg-rr32.9%

      \[\leadsto \color{blue}{-m} \]

    if 2.59999999999999989e-166 < m < 1

    1. Initial program 99.5%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Taylor expanded in m around inf

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({m}^{2} \cdot \left(\frac{1}{m \cdot v} - \frac{1}{v}\right)\right)}, m\right) \]
    4. Step-by-step derivation
      1. distribute-lft-out--N/A

        \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{1}{m \cdot v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      2. associate-/r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{\frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{{m}^{2} \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(m \cdot m\right) \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(m \cdot \frac{1}{m}\right)}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      6. rgt-mult-inverseN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      8. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      9. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - \left(m \cdot m\right) \cdot \frac{1}{v}\right), m\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \left(m \cdot \frac{1}{v}\right)\right), m\right) \]
      12. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m \cdot 1}{v}\right), m\right) \]
      13. *-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m}{v}\right), m\right) \]
      14. distribute-lft-out--N/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \left(\frac{1}{v} - \frac{m}{v}\right)\right), m\right) \]
      15. div-subN/A

        \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), m\right) \]
      16. associate-/l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v}\right), m\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), v\right), m\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), v\right), m\right) \]
      19. --lowering--.f6477.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), v\right), m\right) \]
    5. Simplified77.4%

      \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} \cdot m \]
    6. Taylor expanded in m around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{m}{v}\right)}, m\right) \]
    7. Step-by-step derivation
      1. /-lowering-/.f6473.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, v\right), m\right) \]
    8. Simplified73.6%

      \[\leadsto \color{blue}{\frac{m}{v}} \cdot m \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 2.6 \cdot 10^{-166}:\\ \;\;\;\;0 - m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;m \cdot \frac{m}{v}\\ \mathbf{else}:\\ \;\;\;\;0 - m\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\frac{m}{\frac{v}{m}} - m\\ \mathbf{else}:\\ \;\;\;\;m \cdot \frac{m}{\frac{v}{1 - m}}\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 5e-12) (- (/ m (/ v m)) m) (* m (/ m (/ v (- 1.0 m))))))
double code(double m, double v) {
	double tmp;
	if (m <= 5e-12) {
		tmp = (m / (v / m)) - m;
	} else {
		tmp = m * (m / (v / (1.0 - m)));
	}
	return tmp;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if (m <= 5d-12) then
        tmp = (m / (v / m)) - m
    else
        tmp = m * (m / (v / (1.0d0 - m)))
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 5e-12) {
		tmp = (m / (v / m)) - m;
	} else {
		tmp = m * (m / (v / (1.0 - m)));
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 5e-12:
		tmp = (m / (v / m)) - m
	else:
		tmp = m * (m / (v / (1.0 - m)))
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 5e-12)
		tmp = Float64(Float64(m / Float64(v / m)) - m);
	else
		tmp = Float64(m * Float64(m / Float64(v / Float64(1.0 - m))));
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 5e-12)
		tmp = (m / (v / m)) - m;
	else
		tmp = m * (m / (v / (1.0 - m)));
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 5e-12], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(m / N[(v / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{m}{\frac{v}{m}} - m\\

\mathbf{else}:\\
\;\;\;\;m \cdot \frac{m}{\frac{v}{1 - m}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < 4.9999999999999997e-12

    1. Initial program 99.7%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-negN/A

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
      3. distribute-rgt-inN/A

        \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot m} \]
      4. metadata-evalN/A

        \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + -1 \cdot m \]
      5. neg-mul-1N/A

        \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \left(\mathsf{neg}\left(m\right)\right) \]
      6. unsub-negN/A

        \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m - \color{blue}{m} \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v} \cdot m\right), \color{blue}{m}\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{v} \cdot m\right), m\right) \]
      9. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot \frac{m}{v}\right) \cdot m\right), m\right) \]
      10. associate-*l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(1 - m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
      12. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\left(\frac{m}{v}\right), m\right)\right), m\right) \]
      14. /-lowering-/.f6499.7%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, v\right), m\right)\right), m\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right) - m} \]
    5. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(m \cdot \frac{m}{v}\right)\right), m\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{m}{v}\right), m\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{1}{\frac{v}{m}}\right), m\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{\frac{v}{m}}\right), m\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(1 - m\right) \cdot m\right), \left(\frac{v}{m}\right)\right), m\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
      9. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
    6. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{m}}} - m \]
    7. Taylor expanded in m around 0

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\color{blue}{m}, \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
    8. Step-by-step derivation
      1. Simplified99.4%

        \[\leadsto \frac{\color{blue}{m}}{\frac{v}{m}} - m \]

      if 4.9999999999999997e-12 < m

      1. Initial program 99.9%

        \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
      2. Add Preprocessing
      3. Taylor expanded in m around inf

        \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({m}^{2} \cdot \left(\frac{1}{m \cdot v} - \frac{1}{v}\right)\right)}, m\right) \]
      4. Step-by-step derivation
        1. distribute-lft-out--N/A

          \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{1}{m \cdot v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        2. associate-/r*N/A

          \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{\frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        3. associate-*r/N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{{m}^{2} \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        4. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(m \cdot m\right) \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        5. associate-*l*N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(m \cdot \frac{1}{m}\right)}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        6. rgt-mult-inverseN/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        7. *-rgt-identityN/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        8. *-rgt-identityN/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        9. associate-*r/N/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
        10. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - \left(m \cdot m\right) \cdot \frac{1}{v}\right), m\right) \]
        11. associate-*r*N/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \left(m \cdot \frac{1}{v}\right)\right), m\right) \]
        12. associate-*r/N/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m \cdot 1}{v}\right), m\right) \]
        13. *-rgt-identityN/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m}{v}\right), m\right) \]
        14. distribute-lft-out--N/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \left(\frac{1}{v} - \frac{m}{v}\right)\right), m\right) \]
        15. div-subN/A

          \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), m\right) \]
        16. associate-/l*N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v}\right), m\right) \]
        17. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), v\right), m\right) \]
        18. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), v\right), m\right) \]
        19. --lowering--.f6499.9%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), v\right), m\right) \]
      5. Simplified99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} \cdot m \]
      6. Step-by-step derivation
        1. associate-*l/N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{v} \cdot \left(1 - m\right)\right), m\right) \]
        2. associate-/r/N/A

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{\frac{v}{1 - m}}\right), m\right) \]
        3. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, \left(\frac{v}{1 - m}\right)\right), m\right) \]
        4. /-lowering-/.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, \mathsf{/.f64}\left(v, \left(1 - m\right)\right)\right), m\right) \]
        5. --lowering--.f6499.9%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, \mathsf{/.f64}\left(v, \mathsf{\_.f64}\left(1, m\right)\right)\right), m\right) \]
      7. Applied egg-rr99.9%

        \[\leadsto \color{blue}{\frac{m}{\frac{v}{1 - m}}} \cdot m \]
    9. Recombined 2 regimes into one program.
    10. Final simplification99.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\frac{m}{\frac{v}{m}} - m\\ \mathbf{else}:\\ \;\;\;\;m \cdot \frac{m}{\frac{v}{1 - m}}\\ \end{array} \]
    11. Add Preprocessing

    Alternative 6: 99.7% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\frac{m}{\frac{v}{m}} - m\\ \mathbf{else}:\\ \;\;\;\;m \cdot \left(m \cdot \frac{1 - m}{v}\right)\\ \end{array} \end{array} \]
    (FPCore (m v)
     :precision binary64
     (if (<= m 5e-12) (- (/ m (/ v m)) m) (* m (* m (/ (- 1.0 m) v)))))
    double code(double m, double v) {
    	double tmp;
    	if (m <= 5e-12) {
    		tmp = (m / (v / m)) - m;
    	} else {
    		tmp = m * (m * ((1.0 - m) / v));
    	}
    	return tmp;
    }
    
    real(8) function code(m, v)
        real(8), intent (in) :: m
        real(8), intent (in) :: v
        real(8) :: tmp
        if (m <= 5d-12) then
            tmp = (m / (v / m)) - m
        else
            tmp = m * (m * ((1.0d0 - m) / v))
        end if
        code = tmp
    end function
    
    public static double code(double m, double v) {
    	double tmp;
    	if (m <= 5e-12) {
    		tmp = (m / (v / m)) - m;
    	} else {
    		tmp = m * (m * ((1.0 - m) / v));
    	}
    	return tmp;
    }
    
    def code(m, v):
    	tmp = 0
    	if m <= 5e-12:
    		tmp = (m / (v / m)) - m
    	else:
    		tmp = m * (m * ((1.0 - m) / v))
    	return tmp
    
    function code(m, v)
    	tmp = 0.0
    	if (m <= 5e-12)
    		tmp = Float64(Float64(m / Float64(v / m)) - m);
    	else
    		tmp = Float64(m * Float64(m * Float64(Float64(1.0 - m) / v)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(m, v)
    	tmp = 0.0;
    	if (m <= 5e-12)
    		tmp = (m / (v / m)) - m;
    	else
    		tmp = m * (m * ((1.0 - m) / v));
    	end
    	tmp_2 = tmp;
    end
    
    code[m_, v_] := If[LessEqual[m, 5e-12], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(m * N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;m \leq 5 \cdot 10^{-12}:\\
    \;\;\;\;\frac{m}{\frac{v}{m}} - m\\
    
    \mathbf{else}:\\
    \;\;\;\;m \cdot \left(m \cdot \frac{1 - m}{v}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if m < 4.9999999999999997e-12

      1. Initial program 99.7%

        \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
        2. sub-negN/A

          \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
        3. distribute-rgt-inN/A

          \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot m} \]
        4. metadata-evalN/A

          \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + -1 \cdot m \]
        5. neg-mul-1N/A

          \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \left(\mathsf{neg}\left(m\right)\right) \]
        6. unsub-negN/A

          \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m - \color{blue}{m} \]
        7. --lowering--.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v} \cdot m\right), \color{blue}{m}\right) \]
        8. *-commutativeN/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{v} \cdot m\right), m\right) \]
        9. associate-/l*N/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot \frac{m}{v}\right) \cdot m\right), m\right) \]
        10. associate-*l*N/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
        11. *-lowering-*.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(1 - m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
        12. --lowering--.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
        13. *-lowering-*.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\left(\frac{m}{v}\right), m\right)\right), m\right) \]
        14. /-lowering-/.f6499.7%

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, v\right), m\right)\right), m\right) \]
      4. Applied egg-rr99.7%

        \[\leadsto \color{blue}{\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right) - m} \]
      5. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(m \cdot \frac{m}{v}\right)\right), m\right) \]
        2. associate-*r*N/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{m}{v}\right), m\right) \]
        3. clear-numN/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{1}{\frac{v}{m}}\right), m\right) \]
        4. un-div-invN/A

          \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{\frac{v}{m}}\right), m\right) \]
        5. /-lowering-/.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(1 - m\right) \cdot m\right), \left(\frac{v}{m}\right)\right), m\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
        8. --lowering--.f64N/A

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
        9. /-lowering-/.f6499.8%

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
      6. Applied egg-rr99.8%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{m}}} - m \]
      7. Taylor expanded in m around 0

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\color{blue}{m}, \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
      8. Step-by-step derivation
        1. Simplified99.4%

          \[\leadsto \frac{\color{blue}{m}}{\frac{v}{m}} - m \]

        if 4.9999999999999997e-12 < m

        1. Initial program 99.9%

          \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
        2. Add Preprocessing
        3. Taylor expanded in m around inf

          \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({m}^{2} \cdot \left(\frac{1}{m \cdot v} - \frac{1}{v}\right)\right)}, m\right) \]
        4. Step-by-step derivation
          1. distribute-lft-out--N/A

            \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{1}{m \cdot v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          2. associate-/r*N/A

            \[\leadsto \mathsf{*.f64}\left(\left({m}^{2} \cdot \frac{\frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          3. associate-*r/N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{{m}^{2} \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          4. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(m \cdot m\right) \cdot \frac{1}{m}}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          5. associate-*l*N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(m \cdot \frac{1}{m}\right)}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          6. rgt-mult-inverseN/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          7. *-rgt-identityN/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{m}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          8. *-rgt-identityN/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot 1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          9. associate-*r/N/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - {m}^{2} \cdot \frac{1}{v}\right), m\right) \]
          10. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - \left(m \cdot m\right) \cdot \frac{1}{v}\right), m\right) \]
          11. associate-*r*N/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \left(m \cdot \frac{1}{v}\right)\right), m\right) \]
          12. associate-*r/N/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m \cdot 1}{v}\right), m\right) \]
          13. *-rgt-identityN/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1}{v} - m \cdot \frac{m}{v}\right), m\right) \]
          14. distribute-lft-out--N/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \left(\frac{1}{v} - \frac{m}{v}\right)\right), m\right) \]
          15. div-subN/A

            \[\leadsto \mathsf{*.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), m\right) \]
          16. associate-/l*N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v}\right), m\right) \]
          17. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), v\right), m\right) \]
          18. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), v\right), m\right) \]
          19. --lowering--.f6499.9%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), v\right), m\right) \]
        5. Simplified99.9%

          \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} \cdot m \]
        6. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{v}\right), m\right) \]
          2. associate-*l/N/A

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - m}{v} \cdot m\right), m\right) \]
          3. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\frac{1 - m}{v}\right), m\right), m\right) \]
          4. /-lowering-/.f64N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - m\right), v\right), m\right), m\right) \]
          5. --lowering--.f6499.9%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, m\right), v\right), m\right), m\right) \]
        7. Applied egg-rr99.9%

          \[\leadsto \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \cdot m \]
      9. Recombined 2 regimes into one program.
      10. Final simplification99.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\frac{m}{\frac{v}{m}} - m\\ \mathbf{else}:\\ \;\;\;\;m \cdot \left(m \cdot \frac{1 - m}{v}\right)\\ \end{array} \]
      11. Add Preprocessing

      Alternative 7: 74.9% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}} - m\\ \mathbf{else}:\\ \;\;\;\;\frac{0 - m \cdot m}{m}\\ \end{array} \end{array} \]
      (FPCore (m v)
       :precision binary64
       (if (<= m 1.0) (- (/ m (/ v m)) m) (/ (- 0.0 (* m m)) m)))
      double code(double m, double v) {
      	double tmp;
      	if (m <= 1.0) {
      		tmp = (m / (v / m)) - m;
      	} else {
      		tmp = (0.0 - (m * m)) / m;
      	}
      	return tmp;
      }
      
      real(8) function code(m, v)
          real(8), intent (in) :: m
          real(8), intent (in) :: v
          real(8) :: tmp
          if (m <= 1.0d0) then
              tmp = (m / (v / m)) - m
          else
              tmp = (0.0d0 - (m * m)) / m
          end if
          code = tmp
      end function
      
      public static double code(double m, double v) {
      	double tmp;
      	if (m <= 1.0) {
      		tmp = (m / (v / m)) - m;
      	} else {
      		tmp = (0.0 - (m * m)) / m;
      	}
      	return tmp;
      }
      
      def code(m, v):
      	tmp = 0
      	if m <= 1.0:
      		tmp = (m / (v / m)) - m
      	else:
      		tmp = (0.0 - (m * m)) / m
      	return tmp
      
      function code(m, v)
      	tmp = 0.0
      	if (m <= 1.0)
      		tmp = Float64(Float64(m / Float64(v / m)) - m);
      	else
      		tmp = Float64(Float64(0.0 - Float64(m * m)) / m);
      	end
      	return tmp
      end
      
      function tmp_2 = code(m, v)
      	tmp = 0.0;
      	if (m <= 1.0)
      		tmp = (m / (v / m)) - m;
      	else
      		tmp = (0.0 - (m * m)) / m;
      	end
      	tmp_2 = tmp;
      end
      
      code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(0.0 - N[(m * m), $MachinePrecision]), $MachinePrecision] / m), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;m \leq 1:\\
      \;\;\;\;\frac{m}{\frac{v}{m}} - m\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{0 - m \cdot m}{m}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if m < 1

        1. Initial program 99.7%

          \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
          2. sub-negN/A

            \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
          3. distribute-rgt-inN/A

            \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot m} \]
          4. metadata-evalN/A

            \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + -1 \cdot m \]
          5. neg-mul-1N/A

            \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \left(\mathsf{neg}\left(m\right)\right) \]
          6. unsub-negN/A

            \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m - \color{blue}{m} \]
          7. --lowering--.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v} \cdot m\right), \color{blue}{m}\right) \]
          8. *-commutativeN/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{v} \cdot m\right), m\right) \]
          9. associate-/l*N/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot \frac{m}{v}\right) \cdot m\right), m\right) \]
          10. associate-*l*N/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
          11. *-lowering-*.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(1 - m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
          12. --lowering--.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
          13. *-lowering-*.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\left(\frac{m}{v}\right), m\right)\right), m\right) \]
          14. /-lowering-/.f6499.7%

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, v\right), m\right)\right), m\right) \]
        4. Applied egg-rr99.7%

          \[\leadsto \color{blue}{\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right) - m} \]
        5. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(m \cdot \frac{m}{v}\right)\right), m\right) \]
          2. associate-*r*N/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{m}{v}\right), m\right) \]
          3. clear-numN/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{1}{\frac{v}{m}}\right), m\right) \]
          4. un-div-invN/A

            \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{\frac{v}{m}}\right), m\right) \]
          5. /-lowering-/.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(1 - m\right) \cdot m\right), \left(\frac{v}{m}\right)\right), m\right) \]
          6. *-commutativeN/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
          7. *-lowering-*.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
          8. --lowering--.f64N/A

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
          9. /-lowering-/.f6499.8%

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
        6. Applied egg-rr99.8%

          \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{m}}} - m \]
        7. Taylor expanded in m around 0

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\color{blue}{m}, \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
        8. Step-by-step derivation
          1. Simplified97.7%

            \[\leadsto \frac{\color{blue}{m}}{\frac{v}{m}} - m \]

          if 1 < m

          1. Initial program 99.9%

            \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
          2. Add Preprocessing
          3. Taylor expanded in m around 0

            \[\leadsto \color{blue}{-1 \cdot m} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(m\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{m} \]
            3. --lowering--.f645.7%

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
          5. Simplified5.7%

            \[\leadsto \color{blue}{0 - m} \]
          6. Step-by-step derivation
            1. flip--N/A

              \[\leadsto \frac{0 \cdot 0 - m \cdot m}{\color{blue}{0 + m}} \]
            2. +-lft-identityN/A

              \[\leadsto \frac{0 \cdot 0 - m \cdot m}{m} \]
            3. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\left(0 \cdot 0 - m \cdot m\right), \color{blue}{m}\right) \]
            4. metadata-evalN/A

              \[\leadsto \mathsf{/.f64}\left(\left(0 - m \cdot m\right), m\right) \]
            5. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(0, \left(m \cdot m\right)\right), m\right) \]
            6. *-lowering-*.f6456.8%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(m, m\right)\right), m\right) \]
          7. Applied egg-rr56.8%

            \[\leadsto \color{blue}{\frac{0 - m \cdot m}{m}} \]
        9. Recombined 2 regimes into one program.
        10. Add Preprocessing

        Alternative 8: 74.9% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}} - m\\ \mathbf{else}:\\ \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\ \end{array} \end{array} \]
        (FPCore (m v)
         :precision binary64
         (if (<= m 1.0) (- (/ m (/ v m)) m) (* (* m m) (/ -1.0 m))))
        double code(double m, double v) {
        	double tmp;
        	if (m <= 1.0) {
        		tmp = (m / (v / m)) - m;
        	} else {
        		tmp = (m * m) * (-1.0 / m);
        	}
        	return tmp;
        }
        
        real(8) function code(m, v)
            real(8), intent (in) :: m
            real(8), intent (in) :: v
            real(8) :: tmp
            if (m <= 1.0d0) then
                tmp = (m / (v / m)) - m
            else
                tmp = (m * m) * ((-1.0d0) / m)
            end if
            code = tmp
        end function
        
        public static double code(double m, double v) {
        	double tmp;
        	if (m <= 1.0) {
        		tmp = (m / (v / m)) - m;
        	} else {
        		tmp = (m * m) * (-1.0 / m);
        	}
        	return tmp;
        }
        
        def code(m, v):
        	tmp = 0
        	if m <= 1.0:
        		tmp = (m / (v / m)) - m
        	else:
        		tmp = (m * m) * (-1.0 / m)
        	return tmp
        
        function code(m, v)
        	tmp = 0.0
        	if (m <= 1.0)
        		tmp = Float64(Float64(m / Float64(v / m)) - m);
        	else
        		tmp = Float64(Float64(m * m) * Float64(-1.0 / m));
        	end
        	return tmp
        end
        
        function tmp_2 = code(m, v)
        	tmp = 0.0;
        	if (m <= 1.0)
        		tmp = (m / (v / m)) - m;
        	else
        		tmp = (m * m) * (-1.0 / m);
        	end
        	tmp_2 = tmp;
        end
        
        code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(N[(m * m), $MachinePrecision] * N[(-1.0 / m), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;m \leq 1:\\
        \;\;\;\;\frac{m}{\frac{v}{m}} - m\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if m < 1

          1. Initial program 99.7%

            \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
            2. sub-negN/A

              \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right) \]
            3. distribute-rgt-inN/A

              \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \color{blue}{\left(\mathsf{neg}\left(1\right)\right) \cdot m} \]
            4. metadata-evalN/A

              \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + -1 \cdot m \]
            5. neg-mul-1N/A

              \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m + \left(\mathsf{neg}\left(m\right)\right) \]
            6. unsub-negN/A

              \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot m - \color{blue}{m} \]
            7. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v} \cdot m\right), \color{blue}{m}\right) \]
            8. *-commutativeN/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{v} \cdot m\right), m\right) \]
            9. associate-/l*N/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot \frac{m}{v}\right) \cdot m\right), m\right) \]
            10. associate-*l*N/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
            11. *-lowering-*.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(1 - m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
            12. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \left(\frac{m}{v} \cdot m\right)\right), m\right) \]
            13. *-lowering-*.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\left(\frac{m}{v}\right), m\right)\right), m\right) \]
            14. /-lowering-/.f6499.7%

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, m\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(m, v\right), m\right)\right), m\right) \]
          4. Applied egg-rr99.7%

            \[\leadsto \color{blue}{\left(1 - m\right) \cdot \left(\frac{m}{v} \cdot m\right) - m} \]
          5. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\left(1 - m\right) \cdot \left(m \cdot \frac{m}{v}\right)\right), m\right) \]
            2. associate-*r*N/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{m}{v}\right), m\right) \]
            3. clear-numN/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\left(\left(1 - m\right) \cdot m\right) \cdot \frac{1}{\frac{v}{m}}\right), m\right) \]
            4. un-div-invN/A

              \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\left(1 - m\right) \cdot m}{\frac{v}{m}}\right), m\right) \]
            5. /-lowering-/.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(1 - m\right) \cdot m\right), \left(\frac{v}{m}\right)\right), m\right) \]
            6. *-commutativeN/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(m \cdot \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \left(1 - m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
            8. --lowering--.f64N/A

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \left(\frac{v}{m}\right)\right), m\right) \]
            9. /-lowering-/.f6499.8%

              \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(m, \mathsf{\_.f64}\left(1, m\right)\right), \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
          6. Applied egg-rr99.8%

            \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{m}}} - m \]
          7. Taylor expanded in m around 0

            \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\color{blue}{m}, \mathsf{/.f64}\left(v, m\right)\right), m\right) \]
          8. Step-by-step derivation
            1. Simplified97.7%

              \[\leadsto \frac{\color{blue}{m}}{\frac{v}{m}} - m \]

            if 1 < m

            1. Initial program 99.9%

              \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
            2. Add Preprocessing
            3. Taylor expanded in m around 0

              \[\leadsto \color{blue}{-1 \cdot m} \]
            4. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \mathsf{neg}\left(m\right) \]
              2. neg-sub0N/A

                \[\leadsto 0 - \color{blue}{m} \]
              3. --lowering--.f645.7%

                \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
            5. Simplified5.7%

              \[\leadsto \color{blue}{0 - m} \]
            6. Step-by-step derivation
              1. sub0-negN/A

                \[\leadsto \mathsf{neg}\left(m\right) \]
              2. neg-lowering-neg.f645.7%

                \[\leadsto \mathsf{neg.f64}\left(m\right) \]
            7. Applied egg-rr5.7%

              \[\leadsto \color{blue}{-m} \]
            8. Step-by-step derivation
              1. +-lft-identityN/A

                \[\leadsto \mathsf{neg}\left(\left(0 + m\right)\right) \]
              2. flip-+N/A

                \[\leadsto \mathsf{neg}\left(\frac{0 \cdot 0 - m \cdot m}{0 - m}\right) \]
              3. metadata-evalN/A

                \[\leadsto \mathsf{neg}\left(\frac{0 - m \cdot m}{0 - m}\right) \]
              4. neg-sub0N/A

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(m \cdot m\right)}{0 - m}\right) \]
              5. neg-sub0N/A

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(m \cdot m\right)}{\mathsf{neg}\left(m\right)}\right) \]
              6. distribute-frac-negN/A

                \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(m \cdot m\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(m\right)}} \]
              7. div-invN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(m \cdot m\right)\right)\right)\right) \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(m\right)}} \]
              8. remove-double-negN/A

                \[\leadsto \left(m \cdot m\right) \cdot \frac{\color{blue}{1}}{\mathsf{neg}\left(m\right)} \]
              9. neg-sub0N/A

                \[\leadsto \left(m \cdot m\right) \cdot \frac{1}{0 - \color{blue}{m}} \]
              10. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\left(m \cdot m\right), \color{blue}{\left(\frac{1}{0 - m}\right)}\right) \]
              11. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\color{blue}{1}}{0 - m}\right)\right) \]
              12. metadata-evalN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{0} - m}\right)\right) \]
              13. neg-sub0N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(m\right)}\right)\right) \]
              14. frac-2negN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{-1}{\color{blue}{m}}\right)\right) \]
              15. /-lowering-/.f6456.8%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \mathsf{/.f64}\left(-1, \color{blue}{m}\right)\right) \]
            9. Applied egg-rr56.8%

              \[\leadsto \color{blue}{\left(m \cdot m\right) \cdot \frac{-1}{m}} \]
          9. Recombined 2 regimes into one program.
          10. Add Preprocessing

          Alternative 9: 74.9% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\ \end{array} \end{array} \]
          (FPCore (m v)
           :precision binary64
           (if (<= m 1.0) (* m (+ (/ m v) -1.0)) (* (* m m) (/ -1.0 m))))
          double code(double m, double v) {
          	double tmp;
          	if (m <= 1.0) {
          		tmp = m * ((m / v) + -1.0);
          	} else {
          		tmp = (m * m) * (-1.0 / m);
          	}
          	return tmp;
          }
          
          real(8) function code(m, v)
              real(8), intent (in) :: m
              real(8), intent (in) :: v
              real(8) :: tmp
              if (m <= 1.0d0) then
                  tmp = m * ((m / v) + (-1.0d0))
              else
                  tmp = (m * m) * ((-1.0d0) / m)
              end if
              code = tmp
          end function
          
          public static double code(double m, double v) {
          	double tmp;
          	if (m <= 1.0) {
          		tmp = m * ((m / v) + -1.0);
          	} else {
          		tmp = (m * m) * (-1.0 / m);
          	}
          	return tmp;
          }
          
          def code(m, v):
          	tmp = 0
          	if m <= 1.0:
          		tmp = m * ((m / v) + -1.0)
          	else:
          		tmp = (m * m) * (-1.0 / m)
          	return tmp
          
          function code(m, v)
          	tmp = 0.0
          	if (m <= 1.0)
          		tmp = Float64(m * Float64(Float64(m / v) + -1.0));
          	else
          		tmp = Float64(Float64(m * m) * Float64(-1.0 / m));
          	end
          	return tmp
          end
          
          function tmp_2 = code(m, v)
          	tmp = 0.0;
          	if (m <= 1.0)
          		tmp = m * ((m / v) + -1.0);
          	else
          		tmp = (m * m) * (-1.0 / m);
          	end
          	tmp_2 = tmp;
          end
          
          code[m_, v_] := If[LessEqual[m, 1.0], N[(m * N[(N[(m / v), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(m * m), $MachinePrecision] * N[(-1.0 / m), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;m \leq 1:\\
          \;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if m < 1

            1. Initial program 99.7%

              \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
            2. Add Preprocessing
            3. Taylor expanded in m around 0

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{m}{v}\right)}, 1\right), m\right) \]
            4. Step-by-step derivation
              1. /-lowering-/.f6497.7%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(m, v\right), 1\right), m\right) \]
            5. Simplified97.7%

              \[\leadsto \left(\color{blue}{\frac{m}{v}} - 1\right) \cdot m \]

            if 1 < m

            1. Initial program 99.9%

              \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
            2. Add Preprocessing
            3. Taylor expanded in m around 0

              \[\leadsto \color{blue}{-1 \cdot m} \]
            4. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto \mathsf{neg}\left(m\right) \]
              2. neg-sub0N/A

                \[\leadsto 0 - \color{blue}{m} \]
              3. --lowering--.f645.7%

                \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
            5. Simplified5.7%

              \[\leadsto \color{blue}{0 - m} \]
            6. Step-by-step derivation
              1. sub0-negN/A

                \[\leadsto \mathsf{neg}\left(m\right) \]
              2. neg-lowering-neg.f645.7%

                \[\leadsto \mathsf{neg.f64}\left(m\right) \]
            7. Applied egg-rr5.7%

              \[\leadsto \color{blue}{-m} \]
            8. Step-by-step derivation
              1. +-lft-identityN/A

                \[\leadsto \mathsf{neg}\left(\left(0 + m\right)\right) \]
              2. flip-+N/A

                \[\leadsto \mathsf{neg}\left(\frac{0 \cdot 0 - m \cdot m}{0 - m}\right) \]
              3. metadata-evalN/A

                \[\leadsto \mathsf{neg}\left(\frac{0 - m \cdot m}{0 - m}\right) \]
              4. neg-sub0N/A

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(m \cdot m\right)}{0 - m}\right) \]
              5. neg-sub0N/A

                \[\leadsto \mathsf{neg}\left(\frac{\mathsf{neg}\left(m \cdot m\right)}{\mathsf{neg}\left(m\right)}\right) \]
              6. distribute-frac-negN/A

                \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(m \cdot m\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(m\right)}} \]
              7. div-invN/A

                \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(m \cdot m\right)\right)\right)\right) \cdot \color{blue}{\frac{1}{\mathsf{neg}\left(m\right)}} \]
              8. remove-double-negN/A

                \[\leadsto \left(m \cdot m\right) \cdot \frac{\color{blue}{1}}{\mathsf{neg}\left(m\right)} \]
              9. neg-sub0N/A

                \[\leadsto \left(m \cdot m\right) \cdot \frac{1}{0 - \color{blue}{m}} \]
              10. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\left(m \cdot m\right), \color{blue}{\left(\frac{1}{0 - m}\right)}\right) \]
              11. *-lowering-*.f64N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\color{blue}{1}}{0 - m}\right)\right) \]
              12. metadata-evalN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\color{blue}{0} - m}\right)\right) \]
              13. neg-sub0N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(m\right)}\right)\right) \]
              14. frac-2negN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \left(\frac{-1}{\color{blue}{m}}\right)\right) \]
              15. /-lowering-/.f6456.8%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \mathsf{/.f64}\left(-1, \color{blue}{m}\right)\right) \]
            9. Applied egg-rr56.8%

              \[\leadsto \color{blue}{\left(m \cdot m\right) \cdot \frac{-1}{m}} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification78.2%

            \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(m \cdot m\right) \cdot \frac{-1}{m}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 10: 99.8% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ m \cdot \left(\frac{m}{\frac{v}{1 - m}} + -1\right) \end{array} \]
          (FPCore (m v) :precision binary64 (* m (+ (/ m (/ v (- 1.0 m))) -1.0)))
          double code(double m, double v) {
          	return m * ((m / (v / (1.0 - m))) + -1.0);
          }
          
          real(8) function code(m, v)
              real(8), intent (in) :: m
              real(8), intent (in) :: v
              code = m * ((m / (v / (1.0d0 - m))) + (-1.0d0))
          end function
          
          public static double code(double m, double v) {
          	return m * ((m / (v / (1.0 - m))) + -1.0);
          }
          
          def code(m, v):
          	return m * ((m / (v / (1.0 - m))) + -1.0)
          
          function code(m, v)
          	return Float64(m * Float64(Float64(m / Float64(v / Float64(1.0 - m))) + -1.0))
          end
          
          function tmp = code(m, v)
          	tmp = m * ((m / (v / (1.0 - m))) + -1.0);
          end
          
          code[m_, v_] := N[(m * N[(N[(m / N[(v / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          m \cdot \left(\frac{m}{\frac{v}{1 - m}} + -1\right)
          \end{array}
          
          Derivation
          1. Initial program 99.8%

            \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. --lowering--.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(\frac{m \cdot \left(1 - m\right)}{v}\right), 1\right), m\right) \]
            2. associate-/l*N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), 1\right), m\right) \]
            3. clear-numN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(m \cdot \frac{1}{\frac{v}{1 - m}}\right), 1\right), m\right) \]
            4. un-div-invN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(\frac{m}{\frac{v}{1 - m}}\right), 1\right), m\right) \]
            5. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(m, \left(\frac{v}{1 - m}\right)\right), 1\right), m\right) \]
            6. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(m, \mathsf{/.f64}\left(v, \left(1 - m\right)\right)\right), 1\right), m\right) \]
            7. --lowering--.f6499.8%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(m, \mathsf{/.f64}\left(v, \mathsf{\_.f64}\left(1, m\right)\right)\right), 1\right), m\right) \]
          4. Applied egg-rr99.8%

            \[\leadsto \color{blue}{\left(\frac{m}{\frac{v}{1 - m}} - 1\right)} \cdot m \]
          5. Final simplification99.8%

            \[\leadsto m \cdot \left(\frac{m}{\frac{v}{1 - m}} + -1\right) \]
          6. Add Preprocessing

          Alternative 11: 99.8% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ m \cdot \left(m \cdot \frac{1 - m}{v} + -1\right) \end{array} \]
          (FPCore (m v) :precision binary64 (* m (+ (* m (/ (- 1.0 m) v)) -1.0)))
          double code(double m, double v) {
          	return m * ((m * ((1.0 - m) / v)) + -1.0);
          }
          
          real(8) function code(m, v)
              real(8), intent (in) :: m
              real(8), intent (in) :: v
              code = m * ((m * ((1.0d0 - m) / v)) + (-1.0d0))
          end function
          
          public static double code(double m, double v) {
          	return m * ((m * ((1.0 - m) / v)) + -1.0);
          }
          
          def code(m, v):
          	return m * ((m * ((1.0 - m) / v)) + -1.0)
          
          function code(m, v)
          	return Float64(m * Float64(Float64(m * Float64(Float64(1.0 - m) / v)) + -1.0))
          end
          
          function tmp = code(m, v)
          	tmp = m * ((m * ((1.0 - m) / v)) + -1.0);
          end
          
          code[m_, v_] := N[(m * N[(N[(m * N[(N[(1.0 - m), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          m \cdot \left(m \cdot \frac{1 - m}{v} + -1\right)
          \end{array}
          
          Derivation
          1. Initial program 99.8%

            \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. associate-/l*N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(m \cdot \frac{1 - m}{v}\right), 1\right), m\right) \]
            2. *-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\left(\frac{1 - m}{v} \cdot m\right), 1\right), m\right) \]
            3. *-lowering-*.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(\frac{1 - m}{v}\right), m\right), 1\right), m\right) \]
            4. /-lowering-/.f64N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - m\right), v\right), m\right), 1\right), m\right) \]
            5. --lowering--.f6499.7%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, m\right), v\right), m\right), 1\right), m\right) \]
          4. Applied egg-rr99.7%

            \[\leadsto \left(\color{blue}{\frac{1 - m}{v} \cdot m} - 1\right) \cdot m \]
          5. Final simplification99.7%

            \[\leadsto m \cdot \left(m \cdot \frac{1 - m}{v} + -1\right) \]
          6. Add Preprocessing

          Alternative 12: 27.0% accurate, 3.7× speedup?

          \[\begin{array}{l} \\ 0 - m \end{array} \]
          (FPCore (m v) :precision binary64 (- 0.0 m))
          double code(double m, double v) {
          	return 0.0 - m;
          }
          
          real(8) function code(m, v)
              real(8), intent (in) :: m
              real(8), intent (in) :: v
              code = 0.0d0 - m
          end function
          
          public static double code(double m, double v) {
          	return 0.0 - m;
          }
          
          def code(m, v):
          	return 0.0 - m
          
          function code(m, v)
          	return Float64(0.0 - m)
          end
          
          function tmp = code(m, v)
          	tmp = 0.0 - m;
          end
          
          code[m_, v_] := N[(0.0 - m), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          0 - m
          \end{array}
          
          Derivation
          1. Initial program 99.8%

            \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
          2. Add Preprocessing
          3. Taylor expanded in m around 0

            \[\leadsto \color{blue}{-1 \cdot m} \]
          4. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(m\right) \]
            2. neg-sub0N/A

              \[\leadsto 0 - \color{blue}{m} \]
            3. --lowering--.f6429.2%

              \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{m}\right) \]
          5. Simplified29.2%

            \[\leadsto \color{blue}{0 - m} \]
          6. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto \mathsf{neg}\left(m\right) \]
            2. neg-lowering-neg.f6429.2%

              \[\leadsto \mathsf{neg.f64}\left(m\right) \]
          7. Applied egg-rr29.2%

            \[\leadsto \color{blue}{-m} \]
          8. Final simplification29.2%

            \[\leadsto 0 - m \]
          9. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2024150 
          (FPCore (m v)
            :name "a parameter of renormalized beta distribution"
            :precision binary64
            :pre (and (and (< 0.0 m) (< 0.0 v)) (< v 0.25))
            (* (- (/ (* m (- 1.0 m)) v) 1.0) m))