Trigonometry A

Percentage Accurate: 99.8% → 99.8%
Time: 3.3s
Alternatives: 11
Speedup: N/A×

Specification

?
\[0 \leq e \land e \leq 1\]
\[\begin{array}{l} \\ \frac{e \cdot \sin v}{1 + e \cdot \cos v} \end{array} \]
(FPCore (e v) :precision binary64 (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))
double code(double e, double v) {
	return (e * sin(v)) / (1.0 + (e * cos(v)));
}
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(e, v)
use fmin_fmax_functions
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = (e * sin(v)) / (1.0d0 + (e * cos(v)))
end function
public static double code(double e, double v) {
	return (e * Math.sin(v)) / (1.0 + (e * Math.cos(v)));
}
def code(e, v):
	return (e * math.sin(v)) / (1.0 + (e * math.cos(v)))
function code(e, v)
	return Float64(Float64(e * sin(v)) / Float64(1.0 + Float64(e * cos(v))))
end
function tmp = code(e, v)
	tmp = (e * sin(v)) / (1.0 + (e * cos(v)));
end
code[e_, v_] := N[(N[(e * N[Sin[v], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e \cdot \sin v}{1 + e \cdot \cos v}
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

\[\begin{array}{l} \\ \frac{e \cdot \sin v}{1 + e \cdot \cos v} \end{array} \]
(FPCore (e v) :precision binary64 (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))
double code(double e, double v) {
	return (e * sin(v)) / (1.0 + (e * cos(v)));
}
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(e, v)
use fmin_fmax_functions
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = (e * sin(v)) / (1.0d0 + (e * cos(v)))
end function
public static double code(double e, double v) {
	return (e * Math.sin(v)) / (1.0 + (e * Math.cos(v)));
}
def code(e, v):
	return (e * math.sin(v)) / (1.0 + (e * math.cos(v)))
function code(e, v)
	return Float64(Float64(e * sin(v)) / Float64(1.0 + Float64(e * cos(v))))
end
function tmp = code(e, v)
	tmp = (e * sin(v)) / (1.0 + (e * cos(v)));
end
code[e_, v_] := N[(N[(e * N[Sin[v], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(e * N[Cos[v], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{e \cdot \sin v}{1 + e \cdot \cos v}
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sin v \cdot \frac{e}{\mathsf{fma}\left(\cos v, e, 1\right)} \end{array} \]
(FPCore (e v) :precision binary64 (* (sin v) (/ e (fma (cos v) e 1.0))))
double code(double e, double v) {
	return sin(v) * (e / fma(cos(v), e, 1.0));
}
function code(e, v)
	return Float64(sin(v) * Float64(e / fma(cos(v), e, 1.0)))
end
code[e_, v_] := N[(N[Sin[v], $MachinePrecision] * N[(e / N[(N[Cos[v], $MachinePrecision] * e + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sin v \cdot \frac{e}{\mathsf{fma}\left(\cos v, e, 1\right)}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{e \cdot \sin v}}{1 + e \cdot \cos v} \]
    2. lift-sin.f64N/A

      \[\leadsto \frac{e \cdot \color{blue}{\sin v}}{1 + e \cdot \cos v} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{1 + e \cdot \cos v} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{1 + e \cdot \cos v} \]
    5. lift-sin.f6499.8

      \[\leadsto \frac{\color{blue}{\sin v} \cdot e}{1 + e \cdot \cos v} \]
    6. lift-+.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{1 + e \cdot \cos v}} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{1 + \color{blue}{e \cdot \cos v}} \]
    8. lift-cos.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{1 + e \cdot \color{blue}{\cos v}} \]
    9. +-commutativeN/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{e \cdot \cos v + 1}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\cos v \cdot e} + 1} \]
    11. lower-fma.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
    12. lift-cos.f6499.8

      \[\leadsto \frac{\sin v \cdot e}{\mathsf{fma}\left(\color{blue}{\cos v}, e, 1\right)} \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{\sin v \cdot e}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
  4. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sin v \cdot e}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{\mathsf{fma}\left(\cos v, e, 1\right)} \]
    3. lift-sin.f64N/A

      \[\leadsto \frac{\color{blue}{\sin v} \cdot e}{\mathsf{fma}\left(\cos v, e, 1\right)} \]
    4. lift-cos.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\mathsf{fma}\left(\color{blue}{\cos v}, e, 1\right)} \]
    5. lift-fma.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\cos v \cdot e + 1}} \]
    6. associate-/l*N/A

      \[\leadsto \color{blue}{\sin v \cdot \frac{e}{\cos v \cdot e + 1}} \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\sin v \cdot \frac{e}{\cos v \cdot e + 1}} \]
    8. lift-sin.f64N/A

      \[\leadsto \color{blue}{\sin v} \cdot \frac{e}{\cos v \cdot e + 1} \]
    9. lower-/.f64N/A

      \[\leadsto \sin v \cdot \color{blue}{\frac{e}{\cos v \cdot e + 1}} \]
    10. lift-fma.f64N/A

      \[\leadsto \sin v \cdot \frac{e}{\color{blue}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
    11. lift-cos.f6499.8

      \[\leadsto \sin v \cdot \frac{e}{\mathsf{fma}\left(\color{blue}{\cos v}, e, 1\right)} \]
  5. Applied rewrites99.8%

    \[\leadsto \color{blue}{\sin v \cdot \frac{e}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
  6. Add Preprocessing

Alternative 2: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\sin v}{\cos v + \frac{1}{e}} \end{array} \]
(FPCore (e v) :precision binary64 (/ (sin v) (+ (cos v) (/ 1.0 e))))
double code(double e, double v) {
	return sin(v) / (cos(v) + (1.0 / e));
}
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(e, v)
use fmin_fmax_functions
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = sin(v) / (cos(v) + (1.0d0 / e))
end function
public static double code(double e, double v) {
	return Math.sin(v) / (Math.cos(v) + (1.0 / e));
}
def code(e, v):
	return math.sin(v) / (math.cos(v) + (1.0 / e))
function code(e, v)
	return Float64(sin(v) / Float64(cos(v) + Float64(1.0 / e)))
end
function tmp = code(e, v)
	tmp = sin(v) / (cos(v) + (1.0 / e));
end
code[e_, v_] := N[(N[Sin[v], $MachinePrecision] / N[(N[Cos[v], $MachinePrecision] + N[(1.0 / e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sin v}{\cos v + \frac{1}{e}}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{e \cdot \sin v}}{1 + e \cdot \cos v} \]
    2. lift-sin.f64N/A

      \[\leadsto \frac{e \cdot \color{blue}{\sin v}}{1 + e \cdot \cos v} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{1 + e \cdot \cos v} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{1 + e \cdot \cos v} \]
    5. lift-sin.f6499.8

      \[\leadsto \frac{\color{blue}{\sin v} \cdot e}{1 + e \cdot \cos v} \]
    6. lift-+.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{1 + e \cdot \cos v}} \]
    7. lift-*.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{1 + \color{blue}{e \cdot \cos v}} \]
    8. lift-cos.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{1 + e \cdot \color{blue}{\cos v}} \]
    9. +-commutativeN/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{e \cdot \cos v + 1}} \]
    10. *-commutativeN/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\cos v \cdot e} + 1} \]
    11. lower-fma.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
    12. lift-cos.f6499.8

      \[\leadsto \frac{\sin v \cdot e}{\mathsf{fma}\left(\color{blue}{\cos v}, e, 1\right)} \]
  3. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{\sin v \cdot e}{\mathsf{fma}\left(\cos v, e, 1\right)}} \]
  4. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\mathsf{fma}\left(\color{blue}{\cos v}, e, 1\right)} \]
    2. lift-fma.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\cos v \cdot e + 1}} \]
    3. metadata-evalN/A

      \[\leadsto \frac{\sin v \cdot e}{\cos v \cdot e + \color{blue}{{e}^{0}}} \]
    4. metadata-evalN/A

      \[\leadsto \frac{\sin v \cdot e}{\cos v \cdot e + {e}^{\color{blue}{\left(-1 + 1\right)}}} \]
    5. pow-plusN/A

      \[\leadsto \frac{\sin v \cdot e}{\cos v \cdot e + \color{blue}{{e}^{-1} \cdot e}} \]
    6. inv-powN/A

      \[\leadsto \frac{\sin v \cdot e}{\cos v \cdot e + \color{blue}{\frac{1}{e}} \cdot e} \]
    7. distribute-rgt-inN/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{e \cdot \left(\cos v + \frac{1}{e}\right)}} \]
    8. *-commutativeN/A

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

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\left(\cos v + \frac{1}{e}\right) \cdot e}} \]
    10. lower-+.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\left(\cos v + \frac{1}{e}\right)} \cdot e} \]
    11. lift-cos.f64N/A

      \[\leadsto \frac{\sin v \cdot e}{\left(\color{blue}{\cos v} + \frac{1}{e}\right) \cdot e} \]
    12. lower-/.f6499.6

      \[\leadsto \frac{\sin v \cdot e}{\left(\cos v + \color{blue}{\frac{1}{e}}\right) \cdot e} \]
  5. Applied rewrites99.6%

    \[\leadsto \frac{\sin v \cdot e}{\color{blue}{\left(\cos v + \frac{1}{e}\right) \cdot e}} \]
  6. Taylor expanded in v around inf

    \[\leadsto \color{blue}{\frac{\sin v}{\cos v + \frac{1}{e}}} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    2. distribute-rgt-inN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    4. inv-powN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    5. pow-plusN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    6. metadata-evalN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    7. metadata-evalN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    8. +-commutativeN/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{e}} \]
    9. *-commutativeN/A

      \[\leadsto \frac{\sin \color{blue}{v}}{\cos v + \frac{1}{e}} \]
    10. lower-/.f64N/A

      \[\leadsto \frac{\sin v}{\color{blue}{\cos v + \frac{1}{e}}} \]
    11. lift-sin.f64N/A

      \[\leadsto \frac{\sin v}{\color{blue}{\cos v} + \frac{1}{e}} \]
    12. lift-cos.f64N/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{\color{blue}{1}}{e}} \]
    13. lift-/.f64N/A

      \[\leadsto \frac{\sin v}{\cos v + \frac{1}{\color{blue}{e}}} \]
    14. lift-+.f6499.6

      \[\leadsto \frac{\sin v}{\cos v + \color{blue}{\frac{1}{e}}} \]
  8. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{\sin v}{\cos v + \frac{1}{e}}} \]
  9. Add Preprocessing

Alternative 3: 98.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \frac{\sin v \cdot e}{e + 1} \end{array} \]
(FPCore (e v) :precision binary64 (/ (* (sin v) e) (+ e 1.0)))
double code(double e, double v) {
	return (sin(v) * e) / (e + 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(e, v)
use fmin_fmax_functions
    real(8), intent (in) :: e
    real(8), intent (in) :: v
    code = (sin(v) * e) / (e + 1.0d0)
end function
public static double code(double e, double v) {
	return (Math.sin(v) * e) / (e + 1.0);
}
def code(e, v):
	return (math.sin(v) * e) / (e + 1.0)
function code(e, v)
	return Float64(Float64(sin(v) * e) / Float64(e + 1.0))
end
function tmp = code(e, v)
	tmp = (sin(v) * e) / (e + 1.0);
end
code[e_, v_] := N[(N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision] / N[(e + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sin v \cdot e}{e + 1}
\end{array}
Derivation
  1. Initial program 99.8%

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Taylor expanded in v around 0

    \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
  3. Step-by-step derivation
    1. Applied rewrites98.6%

      \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{e \cdot \sin v}}{1 + e} \]
      2. lift-sin.f64N/A

        \[\leadsto \frac{e \cdot \color{blue}{\sin v}}{1 + e} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{1 + e} \]
      4. lift-sin.f64N/A

        \[\leadsto \frac{\color{blue}{\sin v} \cdot e}{1 + e} \]
      5. lift-*.f6498.6

        \[\leadsto \frac{\color{blue}{\sin v \cdot e}}{1 + e} \]
      6. lift-+.f64N/A

        \[\leadsto \frac{\sin v \cdot e}{\color{blue}{1 + e}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{\sin v \cdot e}{\color{blue}{e + 1}} \]
      8. lower-+.f6498.6

        \[\leadsto \frac{\sin v \cdot e}{\color{blue}{e + 1}} \]
      9. *-commutative98.6

        \[\leadsto \frac{\sin v \cdot e}{e + 1} \]
    3. Applied rewrites98.6%

      \[\leadsto \color{blue}{\frac{\sin v \cdot e}{e + 1}} \]
    4. Add Preprocessing

    Alternative 4: 97.5% accurate, 2.1× speedup?

    \[\begin{array}{l} \\ \sin v \cdot e \end{array} \]
    (FPCore (e v) :precision binary64 (* (sin v) e))
    double code(double e, double v) {
    	return sin(v) * e;
    }
    
    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(e, v)
    use fmin_fmax_functions
        real(8), intent (in) :: e
        real(8), intent (in) :: v
        code = sin(v) * e
    end function
    
    public static double code(double e, double v) {
    	return Math.sin(v) * e;
    }
    
    def code(e, v):
    	return math.sin(v) * e
    
    function code(e, v)
    	return Float64(sin(v) * e)
    end
    
    function tmp = code(e, v)
    	tmp = sin(v) * e;
    end
    
    code[e_, v_] := N[(N[Sin[v], $MachinePrecision] * e), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \sin v \cdot e
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
    2. Taylor expanded in e around 0

      \[\leadsto \color{blue}{e \cdot \sin v} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sin v \cdot \color{blue}{e} \]
      2. lower-*.f64N/A

        \[\leadsto \sin v \cdot \color{blue}{e} \]
      3. lift-sin.f6497.5

        \[\leadsto \sin v \cdot e \]
    4. Applied rewrites97.5%

      \[\leadsto \color{blue}{\sin v \cdot e} \]
    5. Add Preprocessing

    Alternative 5: 52.3% accurate, 2.4× speedup?

    \[\begin{array}{l} \\ \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, \left(v \cdot v\right) \cdot e, -0.5 \cdot e\right), v \cdot v, e\right)} \end{array} \]
    (FPCore (e v)
     :precision binary64
     (/
      (* e v)
      (+ 1.0 (fma (fma 0.041666666666666664 (* (* v v) e) (* -0.5 e)) (* v v) e))))
    double code(double e, double v) {
    	return (e * v) / (1.0 + fma(fma(0.041666666666666664, ((v * v) * e), (-0.5 * e)), (v * v), e));
    }
    
    function code(e, v)
    	return Float64(Float64(e * v) / Float64(1.0 + fma(fma(0.041666666666666664, Float64(Float64(v * v) * e), Float64(-0.5 * e)), Float64(v * v), e)))
    end
    
    code[e_, v_] := N[(N[(e * v), $MachinePrecision] / N[(1.0 + N[(N[(0.041666666666666664 * N[(N[(v * v), $MachinePrecision] * e), $MachinePrecision] + N[(-0.5 * e), $MachinePrecision]), $MachinePrecision] * N[(v * v), $MachinePrecision] + e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, \left(v \cdot v\right) \cdot e, -0.5 \cdot e\right), v \cdot v, e\right)}
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
    2. Taylor expanded in v around 0

      \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
    3. Step-by-step derivation
      1. Applied rewrites98.6%

        \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
      2. Taylor expanded in v around 0

        \[\leadsto \frac{e \cdot \color{blue}{v}}{1 + e} \]
      3. Step-by-step derivation
        1. Applied rewrites51.4%

          \[\leadsto \frac{e \cdot \color{blue}{v}}{1 + e} \]
        2. Taylor expanded in v around 0

          \[\leadsto \frac{e \cdot v}{1 + \color{blue}{\left(e + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e + \frac{1}{24} \cdot \left(e \cdot {v}^{2}\right)\right)\right)}} \]
        3. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \frac{e \cdot v}{1 + \left(\color{blue}{e} + {v}^{2} \cdot \left(\frac{-1}{2} \cdot e + \frac{1}{24} \cdot \left(e \cdot {v}^{2}\right)\right)\right)} \]
          2. +-commutativeN/A

            \[\leadsto \frac{e \cdot v}{1 + \left({v}^{2} \cdot \left(\frac{-1}{2} \cdot e + \frac{1}{24} \cdot \left(e \cdot {v}^{2}\right)\right) + \color{blue}{e}\right)} \]
          3. *-commutativeN/A

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

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\frac{-1}{2} \cdot e + \frac{1}{24} \cdot \left(e \cdot {v}^{2}\right), \color{blue}{{v}^{2}}, e\right)} \]
          5. +-commutativeN/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\frac{1}{24} \cdot \left(e \cdot {v}^{2}\right) + \frac{-1}{2} \cdot e, {\color{blue}{v}}^{2}, e\right)} \]
          6. lower-fma.f64N/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, e \cdot {v}^{2}, \frac{-1}{2} \cdot e\right), {\color{blue}{v}}^{2}, e\right)} \]
          7. *-commutativeN/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, {v}^{2} \cdot e, \frac{-1}{2} \cdot e\right), {v}^{2}, e\right)} \]
          8. pow2N/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, \left(v \cdot v\right) \cdot e, \frac{-1}{2} \cdot e\right), {v}^{2}, e\right)} \]
          9. lift-*.f64N/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, \left(v \cdot v\right) \cdot e, \frac{-1}{2} \cdot e\right), {v}^{2}, e\right)} \]
          10. lift-*.f64N/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, \left(v \cdot v\right) \cdot e, \frac{-1}{2} \cdot e\right), {v}^{2}, e\right)} \]
          11. lower-*.f64N/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, \left(v \cdot v\right) \cdot e, \frac{-1}{2} \cdot e\right), {v}^{2}, e\right)} \]
          12. pow2N/A

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{24}, \left(v \cdot v\right) \cdot e, \frac{-1}{2} \cdot e\right), v \cdot \color{blue}{v}, e\right)} \]
          13. lift-*.f6452.3

            \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, \left(v \cdot v\right) \cdot e, -0.5 \cdot e\right), v \cdot \color{blue}{v}, e\right)} \]
        4. Applied rewrites52.3%

          \[\leadsto \frac{e \cdot v}{1 + \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, \left(v \cdot v\right) \cdot e, -0.5 \cdot e\right), v \cdot v, e\right)}} \]
        5. Add Preprocessing

        Alternative 6: 52.2% accurate, 3.7× speedup?

        \[\begin{array}{l} \\ \frac{e \cdot v}{1 + \mathsf{fma}\left(-0.5, \left(v \cdot v\right) \cdot e, e\right)} \end{array} \]
        (FPCore (e v)
         :precision binary64
         (/ (* e v) (+ 1.0 (fma -0.5 (* (* v v) e) e))))
        double code(double e, double v) {
        	return (e * v) / (1.0 + fma(-0.5, ((v * v) * e), e));
        }
        
        function code(e, v)
        	return Float64(Float64(e * v) / Float64(1.0 + fma(-0.5, Float64(Float64(v * v) * e), e)))
        end
        
        code[e_, v_] := N[(N[(e * v), $MachinePrecision] / N[(1.0 + N[(-0.5 * N[(N[(v * v), $MachinePrecision] * e), $MachinePrecision] + e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{e \cdot v}{1 + \mathsf{fma}\left(-0.5, \left(v \cdot v\right) \cdot e, e\right)}
        \end{array}
        
        Derivation
        1. Initial program 99.8%

          \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
        2. Taylor expanded in v around 0

          \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
        3. Step-by-step derivation
          1. Applied rewrites98.6%

            \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
          2. Taylor expanded in v around 0

            \[\leadsto \frac{e \cdot \color{blue}{v}}{1 + e} \]
          3. Step-by-step derivation
            1. Applied rewrites51.4%

              \[\leadsto \frac{e \cdot \color{blue}{v}}{1 + e} \]
            2. Taylor expanded in v around 0

              \[\leadsto \frac{e \cdot v}{1 + \color{blue}{\left(e + \frac{-1}{2} \cdot \left(e \cdot {v}^{2}\right)\right)}} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \frac{e \cdot v}{1 + \left(\color{blue}{e} + \frac{-1}{2} \cdot \left(e \cdot {v}^{2}\right)\right)} \]
              2. +-commutativeN/A

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

                \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\frac{-1}{2}, \color{blue}{e \cdot {v}^{2}}, e\right)} \]
              4. *-commutativeN/A

                \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\frac{-1}{2}, {v}^{2} \cdot \color{blue}{e}, e\right)} \]
              5. pow2N/A

                \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\frac{-1}{2}, \left(v \cdot v\right) \cdot e, e\right)} \]
              6. lift-*.f64N/A

                \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(\frac{-1}{2}, \left(v \cdot v\right) \cdot e, e\right)} \]
              7. lift-*.f6452.2

                \[\leadsto \frac{e \cdot v}{1 + \mathsf{fma}\left(-0.5, \left(v \cdot v\right) \cdot \color{blue}{e}, e\right)} \]
            4. Applied rewrites52.2%

              \[\leadsto \frac{e \cdot v}{1 + \color{blue}{\mathsf{fma}\left(-0.5, \left(v \cdot v\right) \cdot e, e\right)}} \]
            5. Add Preprocessing

            Alternative 7: 51.4% accurate, 7.6× speedup?

            \[\begin{array}{l} \\ \frac{e \cdot v}{1 + e} \end{array} \]
            (FPCore (e v) :precision binary64 (/ (* e v) (+ 1.0 e)))
            double code(double e, double v) {
            	return (e * v) / (1.0 + e);
            }
            
            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(e, v)
            use fmin_fmax_functions
                real(8), intent (in) :: e
                real(8), intent (in) :: v
                code = (e * v) / (1.0d0 + e)
            end function
            
            public static double code(double e, double v) {
            	return (e * v) / (1.0 + e);
            }
            
            def code(e, v):
            	return (e * v) / (1.0 + e)
            
            function code(e, v)
            	return Float64(Float64(e * v) / Float64(1.0 + e))
            end
            
            function tmp = code(e, v)
            	tmp = (e * v) / (1.0 + e);
            end
            
            code[e_, v_] := N[(N[(e * v), $MachinePrecision] / N[(1.0 + e), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{e \cdot v}{1 + e}
            \end{array}
            
            Derivation
            1. Initial program 99.8%

              \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
            2. Taylor expanded in v around 0

              \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
            3. Step-by-step derivation
              1. Applied rewrites98.6%

                \[\leadsto \frac{e \cdot \sin v}{1 + \color{blue}{e}} \]
              2. Taylor expanded in v around 0

                \[\leadsto \frac{e \cdot \color{blue}{v}}{1 + e} \]
              3. Step-by-step derivation
                1. Applied rewrites51.4%

                  \[\leadsto \frac{e \cdot \color{blue}{v}}{1 + e} \]
                2. Add Preprocessing

                Alternative 8: 51.4% accurate, 7.6× speedup?

                \[\begin{array}{l} \\ e \cdot \frac{v}{1 + e} \end{array} \]
                (FPCore (e v) :precision binary64 (* e (/ v (+ 1.0 e))))
                double code(double e, double v) {
                	return e * (v / (1.0 + e));
                }
                
                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(e, v)
                use fmin_fmax_functions
                    real(8), intent (in) :: e
                    real(8), intent (in) :: v
                    code = e * (v / (1.0d0 + e))
                end function
                
                public static double code(double e, double v) {
                	return e * (v / (1.0 + e));
                }
                
                def code(e, v):
                	return e * (v / (1.0 + e))
                
                function code(e, v)
                	return Float64(e * Float64(v / Float64(1.0 + e)))
                end
                
                function tmp = code(e, v)
                	tmp = e * (v / (1.0 + e));
                end
                
                code[e_, v_] := N[(e * N[(v / N[(1.0 + e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                e \cdot \frac{v}{1 + e}
                \end{array}
                
                Derivation
                1. Initial program 99.8%

                  \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
                2. Taylor expanded in v around 0

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

                    \[\leadsto e \cdot \color{blue}{\frac{v}{1 + e}} \]
                  2. lower-*.f64N/A

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

                    \[\leadsto e \cdot \frac{v}{\color{blue}{1 + e}} \]
                  4. lower-+.f6451.4

                    \[\leadsto e \cdot \frac{v}{1 + \color{blue}{e}} \]
                4. Applied rewrites51.4%

                  \[\leadsto \color{blue}{e \cdot \frac{v}{1 + e}} \]
                5. Add Preprocessing

                Alternative 9: 50.9% accurate, 8.0× speedup?

                \[\begin{array}{l} \\ \left(\left(1 - e\right) \cdot e\right) \cdot v \end{array} \]
                (FPCore (e v) :precision binary64 (* (* (- 1.0 e) e) v))
                double code(double e, double v) {
                	return ((1.0 - e) * e) * v;
                }
                
                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(e, v)
                use fmin_fmax_functions
                    real(8), intent (in) :: e
                    real(8), intent (in) :: v
                    code = ((1.0d0 - e) * e) * v
                end function
                
                public static double code(double e, double v) {
                	return ((1.0 - e) * e) * v;
                }
                
                def code(e, v):
                	return ((1.0 - e) * e) * v
                
                function code(e, v)
                	return Float64(Float64(Float64(1.0 - e) * e) * v)
                end
                
                function tmp = code(e, v)
                	tmp = ((1.0 - e) * e) * v;
                end
                
                code[e_, v_] := N[(N[(N[(1.0 - e), $MachinePrecision] * e), $MachinePrecision] * v), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \left(\left(1 - e\right) \cdot e\right) \cdot v
                \end{array}
                
                Derivation
                1. Initial program 99.8%

                  \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
                2. Taylor expanded in e around 0

                  \[\leadsto \color{blue}{e \cdot \left(\sin v + -1 \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right)} \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

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

                    \[\leadsto \left(\sin v + -1 \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right) \cdot \color{blue}{e} \]
                  3. +-commutativeN/A

                    \[\leadsto \left(-1 \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right) + \sin v\right) \cdot e \]
                  4. lower-+.f64N/A

                    \[\leadsto \left(-1 \cdot \left(e \cdot \left(\cos v \cdot \sin v\right)\right) + \sin v\right) \cdot e \]
                  5. mul-1-negN/A

                    \[\leadsto \left(\left(\mathsf{neg}\left(e \cdot \left(\cos v \cdot \sin v\right)\right)\right) + \sin v\right) \cdot e \]
                  6. lower-neg.f64N/A

                    \[\leadsto \left(\left(-e \cdot \left(\cos v \cdot \sin v\right)\right) + \sin v\right) \cdot e \]
                  7. associate-*r*N/A

                    \[\leadsto \left(\left(-\left(e \cdot \cos v\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                  8. lower-*.f64N/A

                    \[\leadsto \left(\left(-\left(e \cdot \cos v\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                  9. *-commutativeN/A

                    \[\leadsto \left(\left(-\left(\cos v \cdot e\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                  10. lower-*.f64N/A

                    \[\leadsto \left(\left(-\left(\cos v \cdot e\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                  11. lift-cos.f64N/A

                    \[\leadsto \left(\left(-\left(\cos v \cdot e\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                  12. lift-sin.f64N/A

                    \[\leadsto \left(\left(-\left(\cos v \cdot e\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                  13. lift-sin.f6498.7

                    \[\leadsto \left(\left(-\left(\cos v \cdot e\right) \cdot \sin v\right) + \sin v\right) \cdot e \]
                4. Applied rewrites98.7%

                  \[\leadsto \color{blue}{\left(\left(-\left(\cos v \cdot e\right) \cdot \sin v\right) + \sin v\right) \cdot e} \]
                5. Taylor expanded in v around 0

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

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

                    \[\leadsto \left(-1 \cdot \left(e \cdot \left({v}^{2} \cdot \left(\frac{1}{6} + \frac{-2}{3} \cdot e\right)\right)\right) + e \cdot \left(1 - e\right)\right) \cdot v \]
                7. Applied rewrites50.4%

                  \[\leadsto \mathsf{fma}\left(1 - e, e, -\left(\left(v \cdot v\right) \cdot e\right) \cdot \mathsf{fma}\left(-0.6666666666666666, e, 0.16666666666666666\right)\right) \cdot \color{blue}{v} \]
                8. Taylor expanded in v around 0

                  \[\leadsto \left(e \cdot \left(1 - e\right)\right) \cdot v \]
                9. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \left(\left(1 - e\right) \cdot e\right) \cdot v \]
                  2. lower-*.f64N/A

                    \[\leadsto \left(\left(1 - e\right) \cdot e\right) \cdot v \]
                  3. lift--.f6450.9

                    \[\leadsto \left(\left(1 - e\right) \cdot e\right) \cdot v \]
                10. Applied rewrites50.9%

                  \[\leadsto \left(\left(1 - e\right) \cdot e\right) \cdot v \]
                11. Add Preprocessing

                Alternative 10: 50.3% accurate, 19.4× speedup?

                \[\begin{array}{l} \\ e \cdot v \end{array} \]
                (FPCore (e v) :precision binary64 (* e v))
                double code(double e, double v) {
                	return e * v;
                }
                
                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(e, v)
                use fmin_fmax_functions
                    real(8), intent (in) :: e
                    real(8), intent (in) :: v
                    code = e * v
                end function
                
                public static double code(double e, double v) {
                	return e * v;
                }
                
                def code(e, v):
                	return e * v
                
                function code(e, v)
                	return Float64(e * v)
                end
                
                function tmp = code(e, v)
                	tmp = e * v;
                end
                
                code[e_, v_] := N[(e * v), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                e \cdot v
                \end{array}
                
                Derivation
                1. Initial program 99.8%

                  \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
                2. Taylor expanded in v around 0

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

                    \[\leadsto e \cdot \color{blue}{\frac{v}{1 + e}} \]
                  2. lower-*.f64N/A

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

                    \[\leadsto e \cdot \frac{v}{\color{blue}{1 + e}} \]
                  4. lower-+.f6451.4

                    \[\leadsto e \cdot \frac{v}{1 + \color{blue}{e}} \]
                4. Applied rewrites51.4%

                  \[\leadsto \color{blue}{e \cdot \frac{v}{1 + e}} \]
                5. Taylor expanded in e around 0

                  \[\leadsto e \cdot v \]
                6. Step-by-step derivation
                  1. Applied rewrites50.3%

                    \[\leadsto e \cdot v \]
                  2. Add Preprocessing

                  Alternative 11: 4.5% accurate, 76.6× speedup?

                  \[\begin{array}{l} \\ v \end{array} \]
                  (FPCore (e v) :precision binary64 v)
                  double code(double e, double v) {
                  	return v;
                  }
                  
                  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(e, v)
                  use fmin_fmax_functions
                      real(8), intent (in) :: e
                      real(8), intent (in) :: v
                      code = v
                  end function
                  
                  public static double code(double e, double v) {
                  	return v;
                  }
                  
                  def code(e, v):
                  	return v
                  
                  function code(e, v)
                  	return v
                  end
                  
                  function tmp = code(e, v)
                  	tmp = v;
                  end
                  
                  code[e_, v_] := v
                  
                  \begin{array}{l}
                  
                  \\
                  v
                  \end{array}
                  
                  Derivation
                  1. Initial program 99.8%

                    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
                  2. Taylor expanded in v around 0

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

                      \[\leadsto e \cdot \color{blue}{\frac{v}{1 + e}} \]
                    2. lower-*.f64N/A

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

                      \[\leadsto e \cdot \frac{v}{\color{blue}{1 + e}} \]
                    4. lower-+.f6451.4

                      \[\leadsto e \cdot \frac{v}{1 + \color{blue}{e}} \]
                  4. Applied rewrites51.4%

                    \[\leadsto \color{blue}{e \cdot \frac{v}{1 + e}} \]
                  5. Taylor expanded in e around inf

                    \[\leadsto v \]
                  6. Step-by-step derivation
                    1. Applied rewrites4.5%

                      \[\leadsto v \]
                    2. Add Preprocessing

                    Reproduce

                    ?
                    herbie shell --seed 2025112 
                    (FPCore (e v)
                      :name "Trigonometry A"
                      :precision binary64
                      :pre (and (<= 0.0 e) (<= e 1.0))
                      (/ (* e (sin v)) (+ 1.0 (* e (cos v)))))