Trigonometry A

Percentage Accurate: 99.8% → 99.8%
Time: 4.7s
Alternatives: 13
Speedup: 1.0×

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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.7% accurate, 1.0× speedup?

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

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

    \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
  2. Add Preprocessing
  3. 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)} \]
  4. Step-by-step derivation
    1. Applied rewrites99.5%

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

    Alternative 3: 98.7% accurate, 1.9× speedup?

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

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

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

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

      Alternative 4: 98.7% accurate, 1.9× speedup?

      \[\begin{array}{l} \\ \sin v \cdot \frac{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(sin(v) * Float64(e / Float64(e - -1.0)))
      end
      
      function tmp = code(e, v)
      	tmp = sin(v) * (e / (e - -1.0));
      end
      
      code[e_, v_] := N[(N[Sin[v], $MachinePrecision] * N[(e / N[(e - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \sin v \cdot \frac{e}{e - -1}
      \end{array}
      
      Derivation
      1. Initial program 99.8%

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\sin v \cdot \frac{e}{1 + e}} \]
          6. lower-/.f6499.4

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

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

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

            \[\leadsto \sin v \cdot \frac{e}{e + \color{blue}{1 \cdot 1}} \]
          10. fp-cancel-sign-sub-invN/A

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

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

            \[\leadsto \sin v \cdot \frac{e}{e - \color{blue}{-1}} \]
          13. lower--.f6499.4

            \[\leadsto \sin v \cdot \frac{e}{\color{blue}{e - -1}} \]
        3. Applied rewrites99.4%

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

        Alternative 5: 98.1% accurate, 2.0× speedup?

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

          \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
        2. Add Preprocessing
        3. 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)} \]
        4. Step-by-step derivation
          1. Applied rewrites99.5%

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

            \[\leadsto \left(\left(1 + -1 \cdot e\right) \cdot \sin v\right) \cdot e \]
          3. Step-by-step derivation
            1. Applied rewrites99.2%

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

            Alternative 6: 97.7% 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. Add Preprocessing
            3. Taylor expanded in e around 0

              \[\leadsto \color{blue}{e \cdot \sin v} \]
            4. Step-by-step derivation
              1. Applied rewrites99.1%

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

              Alternative 7: 51.6% accurate, 4.6× speedup?

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

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

                \[\leadsto \frac{\color{blue}{v \cdot \left(e + \frac{-1}{6} \cdot \left(e \cdot {v}^{2}\right)\right)}}{1 + e \cdot \cos v} \]
              4. Step-by-step derivation
                1. Applied rewrites49.5%

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

                  \[\leadsto \frac{\mathsf{fma}\left(\left(v \cdot v\right) \cdot e, \frac{-1}{6}, e\right) \cdot v}{1 + e \cdot \color{blue}{\left(1 + {v}^{2} \cdot \left(\frac{1}{24} \cdot {v}^{2} - \frac{1}{2}\right)\right)}} \]
                3. Step-by-step derivation
                  1. Applied rewrites49.5%

                    \[\leadsto \frac{\mathsf{fma}\left(\left(v \cdot v\right) \cdot e, -0.16666666666666666, e\right) \cdot v}{1 + e \cdot \color{blue}{\mathsf{fma}\left(0.041666666666666664 \cdot \left(v \cdot v\right) - 0.5, v \cdot v, 1\right)}} \]
                  2. Taylor expanded in v around 0

                    \[\leadsto \frac{e \cdot v}{1 + e \cdot \mathsf{fma}\left(\frac{1}{24} \cdot \left(v \cdot v\right) - \frac{1}{2}, v \cdot v, 1\right)} \]
                  3. Step-by-step derivation
                    1. Applied rewrites50.5%

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

                    Alternative 8: 50.7% accurate, 7.3× speedup?

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

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

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

                        \[\leadsto \color{blue}{\frac{e}{e - -1} \cdot v} \]
                      2. Step-by-step derivation
                        1. Applied rewrites49.6%

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

                        Alternative 9: 50.7% accurate, 11.3× speedup?

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

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

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

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

                          Alternative 10: 50.2% accurate, 16.1× speedup?

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

                            \[\frac{e \cdot \sin v}{1 + e \cdot \cos v} \]
                          2. Add Preprocessing
                          3. 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)} \]
                          4. Step-by-step derivation
                            1. Applied rewrites99.5%

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

                              \[\leadsto \left(v \cdot \left(1 + -1 \cdot e\right)\right) \cdot e \]
                            3. Step-by-step derivation
                              1. Applied rewrites49.4%

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

                              Alternative 11: 50.2% accurate, 16.1× speedup?

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

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

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

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

                                  \[\leadsto e \cdot \color{blue}{\left(v + -1 \cdot \left(e \cdot v\right)\right)} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites49.4%

                                    \[\leadsto \left(v - e \cdot v\right) \cdot \color{blue}{e} \]
                                  2. Add Preprocessing

                                  Alternative 12: 49.8% accurate, 37.5× 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. Add Preprocessing
                                  3. Taylor expanded in v around 0

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

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

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

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

                                      Alternative 13: 4.5% accurate, 225.0× 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. Add Preprocessing
                                      3. Taylor expanded in v around 0

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

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

                                          \[\leadsto v \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites4.4%

                                            \[\leadsto v \]
                                          2. Add Preprocessing

                                          Reproduce

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