a parameter of renormalized beta distribution

Percentage Accurate: 99.8% → 99.4%
Time: 6.1s
Alternatives: 10
Speedup: N/A×

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 10 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.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1.05 \cdot 10^{-39}:\\ \;\;\;\;m \cdot \frac{m}{v} - m\\ \mathbf{else}:\\ \;\;\;\;\frac{m}{\frac{\frac{v}{m}}{1 - m}}\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 1.05e-39) (- (* m (/ m v)) m) (/ m (/ (/ v m) (- 1.0 m)))))
double code(double m, double v) {
	double tmp;
	if (m <= 1.05e-39) {
		tmp = (m * (m / v)) - m;
	} else {
		tmp = m / ((v / 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.05d-39) then
        tmp = (m * (m / v)) - m
    else
        tmp = m / ((v / m) / (1.0d0 - m))
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 1.05e-39) {
		tmp = (m * (m / v)) - m;
	} else {
		tmp = m / ((v / m) / (1.0 - m));
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 1.05e-39:
		tmp = (m * (m / v)) - m
	else:
		tmp = m / ((v / m) / (1.0 - m))
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 1.05e-39)
		tmp = Float64(Float64(m * Float64(m / v)) - m);
	else
		tmp = Float64(m / Float64(Float64(v / m) / Float64(1.0 - m)));
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 1.05e-39)
		tmp = (m * (m / v)) - m;
	else
		tmp = m / ((v / m) / (1.0 - m));
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 1.05e-39], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m / N[(N[(v / m), $MachinePrecision] / N[(1.0 - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 99.7%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{m \cdot \frac{1 - m}{v}} + \left(-1\right)\right) \]
      4. fma-def99.7%

        \[\leadsto m \cdot \color{blue}{\mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
      5. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
    4. Step-by-step derivation
      1. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
      2. fma-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v} - 1\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} - 1\right) \]
      4. *-commutative99.7%

        \[\leadsto m \cdot \left(\frac{\color{blue}{\left(1 - m\right) \cdot m}}{v} - 1\right) \]
      5. associate-/l*99.7%

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

      \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{\frac{v}{m}} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{\frac{v}{m}} + \left(-1\right)\right)} \]
      2. metadata-eval99.7%

        \[\leadsto m \cdot \left(\frac{1 - m}{\frac{v}{m}} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto \color{blue}{\frac{1 - m}{\frac{v}{m}} \cdot m + -1 \cdot m} \]
      4. associate-/r/99.7%

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

        \[\leadsto \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \cdot m + -1 \cdot m \]
      6. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} + -1 \cdot m \]
      7. *-commutative99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} + -1 \cdot m \]
      8. associate-/r/99.7%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} + -1 \cdot m \]
      9. div-inv99.7%

        \[\leadsto m \cdot \color{blue}{\left(\left(1 - m\right) \cdot \frac{1}{\frac{v}{m}}\right)} + -1 \cdot m \]
      10. clear-num99.7%

        \[\leadsto m \cdot \left(\left(1 - m\right) \cdot \color{blue}{\frac{m}{v}}\right) + -1 \cdot m \]
      11. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + -1 \cdot m \]
      12. neg-mul-199.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v} + \color{blue}{\left(-m\right)} \]
    7. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{\frac{{m}^{2}}{v}} + \left(-m\right) \]
    9. Step-by-step derivation
      1. unpow286.2%

        \[\leadsto \frac{\color{blue}{m \cdot m}}{v} + \left(-m\right) \]
      2. associate-*r/99.7%

        \[\leadsto \color{blue}{m \cdot \frac{m}{v}} + \left(-m\right) \]
    10. Simplified99.7%

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

    if 1.04999999999999997e-39 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/99.8%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.8%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow299.9%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*99.8%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/99.9%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. clear-num99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1}{\frac{\frac{v}{m}}{1 - m}}} \]
      4. un-div-inv99.9%

        \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    8. Applied egg-rr99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 1.05 \cdot 10^{-39}:\\ \;\;\;\;m \cdot \frac{m}{v} - m\\ \mathbf{else}:\\ \;\;\;\;\frac{m}{\frac{\frac{v}{m}}{1 - m}}\\ \end{array} \]

Alternative 2: 74.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{m}{\frac{v}{m}}\\
\mathbf{if}\;m \leq 2.25 \cdot 10^{-187}:\\
\;\;\;\;-m\\

\mathbf{elif}\;m \leq 2.2 \cdot 10^{-88}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;m \leq 3.2 \cdot 10^{-85}:\\
\;\;\;\;-m\\

\mathbf{elif}\;m \leq 1:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if m < 2.2499999999999999e-187 or 2.20000000000000005e-88 < m < 3.20000000000000027e-85

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/80.6%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/100.0%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative100.0%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{-1 \cdot m} \]
    5. Step-by-step derivation
      1. neg-mul-179.7%

        \[\leadsto \color{blue}{-m} \]
    6. Simplified79.7%

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

    if 2.2499999999999999e-187 < m < 2.20000000000000005e-88 or 3.20000000000000027e-85 < m < 1

    1. Initial program 99.6%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.6%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.6%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/91.6%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.6%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.6%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.5%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.5%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.5%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.5%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.6%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.6%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.6%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow263.1%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*63.1%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/70.2%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/70.1%

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

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative70.1%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/70.1%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. clear-num70.1%

        \[\leadsto m \cdot \color{blue}{\frac{1}{\frac{\frac{v}{m}}{1 - m}}} \]
      4. un-div-inv70.4%

        \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    8. Applied egg-rr70.4%

      \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    9. Taylor expanded in m around 0 69.8%

      \[\leadsto \frac{m}{\color{blue}{\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. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow299.9%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*99.9%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/99.9%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. clear-num99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1}{\frac{\frac{v}{m}}{1 - m}}} \]
      4. un-div-inv99.9%

        \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    8. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    9. Taylor expanded in m around 0 0.1%

      \[\leadsto \frac{m}{\color{blue}{\frac{v}{m}}} \]
    10. Step-by-step derivation
      1. associate-/r/0.1%

        \[\leadsto \color{blue}{\frac{m}{v} \cdot m} \]
      2. associate-*l/0.1%

        \[\leadsto \color{blue}{\frac{m \cdot m}{v}} \]
      3. add-sqr-sqrt0.1%

        \[\leadsto \frac{m \cdot m}{\color{blue}{\sqrt{v} \cdot \sqrt{v}}} \]
      4. sqrt-unprod0.1%

        \[\leadsto \frac{m \cdot m}{\color{blue}{\sqrt{v \cdot v}}} \]
      5. sqr-neg0.1%

        \[\leadsto \frac{m \cdot m}{\sqrt{\color{blue}{\left(-v\right) \cdot \left(-v\right)}}} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{m \cdot m}{\color{blue}{\sqrt{-v} \cdot \sqrt{-v}}} \]
      7. add-sqr-sqrt81.8%

        \[\leadsto \frac{m \cdot m}{\color{blue}{-v}} \]
      8. neg-mul-181.8%

        \[\leadsto \frac{m \cdot m}{\color{blue}{-1 \cdot v}} \]
      9. times-frac81.8%

        \[\leadsto \color{blue}{\frac{m}{-1} \cdot \frac{m}{v}} \]
    11. Applied egg-rr81.8%

      \[\leadsto \color{blue}{\frac{m}{-1} \cdot \frac{m}{v}} \]
    12. Step-by-step derivation
      1. *-commutative81.8%

        \[\leadsto \color{blue}{\frac{m}{v} \cdot \frac{m}{-1}} \]
      2. times-frac81.8%

        \[\leadsto \color{blue}{\frac{m \cdot m}{v \cdot -1}} \]
      3. associate-/l*81.8%

        \[\leadsto \color{blue}{\frac{m}{\frac{v \cdot -1}{m}}} \]
      4. *-commutative81.8%

        \[\leadsto \frac{m}{\frac{\color{blue}{-1 \cdot v}}{m}} \]
      5. neg-mul-181.8%

        \[\leadsto \frac{m}{\frac{\color{blue}{-v}}{m}} \]
    13. Simplified81.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq 2.25 \cdot 10^{-187}:\\ \;\;\;\;-m\\ \mathbf{elif}\;m \leq 2.2 \cdot 10^{-88}:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{elif}\;m \leq 3.2 \cdot 10^{-85}:\\ \;\;\;\;-m\\ \mathbf{elif}\;m \leq 1:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{m}{\frac{-v}{m}}\\ \end{array} \]

Alternative 3: 36.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 5.1 \cdot 10^{-223} \lor \neg \left(v \leq 2.3 \cdot 10^{-173}\right) \land v \leq 2.6 \cdot 10^{-145}:\\ \;\;\;\;m \cdot \frac{m}{v}\\ \mathbf{else}:\\ \;\;\;\;-m\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (or (<= v 5.1e-223) (and (not (<= v 2.3e-173)) (<= v 2.6e-145)))
   (* m (/ m v))
   (- m)))
double code(double m, double v) {
	double tmp;
	if ((v <= 5.1e-223) || (!(v <= 2.3e-173) && (v <= 2.6e-145))) {
		tmp = m * (m / v);
	} else {
		tmp = -m;
	}
	return tmp;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if ((v <= 5.1d-223) .or. (.not. (v <= 2.3d-173)) .and. (v <= 2.6d-145)) then
        tmp = m * (m / v)
    else
        tmp = -m
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if ((v <= 5.1e-223) || (!(v <= 2.3e-173) && (v <= 2.6e-145))) {
		tmp = m * (m / v);
	} else {
		tmp = -m;
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if (v <= 5.1e-223) or (not (v <= 2.3e-173) and (v <= 2.6e-145)):
		tmp = m * (m / v)
	else:
		tmp = -m
	return tmp
function code(m, v)
	tmp = 0.0
	if ((v <= 5.1e-223) || (!(v <= 2.3e-173) && (v <= 2.6e-145)))
		tmp = Float64(m * Float64(m / v));
	else
		tmp = Float64(-m);
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if ((v <= 5.1e-223) || (~((v <= 2.3e-173)) && (v <= 2.6e-145)))
		tmp = m * (m / v);
	else
		tmp = -m;
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[Or[LessEqual[v, 5.1e-223], And[N[Not[LessEqual[v, 2.3e-173]], $MachinePrecision], LessEqual[v, 2.6e-145]]], N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq 5.1 \cdot 10^{-223} \lor \neg \left(v \leq 2.3 \cdot 10^{-173}\right) \land v \leq 2.6 \cdot 10^{-145}:\\
\;\;\;\;m \cdot \frac{m}{v}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 5.09999999999999974e-223 or 2.29999999999999988e-173 < v < 2.6e-145

    1. Initial program 99.6%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.6%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.6%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/83.8%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.7%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.7%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.6%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.6%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.6%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.6%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow278.5%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*78.5%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/90.6%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/90.7%

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

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

      \[\leadsto \color{blue}{\frac{{m}^{2}}{v}} \]
    8. Step-by-step derivation
      1. unpow233.4%

        \[\leadsto \frac{\color{blue}{m \cdot m}}{v} \]
      2. associate-*r/45.6%

        \[\leadsto \color{blue}{m \cdot \frac{m}{v}} \]
    9. Simplified45.6%

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

    if 5.09999999999999974e-223 < v < 2.29999999999999988e-173 or 2.6e-145 < v

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/98.8%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.8%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{-1 \cdot m} \]
    5. Step-by-step derivation
      1. neg-mul-143.5%

        \[\leadsto \color{blue}{-m} \]
    6. Simplified43.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 5.1 \cdot 10^{-223} \lor \neg \left(v \leq 2.3 \cdot 10^{-173}\right) \land v \leq 2.6 \cdot 10^{-145}:\\ \;\;\;\;m \cdot \frac{m}{v}\\ \mathbf{else}:\\ \;\;\;\;-m\\ \end{array} \]

Alternative 4: 36.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 2.45 \cdot 10^{-223} \lor \neg \left(v \leq 8.2 \cdot 10^{-174}\right) \land v \leq 7 \cdot 10^{-146}:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;-m\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (or (<= v 2.45e-223) (and (not (<= v 8.2e-174)) (<= v 7e-146)))
   (/ m (/ v m))
   (- m)))
double code(double m, double v) {
	double tmp;
	if ((v <= 2.45e-223) || (!(v <= 8.2e-174) && (v <= 7e-146))) {
		tmp = m / (v / m);
	} else {
		tmp = -m;
	}
	return tmp;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if ((v <= 2.45d-223) .or. (.not. (v <= 8.2d-174)) .and. (v <= 7d-146)) then
        tmp = m / (v / m)
    else
        tmp = -m
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if ((v <= 2.45e-223) || (!(v <= 8.2e-174) && (v <= 7e-146))) {
		tmp = m / (v / m);
	} else {
		tmp = -m;
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if (v <= 2.45e-223) or (not (v <= 8.2e-174) and (v <= 7e-146)):
		tmp = m / (v / m)
	else:
		tmp = -m
	return tmp
function code(m, v)
	tmp = 0.0
	if ((v <= 2.45e-223) || (!(v <= 8.2e-174) && (v <= 7e-146)))
		tmp = Float64(m / Float64(v / m));
	else
		tmp = Float64(-m);
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if ((v <= 2.45e-223) || (~((v <= 8.2e-174)) && (v <= 7e-146)))
		tmp = m / (v / m);
	else
		tmp = -m;
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[Or[LessEqual[v, 2.45e-223], And[N[Not[LessEqual[v, 8.2e-174]], $MachinePrecision], LessEqual[v, 7e-146]]], N[(m / N[(v / m), $MachinePrecision]), $MachinePrecision], (-m)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq 2.45 \cdot 10^{-223} \lor \neg \left(v \leq 8.2 \cdot 10^{-174}\right) \land v \leq 7 \cdot 10^{-146}:\\
\;\;\;\;\frac{m}{\frac{v}{m}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 2.45e-223 or 8.2000000000000002e-174 < v < 7.0000000000000003e-146

    1. Initial program 99.6%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.6%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.6%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/83.8%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.7%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.7%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.6%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.6%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.6%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.6%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.6%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow278.5%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*78.5%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/90.6%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/90.7%

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

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative90.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/90.6%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. clear-num90.6%

        \[\leadsto m \cdot \color{blue}{\frac{1}{\frac{\frac{v}{m}}{1 - m}}} \]
      4. un-div-inv90.8%

        \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    8. Applied egg-rr90.8%

      \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    9. Taylor expanded in m around 0 45.7%

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

    if 2.45e-223 < v < 8.2000000000000002e-174 or 7.0000000000000003e-146 < v

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/98.8%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.8%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{-1 \cdot m} \]
    5. Step-by-step derivation
      1. neg-mul-143.5%

        \[\leadsto \color{blue}{-m} \]
    6. Simplified43.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 2.45 \cdot 10^{-223} \lor \neg \left(v \leq 8.2 \cdot 10^{-174}\right) \land v \leq 7 \cdot 10^{-146}:\\ \;\;\;\;\frac{m}{\frac{v}{m}}\\ \mathbf{else}:\\ \;\;\;\;-m\\ \end{array} \]

Alternative 5: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 10^{-30}:\\ \;\;\;\;m \cdot \frac{m}{v} - m\\ \mathbf{else}:\\ \;\;\;\;m \cdot \left(m \cdot \frac{1 - m}{v}\right)\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 1e-30) (- (* m (/ m v)) m) (* m (* m (/ (- 1.0 m) v)))))
double code(double m, double v) {
	double tmp;
	if (m <= 1e-30) {
		tmp = (m * (m / v)) - 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 <= 1d-30) then
        tmp = (m * (m / v)) - 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 <= 1e-30) {
		tmp = (m * (m / v)) - m;
	} else {
		tmp = m * (m * ((1.0 - m) / v));
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 1e-30:
		tmp = (m * (m / v)) - m
	else:
		tmp = m * (m * ((1.0 - m) / v))
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 1e-30)
		tmp = Float64(Float64(m * Float64(m / v)) - 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 <= 1e-30)
		tmp = (m * (m / v)) - m;
	else
		tmp = m * (m * ((1.0 - m) / v));
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 1e-30], N[(N[(m * N[(m / v), $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 10^{-30}:\\
\;\;\;\;m \cdot \frac{m}{v} - 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 < 1e-30

    1. Initial program 99.7%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{m \cdot \frac{1 - m}{v}} + \left(-1\right)\right) \]
      4. fma-def99.7%

        \[\leadsto m \cdot \color{blue}{\mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
      5. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
    4. Step-by-step derivation
      1. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
      2. fma-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v} - 1\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} - 1\right) \]
      4. *-commutative99.7%

        \[\leadsto m \cdot \left(\frac{\color{blue}{\left(1 - m\right) \cdot m}}{v} - 1\right) \]
      5. associate-/l*99.7%

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

      \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{\frac{v}{m}} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{\frac{v}{m}} + \left(-1\right)\right)} \]
      2. metadata-eval99.7%

        \[\leadsto m \cdot \left(\frac{1 - m}{\frac{v}{m}} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto \color{blue}{\frac{1 - m}{\frac{v}{m}} \cdot m + -1 \cdot m} \]
      4. associate-/r/99.7%

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

        \[\leadsto \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \cdot m + -1 \cdot m \]
      6. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} + -1 \cdot m \]
      7. *-commutative99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} + -1 \cdot m \]
      8. associate-/r/99.7%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} + -1 \cdot m \]
      9. div-inv99.7%

        \[\leadsto m \cdot \color{blue}{\left(\left(1 - m\right) \cdot \frac{1}{\frac{v}{m}}\right)} + -1 \cdot m \]
      10. clear-num99.7%

        \[\leadsto m \cdot \left(\left(1 - m\right) \cdot \color{blue}{\frac{m}{v}}\right) + -1 \cdot m \]
      11. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + -1 \cdot m \]
      12. neg-mul-199.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v} + \color{blue}{\left(-m\right)} \]
    7. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{\frac{{m}^{2}}{v}} + \left(-m\right) \]
    9. Step-by-step derivation
      1. unpow286.5%

        \[\leadsto \frac{\color{blue}{m \cdot m}}{v} + \left(-m\right) \]
      2. associate-*r/99.7%

        \[\leadsto \color{blue}{m \cdot \frac{m}{v}} + \left(-m\right) \]
    10. Simplified99.7%

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

    if 1e-30 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow299.9%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*99.9%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/99.9%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \]
    6. Simplified99.9%

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

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

Alternative 6: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + -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(Float64(m / 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[(N[(m / v), $MachinePrecision] * N[(1.0 - m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
  2. Step-by-step derivation
    1. *-commutative99.8%

      \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
    2. sub-neg99.8%

      \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
    3. distribute-lft-in99.8%

      \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
    4. *-commutative99.8%

      \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
    5. associate-*l/92.8%

      \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
    6. associate-*r/99.8%

      \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
    7. *-lft-identity99.8%

      \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
    8. associate-*l/99.8%

      \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
    9. associate-*r*99.8%

      \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
    10. *-commutative99.8%

      \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
    11. distribute-rgt-out99.8%

      \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
    12. associate-*r/99.8%

      \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
    13. associate-/l*99.8%

      \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
    14. /-rgt-identity99.8%

      \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
    15. associate-*l/99.8%

      \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
    16. metadata-eval99.8%

      \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
  3. Simplified99.8%

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

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

Alternative 7: 97.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;m \cdot \left(m \cdot \frac{-m}{v}\right)\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 1.0) (* m (+ (/ m v) -1.0)) (* m (* m (/ (- m) v)))))
double code(double m, double v) {
	double tmp;
	if (m <= 1.0) {
		tmp = m * ((m / v) + -1.0);
	} else {
		tmp = m * (m * (-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 <= 1.0d0) then
        tmp = m * ((m / v) + (-1.0d0))
    else
        tmp = m * (m * (-m / v))
    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 * (-m / v));
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 1.0:
		tmp = m * ((m / v) + -1.0)
	else:
		tmp = m * (m * (-m / v))
	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(m * Float64(m * Float64(Float64(-m) / v)));
	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 * (-m / v));
	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[(m * N[(m * N[((-m) / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\

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


\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. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{m \cdot \frac{1 - m}{v}} + \left(-1\right)\right) \]
      4. fma-def99.7%

        \[\leadsto m \cdot \color{blue}{\mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
      5. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
    4. Taylor expanded in m around 0 99.3%

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

    if 1 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow299.9%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*99.9%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/99.9%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. div-sub39.0%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1}{\frac{v}{m}} - \frac{m}{\frac{v}{m}}\right)} \]
      4. frac-sub41.0%

        \[\leadsto m \cdot \color{blue}{\frac{1 \cdot \frac{v}{m} - \frac{v}{m} \cdot m}{\frac{v}{m} \cdot \frac{v}{m}}} \]
      5. *-un-lft-identity41.0%

        \[\leadsto m \cdot \frac{\color{blue}{\frac{v}{m}} - \frac{v}{m} \cdot m}{\frac{v}{m} \cdot \frac{v}{m}} \]
      6. pow241.0%

        \[\leadsto m \cdot \frac{\frac{v}{m} - \frac{v}{m} \cdot m}{\color{blue}{{\left(\frac{v}{m}\right)}^{2}}} \]
    8. Applied egg-rr41.0%

      \[\leadsto m \cdot \color{blue}{\frac{\frac{v}{m} - \frac{v}{m} \cdot m}{{\left(\frac{v}{m}\right)}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*l/95.8%

        \[\leadsto m \cdot \frac{\frac{v}{m} - \color{blue}{\frac{v \cdot m}{m}}}{{\left(\frac{v}{m}\right)}^{2}} \]
      2. associate-/l*95.8%

        \[\leadsto m \cdot \frac{\frac{v}{m} - \color{blue}{\frac{v}{\frac{m}{m}}}}{{\left(\frac{v}{m}\right)}^{2}} \]
    10. Simplified95.8%

      \[\leadsto m \cdot \color{blue}{\frac{\frac{v}{m} - \frac{v}{\frac{m}{m}}}{{\left(\frac{v}{m}\right)}^{2}}} \]
    11. Taylor expanded in m around inf 97.7%

      \[\leadsto m \cdot \color{blue}{\left(-1 \cdot \frac{{m}^{2}}{v}\right)} \]
    12. Step-by-step derivation
      1. *-commutative97.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{{m}^{2}}{v} \cdot -1\right)} \]
      2. unpow297.7%

        \[\leadsto m \cdot \left(\frac{\color{blue}{m \cdot m}}{v} \cdot -1\right) \]
      3. associate-*r/97.7%

        \[\leadsto m \cdot \left(\color{blue}{\left(m \cdot \frac{m}{v}\right)} \cdot -1\right) \]
      4. associate-*l*97.7%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \left(\frac{m}{v} \cdot -1\right)\right)} \]
      5. associate-*l/97.7%

        \[\leadsto m \cdot \left(m \cdot \color{blue}{\frac{m \cdot -1}{v}}\right) \]
      6. *-commutative97.7%

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

        \[\leadsto m \cdot \left(m \cdot \frac{\color{blue}{-m}}{v}\right) \]
    13. Simplified97.7%

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

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

Alternative 8: 97.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;m \cdot \frac{m}{v} - m\\ \mathbf{else}:\\ \;\;\;\;m \cdot \left(m \cdot \frac{-m}{v}\right)\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 1.0) (- (* m (/ m v)) m) (* m (* m (/ (- m) v)))))
double code(double m, double v) {
	double tmp;
	if (m <= 1.0) {
		tmp = (m * (m / v)) - m;
	} else {
		tmp = m * (m * (-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 <= 1.0d0) then
        tmp = (m * (m / v)) - m
    else
        tmp = m * (m * (-m / v))
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 1.0) {
		tmp = (m * (m / v)) - m;
	} else {
		tmp = m * (m * (-m / v));
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 1.0:
		tmp = (m * (m / v)) - m
	else:
		tmp = m * (m * (-m / v))
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 1.0)
		tmp = Float64(Float64(m * Float64(m / v)) - m);
	else
		tmp = Float64(m * Float64(m * Float64(Float64(-m) / v)));
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 1.0)
		tmp = (m * (m / v)) - m;
	else
		tmp = m * (m * (-m / v));
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 1.0], N[(N[(m * N[(m / v), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision], N[(m * N[(m * N[((-m) / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \frac{m}{v} - m\\

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


\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. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{m \cdot \frac{1 - m}{v}} + \left(-1\right)\right) \]
      4. fma-def99.7%

        \[\leadsto m \cdot \color{blue}{\mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
      5. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
    4. Step-by-step derivation
      1. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
      2. fma-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v} - 1\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{v}} - 1\right) \]
      4. *-commutative99.7%

        \[\leadsto m \cdot \left(\frac{\color{blue}{\left(1 - m\right) \cdot m}}{v} - 1\right) \]
      5. associate-/l*99.7%

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

      \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{\frac{v}{m}} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{\frac{v}{m}} + \left(-1\right)\right)} \]
      2. metadata-eval99.7%

        \[\leadsto m \cdot \left(\frac{1 - m}{\frac{v}{m}} + \color{blue}{-1}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto \color{blue}{\frac{1 - m}{\frac{v}{m}} \cdot m + -1 \cdot m} \]
      4. associate-/r/99.7%

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

        \[\leadsto \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \cdot m + -1 \cdot m \]
      6. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} + -1 \cdot m \]
      7. *-commutative99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} + -1 \cdot m \]
      8. associate-/r/99.7%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} + -1 \cdot m \]
      9. div-inv99.7%

        \[\leadsto m \cdot \color{blue}{\left(\left(1 - m\right) \cdot \frac{1}{\frac{v}{m}}\right)} + -1 \cdot m \]
      10. clear-num99.7%

        \[\leadsto m \cdot \left(\left(1 - m\right) \cdot \color{blue}{\frac{m}{v}}\right) + -1 \cdot m \]
      11. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + -1 \cdot m \]
      12. neg-mul-199.7%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v} + \color{blue}{\left(-m\right)} \]
    7. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{\frac{{m}^{2}}{v}} + \left(-m\right) \]
    9. Step-by-step derivation
      1. unpow286.7%

        \[\leadsto \frac{\color{blue}{m \cdot m}}{v} + \left(-m\right) \]
      2. associate-*r/99.4%

        \[\leadsto \color{blue}{m \cdot \frac{m}{v}} + \left(-m\right) \]
    10. Simplified99.4%

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

    if 1 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow299.9%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*99.9%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/99.9%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. div-sub39.0%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1}{\frac{v}{m}} - \frac{m}{\frac{v}{m}}\right)} \]
      4. frac-sub41.0%

        \[\leadsto m \cdot \color{blue}{\frac{1 \cdot \frac{v}{m} - \frac{v}{m} \cdot m}{\frac{v}{m} \cdot \frac{v}{m}}} \]
      5. *-un-lft-identity41.0%

        \[\leadsto m \cdot \frac{\color{blue}{\frac{v}{m}} - \frac{v}{m} \cdot m}{\frac{v}{m} \cdot \frac{v}{m}} \]
      6. pow241.0%

        \[\leadsto m \cdot \frac{\frac{v}{m} - \frac{v}{m} \cdot m}{\color{blue}{{\left(\frac{v}{m}\right)}^{2}}} \]
    8. Applied egg-rr41.0%

      \[\leadsto m \cdot \color{blue}{\frac{\frac{v}{m} - \frac{v}{m} \cdot m}{{\left(\frac{v}{m}\right)}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*l/95.8%

        \[\leadsto m \cdot \frac{\frac{v}{m} - \color{blue}{\frac{v \cdot m}{m}}}{{\left(\frac{v}{m}\right)}^{2}} \]
      2. associate-/l*95.8%

        \[\leadsto m \cdot \frac{\frac{v}{m} - \color{blue}{\frac{v}{\frac{m}{m}}}}{{\left(\frac{v}{m}\right)}^{2}} \]
    10. Simplified95.8%

      \[\leadsto m \cdot \color{blue}{\frac{\frac{v}{m} - \frac{v}{\frac{m}{m}}}{{\left(\frac{v}{m}\right)}^{2}}} \]
    11. Taylor expanded in m around inf 97.7%

      \[\leadsto m \cdot \color{blue}{\left(-1 \cdot \frac{{m}^{2}}{v}\right)} \]
    12. Step-by-step derivation
      1. *-commutative97.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{{m}^{2}}{v} \cdot -1\right)} \]
      2. unpow297.7%

        \[\leadsto m \cdot \left(\frac{\color{blue}{m \cdot m}}{v} \cdot -1\right) \]
      3. associate-*r/97.7%

        \[\leadsto m \cdot \left(\color{blue}{\left(m \cdot \frac{m}{v}\right)} \cdot -1\right) \]
      4. associate-*l*97.7%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \left(\frac{m}{v} \cdot -1\right)\right)} \]
      5. associate-*l/97.7%

        \[\leadsto m \cdot \left(m \cdot \color{blue}{\frac{m \cdot -1}{v}}\right) \]
      6. *-commutative97.7%

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

        \[\leadsto m \cdot \left(m \cdot \frac{\color{blue}{-m}}{v}\right) \]
    13. Simplified97.7%

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

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

Alternative 9: 87.8% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq 1:\\ \;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{m}{\frac{-v}{m}}\\ \end{array} \end{array} \]
(FPCore (m v)
 :precision binary64
 (if (<= m 1.0) (* m (+ (/ m v) -1.0)) (/ m (/ (- v) m))))
double code(double m, double v) {
	double tmp;
	if (m <= 1.0) {
		tmp = m * ((m / v) + -1.0);
	} else {
		tmp = m / (-v / 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 / (-v / 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 / (-v / m);
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 1.0:
		tmp = m * ((m / v) + -1.0)
	else:
		tmp = m / (-v / 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(m / Float64(Float64(-v) / 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 / (-v / 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[(m / N[((-v) / m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq 1:\\
\;\;\;\;m \cdot \left(\frac{m}{v} + -1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{m}{\frac{-v}{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. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.7%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. associate-*r/99.7%

        \[\leadsto m \cdot \left(\color{blue}{m \cdot \frac{1 - m}{v}} + \left(-1\right)\right) \]
      4. fma-def99.7%

        \[\leadsto m \cdot \color{blue}{\mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
      5. metadata-eval99.7%

        \[\leadsto m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, \color{blue}{-1}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{m \cdot \mathsf{fma}\left(m, \frac{1 - m}{v}, -1\right)} \]
    4. Taylor expanded in m around 0 99.3%

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

    if 1 < m

    1. Initial program 99.9%

      \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
    2. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
      2. sub-neg99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
      3. distribute-lft-in99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
      5. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
      6. associate-*r/99.9%

        \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
      7. *-lft-identity99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
      8. associate-*l/99.9%

        \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
      9. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
      10. *-commutative99.9%

        \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
      11. distribute-rgt-out99.9%

        \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
      12. associate-*r/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
      13. associate-/l*99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
      14. /-rgt-identity99.9%

        \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
      15. associate-*l/99.9%

        \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
      16. metadata-eval99.9%

        \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{{m}^{2} \cdot \left(1 - m\right)}{v}} \]
    5. Step-by-step derivation
      1. unpow299.9%

        \[\leadsto \frac{\color{blue}{\left(m \cdot m\right)} \cdot \left(1 - m\right)}{v} \]
      2. associate-*r*99.9%

        \[\leadsto \frac{\color{blue}{m \cdot \left(m \cdot \left(1 - m\right)\right)}}{v} \]
      3. associate-*r/99.9%

        \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v}} \]
      4. associate-*r/99.9%

        \[\leadsto m \cdot \color{blue}{\left(m \cdot \frac{1 - m}{v}\right)} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{1 - m}{v}\right)} \]
    7. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto m \cdot \color{blue}{\left(\frac{1 - m}{v} \cdot m\right)} \]
      2. associate-/r/99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1 - m}{\frac{v}{m}}} \]
      3. clear-num99.9%

        \[\leadsto m \cdot \color{blue}{\frac{1}{\frac{\frac{v}{m}}{1 - m}}} \]
      4. un-div-inv99.9%

        \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    8. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{m}{\frac{\frac{v}{m}}{1 - m}}} \]
    9. Taylor expanded in m around 0 0.1%

      \[\leadsto \frac{m}{\color{blue}{\frac{v}{m}}} \]
    10. Step-by-step derivation
      1. associate-/r/0.1%

        \[\leadsto \color{blue}{\frac{m}{v} \cdot m} \]
      2. associate-*l/0.1%

        \[\leadsto \color{blue}{\frac{m \cdot m}{v}} \]
      3. add-sqr-sqrt0.1%

        \[\leadsto \frac{m \cdot m}{\color{blue}{\sqrt{v} \cdot \sqrt{v}}} \]
      4. sqrt-unprod0.1%

        \[\leadsto \frac{m \cdot m}{\color{blue}{\sqrt{v \cdot v}}} \]
      5. sqr-neg0.1%

        \[\leadsto \frac{m \cdot m}{\sqrt{\color{blue}{\left(-v\right) \cdot \left(-v\right)}}} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{m \cdot m}{\color{blue}{\sqrt{-v} \cdot \sqrt{-v}}} \]
      7. add-sqr-sqrt81.8%

        \[\leadsto \frac{m \cdot m}{\color{blue}{-v}} \]
      8. neg-mul-181.8%

        \[\leadsto \frac{m \cdot m}{\color{blue}{-1 \cdot v}} \]
      9. times-frac81.8%

        \[\leadsto \color{blue}{\frac{m}{-1} \cdot \frac{m}{v}} \]
    11. Applied egg-rr81.8%

      \[\leadsto \color{blue}{\frac{m}{-1} \cdot \frac{m}{v}} \]
    12. Step-by-step derivation
      1. *-commutative81.8%

        \[\leadsto \color{blue}{\frac{m}{v} \cdot \frac{m}{-1}} \]
      2. times-frac81.8%

        \[\leadsto \color{blue}{\frac{m \cdot m}{v \cdot -1}} \]
      3. associate-/l*81.8%

        \[\leadsto \color{blue}{\frac{m}{\frac{v \cdot -1}{m}}} \]
      4. *-commutative81.8%

        \[\leadsto \frac{m}{\frac{\color{blue}{-1 \cdot v}}{m}} \]
      5. neg-mul-181.8%

        \[\leadsto \frac{m}{\frac{\color{blue}{-v}}{m}} \]
    13. Simplified81.8%

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

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

Alternative 10: 27.9% accurate, 5.5× speedup?

\[\begin{array}{l} \\ -m \end{array} \]
(FPCore (m v) :precision binary64 (- m))
double code(double m, double v) {
	return -m;
}
real(8) function code(m, v)
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    code = -m
end function
public static double code(double m, double v) {
	return -m;
}
def code(m, v):
	return -m
function code(m, v)
	return Float64(-m)
end
function tmp = code(m, v)
	tmp = -m;
end
code[m_, v_] := (-m)
\begin{array}{l}

\\
-m
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot m \]
  2. Step-by-step derivation
    1. *-commutative99.8%

      \[\leadsto \color{blue}{m \cdot \left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right)} \]
    2. sub-neg99.8%

      \[\leadsto m \cdot \color{blue}{\left(\frac{m \cdot \left(1 - m\right)}{v} + \left(-1\right)\right)} \]
    3. distribute-lft-in99.8%

      \[\leadsto \color{blue}{m \cdot \frac{m \cdot \left(1 - m\right)}{v} + m \cdot \left(-1\right)} \]
    4. *-commutative99.8%

      \[\leadsto \color{blue}{\frac{m \cdot \left(1 - m\right)}{v} \cdot m} + m \cdot \left(-1\right) \]
    5. associate-*l/92.8%

      \[\leadsto \color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot m}{v}} + m \cdot \left(-1\right) \]
    6. associate-*r/99.8%

      \[\leadsto \color{blue}{\left(m \cdot \left(1 - m\right)\right) \cdot \frac{m}{v}} + m \cdot \left(-1\right) \]
    7. *-lft-identity99.8%

      \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \frac{\color{blue}{1 \cdot m}}{v} + m \cdot \left(-1\right) \]
    8. associate-*l/99.8%

      \[\leadsto \left(m \cdot \left(1 - m\right)\right) \cdot \color{blue}{\left(\frac{1}{v} \cdot m\right)} + m \cdot \left(-1\right) \]
    9. associate-*r*99.8%

      \[\leadsto \color{blue}{\left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m} + m \cdot \left(-1\right) \]
    10. *-commutative99.8%

      \[\leadsto \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v}\right) \cdot m + \color{blue}{\left(-1\right) \cdot m} \]
    11. distribute-rgt-out99.8%

      \[\leadsto \color{blue}{m \cdot \left(\left(m \cdot \left(1 - m\right)\right) \cdot \frac{1}{v} + \left(-1\right)\right)} \]
    12. associate-*r/99.8%

      \[\leadsto m \cdot \left(\color{blue}{\frac{\left(m \cdot \left(1 - m\right)\right) \cdot 1}{v}} + \left(-1\right)\right) \]
    13. associate-/l*99.8%

      \[\leadsto m \cdot \left(\color{blue}{\frac{m \cdot \left(1 - m\right)}{\frac{v}{1}}} + \left(-1\right)\right) \]
    14. /-rgt-identity99.8%

      \[\leadsto m \cdot \left(\frac{m \cdot \left(1 - m\right)}{\color{blue}{v}} + \left(-1\right)\right) \]
    15. associate-*l/99.8%

      \[\leadsto m \cdot \left(\color{blue}{\frac{m}{v} \cdot \left(1 - m\right)} + \left(-1\right)\right) \]
    16. metadata-eval99.8%

      \[\leadsto m \cdot \left(\frac{m}{v} \cdot \left(1 - m\right) + \color{blue}{-1}\right) \]
  3. Simplified99.8%

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

    \[\leadsto \color{blue}{-1 \cdot m} \]
  5. Step-by-step derivation
    1. neg-mul-130.0%

      \[\leadsto \color{blue}{-m} \]
  6. Simplified30.0%

    \[\leadsto \color{blue}{-m} \]
  7. Final simplification30.0%

    \[\leadsto -m \]

Reproduce

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