b parameter of renormalized beta distribution

Percentage Accurate: 99.9% → 99.9%
Time: 1.5s
Alternatives: 7
Speedup: N/A×

Specification

?
\[\left(0 < m \land 0 < v\right) \land v < \frac{1}{4}\]
\[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right) \]
(FPCore (m v)
  :precision binary64
  (* (- (/ (* m (- 1 m)) v) 1) (- 1 m)))
double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(m, v)
use fmin_fmax_functions
    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 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1), $MachinePrecision] * N[(1 - m), $MachinePrecision]), $MachinePrecision]
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)

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 7 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?

\[\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right) \]
(FPCore (m v)
  :precision binary64
  (* (- (/ (* m (- 1 m)) v) 1) (- 1 m)))
double code(double m, double v) {
	return (((m * (1.0 - m)) / v) - 1.0) * (1.0 - m);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(m, v)
use fmin_fmax_functions
    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 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1), $MachinePrecision] * N[(1 - m), $MachinePrecision]), $MachinePrecision]
\left(\frac{m \cdot \left(1 - m\right)}{v} - 1\right) \cdot \left(1 - m\right)

Alternative 1: 99.9% accurate, 1.0× speedup?

\[\frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
(FPCore (m v)
  :precision binary64
  (- (/ (* m (+ 1 (* m (- m 2)))) v) 1))
double code(double m, double v) {
	return ((m * (1.0 + (m * (m - 2.0)))) / v) - 1.0;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

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

    \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
  3. Step-by-step derivation
    1. lower--.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
    2. lower-*.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    3. lower-+.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    4. lower-+.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    5. lower-*.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    6. lower--.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    7. lower-/.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    8. lower-*.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    9. lower-/.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    10. lower-/.f6499.8%

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
  4. Applied rewrites99.8%

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

    \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
  6. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    2. lower-*.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    3. lower-+.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    4. lower-*.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    5. lower--.f6499.9%

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
  7. Applied rewrites99.9%

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

Alternative 2: 99.9% accurate, 1.0× speedup?

\[\left(1 - \left(2 - m\right) \cdot m\right) \cdot \frac{m}{v} - 1 \]
(FPCore (m v)
  :precision binary64
  (- (* (- 1 (* (- 2 m) m)) (/ m v)) 1))
double code(double m, double v) {
	return ((1.0 - ((2.0 - m) * m)) * (m / v)) - 1.0;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(m, v)
use fmin_fmax_functions
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    code = ((1.0d0 - ((2.0d0 - m) * m)) * (m / v)) - 1.0d0
end function
public static double code(double m, double v) {
	return ((1.0 - ((2.0 - m) * m)) * (m / v)) - 1.0;
}
def code(m, v):
	return ((1.0 - ((2.0 - m) * m)) * (m / v)) - 1.0
function code(m, v)
	return Float64(Float64(Float64(1.0 - Float64(Float64(2.0 - m) * m)) * Float64(m / v)) - 1.0)
end
function tmp = code(m, v)
	tmp = ((1.0 - ((2.0 - m) * m)) * (m / v)) - 1.0;
end
code[m_, v_] := N[(N[(N[(1 - N[(N[(2 - m), $MachinePrecision] * m), $MachinePrecision]), $MachinePrecision] * N[(m / v), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]
\left(1 - \left(2 - m\right) \cdot m\right) \cdot \frac{m}{v} - 1
Derivation
  1. Initial program 99.9%

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

    \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
  3. Step-by-step derivation
    1. lower--.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
    2. lower-*.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    3. lower-+.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    4. lower-+.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    5. lower-*.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    6. lower--.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    7. lower-/.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    8. lower-*.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    9. lower-/.f64N/A

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    10. lower-/.f6499.8%

      \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
  4. Applied rewrites99.8%

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

    \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
  6. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    2. lower-*.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    3. lower-+.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    4. lower-*.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    5. lower--.f6499.9%

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
  7. Applied rewrites99.9%

    \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
  8. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    2. lift-*.f64N/A

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    3. *-commutativeN/A

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

      \[\leadsto \left(1 + m \cdot \left(m - 2\right)\right) \cdot \frac{m}{v} - 1 \]
    5. lift-/.f64N/A

      \[\leadsto \left(1 + m \cdot \left(m - 2\right)\right) \cdot \frac{m}{v} - 1 \]
    6. lower-*.f6499.9%

      \[\leadsto \left(1 + m \cdot \left(m - 2\right)\right) \cdot \frac{m}{v} - 1 \]
    7. lift-+.f64N/A

      \[\leadsto \left(1 + m \cdot \left(m - 2\right)\right) \cdot \frac{m}{v} - 1 \]
    8. add-flipN/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(m \cdot \left(m - 2\right)\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    9. lower--.f64N/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(m \cdot \left(m - 2\right)\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    10. lift-*.f64N/A

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

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(m - 2\right) \cdot m\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    12. lift--.f64N/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(m - 2\right) \cdot m\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    13. sub-flipN/A

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

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(m + -2\right) \cdot m\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    15. +-commutativeN/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(-2 + m\right) \cdot m\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    16. lift-+.f64N/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(-2 + m\right) \cdot m\right)\right)\right) \cdot \frac{m}{v} - 1 \]
    17. distribute-lft-neg-inN/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(-2 + m\right)\right)\right) \cdot m\right) \cdot \frac{m}{v} - 1 \]
    18. lower-*.f64N/A

      \[\leadsto \left(1 - \left(\mathsf{neg}\left(\left(-2 + m\right)\right)\right) \cdot m\right) \cdot \frac{m}{v} - 1 \]
    19. lift-+.f64N/A

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

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

      \[\leadsto \left(1 - \left(2 + \left(\mathsf{neg}\left(m\right)\right)\right) \cdot m\right) \cdot \frac{m}{v} - 1 \]
    22. sub-flipN/A

      \[\leadsto \left(1 - \left(2 - m\right) \cdot m\right) \cdot \frac{m}{v} - 1 \]
    23. lower--.f6499.9%

      \[\leadsto \left(1 - \left(2 - m\right) \cdot m\right) \cdot \frac{m}{v} - 1 \]
  9. Applied rewrites99.9%

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

Alternative 3: 98.5% accurate, 0.9× speedup?

\[\begin{array}{l} \mathbf{if}\;m \leq \frac{5404319552844595}{9007199254740992}:\\ \;\;\;\;\frac{m \cdot \left(1 + m \cdot -2\right)}{v} - 1\\ \mathbf{else}:\\ \;\;\;\;\frac{m \cdot \left(1 - m\right)}{v} \cdot \left(-1 \cdot m\right)\\ \end{array} \]
(FPCore (m v)
  :precision binary64
  (if (<= m 5404319552844595/9007199254740992)
  (- (/ (* m (+ 1 (* m -2))) v) 1)
  (* (/ (* m (- 1 m)) v) (* -1 m))))
double code(double m, double v) {
	double tmp;
	if (m <= 0.6) {
		tmp = ((m * (1.0 + (m * -2.0))) / v) - 1.0;
	} else {
		tmp = ((m * (1.0 - m)) / v) * (-1.0 * m);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(m, v)
use fmin_fmax_functions
    real(8), intent (in) :: m
    real(8), intent (in) :: v
    real(8) :: tmp
    if (m <= 0.6d0) then
        tmp = ((m * (1.0d0 + (m * (-2.0d0)))) / v) - 1.0d0
    else
        tmp = ((m * (1.0d0 - m)) / v) * ((-1.0d0) * m)
    end if
    code = tmp
end function
public static double code(double m, double v) {
	double tmp;
	if (m <= 0.6) {
		tmp = ((m * (1.0 + (m * -2.0))) / v) - 1.0;
	} else {
		tmp = ((m * (1.0 - m)) / v) * (-1.0 * m);
	}
	return tmp;
}
def code(m, v):
	tmp = 0
	if m <= 0.6:
		tmp = ((m * (1.0 + (m * -2.0))) / v) - 1.0
	else:
		tmp = ((m * (1.0 - m)) / v) * (-1.0 * m)
	return tmp
function code(m, v)
	tmp = 0.0
	if (m <= 0.6)
		tmp = Float64(Float64(Float64(m * Float64(1.0 + Float64(m * -2.0))) / v) - 1.0);
	else
		tmp = Float64(Float64(Float64(m * Float64(1.0 - m)) / v) * Float64(-1.0 * m));
	end
	return tmp
end
function tmp_2 = code(m, v)
	tmp = 0.0;
	if (m <= 0.6)
		tmp = ((m * (1.0 + (m * -2.0))) / v) - 1.0;
	else
		tmp = ((m * (1.0 - m)) / v) * (-1.0 * m);
	end
	tmp_2 = tmp;
end
code[m_, v_] := If[LessEqual[m, 5404319552844595/9007199254740992], N[(N[(N[(m * N[(1 + N[(m * -2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] - 1), $MachinePrecision], N[(N[(N[(m * N[(1 - m), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision] * N[(-1 * m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq \frac{5404319552844595}{9007199254740992}:\\
\;\;\;\;\frac{m \cdot \left(1 + m \cdot -2\right)}{v} - 1\\

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


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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
    3. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
      2. lower-*.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      3. lower-+.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      4. lower-+.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      5. lower-*.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      6. lower--.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      7. lower-/.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      8. lower-*.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      9. lower-/.f64N/A

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      10. lower-/.f6499.8%

        \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
    4. Applied rewrites99.8%

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

      \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
      2. lower-*.f64N/A

        \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
      3. lower-+.f64N/A

        \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
      4. lower-*.f64N/A

        \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
      5. lower--.f6499.9%

        \[\leadsto \frac{m \cdot \left(1 + m \cdot \left(m - 2\right)\right)}{v} - 1 \]
    7. Applied rewrites99.9%

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

      \[\leadsto \frac{m \cdot \left(1 + m \cdot -2\right)}{v} - 1 \]
    9. Step-by-step derivation
      1. Applied rewrites49.9%

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

      if 0.59999999999999998 < m

      1. Initial program 99.9%

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

        \[\leadsto \color{blue}{-1} \cdot \left(1 - m\right) \]
      3. Step-by-step derivation
        1. Applied rewrites27.2%

          \[\leadsto \color{blue}{-1} \cdot \left(1 - m\right) \]
        2. Taylor expanded in m around inf

          \[\leadsto -1 \cdot \color{blue}{\left(-1 \cdot m\right)} \]
        3. Step-by-step derivation
          1. lower-*.f644.5%

            \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{m}\right) \]
        4. Applied rewrites4.5%

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

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

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

            \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot \left(-1 \cdot m\right) \]
          3. lower--.f6449.9%

            \[\leadsto \frac{m \cdot \left(1 - m\right)}{v} \cdot \left(-1 \cdot m\right) \]
        7. Applied rewrites49.9%

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

      Alternative 4: 82.1% accurate, 0.9× speedup?

      \[\begin{array}{l} \mathbf{if}\;m \leq 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160:\\ \;\;\;\;\left(m - \frac{-m}{v}\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\frac{m \cdot m - 1 \cdot 1}{m + 1}\\ \end{array} \]
      (FPCore (m v)
        :precision binary64
        (if (<=
           m
           13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160)
        (- (- m (/ (- m) v)) 1)
        (/ (- (* m m) (* 1 1)) (+ m 1))))
      double code(double m, double v) {
      	double tmp;
      	if (m <= 1.35e+154) {
      		tmp = (m - (-m / v)) - 1.0;
      	} else {
      		tmp = ((m * m) - (1.0 * 1.0)) / (m + 1.0);
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(m, v)
      use fmin_fmax_functions
          real(8), intent (in) :: m
          real(8), intent (in) :: v
          real(8) :: tmp
          if (m <= 1.35d+154) then
              tmp = (m - (-m / v)) - 1.0d0
          else
              tmp = ((m * m) - (1.0d0 * 1.0d0)) / (m + 1.0d0)
          end if
          code = tmp
      end function
      
      public static double code(double m, double v) {
      	double tmp;
      	if (m <= 1.35e+154) {
      		tmp = (m - (-m / v)) - 1.0;
      	} else {
      		tmp = ((m * m) - (1.0 * 1.0)) / (m + 1.0);
      	}
      	return tmp;
      }
      
      def code(m, v):
      	tmp = 0
      	if m <= 1.35e+154:
      		tmp = (m - (-m / v)) - 1.0
      	else:
      		tmp = ((m * m) - (1.0 * 1.0)) / (m + 1.0)
      	return tmp
      
      function code(m, v)
      	tmp = 0.0
      	if (m <= 1.35e+154)
      		tmp = Float64(Float64(m - Float64(Float64(-m) / v)) - 1.0);
      	else
      		tmp = Float64(Float64(Float64(m * m) - Float64(1.0 * 1.0)) / Float64(m + 1.0));
      	end
      	return tmp
      end
      
      function tmp_2 = code(m, v)
      	tmp = 0.0;
      	if (m <= 1.35e+154)
      		tmp = (m - (-m / v)) - 1.0;
      	else
      		tmp = ((m * m) - (1.0 * 1.0)) / (m + 1.0);
      	end
      	tmp_2 = tmp;
      end
      
      code[m_, v_] := If[LessEqual[m, 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160], N[(N[(m - N[((-m) / v), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision], N[(N[(N[(m * m), $MachinePrecision] - N[(1 * 1), $MachinePrecision]), $MachinePrecision] / N[(m + 1), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      \mathbf{if}\;m \leq 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160:\\
      \;\;\;\;\left(m - \frac{-m}{v}\right) - 1\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{m \cdot m - 1 \cdot 1}{m + 1}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if m < 1.35e154

        1. Initial program 99.9%

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

          \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
        3. Step-by-step derivation
          1. lower--.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
          2. lower-*.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          3. lower-+.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          4. lower-+.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          5. lower-*.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          6. lower--.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          7. lower-/.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          8. lower-*.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          9. lower-/.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          10. lower-/.f6499.8%

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        4. Applied rewrites99.8%

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

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          2. lift-+.f64N/A

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

            \[\leadsto \left(1 \cdot m + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right) \cdot m\right) - 1 \]
          4. fp-cancel-sign-sub-invN/A

            \[\leadsto \left(1 \cdot m - \left(\mathsf{neg}\left(\left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right)\right) \cdot m\right) - 1 \]
          5. *-lft-identityN/A

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

            \[\leadsto \left(m - \left(\mathsf{neg}\left(\left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right)\right) \cdot m\right) - 1 \]
          7. lower-*.f64N/A

            \[\leadsto \left(m - \left(\mathsf{neg}\left(\left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right)\right) \cdot m\right) - 1 \]
        6. Applied rewrites99.8%

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

          \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
        8. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
          2. lower-/.f6476.0%

            \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
        9. Applied rewrites76.0%

          \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
        10. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
          2. lift-/.f64N/A

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

            \[\leadsto \left(m - \frac{-1 \cdot m}{v}\right) - 1 \]
          4. mul-1-negN/A

            \[\leadsto \left(m - \frac{\mathsf{neg}\left(m\right)}{v}\right) - 1 \]
          5. lower-/.f64N/A

            \[\leadsto \left(m - \frac{\mathsf{neg}\left(m\right)}{v}\right) - 1 \]
          6. lower-neg.f6476.0%

            \[\leadsto \left(m - \frac{-m}{v}\right) - 1 \]
        11. Applied rewrites76.0%

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

        if 1.35e154 < m

        1. Initial program 99.9%

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

          \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
        3. Step-by-step derivation
          1. lower--.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
          2. lower-*.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          3. lower-+.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          4. lower-+.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          5. lower-*.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          6. lower--.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          7. lower-/.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          8. lower-*.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          9. lower-/.f64N/A

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
          10. lower-/.f6499.8%

            \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        4. Applied rewrites99.8%

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

          \[\leadsto m - \color{blue}{1} \]
        6. Step-by-step derivation
          1. lower--.f6427.2%

            \[\leadsto m - 1 \]
        7. Applied rewrites27.2%

          \[\leadsto m - \color{blue}{1} \]
        8. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto m - 1 \]
          2. flip--N/A

            \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + \color{blue}{1}} \]
          3. lower-unsound-/.f64N/A

            \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + \color{blue}{1}} \]
          4. lower-unsound--.f64N/A

            \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + 1} \]
          5. lower-unsound-*.f64N/A

            \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + 1} \]
          6. lower-unsound-*.f64N/A

            \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + 1} \]
          7. lower-unsound-+.f6450.7%

            \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + 1} \]
        9. Applied rewrites50.7%

          \[\leadsto \frac{m \cdot m - 1 \cdot 1}{m + \color{blue}{1}} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 5: 76.0% accurate, 1.6× speedup?

      \[\left(m - \frac{-m}{v}\right) - 1 \]
      (FPCore (m v)
        :precision binary64
        (- (- m (/ (- m) v)) 1))
      double code(double m, double v) {
      	return (m - (-m / v)) - 1.0;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(m, v)
      use fmin_fmax_functions
          real(8), intent (in) :: m
          real(8), intent (in) :: v
          code = (m - (-m / v)) - 1.0d0
      end function
      
      public static double code(double m, double v) {
      	return (m - (-m / v)) - 1.0;
      }
      
      def code(m, v):
      	return (m - (-m / v)) - 1.0
      
      function code(m, v)
      	return Float64(Float64(m - Float64(Float64(-m) / v)) - 1.0)
      end
      
      function tmp = code(m, v)
      	tmp = (m - (-m / v)) - 1.0;
      end
      
      code[m_, v_] := N[(N[(m - N[((-m) / v), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]
      
      \left(m - \frac{-m}{v}\right) - 1
      
      Derivation
      1. Initial program 99.9%

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

        \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
      3. Step-by-step derivation
        1. lower--.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
        2. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        3. lower-+.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        4. lower-+.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        5. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        6. lower--.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        7. lower-/.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        8. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        9. lower-/.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        10. lower-/.f6499.8%

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      4. Applied rewrites99.8%

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

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        2. lift-+.f64N/A

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

          \[\leadsto \left(1 \cdot m + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right) \cdot m\right) - 1 \]
        4. fp-cancel-sign-sub-invN/A

          \[\leadsto \left(1 \cdot m - \left(\mathsf{neg}\left(\left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right)\right) \cdot m\right) - 1 \]
        5. *-lft-identityN/A

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

          \[\leadsto \left(m - \left(\mathsf{neg}\left(\left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right)\right) \cdot m\right) - 1 \]
        7. lower-*.f64N/A

          \[\leadsto \left(m - \left(\mathsf{neg}\left(\left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right)\right) \cdot m\right) - 1 \]
      6. Applied rewrites99.8%

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

        \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
      8. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
        2. lower-/.f6476.0%

          \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
      9. Applied rewrites76.0%

        \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
      10. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \left(m - -1 \cdot \frac{m}{v}\right) - 1 \]
        2. lift-/.f64N/A

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

          \[\leadsto \left(m - \frac{-1 \cdot m}{v}\right) - 1 \]
        4. mul-1-negN/A

          \[\leadsto \left(m - \frac{\mathsf{neg}\left(m\right)}{v}\right) - 1 \]
        5. lower-/.f64N/A

          \[\leadsto \left(m - \frac{\mathsf{neg}\left(m\right)}{v}\right) - 1 \]
        6. lower-neg.f6476.0%

          \[\leadsto \left(m - \frac{-m}{v}\right) - 1 \]
      11. Applied rewrites76.0%

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

      Alternative 6: 27.2% accurate, 7.8× speedup?

      \[m - 1 \]
      (FPCore (m v)
        :precision binary64
        (- m 1))
      double code(double m, double v) {
      	return m - 1.0;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(m, v)
      use fmin_fmax_functions
          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), $MachinePrecision]
      
      m - 1
      
      Derivation
      1. Initial program 99.9%

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

        \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
      3. Step-by-step derivation
        1. lower--.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
        2. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        3. lower-+.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        4. lower-+.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        5. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        6. lower--.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        7. lower-/.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        8. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        9. lower-/.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        10. lower-/.f6499.8%

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      4. Applied rewrites99.8%

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

        \[\leadsto m - \color{blue}{1} \]
      6. Step-by-step derivation
        1. lower--.f6427.2%

          \[\leadsto m - 1 \]
      7. Applied rewrites27.2%

        \[\leadsto m - \color{blue}{1} \]
      8. Add Preprocessing

      Alternative 7: 24.7% accurate, 31.0× speedup?

      \[-1 \]
      (FPCore (m v)
        :precision binary64
        -1)
      double code(double m, double v) {
      	return -1.0;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(m, v)
      use fmin_fmax_functions
          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
      
      -1
      
      Derivation
      1. Initial program 99.9%

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

        \[\leadsto \color{blue}{m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1} \]
      3. Step-by-step derivation
        1. lower--.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - \color{blue}{1} \]
        2. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        3. lower-+.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        4. lower-+.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        5. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        6. lower--.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        7. lower-/.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        8. lower-*.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        9. lower-/.f64N/A

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
        10. lower-/.f6499.8%

          \[\leadsto m \cdot \left(1 + \left(m \cdot \left(\frac{m}{v} - 2 \cdot \frac{1}{v}\right) + \frac{1}{v}\right)\right) - 1 \]
      4. Applied rewrites99.8%

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

        \[\leadsto m - \color{blue}{1} \]
      6. Step-by-step derivation
        1. lower--.f6427.2%

          \[\leadsto m - 1 \]
      7. Applied rewrites27.2%

        \[\leadsto m - \color{blue}{1} \]
      8. Taylor expanded in m around 0

        \[\leadsto -1 \]
      9. Step-by-step derivation
        1. Applied rewrites24.7%

          \[\leadsto -1 \]
        2. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2025285 -o generate:evaluate
        (FPCore (m v)
          :name "b parameter of renormalized beta distribution"
          :precision binary64
          :pre (and (and (< 0 m) (< 0 v)) (< v 1/4))
          (* (- (/ (* m (- 1 m)) v) 1) (- 1 m)))