ENA, Section 1.4, Exercise 1

Percentage Accurate: 94.5% → 99.2%
Time: 5.5s
Alternatives: 17
Speedup: 1.0×

Specification

?
\[1.99 \leq x \land x \leq 2.01\]
\[\begin{array}{l} \\ \cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \end{array} \]
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
double code(double x) {
	return cos(x) * exp((10.0 * (x * x)));
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = cos(x) * exp((10.0d0 * (x * x)))
end function
public static double code(double x) {
	return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
def code(x):
	return math.cos(x) * math.exp((10.0 * (x * x)))
function code(x)
	return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x))))
end
function tmp = code(x)
	tmp = cos(x) * exp((10.0 * (x * x)));
end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 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: 94.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \end{array} \]
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
double code(double x) {
	return cos(x) * exp((10.0 * (x * x)));
}
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(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = cos(x) * exp((10.0d0 * (x * x)))
end function
public static double code(double x) {
	return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
def code(x):
	return math.cos(x) * math.exp((10.0 * (x * x)))
function code(x)
	return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x))))
end
function tmp = code(x)
	tmp = cos(x) * exp((10.0 * (x * x)));
end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
\end{array}

Alternative 1: 99.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\ \mathsf{fma}\left(x, \cos t\_0, \cos x \cdot \sin t\_0\right) \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ (PI) 2.0)))
   (* (fma x (cos t_0) (* (cos x) (sin t_0))) (pow (pow (exp 10.0) x) x))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{2}\\
\mathsf{fma}\left(x, \cos t\_0, \cos x \cdot \sin t\_0\right) \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}
\end{array}
\end{array}
Derivation
  1. Initial program 94.8%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-exp.f64N/A

      \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
    2. lift-*.f64N/A

      \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
    3. exp-prodN/A

      \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(x \cdot x\right)}} \]
    5. pow-unpowN/A

      \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
    6. sqr-powN/A

      \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
    7. lower-*.f64N/A

      \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
    8. lower-pow.f64N/A

      \[\leadsto \cos x \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    9. lower-pow.f64N/A

      \[\leadsto \cos x \cdot \left({\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    10. lower-exp.f64N/A

      \[\leadsto \cos x \cdot \left({\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    11. lower-/.f64N/A

      \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    12. lower-pow.f64N/A

      \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
    13. lower-pow.f64N/A

      \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)}\right) \]
    14. lower-exp.f64N/A

      \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    15. lower-/.f6498.1

      \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}}\right) \]
  4. Applied rewrites98.1%

    \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
  5. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \color{blue}{\cos x} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    2. sin-+PI/2-revN/A

      \[\leadsto \color{blue}{\sin \left(x + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    3. sin-sumN/A

      \[\leadsto \color{blue}{\left(\sin x \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right) + \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    4. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    5. lower-sin.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\sin x}, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    6. lower-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \color{blue}{\cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}, \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    7. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}, \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    8. lower-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    9. lift-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \color{blue}{\cos x} \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    10. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \color{blue}{\cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    11. lower-sin.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \color{blue}{\sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    12. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    13. lower-PI.f6498.8

      \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
  6. Applied rewrites98.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
  7. Taylor expanded in x around 0

    \[\leadsto \mathsf{fma}\left(\color{blue}{x}, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
  8. Step-by-step derivation
    1. Applied rewrites99.0%

      \[\leadsto \mathsf{fma}\left(\color{blue}{x}, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      2. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      4. lift-pow.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
      5. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}}\right) \]
      6. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
      7. lower-pow.f6499.2

        \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
    3. Applied rewrites99.2%

      \[\leadsto \mathsf{fma}\left(x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
    4. Add Preprocessing

    Alternative 2: 98.0% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \frac{{\cos x}^{2}}{\cos x \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{x}} \end{array} \]
    (FPCore (x)
     :precision binary64
     (/ (pow (cos x) 2.0) (* (cos x) (pow (pow (exp 10.0) (- x)) x))))
    double code(double x) {
    	return pow(cos(x), 2.0) / (cos(x) * pow(pow(exp(10.0), -x), x));
    }
    
    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(x)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        code = (cos(x) ** 2.0d0) / (cos(x) * ((exp(10.0d0) ** -x) ** x))
    end function
    
    public static double code(double x) {
    	return Math.pow(Math.cos(x), 2.0) / (Math.cos(x) * Math.pow(Math.pow(Math.exp(10.0), -x), x));
    }
    
    def code(x):
    	return math.pow(math.cos(x), 2.0) / (math.cos(x) * math.pow(math.pow(math.exp(10.0), -x), x))
    
    function code(x)
    	return Float64((cos(x) ^ 2.0) / Float64(cos(x) * ((exp(10.0) ^ Float64(-x)) ^ x)))
    end
    
    function tmp = code(x)
    	tmp = (cos(x) ^ 2.0) / (cos(x) * ((exp(10.0) ^ -x) ^ x));
    end
    
    code[x_] := N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[10.0], $MachinePrecision], (-x)], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{{\cos x}^{2}}{\cos x \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{x}}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(x \cdot x\right)}} \]
      5. pow-unpowN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
      6. sqr-powN/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      8. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      9. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      10. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      11. lower-/.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      12. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
      13. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)}\right) \]
      14. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      15. lower-/.f6498.1

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}}\right) \]
    4. Applied rewrites98.1%

      \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
    5. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \color{blue}{\cos x} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      2. sin-+PI/2-revN/A

        \[\leadsto \color{blue}{\sin \left(x + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      3. sin-sumN/A

        \[\leadsto \color{blue}{\left(\sin x \cdot \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right) + \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      5. lower-sin.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sin x}, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      6. lower-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \color{blue}{\cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}, \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      7. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}, \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      8. lower-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      9. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \color{blue}{\cos x} \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      10. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \color{blue}{\cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      11. lower-sin.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \color{blue}{\sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      12. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2}\right)}\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      13. lower-PI.f6498.8

        \[\leadsto \mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right)\right) \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    6. Applied rewrites98.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sin x, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos x \cdot \sin \left(\frac{\mathsf{PI}\left(\right)}{2}\right)\right)} \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
    7. Applied rewrites98.1%

      \[\leadsto \color{blue}{\frac{\left(0 - {\cos x}^{2}\right) \cdot 1}{\left(-\cos x\right) \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{x}}} \]
    8. Final simplification98.1%

      \[\leadsto \frac{{\cos x}^{2}}{\cos x \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{x}} \]
    9. Add Preprocessing

    Alternative 3: 98.0% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \cos x \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{\left(-x\right)} \end{array} \]
    (FPCore (x) :precision binary64 (* (cos x) (pow (pow (exp 10.0) (- x)) (- x))))
    double code(double x) {
    	return cos(x) * pow(pow(exp(10.0), -x), -x);
    }
    
    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(x)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        code = cos(x) * ((exp(10.0d0) ** -x) ** -x)
    end function
    
    public static double code(double x) {
    	return Math.cos(x) * Math.pow(Math.pow(Math.exp(10.0), -x), -x);
    }
    
    def code(x):
    	return math.cos(x) * math.pow(math.pow(math.exp(10.0), -x), -x)
    
    function code(x)
    	return Float64(cos(x) * ((exp(10.0) ^ Float64(-x)) ^ Float64(-x)))
    end
    
    function tmp = code(x)
    	tmp = cos(x) * ((exp(10.0) ^ -x) ^ -x);
    end
    
    code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[10.0], $MachinePrecision], (-x)], $MachinePrecision], (-x)], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \cos x \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{\left(-x\right)}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(x \cdot x\right)}} \]
      5. sqr-neg-revN/A

        \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)}} \]
      6. pow-unpowN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}} \]
      7. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}} \]
      8. lower-pow.f64N/A

        \[\leadsto \cos x \cdot {\color{blue}{\left({\left(e^{10}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}}^{\left(\mathsf{neg}\left(x\right)\right)} \]
      9. lower-exp.f64N/A

        \[\leadsto \cos x \cdot {\left({\color{blue}{\left(e^{10}\right)}}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)} \]
      10. lower-neg.f64N/A

        \[\leadsto \cos x \cdot {\left({\left(e^{10}\right)}^{\color{blue}{\left(-x\right)}}\right)}^{\left(\mathsf{neg}\left(x\right)\right)} \]
      11. lower-neg.f6498.1

        \[\leadsto \cos x \cdot {\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{\color{blue}{\left(-x\right)}} \]
    4. Applied rewrites98.1%

      \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{\left(-x\right)}\right)}^{\left(-x\right)}} \]
    5. Add Preprocessing

    Alternative 4: 97.9% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x} \end{array} \]
    (FPCore (x) :precision binary64 (* (cos x) (pow (pow (exp 10.0) x) x)))
    double code(double x) {
    	return cos(x) * pow(pow(exp(10.0), x), x);
    }
    
    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(x)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        code = cos(x) * ((exp(10.0d0) ** x) ** x)
    end function
    
    public static double code(double x) {
    	return Math.cos(x) * Math.pow(Math.pow(Math.exp(10.0), x), x);
    }
    
    def code(x):
    	return math.cos(x) * math.pow(math.pow(math.exp(10.0), x), x)
    
    function code(x)
    	return Float64(cos(x) * ((exp(10.0) ^ x) ^ x))
    end
    
    function tmp = code(x)
    	tmp = cos(x) * ((exp(10.0) ^ x) ^ x);
    end
    
    code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[10.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(x \cdot x\right)}} \]
      5. pow-unpowN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
      6. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
      7. lower-pow.f64N/A

        \[\leadsto \cos x \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{x} \]
      8. lower-exp.f6498.0

        \[\leadsto \cos x \cdot {\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{x} \]
    4. Applied rewrites98.0%

      \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
    5. Add Preprocessing

    Alternative 5: 95.2% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \sin \left(\frac{\mathsf{PI}\left(\right)}{2} + x\right) \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \end{array} \]
    (FPCore (x)
     :precision binary64
     (* (sin (+ (/ (PI) 2.0) x)) (pow (exp 10.0) (* x x))))
    \begin{array}{l}
    
    \\
    \sin \left(\frac{\mathsf{PI}\left(\right)}{2} + x\right) \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      5. lower-exp.f6495.2

        \[\leadsto \cos x \cdot {\color{blue}{\left(e^{10}\right)}}^{\left(x \cdot x\right)} \]
    4. Applied rewrites95.2%

      \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
    5. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \color{blue}{\cos x} \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
      2. sin-+PI/2-revN/A

        \[\leadsto \color{blue}{\sin \left(x + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
      3. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin \left(x + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
      4. +-commutativeN/A

        \[\leadsto \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + x\right)} \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
      5. lower-+.f64N/A

        \[\leadsto \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + x\right)} \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
      6. lower-/.f64N/A

        \[\leadsto \sin \left(\color{blue}{\frac{\mathsf{PI}\left(\right)}{2}} + x\right) \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
      7. lower-PI.f6495.2

        \[\leadsto \sin \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2} + x\right) \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
    6. Applied rewrites95.2%

      \[\leadsto \color{blue}{\sin \left(\frac{\mathsf{PI}\left(\right)}{2} + x\right)} \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
    7. Add Preprocessing

    Alternative 6: 95.3% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \cos x \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \end{array} \]
    (FPCore (x) :precision binary64 (* (cos x) (pow (exp 10.0) (* x x))))
    double code(double x) {
    	return cos(x) * pow(exp(10.0), (x * x));
    }
    
    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(x)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        code = cos(x) * (exp(10.0d0) ** (x * x))
    end function
    
    public static double code(double x) {
    	return Math.cos(x) * Math.pow(Math.exp(10.0), (x * x));
    }
    
    def code(x):
    	return math.cos(x) * math.pow(math.exp(10.0), (x * x))
    
    function code(x)
    	return Float64(cos(x) * (exp(10.0) ^ Float64(x * x)))
    end
    
    function tmp = code(x)
    	tmp = cos(x) * (exp(10.0) ^ (x * x));
    end
    
    code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Exp[10.0], $MachinePrecision], N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \cos x \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      5. lower-exp.f6495.2

        \[\leadsto \cos x \cdot {\color{blue}{\left(e^{10}\right)}}^{\left(x \cdot x\right)} \]
    4. Applied rewrites95.2%

      \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
    5. Add Preprocessing

    Alternative 7: 94.6% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, 5 \cdot \left(x \cdot x\right)\right)} \end{array} \]
    (FPCore (x)
     :precision binary64
     (* (cos x) (exp (fma x (* 5.0 x) (* 5.0 (* x x))))))
    double code(double x) {
    	return cos(x) * exp(fma(x, (5.0 * x), (5.0 * (x * x))));
    }
    
    function code(x)
    	return Float64(cos(x) * exp(fma(x, Float64(5.0 * x), Float64(5.0 * Float64(x * x)))))
    end
    
    code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(x * N[(5.0 * x), $MachinePrecision] + N[(5.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, 5 \cdot \left(x \cdot x\right)\right)}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(x \cdot x\right)}} \]
      5. pow-unpowN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
      6. sqr-powN/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      8. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      9. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      10. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      11. lower-/.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      12. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
      13. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)}\right) \]
      14. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      15. lower-/.f6498.1

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}}\right) \]
    4. Applied rewrites98.1%

      \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      2. lift-pow.f64N/A

        \[\leadsto \cos x \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      3. pow-to-expN/A

        \[\leadsto \cos x \cdot \left(\color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      4. lift-pow.f64N/A

        \[\leadsto \cos x \cdot \left(e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
      5. pow-to-expN/A

        \[\leadsto \cos x \cdot \left(e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \cdot \color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}}\right) \]
      6. prod-expN/A

        \[\leadsto \cos x \cdot \color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}} \]
      7. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}} \]
      8. lift-pow.f64N/A

        \[\leadsto \cos x \cdot e^{\log \color{blue}{\left({\left(e^{10}\right)}^{x}\right)} \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \]
      9. pow-to-expN/A

        \[\leadsto \cos x \cdot e^{\log \color{blue}{\left(e^{\log \left(e^{10}\right) \cdot x}\right)} \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \]
      10. rem-log-expN/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\left(\log \left(e^{10}\right) \cdot x\right)} \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \]
      11. lower-fma.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\mathsf{fma}\left(\log \left(e^{10}\right) \cdot x, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)}} \]
      12. lift-exp.f64N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(\log \color{blue}{\left(e^{10}\right)} \cdot x, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)} \]
      13. rem-log-expN/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(\color{blue}{10} \cdot x, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(\color{blue}{10 \cdot x}, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)} \]
    6. Applied rewrites94.9%

      \[\leadsto \cos x \cdot \color{blue}{e^{\mathsf{fma}\left(10 \cdot x, \frac{x}{2}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)}} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\left(10 \cdot x\right) \cdot \frac{x}{2} + \frac{\left(x \cdot x\right) \cdot 10}{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\frac{x}{2} \cdot \left(10 \cdot x\right)} + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      3. lift-/.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\frac{x}{2}} \cdot \left(10 \cdot x\right) + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      4. associate-*l/N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\frac{x \cdot \left(10 \cdot x\right)}{2}} + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      5. associate-/l*N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{x \cdot \frac{10 \cdot x}{2}} + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      6. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{x \cdot \frac{\color{blue}{10 \cdot x}}{2} + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      7. *-commutativeN/A

        \[\leadsto \cos x \cdot e^{x \cdot \frac{\color{blue}{x \cdot 10}}{2} + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      8. associate-*r/N/A

        \[\leadsto \cos x \cdot e^{x \cdot \color{blue}{\left(x \cdot \frac{10}{2}\right)} + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      9. metadata-evalN/A

        \[\leadsto \cos x \cdot e^{x \cdot \left(x \cdot \color{blue}{5}\right) + \frac{\left(x \cdot x\right) \cdot 10}{2}} \]
      10. lower-fma.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\mathsf{fma}\left(x, x \cdot 5, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)}} \]
      11. *-commutativeN/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, \color{blue}{5 \cdot x}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)} \]
      12. lower-*.f6494.9

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, \color{blue}{5 \cdot x}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)} \]
      13. lift-/.f64N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, \color{blue}{\frac{\left(x \cdot x\right) \cdot 10}{2}}\right)} \]
      14. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, \frac{\color{blue}{\left(x \cdot x\right) \cdot 10}}{2}\right)} \]
      15. associate-/l*N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, \color{blue}{\left(x \cdot x\right) \cdot \frac{10}{2}}\right)} \]
      16. metadata-evalN/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, \left(x \cdot x\right) \cdot \color{blue}{5}\right)} \]
      17. *-commutativeN/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, \color{blue}{5 \cdot \left(x \cdot x\right)}\right)} \]
      18. lower-*.f6494.9

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(x, 5 \cdot x, \color{blue}{5 \cdot \left(x \cdot x\right)}\right)} \]
    8. Applied rewrites94.9%

      \[\leadsto \cos x \cdot e^{\color{blue}{\mathsf{fma}\left(x, 5 \cdot x, 5 \cdot \left(x \cdot x\right)\right)}} \]
    9. Add Preprocessing

    Alternative 8: 94.5% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \end{array} \]
    (FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
    double code(double x) {
    	return cos(x) * exp((10.0 * (x * x)));
    }
    
    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(x)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        code = cos(x) * exp((10.0d0 * (x * x)))
    end function
    
    public static double code(double x) {
    	return Math.cos(x) * Math.exp((10.0 * (x * x)));
    }
    
    def code(x):
    	return math.cos(x) * math.exp((10.0 * (x * x)))
    
    function code(x)
    	return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x))))
    end
    
    function tmp = code(x)
    	tmp = cos(x) * exp((10.0 * (x * x)));
    end
    
    code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Add Preprocessing

    Alternative 9: 27.5% accurate, 1.2× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{\mathsf{fma}\left(10 \cdot x, \frac{x}{2}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)} \end{array} \]
    (FPCore (x)
     :precision binary64
     (*
      (fma
       (fma (fma -0.001388888888888889 (* x x) 0.041666666666666664) (* x x) -0.5)
       (* x x)
       1.0)
      (exp (fma (* 10.0 x) (/ x 2.0) (/ (* (* x x) 10.0) 2.0)))))
    double code(double x) {
    	return fma(fma(fma(-0.001388888888888889, (x * x), 0.041666666666666664), (x * x), -0.5), (x * x), 1.0) * exp(fma((10.0 * x), (x / 2.0), (((x * x) * 10.0) / 2.0)));
    }
    
    function code(x)
    	return Float64(fma(fma(fma(-0.001388888888888889, Float64(x * x), 0.041666666666666664), Float64(x * x), -0.5), Float64(x * x), 1.0) * exp(fma(Float64(10.0 * x), Float64(x / 2.0), Float64(Float64(Float64(x * x) * 10.0) / 2.0))))
    end
    
    code[x_] := N[(N[(N[(N[(-0.001388888888888889 * N[(x * x), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(10.0 * x), $MachinePrecision] * N[(x / 2.0), $MachinePrecision] + N[(N[(N[(x * x), $MachinePrecision] * 10.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{\mathsf{fma}\left(10 \cdot x, \frac{x}{2}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      3. exp-prodN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left(e^{10}\right)}^{\left(x \cdot x\right)}} \]
      4. lift-*.f64N/A

        \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\color{blue}{\left(x \cdot x\right)}} \]
      5. pow-unpowN/A

        \[\leadsto \cos x \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \]
      6. sqr-powN/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      8. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      9. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      10. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      11. lower-/.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      12. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
      13. lower-pow.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\color{blue}{\left({\left(e^{10}\right)}^{x}\right)}}^{\left(\frac{x}{2}\right)}\right) \]
      14. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\color{blue}{\left(e^{10}\right)}}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      15. lower-/.f6498.1

        \[\leadsto \cos x \cdot \left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2}\right)}}\right) \]
    4. Applied rewrites98.1%

      \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{\left({\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right)} \]
      2. lift-pow.f64N/A

        \[\leadsto \cos x \cdot \left(\color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      3. pow-to-expN/A

        \[\leadsto \cos x \cdot \left(\color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}} \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}\right) \]
      4. lift-pow.f64N/A

        \[\leadsto \cos x \cdot \left(e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \cdot \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}}\right) \]
      5. pow-to-expN/A

        \[\leadsto \cos x \cdot \left(e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \cdot \color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}}\right) \]
      6. prod-expN/A

        \[\leadsto \cos x \cdot \color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}} \]
      7. lower-exp.f64N/A

        \[\leadsto \cos x \cdot \color{blue}{e^{\log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}}} \]
      8. lift-pow.f64N/A

        \[\leadsto \cos x \cdot e^{\log \color{blue}{\left({\left(e^{10}\right)}^{x}\right)} \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \]
      9. pow-to-expN/A

        \[\leadsto \cos x \cdot e^{\log \color{blue}{\left(e^{\log \left(e^{10}\right) \cdot x}\right)} \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \]
      10. rem-log-expN/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\left(\log \left(e^{10}\right) \cdot x\right)} \cdot \frac{x}{2} + \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}} \]
      11. lower-fma.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\mathsf{fma}\left(\log \left(e^{10}\right) \cdot x, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)}} \]
      12. lift-exp.f64N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(\log \color{blue}{\left(e^{10}\right)} \cdot x, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)} \]
      13. rem-log-expN/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(\color{blue}{10} \cdot x, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \cos x \cdot e^{\mathsf{fma}\left(\color{blue}{10 \cdot x}, \frac{x}{2}, \log \left({\left(e^{10}\right)}^{x}\right) \cdot \frac{x}{2}\right)} \]
    6. Applied rewrites94.9%

      \[\leadsto \cos x \cdot \color{blue}{e^{\mathsf{fma}\left(10 \cdot x, \frac{x}{2}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)}} \]
    7. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {x}^{2}\right) - \frac{1}{2}\right)\right)} \cdot e^{\mathsf{fma}\left(10 \cdot x, \frac{x}{2}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)} \]
    8. Applied rewrites27.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, -0.5\right), x \cdot x, 1\right)} \cdot e^{\mathsf{fma}\left(10 \cdot x, \frac{x}{2}, \frac{\left(x \cdot x\right) \cdot 10}{2}\right)} \]
    9. Final simplification27.5%

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

    Alternative 10: 27.5% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{\left(10 \cdot x\right) \cdot x} \end{array} \]
    (FPCore (x)
     :precision binary64
     (*
      (fma
       (fma (fma -0.001388888888888889 (* x x) 0.041666666666666664) (* x x) -0.5)
       (* x x)
       1.0)
      (exp (* (* 10.0 x) x))))
    double code(double x) {
    	return fma(fma(fma(-0.001388888888888889, (x * x), 0.041666666666666664), (x * x), -0.5), (x * x), 1.0) * exp(((10.0 * x) * x));
    }
    
    function code(x)
    	return Float64(fma(fma(fma(-0.001388888888888889, Float64(x * x), 0.041666666666666664), Float64(x * x), -0.5), Float64(x * x), 1.0) * exp(Float64(Float64(10.0 * x) * x)))
    end
    
    code[x_] := N[(N[(N[(N[(-0.001388888888888889 * N[(x * x), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(x * x), $MachinePrecision] + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{\left(10 \cdot x\right) \cdot x}
    \end{array}
    
    Derivation
    1. Initial program 94.8%

      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{10 \cdot \left(x \cdot x\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \cos x \cdot e^{10 \cdot \color{blue}{\left(x \cdot x\right)}} \]
      3. associate-*r*N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \]
      4. lower-*.f64N/A

        \[\leadsto \cos x \cdot e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \]
      5. lower-*.f6494.4

        \[\leadsto \cos x \cdot e^{\color{blue}{\left(10 \cdot x\right)} \cdot x} \]
    4. Applied rewrites94.4%

      \[\leadsto \cos x \cdot e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {x}^{2}\right) - \frac{1}{2}\right)\right)} \cdot e^{\left(10 \cdot x\right) \cdot x} \]
    6. Step-by-step derivation
      1. Applied rewrites27.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, x \cdot x, 0.041666666666666664\right), x \cdot x, -0.5\right), x \cdot x, 1\right)} \cdot e^{\left(10 \cdot x\right) \cdot x} \]
      2. Add Preprocessing

      Alternative 11: 21.3% accurate, 1.6× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)} \end{array} \]
      (FPCore (x)
       :precision binary64
       (*
        (fma (fma 0.041666666666666664 (* x x) -0.5) (* x x) 1.0)
        (exp (* 10.0 (* x x)))))
      double code(double x) {
      	return fma(fma(0.041666666666666664, (x * x), -0.5), (x * x), 1.0) * exp((10.0 * (x * x)));
      }
      
      function code(x)
      	return Float64(fma(fma(0.041666666666666664, Float64(x * x), -0.5), Float64(x * x), 1.0) * exp(Float64(10.0 * Float64(x * x))))
      end
      
      code[x_] := N[(N[(N[(0.041666666666666664 * N[(x * x), $MachinePrecision] + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)}
      \end{array}
      
      Derivation
      1. Initial program 94.8%

        \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left(\frac{1}{24} \cdot {x}^{2} - \frac{1}{2}\right)\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
      4. Step-by-step derivation
        1. Applied rewrites21.3%

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

          \[\leadsto \mathsf{fma}\left(\frac{1}{24} \cdot {x}^{2} - \frac{1}{2}, \color{blue}{x} \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)} \]
        3. Step-by-step derivation
          1. Applied rewrites21.3%

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, x \cdot x, -0.5\right), \color{blue}{x} \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)} \]
          2. Final simplification21.3%

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, x \cdot x, -0.5\right), x \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)} \]
          3. Add Preprocessing

          Alternative 12: 18.2% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(-0.5, x \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)} \end{array} \]
          (FPCore (x)
           :precision binary64
           (* (fma -0.5 (* x x) 1.0) (exp (* 10.0 (* x x)))))
          double code(double x) {
          	return fma(-0.5, (x * x), 1.0) * exp((10.0 * (x * x)));
          }
          
          function code(x)
          	return Float64(fma(-0.5, Float64(x * x), 1.0) * exp(Float64(10.0 * Float64(x * x))))
          end
          
          code[x_] := N[(N[(-0.5 * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(-0.5, x \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)}
          \end{array}
          
          Derivation
          1. Initial program 94.8%

            \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

            \[\leadsto \color{blue}{\left(1 + \frac{-1}{2} \cdot {x}^{2}\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
          4. Step-by-step derivation
            1. Applied rewrites18.2%

              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5, x \cdot x, 1\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
            2. Final simplification18.2%

              \[\leadsto \mathsf{fma}\left(-0.5, x \cdot x, 1\right) \cdot e^{10 \cdot \left(x \cdot x\right)} \]
            3. Add Preprocessing

            Alternative 13: 10.2% accurate, 3.4× speedup?

            \[\begin{array}{l} \\ \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(166.66666666666666, x \cdot x, 50\right), x \cdot x, 10\right), x \cdot x, 1\right) \end{array} \]
            (FPCore (x)
             :precision binary64
             (*
              (fma (- (* 0.041666666666666664 (* x x)) 0.5) (* x x) 1.0)
              (fma (fma (fma 166.66666666666666 (* x x) 50.0) (* x x) 10.0) (* x x) 1.0)))
            double code(double x) {
            	return fma(((0.041666666666666664 * (x * x)) - 0.5), (x * x), 1.0) * fma(fma(fma(166.66666666666666, (x * x), 50.0), (x * x), 10.0), (x * x), 1.0);
            }
            
            function code(x)
            	return Float64(fma(Float64(Float64(0.041666666666666664 * Float64(x * x)) - 0.5), Float64(x * x), 1.0) * fma(fma(fma(166.66666666666666, Float64(x * x), 50.0), Float64(x * x), 10.0), Float64(x * x), 1.0))
            end
            
            code[x_] := N[(N[(N[(N[(0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(166.66666666666666 * N[(x * x), $MachinePrecision] + 50.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 10.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(166.66666666666666, x \cdot x, 50\right), x \cdot x, 10\right), x \cdot x, 1\right)
            \end{array}
            
            Derivation
            1. Initial program 94.8%

              \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

              \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left(\frac{1}{24} \cdot {x}^{2} - \frac{1}{2}\right)\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
            4. Step-by-step derivation
              1. Applied rewrites21.3%

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

                \[\leadsto \mathsf{fma}\left(\frac{1}{24} \cdot \left(x \cdot x\right) - \frac{1}{2}, x \cdot x, 1\right) \cdot \color{blue}{\left(1 + {x}^{2} \cdot \left(10 + {x}^{2} \cdot \left(50 + \frac{500}{3} \cdot {x}^{2}\right)\right)\right)} \]
              3. Step-by-step derivation
                1. Applied rewrites10.2%

                  \[\leadsto \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(166.66666666666666, x \cdot x, 50\right), x \cdot x, 10\right), x \cdot x, 1\right)} \]
                2. Final simplification10.2%

                  \[\leadsto \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(166.66666666666666, x \cdot x, 50\right), x \cdot x, 10\right), x \cdot x, 1\right) \]
                3. Add Preprocessing

                Alternative 14: 10.0% accurate, 4.2× speedup?

                \[\begin{array}{l} \\ \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(50, x \cdot x, 10\right), x \cdot x, 1\right) \end{array} \]
                (FPCore (x)
                 :precision binary64
                 (*
                  (fma (- (* 0.041666666666666664 (* x x)) 0.5) (* x x) 1.0)
                  (fma (fma 50.0 (* x x) 10.0) (* x x) 1.0)))
                double code(double x) {
                	return fma(((0.041666666666666664 * (x * x)) - 0.5), (x * x), 1.0) * fma(fma(50.0, (x * x), 10.0), (x * x), 1.0);
                }
                
                function code(x)
                	return Float64(fma(Float64(Float64(0.041666666666666664 * Float64(x * x)) - 0.5), Float64(x * x), 1.0) * fma(fma(50.0, Float64(x * x), 10.0), Float64(x * x), 1.0))
                end
                
                code[x_] := N[(N[(N[(N[(0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(50.0 * N[(x * x), $MachinePrecision] + 10.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(50, x \cdot x, 10\right), x \cdot x, 1\right)
                \end{array}
                
                Derivation
                1. Initial program 94.8%

                  \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left(\frac{1}{24} \cdot {x}^{2} - \frac{1}{2}\right)\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                4. Step-by-step derivation
                  1. Applied rewrites21.3%

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

                    \[\leadsto \mathsf{fma}\left(\frac{1}{24} \cdot \left(x \cdot x\right) - \frac{1}{2}, x \cdot x, 1\right) \cdot \color{blue}{\left(1 + {x}^{2} \cdot \left(10 + 50 \cdot {x}^{2}\right)\right)} \]
                  3. Step-by-step derivation
                    1. Applied rewrites10.0%

                      \[\leadsto \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(50, x \cdot x, 10\right), x \cdot x, 1\right)} \]
                    2. Final simplification10.0%

                      \[\leadsto \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(50, x \cdot x, 10\right), x \cdot x, 1\right) \]
                    3. Add Preprocessing

                    Alternative 15: 9.8% accurate, 5.3× speedup?

                    \[\begin{array}{l} \\ \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(x \cdot x, 10, 1\right) \end{array} \]
                    (FPCore (x)
                     :precision binary64
                     (*
                      (fma (- (* 0.041666666666666664 (* x x)) 0.5) (* x x) 1.0)
                      (fma (* x x) 10.0 1.0)))
                    double code(double x) {
                    	return fma(((0.041666666666666664 * (x * x)) - 0.5), (x * x), 1.0) * fma((x * x), 10.0, 1.0);
                    }
                    
                    function code(x)
                    	return Float64(fma(Float64(Float64(0.041666666666666664 * Float64(x * x)) - 0.5), Float64(x * x), 1.0) * fma(Float64(x * x), 10.0, 1.0))
                    end
                    
                    code[x_] := N[(N[(N[(N[(0.041666666666666664 * N[(x * x), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 10.0 + 1.0), $MachinePrecision]), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(x \cdot x, 10, 1\right)
                    \end{array}
                    
                    Derivation
                    1. Initial program 94.8%

                      \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left(\frac{1}{24} \cdot {x}^{2} - \frac{1}{2}\right)\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                    4. Step-by-step derivation
                      1. Applied rewrites21.3%

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

                        \[\leadsto \mathsf{fma}\left(\frac{1}{24} \cdot \left(x \cdot x\right) - \frac{1}{2}, x \cdot x, 1\right) \cdot \color{blue}{\left(1 + 10 \cdot {x}^{2}\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites9.8%

                          \[\leadsto \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \color{blue}{\mathsf{fma}\left(x \cdot x, 10, 1\right)} \]
                        2. Final simplification9.8%

                          \[\leadsto \mathsf{fma}\left(0.041666666666666664 \cdot \left(x \cdot x\right) - 0.5, x \cdot x, 1\right) \cdot \mathsf{fma}\left(x \cdot x, 10, 1\right) \]
                        3. Add Preprocessing

                        Alternative 16: 9.7% accurate, 12.7× speedup?

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

                          \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around 0

                          \[\leadsto \color{blue}{\left(1 + {x}^{2} \cdot \left(\frac{1}{24} \cdot {x}^{2} - \frac{1}{2}\right)\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                        4. Step-by-step derivation
                          1. Applied rewrites21.3%

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

                            \[\leadsto \mathsf{fma}\left(\frac{1}{24} \cdot \left(x \cdot x\right) - \frac{1}{2}, x \cdot x, 1\right) \cdot \color{blue}{1} \]
                          3. Step-by-step derivation
                            1. Applied rewrites9.6%

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

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2}, \color{blue}{x} \cdot x, 1\right) \cdot 1 \]
                            3. Step-by-step derivation
                              1. Applied rewrites9.7%

                                \[\leadsto \mathsf{fma}\left(-0.5, \color{blue}{x} \cdot x, 1\right) \cdot 1 \]
                              2. Final simplification9.7%

                                \[\leadsto \mathsf{fma}\left(-0.5, x \cdot x, 1\right) \cdot 1 \]
                              3. Add Preprocessing

                              Alternative 17: 1.5% accurate, 216.0× speedup?

                              \[\begin{array}{l} \\ 1 \end{array} \]
                              (FPCore (x) :precision binary64 1.0)
                              double code(double x) {
                              	return 1.0;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: x
                                  code = 1.0d0
                              end function
                              
                              public static double code(double x) {
                              	return 1.0;
                              }
                              
                              def code(x):
                              	return 1.0
                              
                              function code(x)
                              	return 1.0
                              end
                              
                              function tmp = code(x)
                              	tmp = 1.0;
                              end
                              
                              code[x_] := 1.0
                              
                              \begin{array}{l}
                              
                              \\
                              1
                              \end{array}
                              
                              Derivation
                              1. Initial program 94.8%

                                \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
                              2. Add Preprocessing
                              3. Taylor expanded in x around 0

                                \[\leadsto \color{blue}{1} \]
                              4. Step-by-step derivation
                                1. Applied rewrites1.5%

                                  \[\leadsto \color{blue}{1} \]
                                2. Add Preprocessing

                                Reproduce

                                ?
                                herbie shell --seed 2025018 
                                (FPCore (x)
                                  :name "ENA, Section 1.4, Exercise 1"
                                  :precision binary64
                                  :pre (and (<= 1.99 x) (<= x 2.01))
                                  (* (cos x) (exp (* 10.0 (* x x)))))