b parameter of renormalized beta distribution

Percentage Accurate: 99.9% → 99.9%
Time: 6.1s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right) \]
  2. Final simplification99.9%

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

Alternative 2: 97.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \left(1 - m\right) \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 \left(1 - m\right) \]
    2. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - \left(1 - m\right)\right)} \cdot \left(m \cdot m\right)}{v} \]
      7. associate--r-98.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{m}^{2}}{v} + \frac{{m}^{3}}{v}} \]
    11. Step-by-step derivation
      1. +-commutative19.2%

        \[\leadsto \color{blue}{\frac{{m}^{3}}{v} + -1 \cdot \frac{{m}^{2}}{v}} \]
      2. cube-mult19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{m \cdot \left(m \cdot \frac{m + -1}{v}\right)} \]
    13. Step-by-step derivation
      1. associate-*r/98.6%

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

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

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

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

Alternative 3: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 4: 97.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < m

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - \left(1 - m\right)\right)} \cdot \left(m \cdot m\right)}{v} \]
      7. associate--r-98.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{m}^{2}}{v} + \frac{{m}^{3}}{v}} \]
    11. Step-by-step derivation
      1. +-commutative19.2%

        \[\leadsto \color{blue}{\frac{{m}^{3}}{v} + -1 \cdot \frac{{m}^{2}}{v}} \]
      2. cube-mult19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \left(1 - m\right) \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 \left(1 - m\right) \]
    2. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - \left(1 - m\right)\right)} \cdot \left(m \cdot m\right)}{v} \]
      7. associate--r-98.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{m}^{2}}{v} + \frac{{m}^{3}}{v}} \]
    11. Step-by-step derivation
      1. +-commutative19.2%

        \[\leadsto \color{blue}{\frac{{m}^{3}}{v} + -1 \cdot \frac{{m}^{2}}{v}} \]
      2. cube-mult19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.9% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \left(1 - m\right) \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 \left(1 - m\right) \]
    2. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - \left(1 - m\right)\right)} \cdot \left(m \cdot m\right)}{v} \]
      7. associate--r-98.6%

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

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

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

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

Alternative 7: 97.9% accurate, 1.4× speedup?

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

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

\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 < 2.5

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5 < m

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - \left(1 - m\right)\right)} \cdot \left(m \cdot m\right)}{v} \]
      7. associate--r-98.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{m}^{2}}{v} + \frac{{m}^{3}}{v}} \]
    11. Step-by-step derivation
      1. +-commutative19.2%

        \[\leadsto \color{blue}{\frac{{m}^{3}}{v} + -1 \cdot \frac{{m}^{2}}{v}} \]
      2. cube-mult19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto m \cdot \color{blue}{\frac{{m}^{2}}{v}} \]
    14. Step-by-step derivation
      1. unpow298.6%

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

        \[\leadsto m \cdot \color{blue}{\left(\frac{m}{v} \cdot m\right)} \]
    15. Simplified98.6%

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

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

Alternative 8: 97.9% accurate, 1.4× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < 2.7000000000000002

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.7000000000000002 < m

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(0 - \left(1 - m\right)\right)} \cdot \left(m \cdot m\right)}{v} \]
      7. associate--r-98.6%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{{m}^{2}}{v} + \frac{{m}^{3}}{v}} \]
    11. Step-by-step derivation
      1. +-commutative19.2%

        \[\leadsto \color{blue}{\frac{{m}^{3}}{v} + -1 \cdot \frac{{m}^{2}}{v}} \]
      2. cube-mult19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto m \cdot \color{blue}{\frac{{m}^{2}}{v}} \]
    14. Step-by-step derivation
      1. unpow298.6%

        \[\leadsto m \cdot \frac{\color{blue}{m \cdot m}}{v} \]
    15. Simplified98.6%

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

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

Alternative 9: 75.3% accurate, 2.6× speedup?

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

\\
\frac{m}{v} + -1
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto -1 + \color{blue}{\frac{m}{v}} \]
  8. Final simplification78.0%

    \[\leadsto \frac{m}{v} + -1 \]

Alternative 10: 26.5% accurate, 4.3× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(1 - m\right)} \]
  5. Step-by-step derivation
    1. neg-mul-122.2%

      \[\leadsto \color{blue}{-\left(1 - m\right)} \]
    2. neg-sub022.2%

      \[\leadsto \color{blue}{0 - \left(1 - m\right)} \]
    3. associate--r-22.2%

      \[\leadsto \color{blue}{\left(0 - 1\right) + m} \]
    4. metadata-eval22.2%

      \[\leadsto \color{blue}{-1} + m \]
  6. Simplified22.2%

    \[\leadsto \color{blue}{-1 + m} \]
  7. Final simplification22.2%

    \[\leadsto m + -1 \]

Alternative 11: 24.1% accurate, 13.0× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification19.5%

    \[\leadsto -1 \]

Reproduce

?
herbie shell --seed 2023193 
(FPCore (m v)
  :name "b 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) (- 1.0 m)))