expfmod (used to be hard to sample)

Percentage Accurate: 12.5% → 97.1%
Time: 32.7s
Alternatives: 15
Speedup: 3.5×

Specification

?
\[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
(FPCore (x)
  :precision binary64
  (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
	return fmod(exp(x), sqrt(cos(x))) * exp(-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 = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x):
	return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x)
	return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x)))
end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}

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 15 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: 12.5% accurate, 1.0× speedup?

\[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
(FPCore (x)
  :precision binary64
  (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
	return fmod(exp(x), sqrt(cos(x))) * exp(-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 = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x):
	return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x)
	return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x)))
end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}

Alternative 1: 97.1% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \sqrt{\cos x}\\ t_1 := \left(\left(e^{x}\right) \bmod t\_0\right)\\ t_2 := e^{-x}\\ t_3 := t\_1 \cdot t\_2\\ \mathbf{if}\;t\_3 \leq 0:\\ \;\;\;\;\left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod t\_0\right) \cdot t\_2\\ \mathbf{elif}\;t\_3 \leq 2:\\ \;\;\;\;\frac{1}{\frac{e^{x}}{t\_1}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\ \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (sqrt (cos x)))
       (t_1 (fmod (exp x) t_0))
       (t_2 (exp (- x)))
       (t_3 (* t_1 t_2)))
  (if (<= t_3 0)
    (*
     (fmod
      (*
       (/
        (- (pow 1 3) (pow (/ -1 x) 3))
        (+ (* 1 1) (+ (exp (* (log (* x x)) -1)) (/ -1 x))))
       x)
      t_0)
     t_2)
    (if (<= t_3 2)
      (/ 1 (/ (exp x) t_1))
      (* (fmod 1 (sqrt 1)) (- 1 x))))))
double code(double x) {
	double t_0 = sqrt(cos(x));
	double t_1 = fmod(exp(x), t_0);
	double t_2 = exp(-x);
	double t_3 = t_1 * t_2;
	double tmp;
	if (t_3 <= 0.0) {
		tmp = fmod((((pow(1.0, 3.0) - pow((-1.0 / x), 3.0)) / ((1.0 * 1.0) + (exp((log((x * x)) * -1.0)) + (-1.0 / x)))) * x), t_0) * t_2;
	} else if (t_3 <= 2.0) {
		tmp = 1.0 / (exp(x) / t_1);
	} else {
		tmp = fmod(1.0, sqrt(1.0)) * (1.0 - x);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = sqrt(cos(x))
    t_1 = mod(exp(x), t_0)
    t_2 = exp(-x)
    t_3 = t_1 * t_2
    if (t_3 <= 0.0d0) then
        tmp = mod(((((1.0d0 ** 3.0d0) - (((-1.0d0) / x) ** 3.0d0)) / ((1.0d0 * 1.0d0) + (exp((log((x * x)) * (-1.0d0))) + ((-1.0d0) / x)))) * x), t_0) * t_2
    else if (t_3 <= 2.0d0) then
        tmp = 1.0d0 / (exp(x) / t_1)
    else
        tmp = mod(1.0d0, sqrt(1.0d0)) * (1.0d0 - x)
    end if
    code = tmp
end function
def code(x):
	t_0 = math.sqrt(math.cos(x))
	t_1 = math.fmod(math.exp(x), t_0)
	t_2 = math.exp(-x)
	t_3 = t_1 * t_2
	tmp = 0
	if t_3 <= 0.0:
		tmp = math.fmod((((math.pow(1.0, 3.0) - math.pow((-1.0 / x), 3.0)) / ((1.0 * 1.0) + (math.exp((math.log((x * x)) * -1.0)) + (-1.0 / x)))) * x), t_0) * t_2
	elif t_3 <= 2.0:
		tmp = 1.0 / (math.exp(x) / t_1)
	else:
		tmp = math.fmod(1.0, math.sqrt(1.0)) * (1.0 - x)
	return tmp
function code(x)
	t_0 = sqrt(cos(x))
	t_1 = rem(exp(x), t_0)
	t_2 = exp(Float64(-x))
	t_3 = Float64(t_1 * t_2)
	tmp = 0.0
	if (t_3 <= 0.0)
		tmp = Float64(rem(Float64(Float64(Float64((1.0 ^ 3.0) - (Float64(-1.0 / x) ^ 3.0)) / Float64(Float64(1.0 * 1.0) + Float64(exp(Float64(log(Float64(x * x)) * -1.0)) + Float64(-1.0 / x)))) * x), t_0) * t_2);
	elseif (t_3 <= 2.0)
		tmp = Float64(1.0 / Float64(exp(x) / t_1));
	else
		tmp = Float64(rem(1.0, sqrt(1.0)) * Float64(1.0 - x));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, 0], N[(N[With[{TMP1 = N[(N[(N[(N[Power[1, 3], $MachinePrecision] - N[Power[N[(-1 / x), $MachinePrecision], 3], $MachinePrecision]), $MachinePrecision] / N[(N[(1 * 1), $MachinePrecision] + N[(N[Exp[N[(N[Log[N[(x * x), $MachinePrecision]], $MachinePrecision] * -1), $MachinePrecision]], $MachinePrecision] + N[(-1 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$3, 2], N[(1 / N[(N[Exp[x], $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1, TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 - x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
t_1 := \left(\left(e^{x}\right) \bmod t\_0\right)\\
t_2 := e^{-x}\\
t_3 := t\_1 \cdot t\_2\\
\mathbf{if}\;t\_3 \leq 0:\\
\;\;\;\;\left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod t\_0\right) \cdot t\_2\\

\mathbf{elif}\;t\_3 \leq 2:\\
\;\;\;\;\frac{1}{\frac{e^{x}}{t\_1}}\\

\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0

    1. Initial program 12.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Taylor expanded in x around 0

      \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    3. Step-by-step derivation
      1. lower-+.f6491.4%

        \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    4. Applied rewrites91.4%

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

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

        \[\leadsto \left(\left(x + \color{blue}{1}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      3. sum-to-multN/A

        \[\leadsto \left(\left(\left(1 + \frac{1}{x}\right) \cdot \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      4. lower-unsound-*.f64N/A

        \[\leadsto \left(\left(\left(1 + \frac{1}{x}\right) \cdot \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      5. lower-unsound-+.f64N/A

        \[\leadsto \left(\left(\left(1 + \frac{1}{x}\right) \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      6. lower-unsound-/.f6491.7%

        \[\leadsto \left(\left(\left(1 + \frac{1}{x}\right) \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    6. Applied rewrites91.7%

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

        \[\leadsto \left(\left(\left(1 + \frac{1}{x}\right) \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      2. add-flipN/A

        \[\leadsto \left(\left(\left(1 - \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right) \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      3. flip3--N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\mathsf{neg}\left(\frac{1}{x}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      4. lower-unsound-/.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\mathsf{neg}\left(\frac{1}{x}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      5. lower-unsound--.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\mathsf{neg}\left(\frac{1}{x}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      6. lower-unsound-pow.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\mathsf{neg}\left(\frac{1}{x}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      7. lower-unsound-pow.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\mathsf{neg}\left(\frac{1}{x}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      8. lift-/.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\mathsf{neg}\left(\frac{1}{x}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      9. distribute-neg-fracN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{\mathsf{neg}\left(1\right)}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      10. metadata-evalN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      11. lower-/.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      12. lower-unsound-+.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      13. lower-unsound-*.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      14. lower-unsound-*.f32N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      15. lower-*.f32N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1 \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      16. distribute-rgt-neg-inN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + \left(\mathsf{neg}\left(1 \cdot \frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      17. *-lft-identityN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      18. lower-unsound-+.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    8. Applied rewrites91.9%

      \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\frac{-1}{x} \cdot \frac{-1}{x} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\frac{-1}{x} \cdot \frac{-1}{x} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      3. lift-/.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\frac{-1}{x} \cdot \frac{-1}{x} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      4. frac-timesN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\frac{-1 \cdot -1}{x \cdot x} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      5. metadata-evalN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(\frac{1}{x \cdot x} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      6. inv-powN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left({\left(x \cdot x\right)}^{-1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      7. pow-to-expN/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      8. lower-unsound-exp.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      9. lower-unsound-*.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      10. lower-unsound-log.f64N/A

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      11. lower-*.f6492.2%

        \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    10. Applied rewrites92.2%

      \[\leadsto \left(\left(\frac{{1}^{3} - {\left(\frac{-1}{x}\right)}^{3}}{1 \cdot 1 + \left(e^{\log \left(x \cdot x\right) \cdot -1} + \frac{-1}{x}\right)} \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]

    if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2

    1. Initial program 12.5%

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

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

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      3. exp-negN/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
      4. lift-exp.f64N/A

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
      5. lower-/.f6412.5%

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
    3. Applied rewrites12.5%

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

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

        \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
      3. mult-flip-revN/A

        \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
      4. div-flipN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}} \]
      5. lower-unsound-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}} \]
      6. lower-unsound-/.f6412.6%

        \[\leadsto \frac{1}{\color{blue}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}} \]
    5. Applied rewrites12.6%

      \[\leadsto \color{blue}{\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}}} \]

    if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x)))

    1. Initial program 12.5%

      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    2. Taylor expanded in x around 0

      \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
    3. Step-by-step derivation
      1. Applied rewrites84.4%

        \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
      2. Taylor expanded in x around 0

        \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
      3. Step-by-step derivation
        1. Applied rewrites83.6%

          \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
        2. Taylor expanded in x around 0

          \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
        3. Step-by-step derivation
          1. lower-+.f64N/A

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
          2. lower-*.f6483.6%

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
        4. Applied rewrites83.6%

          \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
        5. Step-by-step derivation
          1. lift-+.f64N/A

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
          2. lift-*.f64N/A

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
          3. mul-1-negN/A

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \left(\mathsf{neg}\left(x\right)\right)\right) \]
          4. sub-flip-reverseN/A

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
          5. lower--.f6483.6%

            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
        6. Applied rewrites83.6%

          \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
      4. Recombined 3 regimes into one program.
      5. Add Preprocessing

      Alternative 2: 95.6% accurate, 0.5× speedup?

      \[\begin{array}{l} t_0 := \sqrt{\cos x}\\ t_1 := \sqrt{e^{x + x}}\\ \mathbf{if}\;\left(\left(e^{x}\right) \bmod t\_0\right) \cdot e^{-x} \leq 2:\\ \;\;\;\;\left(t\_1 \bmod t\_0\right) \cdot \frac{1}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\ \end{array} \]
      (FPCore (x)
        :precision binary64
        (let* ((t_0 (sqrt (cos x))) (t_1 (sqrt (exp (+ x x)))))
        (if (<= (* (fmod (exp x) t_0) (exp (- x))) 2)
          (* (fmod t_1 t_0) (/ 1 t_1))
          (* (fmod 1 (sqrt 1)) (- 1 x)))))
      double code(double x) {
      	double t_0 = sqrt(cos(x));
      	double t_1 = sqrt(exp((x + x)));
      	double tmp;
      	if ((fmod(exp(x), t_0) * exp(-x)) <= 2.0) {
      		tmp = fmod(t_1, t_0) * (1.0 / t_1);
      	} else {
      		tmp = fmod(1.0, sqrt(1.0)) * (1.0 - x);
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8) :: t_0
          real(8) :: t_1
          real(8) :: tmp
          t_0 = sqrt(cos(x))
          t_1 = sqrt(exp((x + x)))
          if ((mod(exp(x), t_0) * exp(-x)) <= 2.0d0) then
              tmp = mod(t_1, t_0) * (1.0d0 / t_1)
          else
              tmp = mod(1.0d0, sqrt(1.0d0)) * (1.0d0 - x)
          end if
          code = tmp
      end function
      
      def code(x):
      	t_0 = math.sqrt(math.cos(x))
      	t_1 = math.sqrt(math.exp((x + x)))
      	tmp = 0
      	if (math.fmod(math.exp(x), t_0) * math.exp(-x)) <= 2.0:
      		tmp = math.fmod(t_1, t_0) * (1.0 / t_1)
      	else:
      		tmp = math.fmod(1.0, math.sqrt(1.0)) * (1.0 - x)
      	return tmp
      
      function code(x)
      	t_0 = sqrt(cos(x))
      	t_1 = sqrt(exp(Float64(x + x)))
      	tmp = 0.0
      	if (Float64(rem(exp(x), t_0) * exp(Float64(-x))) <= 2.0)
      		tmp = Float64(rem(t_1, t_0) * Float64(1.0 / t_1));
      	else
      		tmp = Float64(rem(1.0, sqrt(1.0)) * Float64(1.0 - x));
      	end
      	return tmp
      end
      
      code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Exp[N[(x + x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], 2], N[(N[With[{TMP1 = t$95$1, TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1, TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 - x), $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      t_0 := \sqrt{\cos x}\\
      t_1 := \sqrt{e^{x + x}}\\
      \mathbf{if}\;\left(\left(e^{x}\right) \bmod t\_0\right) \cdot e^{-x} \leq 2:\\
      \;\;\;\;\left(t\_1 \bmod t\_0\right) \cdot \frac{1}{t\_1}\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2

        1. Initial program 12.5%

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

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

            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
          3. exp-negN/A

            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
          4. lift-exp.f64N/A

            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
          5. lower-/.f6412.5%

            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
        3. Applied rewrites12.5%

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

            \[\leadsto \left(\color{blue}{\left(e^{x}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          2. exp-fabsN/A

            \[\leadsto \left(\color{blue}{\left(\left|e^{x}\right|\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          3. lift-exp.f64N/A

            \[\leadsto \left(\left(\left|\color{blue}{e^{x}}\right|\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          4. rem-sqrt-square-revN/A

            \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          5. lower-sqrt.f64N/A

            \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          6. lift-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x}} \cdot e^{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          7. lift-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{e^{x} \cdot \color{blue}{e^{x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          8. prod-expN/A

            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          9. lower-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
          10. lower-+.f6412.5%

            \[\leadsto \left(\left(\sqrt{e^{\color{blue}{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
        5. Applied rewrites12.5%

          \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x + x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
        6. Step-by-step derivation
          1. lift-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
          2. exp-fabsN/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{\left|e^{x}\right|}} \]
          3. lift-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\left|\color{blue}{e^{x}}\right|} \]
          4. rem-sqrt-square-revN/A

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

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{\sqrt{e^{x} \cdot e^{x}}}} \]
          6. lift-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\sqrt{\color{blue}{e^{x}} \cdot e^{x}}} \]
          7. lift-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\sqrt{e^{x} \cdot \color{blue}{e^{x}}}} \]
          8. prod-expN/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\sqrt{\color{blue}{e^{x + x}}}} \]
          9. lower-exp.f64N/A

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\sqrt{\color{blue}{e^{x + x}}}} \]
          10. lower-+.f6412.5%

            \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\sqrt{e^{\color{blue}{x + x}}}} \]
        7. Applied rewrites12.5%

          \[\leadsto \left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{\sqrt{e^{x + x}}}} \]

        if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x)))

        1. Initial program 12.5%

          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
        2. Taylor expanded in x around 0

          \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
        3. Step-by-step derivation
          1. Applied rewrites84.4%

            \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
          2. Taylor expanded in x around 0

            \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
          3. Step-by-step derivation
            1. Applied rewrites83.6%

              \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
            2. Taylor expanded in x around 0

              \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
            3. Step-by-step derivation
              1. lower-+.f64N/A

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
              2. lower-*.f6483.6%

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
            4. Applied rewrites83.6%

              \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
            5. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
              2. lift-*.f64N/A

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
              3. mul-1-negN/A

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \left(\mathsf{neg}\left(x\right)\right)\right) \]
              4. sub-flip-reverseN/A

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
              5. lower--.f6483.6%

                \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
            6. Applied rewrites83.6%

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

          Alternative 3: 95.6% accurate, 1.0× speedup?

          \[\begin{array}{l} \mathbf{if}\;x \leq \frac{6530219459687219}{562949953421312}:\\ \;\;\;\;\left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\ \end{array} \]
          (FPCore (x)
            :precision binary64
            (if (<= x 6530219459687219/562949953421312)
            (* (fmod (sqrt (exp (+ x x))) (sqrt (cos x))) (exp (- x)))
            (* (fmod 1 (sqrt 1)) (- 1 x))))
          double code(double x) {
          	double tmp;
          	if (x <= 11.6) {
          		tmp = fmod(sqrt(exp((x + x))), sqrt(cos(x))) * exp(-x);
          	} else {
          		tmp = fmod(1.0, sqrt(1.0)) * (1.0 - x);
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8) :: tmp
              if (x <= 11.6d0) then
                  tmp = mod(sqrt(exp((x + x))), sqrt(cos(x))) * exp(-x)
              else
                  tmp = mod(1.0d0, sqrt(1.0d0)) * (1.0d0 - x)
              end if
              code = tmp
          end function
          
          def code(x):
          	tmp = 0
          	if x <= 11.6:
          		tmp = math.fmod(math.sqrt(math.exp((x + x))), math.sqrt(math.cos(x))) * math.exp(-x)
          	else:
          		tmp = math.fmod(1.0, math.sqrt(1.0)) * (1.0 - x)
          	return tmp
          
          function code(x)
          	tmp = 0.0
          	if (x <= 11.6)
          		tmp = Float64(rem(sqrt(exp(Float64(x + x))), sqrt(cos(x))) * exp(Float64(-x)));
          	else
          		tmp = Float64(rem(1.0, sqrt(1.0)) * Float64(1.0 - x));
          	end
          	return tmp
          end
          
          code[x_] := If[LessEqual[x, 6530219459687219/562949953421312], N[(N[With[{TMP1 = N[Sqrt[N[Exp[N[(x + x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1, TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 - x), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          \mathbf{if}\;x \leq \frac{6530219459687219}{562949953421312}:\\
          \;\;\;\;\left(\left(\sqrt{e^{x + x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < 11.6

            1. Initial program 12.5%

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

                \[\leadsto \left(\color{blue}{\left(e^{x}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              2. exp-fabsN/A

                \[\leadsto \left(\color{blue}{\left(\left|e^{x}\right|\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              3. lift-exp.f64N/A

                \[\leadsto \left(\left(\left|\color{blue}{e^{x}}\right|\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              4. rem-sqrt-square-revN/A

                \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              5. lower-sqrt.f64N/A

                \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              6. lift-exp.f64N/A

                \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x}} \cdot e^{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              7. lift-exp.f64N/A

                \[\leadsto \left(\left(\sqrt{e^{x} \cdot \color{blue}{e^{x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              8. prod-expN/A

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

                \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              10. lower-+.f6412.5%

                \[\leadsto \left(\left(\sqrt{e^{\color{blue}{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
            3. Applied rewrites12.5%

              \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x + x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]

            if 11.6 < x

            1. Initial program 12.5%

              \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
            2. Taylor expanded in x around 0

              \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
            3. Step-by-step derivation
              1. Applied rewrites84.4%

                \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
              2. Taylor expanded in x around 0

                \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
              3. Step-by-step derivation
                1. Applied rewrites83.6%

                  \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                3. Step-by-step derivation
                  1. lower-+.f64N/A

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                  2. lower-*.f6483.6%

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                4. Applied rewrites83.6%

                  \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                5. Step-by-step derivation
                  1. lift-+.f64N/A

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                  2. lift-*.f64N/A

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                  3. mul-1-negN/A

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \left(\mathsf{neg}\left(x\right)\right)\right) \]
                  4. sub-flip-reverseN/A

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                  5. lower--.f6483.6%

                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                6. Applied rewrites83.6%

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

              Alternative 4: 95.6% accurate, 1.0× speedup?

              \[\begin{array}{l} \mathbf{if}\;x \leq \frac{6530219459687219}{562949953421312}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\ \end{array} \]
              (FPCore (x)
                :precision binary64
                (if (<= x 6530219459687219/562949953421312)
                (/ (fmod (exp x) (sqrt (cos x))) (exp x))
                (* (fmod 1 (sqrt 1)) (- 1 x))))
              double code(double x) {
              	double tmp;
              	if (x <= 11.6) {
              		tmp = fmod(exp(x), sqrt(cos(x))) / exp(x);
              	} else {
              		tmp = fmod(1.0, sqrt(1.0)) * (1.0 - x);
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8) :: tmp
                  if (x <= 11.6d0) then
                      tmp = mod(exp(x), sqrt(cos(x))) / exp(x)
                  else
                      tmp = mod(1.0d0, sqrt(1.0d0)) * (1.0d0 - x)
                  end if
                  code = tmp
              end function
              
              def code(x):
              	tmp = 0
              	if x <= 11.6:
              		tmp = math.fmod(math.exp(x), math.sqrt(math.cos(x))) / math.exp(x)
              	else:
              		tmp = math.fmod(1.0, math.sqrt(1.0)) * (1.0 - x)
              	return tmp
              
              function code(x)
              	tmp = 0.0
              	if (x <= 11.6)
              		tmp = Float64(rem(exp(x), sqrt(cos(x))) / exp(x));
              	else
              		tmp = Float64(rem(1.0, sqrt(1.0)) * Float64(1.0 - x));
              	end
              	return tmp
              end
              
              code[x_] := If[LessEqual[x, 6530219459687219/562949953421312], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1, TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 - x), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              \mathbf{if}\;x \leq \frac{6530219459687219}{562949953421312}:\\
              \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\
              
              
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if x < 11.6

                1. Initial program 12.5%

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

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

                    \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                  3. exp-negN/A

                    \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                  4. lift-exp.f64N/A

                    \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
                  5. lower-/.f6412.5%

                    \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                3. Applied rewrites12.5%

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

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

                    \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                  3. mult-flip-revN/A

                    \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
                  4. lower-/.f6412.6%

                    \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]
                5. Applied rewrites12.6%

                  \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}} \]

                if 11.6 < x

                1. Initial program 12.5%

                  \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                2. Taylor expanded in x around 0

                  \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                3. Step-by-step derivation
                  1. Applied rewrites84.4%

                    \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                  2. Taylor expanded in x around 0

                    \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                  3. Step-by-step derivation
                    1. Applied rewrites83.6%

                      \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                    2. Taylor expanded in x around 0

                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                    3. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                      2. lower-*.f6483.6%

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                    4. Applied rewrites83.6%

                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                    5. Step-by-step derivation
                      1. lift-+.f64N/A

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                      2. lift-*.f64N/A

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                      3. mul-1-negN/A

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \left(\mathsf{neg}\left(x\right)\right)\right) \]
                      4. sub-flip-reverseN/A

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                      5. lower--.f6483.6%

                        \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                    6. Applied rewrites83.6%

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

                  Alternative 5: 95.6% accurate, 1.0× speedup?

                  \[\begin{array}{l} \mathbf{if}\;x \leq \frac{6530219459687219}{562949953421312}:\\ \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\ \end{array} \]
                  (FPCore (x)
                    :precision binary64
                    (if (<= x 6530219459687219/562949953421312)
                    (* (fmod (exp x) (sqrt (cos x))) (exp (- x)))
                    (* (fmod 1 (sqrt 1)) (- 1 x))))
                  double code(double x) {
                  	double tmp;
                  	if (x <= 11.6) {
                  		tmp = fmod(exp(x), sqrt(cos(x))) * exp(-x);
                  	} else {
                  		tmp = fmod(1.0, sqrt(1.0)) * (1.0 - x);
                  	}
                  	return tmp;
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      real(8) :: tmp
                      if (x <= 11.6d0) then
                          tmp = mod(exp(x), sqrt(cos(x))) * exp(-x)
                      else
                          tmp = mod(1.0d0, sqrt(1.0d0)) * (1.0d0 - x)
                      end if
                      code = tmp
                  end function
                  
                  def code(x):
                  	tmp = 0
                  	if x <= 11.6:
                  		tmp = math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
                  	else:
                  		tmp = math.fmod(1.0, math.sqrt(1.0)) * (1.0 - x)
                  	return tmp
                  
                  function code(x)
                  	tmp = 0.0
                  	if (x <= 11.6)
                  		tmp = Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x)));
                  	else
                  		tmp = Float64(rem(1.0, sqrt(1.0)) * Float64(1.0 - x));
                  	end
                  	return tmp
                  end
                  
                  code[x_] := If[LessEqual[x, 6530219459687219/562949953421312], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1, TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 - x), $MachinePrecision]), $MachinePrecision]]
                  
                  \begin{array}{l}
                  \mathbf{if}\;x \leq \frac{6530219459687219}{562949953421312}:\\
                  \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if x < 11.6

                    1. Initial program 12.5%

                      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]

                    if 11.6 < x

                    1. Initial program 12.5%

                      \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                    2. Taylor expanded in x around 0

                      \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                    3. Step-by-step derivation
                      1. Applied rewrites84.4%

                        \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      2. Taylor expanded in x around 0

                        \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                      3. Step-by-step derivation
                        1. Applied rewrites83.6%

                          \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                        3. Step-by-step derivation
                          1. lower-+.f64N/A

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                          2. lower-*.f6483.6%

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                        4. Applied rewrites83.6%

                          \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                        5. Step-by-step derivation
                          1. lift-+.f64N/A

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                          2. lift-*.f64N/A

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                          3. mul-1-negN/A

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \left(\mathsf{neg}\left(x\right)\right)\right) \]
                          4. sub-flip-reverseN/A

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                          5. lower--.f6483.6%

                            \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                        6. Applied rewrites83.6%

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

                      Alternative 6: 94.9% accurate, 1.2× speedup?

                      \[\begin{array}{l} t_0 := \frac{-1}{4} \cdot \left(x \cdot x\right)\\ t_1 := e^{-x}\\ \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\ \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{t\_0}\right) \cdot t\_0\right)\right) \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\sqrt{1 + 2 \cdot x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_1\\ \end{array} \]
                      (FPCore (x)
                        :precision binary64
                        (let* ((t_0 (* -1/4 (* x x))) (t_1 (exp (- x))))
                        (if (<= x 6530219459687219/1125899906842624)
                          (* (fmod (exp x) (* (+ 1 (/ 1 t_0)) t_0)) t_1)
                          (* (fmod (sqrt (+ 1 (* 2 x))) (sqrt (cos x))) t_1))))
                      double code(double x) {
                      	double t_0 = -0.25 * (x * x);
                      	double t_1 = exp(-x);
                      	double tmp;
                      	if (x <= 5.8) {
                      		tmp = fmod(exp(x), ((1.0 + (1.0 / t_0)) * t_0)) * t_1;
                      	} else {
                      		tmp = fmod(sqrt((1.0 + (2.0 * x))), sqrt(cos(x))) * t_1;
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8) :: t_0
                          real(8) :: t_1
                          real(8) :: tmp
                          t_0 = (-0.25d0) * (x * x)
                          t_1 = exp(-x)
                          if (x <= 5.8d0) then
                              tmp = mod(exp(x), ((1.0d0 + (1.0d0 / t_0)) * t_0)) * t_1
                          else
                              tmp = mod(sqrt((1.0d0 + (2.0d0 * x))), sqrt(cos(x))) * t_1
                          end if
                          code = tmp
                      end function
                      
                      def code(x):
                      	t_0 = -0.25 * (x * x)
                      	t_1 = math.exp(-x)
                      	tmp = 0
                      	if x <= 5.8:
                      		tmp = math.fmod(math.exp(x), ((1.0 + (1.0 / t_0)) * t_0)) * t_1
                      	else:
                      		tmp = math.fmod(math.sqrt((1.0 + (2.0 * x))), math.sqrt(math.cos(x))) * t_1
                      	return tmp
                      
                      function code(x)
                      	t_0 = Float64(-0.25 * Float64(x * x))
                      	t_1 = exp(Float64(-x))
                      	tmp = 0.0
                      	if (x <= 5.8)
                      		tmp = Float64(rem(exp(x), Float64(Float64(1.0 + Float64(1.0 / t_0)) * t_0)) * t_1);
                      	else
                      		tmp = Float64(rem(sqrt(Float64(1.0 + Float64(2.0 * x))), sqrt(cos(x))) * t_1);
                      	end
                      	return tmp
                      end
                      
                      code[x_] := Block[{t$95$0 = N[(-1/4 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, 6530219459687219/1125899906842624], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(1 + N[(1 / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[With[{TMP1 = N[Sqrt[N[(1 + N[(2 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      t_0 := \frac{-1}{4} \cdot \left(x \cdot x\right)\\
                      t_1 := e^{-x}\\
                      \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\
                      \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{t\_0}\right) \cdot t\_0\right)\right) \cdot t\_1\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(\sqrt{1 + 2 \cdot x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_1\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 5.7999999999999998

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{\frac{-1}{4} \cdot {x}^{2}}\right)\right) \cdot e^{-x} \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot \color{blue}{{x}^{2}}\right)\right) \cdot e^{-x} \]
                          3. lower-pow.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{\color{blue}{2}}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites11.7%

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

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} + \color{blue}{1}\right)\right) \cdot e^{-x} \]
                          3. sum-to-multN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot {x}^{2}}\right) \cdot \color{blue}{\left(\frac{-1}{4} \cdot {x}^{2}\right)}\right)\right) \cdot e^{-x} \]
                          4. lower-unsound-*.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot {x}^{2}}\right) \cdot \color{blue}{\left(\frac{-1}{4} \cdot {x}^{2}\right)}\right)\right) \cdot e^{-x} \]
                          5. lower-unsound-+.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot {x}^{2}}\right) \cdot \left(\color{blue}{\frac{-1}{4}} \cdot {x}^{2}\right)\right)\right) \cdot e^{-x} \]
                          6. lower-unsound-/.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot {x}^{2}}\right) \cdot \left(\frac{-1}{4} \cdot {x}^{2}\right)\right)\right) \cdot e^{-x} \]
                          7. lift-pow.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot {x}^{2}}\right) \cdot \left(\frac{-1}{4} \cdot {x}^{2}\right)\right)\right) \cdot e^{-x} \]
                          8. unpow2N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot \left(x \cdot x\right)}\right) \cdot \left(\frac{-1}{4} \cdot {x}^{2}\right)\right)\right) \cdot e^{-x} \]
                          9. lower-*.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot \left(x \cdot x\right)}\right) \cdot \left(\frac{-1}{4} \cdot {x}^{2}\right)\right)\right) \cdot e^{-x} \]
                          10. lift-pow.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot \left(x \cdot x\right)}\right) \cdot \left(\frac{-1}{4} \cdot {x}^{\color{blue}{2}}\right)\right)\right) \cdot e^{-x} \]
                          11. unpow2N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot \left(x \cdot x\right)}\right) \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \color{blue}{x}\right)\right)\right)\right) \cdot e^{-x} \]
                          12. lower-*.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot \left(x \cdot x\right)}\right) \cdot \left(\frac{-1}{4} \cdot \left(x \cdot \color{blue}{x}\right)\right)\right)\right) \cdot e^{-x} \]
                        6. Applied rewrites11.7%

                          \[\leadsto \left(\left(e^{x}\right) \bmod \left(\left(1 + \frac{1}{\frac{-1}{4} \cdot \left(x \cdot x\right)}\right) \cdot \color{blue}{\left(\frac{-1}{4} \cdot \left(x \cdot x\right)\right)}\right)\right) \cdot e^{-x} \]

                        if 5.7999999999999998 < x

                        1. Initial program 12.5%

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

                            \[\leadsto \left(\color{blue}{\left(e^{x}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          2. exp-fabsN/A

                            \[\leadsto \left(\color{blue}{\left(\left|e^{x}\right|\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          3. lift-exp.f64N/A

                            \[\leadsto \left(\left(\left|\color{blue}{e^{x}}\right|\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          4. rem-sqrt-square-revN/A

                            \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          5. lower-sqrt.f64N/A

                            \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          6. lift-exp.f64N/A

                            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x}} \cdot e^{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          7. lift-exp.f64N/A

                            \[\leadsto \left(\left(\sqrt{e^{x} \cdot \color{blue}{e^{x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          8. prod-expN/A

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

                            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          10. lower-+.f6412.5%

                            \[\leadsto \left(\left(\sqrt{e^{\color{blue}{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        3. Applied rewrites12.5%

                          \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x + x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        4. Taylor expanded in x around 0

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

                            \[\leadsto \left(\left(\sqrt{1 + \color{blue}{2 \cdot x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          2. lower-*.f6491.2%

                            \[\leadsto \left(\left(\sqrt{1 + 2 \cdot \color{blue}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        6. Applied rewrites91.2%

                          \[\leadsto \left(\left(\sqrt{\color{blue}{1 + 2 \cdot x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 7: 94.8% accurate, 1.2× speedup?

                      \[\begin{array}{l} \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\sqrt{1 + 2 \cdot x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\ \end{array} \]
                      (FPCore (x)
                        :precision binary64
                        (if (<= x 6530219459687219/1125899906842624)
                        (/ (fmod (exp x) (- (* -1/4 (* x x)) -1)) (exp x))
                        (* (fmod (sqrt (+ 1 (* 2 x))) (sqrt (cos x))) (exp (- x)))))
                      double code(double x) {
                      	double tmp;
                      	if (x <= 5.8) {
                      		tmp = fmod(exp(x), ((-0.25 * (x * x)) - -1.0)) / exp(x);
                      	} else {
                      		tmp = fmod(sqrt((1.0 + (2.0 * x))), sqrt(cos(x))) * exp(-x);
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8) :: tmp
                          if (x <= 5.8d0) then
                              tmp = mod(exp(x), (((-0.25d0) * (x * x)) - (-1.0d0))) / exp(x)
                          else
                              tmp = mod(sqrt((1.0d0 + (2.0d0 * x))), sqrt(cos(x))) * exp(-x)
                          end if
                          code = tmp
                      end function
                      
                      def code(x):
                      	tmp = 0
                      	if x <= 5.8:
                      		tmp = math.fmod(math.exp(x), ((-0.25 * (x * x)) - -1.0)) / math.exp(x)
                      	else:
                      		tmp = math.fmod(math.sqrt((1.0 + (2.0 * x))), math.sqrt(math.cos(x))) * math.exp(-x)
                      	return tmp
                      
                      function code(x)
                      	tmp = 0.0
                      	if (x <= 5.8)
                      		tmp = Float64(rem(exp(x), Float64(Float64(-0.25 * Float64(x * x)) - -1.0)) / exp(x));
                      	else
                      		tmp = Float64(rem(sqrt(Float64(1.0 + Float64(2.0 * x))), sqrt(cos(x))) * exp(Float64(-x)));
                      	end
                      	return tmp
                      end
                      
                      code[x_] := If[LessEqual[x, 6530219459687219/1125899906842624], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(-1/4 * N[(x * x), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[Sqrt[N[(1 + N[(2 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]
                      
                      \begin{array}{l}
                      \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\
                      \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(\sqrt{1 + 2 \cdot x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 5.7999999999999998

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{\frac{-1}{4} \cdot {x}^{2}}\right)\right) \cdot e^{-x} \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot \color{blue}{{x}^{2}}\right)\right) \cdot e^{-x} \]
                          3. lower-pow.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{\color{blue}{2}}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites11.7%

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

                            \[\leadsto \color{blue}{\left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right) \cdot e^{-x}} \]
                          2. lift-exp.f64N/A

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                          4. exp-negN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                          5. mult-flip-revN/A

                            \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right)}{e^{x}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right)}{e^{x}}} \]
                          7. lift-+.f64N/A

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

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} + \color{blue}{1}\right)\right)}{e^{x}} \]
                          9. add-flipN/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)}{e^{x}} \]
                          10. metadata-evalN/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - -1\right)\right)}{e^{x}} \]
                          11. lower--.f64N/A

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

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - -1\right)\right)}{e^{x}} \]
                          13. unpow2N/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}} \]
                          14. lower-*.f64N/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}} \]
                          15. lower-*.f64N/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{\mathsf{Rewrite<=}\left(lift-exp.f64, \left(e^{x}\right)\right)} \]
                        6. Applied rewrites11.8%

                          \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}}} \]

                        if 5.7999999999999998 < x

                        1. Initial program 12.5%

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

                            \[\leadsto \left(\color{blue}{\left(e^{x}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          2. exp-fabsN/A

                            \[\leadsto \left(\color{blue}{\left(\left|e^{x}\right|\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          3. lift-exp.f64N/A

                            \[\leadsto \left(\left(\left|\color{blue}{e^{x}}\right|\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          4. rem-sqrt-square-revN/A

                            \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          5. lower-sqrt.f64N/A

                            \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x} \cdot e^{x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          6. lift-exp.f64N/A

                            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x}} \cdot e^{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          7. lift-exp.f64N/A

                            \[\leadsto \left(\left(\sqrt{e^{x} \cdot \color{blue}{e^{x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          8. prod-expN/A

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

                            \[\leadsto \left(\left(\sqrt{\color{blue}{e^{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          10. lower-+.f6412.5%

                            \[\leadsto \left(\left(\sqrt{e^{\color{blue}{x + x}}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        3. Applied rewrites12.5%

                          \[\leadsto \left(\color{blue}{\left(\sqrt{e^{x + x}}\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        4. Taylor expanded in x around 0

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

                            \[\leadsto \left(\left(\sqrt{1 + \color{blue}{2 \cdot x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          2. lower-*.f6491.2%

                            \[\leadsto \left(\left(\sqrt{1 + 2 \cdot \color{blue}{x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        6. Applied rewrites91.2%

                          \[\leadsto \left(\left(\sqrt{\color{blue}{1 + 2 \cdot x}}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 8: 94.8% accurate, 1.3× speedup?

                      \[\begin{array}{l} \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\ \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\ \end{array} \]
                      (FPCore (x)
                        :precision binary64
                        (if (<= x 6530219459687219/1125899906842624)
                        (/ (fmod (exp x) (- (* -1/4 (* x x)) -1)) (exp x))
                        (* (fmod (+ 1 x) (sqrt (cos x))) (exp (- x)))))
                      double code(double x) {
                      	double tmp;
                      	if (x <= 5.8) {
                      		tmp = fmod(exp(x), ((-0.25 * (x * x)) - -1.0)) / exp(x);
                      	} else {
                      		tmp = fmod((1.0 + x), sqrt(cos(x))) * exp(-x);
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8) :: tmp
                          if (x <= 5.8d0) then
                              tmp = mod(exp(x), (((-0.25d0) * (x * x)) - (-1.0d0))) / exp(x)
                          else
                              tmp = mod((1.0d0 + x), sqrt(cos(x))) * exp(-x)
                          end if
                          code = tmp
                      end function
                      
                      def code(x):
                      	tmp = 0
                      	if x <= 5.8:
                      		tmp = math.fmod(math.exp(x), ((-0.25 * (x * x)) - -1.0)) / math.exp(x)
                      	else:
                      		tmp = math.fmod((1.0 + x), math.sqrt(math.cos(x))) * math.exp(-x)
                      	return tmp
                      
                      function code(x)
                      	tmp = 0.0
                      	if (x <= 5.8)
                      		tmp = Float64(rem(exp(x), Float64(Float64(-0.25 * Float64(x * x)) - -1.0)) / exp(x));
                      	else
                      		tmp = Float64(rem(Float64(1.0 + x), sqrt(cos(x))) * exp(Float64(-x)));
                      	end
                      	return tmp
                      end
                      
                      code[x_] := If[LessEqual[x, 6530219459687219/1125899906842624], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(-1/4 * N[(x * x), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]
                      
                      \begin{array}{l}
                      \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\
                      \;\;\;\;\frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 5.7999999999999998

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{\frac{-1}{4} \cdot {x}^{2}}\right)\right) \cdot e^{-x} \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot \color{blue}{{x}^{2}}\right)\right) \cdot e^{-x} \]
                          3. lower-pow.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{\color{blue}{2}}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites11.7%

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

                            \[\leadsto \color{blue}{\left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right) \cdot e^{-x}} \]
                          2. lift-exp.f64N/A

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                          4. exp-negN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                          5. mult-flip-revN/A

                            \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right)}{e^{x}}} \]
                          6. lower-/.f64N/A

                            \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{2}\right)\right)}{e^{x}}} \]
                          7. lift-+.f64N/A

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

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} + \color{blue}{1}\right)\right)}{e^{x}} \]
                          9. add-flipN/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)}{e^{x}} \]
                          10. metadata-evalN/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - -1\right)\right)}{e^{x}} \]
                          11. lower--.f64N/A

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

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - -1\right)\right)}{e^{x}} \]
                          13. unpow2N/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}} \]
                          14. lower-*.f64N/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}} \]
                          15. lower-*.f64N/A

                            \[\leadsto \frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{\mathsf{Rewrite<=}\left(lift-exp.f64, \left(e^{x}\right)\right)} \]
                        6. Applied rewrites11.8%

                          \[\leadsto \color{blue}{\frac{\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right)}{e^{x}}} \]

                        if 5.7999999999999998 < x

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        3. Step-by-step derivation
                          1. lower-+.f6491.4%

                            \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites91.4%

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 9: 94.7% accurate, 1.3× speedup?

                      \[\begin{array}{l} t_0 := e^{-x}\\ \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\ \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_0\\ \end{array} \]
                      (FPCore (x)
                        :precision binary64
                        (let* ((t_0 (exp (- x))))
                        (if (<= x 6530219459687219/1125899906842624)
                          (* (fmod (exp x) (- (* -1/4 (* x x)) -1)) t_0)
                          (* (fmod (+ 1 x) (sqrt (cos x))) t_0))))
                      double code(double x) {
                      	double t_0 = exp(-x);
                      	double tmp;
                      	if (x <= 5.8) {
                      		tmp = fmod(exp(x), ((-0.25 * (x * x)) - -1.0)) * t_0;
                      	} else {
                      		tmp = fmod((1.0 + x), sqrt(cos(x))) * t_0;
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = exp(-x)
                          if (x <= 5.8d0) then
                              tmp = mod(exp(x), (((-0.25d0) * (x * x)) - (-1.0d0))) * t_0
                          else
                              tmp = mod((1.0d0 + x), sqrt(cos(x))) * t_0
                          end if
                          code = tmp
                      end function
                      
                      def code(x):
                      	t_0 = math.exp(-x)
                      	tmp = 0
                      	if x <= 5.8:
                      		tmp = math.fmod(math.exp(x), ((-0.25 * (x * x)) - -1.0)) * t_0
                      	else:
                      		tmp = math.fmod((1.0 + x), math.sqrt(math.cos(x))) * t_0
                      	return tmp
                      
                      function code(x)
                      	t_0 = exp(Float64(-x))
                      	tmp = 0.0
                      	if (x <= 5.8)
                      		tmp = Float64(rem(exp(x), Float64(Float64(-0.25 * Float64(x * x)) - -1.0)) * t_0);
                      	else
                      		tmp = Float64(rem(Float64(1.0 + x), sqrt(cos(x))) * t_0);
                      	end
                      	return tmp
                      end
                      
                      code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, 6530219459687219/1125899906842624], N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(-1/4 * N[(x * x), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      t_0 := e^{-x}\\
                      \mathbf{if}\;x \leq \frac{6530219459687219}{1125899906842624}:\\
                      \;\;\;\;\left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right) \cdot t\_0\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_0\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 5.7999999999999998

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \color{blue}{\frac{-1}{4} \cdot {x}^{2}}\right)\right) \cdot e^{-x} \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot \color{blue}{{x}^{2}}\right)\right) \cdot e^{-x} \]
                          3. lower-pow.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(1 + \frac{-1}{4} \cdot {x}^{\color{blue}{2}}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites11.7%

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

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} + \color{blue}{1}\right)\right) \cdot e^{-x} \]
                          3. add-flipN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right) \cdot e^{-x} \]
                          4. metadata-evalN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - -1\right)\right) \cdot e^{-x} \]
                          5. lower--.f6411.7%

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot {x}^{2} - -1\right)\right) \cdot e^{-x} \]
                          7. unpow2N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right) \cdot e^{-x} \]
                          8. lower-*.f6411.7%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - -1\right)\right) \cdot e^{-x} \]
                        6. Applied rewrites11.7%

                          \[\leadsto \left(\left(e^{x}\right) \bmod \left(\frac{-1}{4} \cdot \left(x \cdot x\right) - \color{blue}{-1}\right)\right) \cdot e^{-x} \]

                        if 5.7999999999999998 < x

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        3. Step-by-step derivation
                          1. lower-+.f6491.4%

                            \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites91.4%

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 10: 94.3% accurate, 1.3× speedup?

                      \[\begin{array}{l} t_0 := 1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\\ t_1 := \sqrt{\cos x}\\ \mathbf{if}\;x \leq 1:\\ \;\;\;\;\left(t\_0 \bmod t\_1\right) \cdot \frac{1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod t\_1\right) \cdot e^{-x}\\ \end{array} \]
                      (FPCore (x)
                        :precision binary64
                        (let* ((t_0 (+ 1 (* x (+ 1 (* x (+ 1/2 (* 1/6 x)))))))
                             (t_1 (sqrt (cos x))))
                        (if (<= x 1)
                          (* (fmod t_0 t_1) (/ 1 t_0))
                          (* (fmod (+ 1 x) t_1) (exp (- x))))))
                      double code(double x) {
                      	double t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (0.16666666666666666 * x)))));
                      	double t_1 = sqrt(cos(x));
                      	double tmp;
                      	if (x <= 1.0) {
                      		tmp = fmod(t_0, t_1) * (1.0 / t_0);
                      	} else {
                      		tmp = fmod((1.0 + x), t_1) * exp(-x);
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8) :: t_0
                          real(8) :: t_1
                          real(8) :: tmp
                          t_0 = 1.0d0 + (x * (1.0d0 + (x * (0.5d0 + (0.16666666666666666d0 * x)))))
                          t_1 = sqrt(cos(x))
                          if (x <= 1.0d0) then
                              tmp = mod(t_0, t_1) * (1.0d0 / t_0)
                          else
                              tmp = mod((1.0d0 + x), t_1) * exp(-x)
                          end if
                          code = tmp
                      end function
                      
                      def code(x):
                      	t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (0.16666666666666666 * x)))))
                      	t_1 = math.sqrt(math.cos(x))
                      	tmp = 0
                      	if x <= 1.0:
                      		tmp = math.fmod(t_0, t_1) * (1.0 / t_0)
                      	else:
                      		tmp = math.fmod((1.0 + x), t_1) * math.exp(-x)
                      	return tmp
                      
                      function code(x)
                      	t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(0.16666666666666666 * x))))))
                      	t_1 = sqrt(cos(x))
                      	tmp = 0.0
                      	if (x <= 1.0)
                      		tmp = Float64(rem(t_0, t_1) * Float64(1.0 / t_0));
                      	else
                      		tmp = Float64(rem(Float64(1.0 + x), t_1) * exp(Float64(-x)));
                      	end
                      	return tmp
                      end
                      
                      code[x_] := Block[{t$95$0 = N[(1 + N[(x * N[(1 + N[(x * N[(1/2 + N[(1/6 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1], N[(N[With[{TMP1 = t$95$0, TMP2 = t$95$1}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = t$95$1}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]]]
                      
                      \begin{array}{l}
                      t_0 := 1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\\
                      t_1 := \sqrt{\cos x}\\
                      \mathbf{if}\;x \leq 1:\\
                      \;\;\;\;\left(t\_0 \bmod t\_1\right) \cdot \frac{1}{t\_0}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(1 + x\right) \bmod t\_1\right) \cdot e^{-x}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 1

                        1. Initial program 12.5%

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

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                          3. exp-negN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                          4. lift-exp.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
                          5. lower-/.f6412.5%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                        3. Applied rewrites12.5%

                          \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                        4. Taylor expanded in x around 0

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

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

                            \[\leadsto \left(\left(1 + x \cdot \color{blue}{\left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          3. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          4. lower-*.f64N/A

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

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{6} \cdot x}\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          6. lower-*.f6436.9%

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \color{blue}{x}\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                        6. Applied rewrites36.9%

                          \[\leadsto \left(\color{blue}{\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                        7. Taylor expanded in x around 0

                          \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]
                        8. Step-by-step derivation
                          1. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \color{blue}{\left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]
                          3. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right)} \]
                          4. lower-*.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + x \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right)} \]
                          5. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{6} \cdot x}\right)\right)} \]
                          6. lower-*.f6412.7%

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \color{blue}{x}\right)\right)} \]
                        9. Applied rewrites12.7%

                          \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]

                        if 1 < x

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        3. Step-by-step derivation
                          1. lower-+.f6491.4%

                            \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites91.4%

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                      3. Recombined 2 regimes into one program.
                      4. Add Preprocessing

                      Alternative 11: 94.3% accurate, 1.5× speedup?

                      \[\begin{array}{l} t_0 := 1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\\ \mathbf{if}\;x \leq \frac{5854679515581645}{4503599627370496}:\\ \;\;\;\;\left(t\_0 \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}\\ \end{array} \]
                      (FPCore (x)
                        :precision binary64
                        (let* ((t_0 (+ 1 (* x (+ 1 (* x (+ 1/2 (* 1/6 x))))))))
                        (if (<= x 5854679515581645/4503599627370496)
                          (* (fmod t_0 (sqrt (cos x))) (/ 1 t_0))
                          (* (fmod (+ 1 x) (sqrt 1)) (exp (- x))))))
                      double code(double x) {
                      	double t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (0.16666666666666666 * x)))));
                      	double tmp;
                      	if (x <= 1.3) {
                      		tmp = fmod(t_0, sqrt(cos(x))) * (1.0 / t_0);
                      	} else {
                      		tmp = fmod((1.0 + x), sqrt(1.0)) * exp(-x);
                      	}
                      	return tmp;
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          real(8) :: t_0
                          real(8) :: tmp
                          t_0 = 1.0d0 + (x * (1.0d0 + (x * (0.5d0 + (0.16666666666666666d0 * x)))))
                          if (x <= 1.3d0) then
                              tmp = mod(t_0, sqrt(cos(x))) * (1.0d0 / t_0)
                          else
                              tmp = mod((1.0d0 + x), sqrt(1.0d0)) * exp(-x)
                          end if
                          code = tmp
                      end function
                      
                      def code(x):
                      	t_0 = 1.0 + (x * (1.0 + (x * (0.5 + (0.16666666666666666 * x)))))
                      	tmp = 0
                      	if x <= 1.3:
                      		tmp = math.fmod(t_0, math.sqrt(math.cos(x))) * (1.0 / t_0)
                      	else:
                      		tmp = math.fmod((1.0 + x), math.sqrt(1.0)) * math.exp(-x)
                      	return tmp
                      
                      function code(x)
                      	t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(x * Float64(0.5 + Float64(0.16666666666666666 * x))))))
                      	tmp = 0.0
                      	if (x <= 1.3)
                      		tmp = Float64(rem(t_0, sqrt(cos(x))) * Float64(1.0 / t_0));
                      	else
                      		tmp = Float64(rem(Float64(1.0 + x), sqrt(1.0)) * exp(Float64(-x)));
                      	end
                      	return tmp
                      end
                      
                      code[x_] := Block[{t$95$0 = N[(1 + N[(x * N[(1 + N[(x * N[(1/2 + N[(1/6 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5854679515581645/4503599627370496], N[(N[With[{TMP1 = t$95$0, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      t_0 := 1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\\
                      \mathbf{if}\;x \leq \frac{5854679515581645}{4503599627370496}:\\
                      \;\;\;\;\left(t\_0 \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{t\_0}\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}\\
                      
                      
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if x < 1.3

                        1. Initial program 12.5%

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

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

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                          3. exp-negN/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                          4. lift-exp.f64N/A

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
                          5. lower-/.f6412.5%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                        3. Applied rewrites12.5%

                          \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                        4. Taylor expanded in x around 0

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

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

                            \[\leadsto \left(\left(1 + x \cdot \color{blue}{\left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          3. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          4. lower-*.f64N/A

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

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{6} \cdot x}\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          6. lower-*.f6436.9%

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \color{blue}{x}\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                        6. Applied rewrites36.9%

                          \[\leadsto \left(\color{blue}{\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                        7. Taylor expanded in x around 0

                          \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]
                        8. Step-by-step derivation
                          1. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]
                          2. lower-*.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \color{blue}{\left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]
                          3. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right)} \]
                          4. lower-*.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + x \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right)} \]
                          5. lower-+.f64N/A

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \color{blue}{\frac{1}{6} \cdot x}\right)\right)} \]
                          6. lower-*.f6412.7%

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \color{blue}{x}\right)\right)} \]
                        9. Applied rewrites12.7%

                          \[\leadsto \left(\left(1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right)}} \]

                        if 1.3 < x

                        1. Initial program 12.5%

                          \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        3. Step-by-step derivation
                          1. lower-+.f6491.4%

                            \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                        4. Applied rewrites91.4%

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

                          \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                        6. Step-by-step derivation
                          1. Applied rewrites91.3%

                            \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                        7. Recombined 2 regimes into one program.
                        8. Add Preprocessing

                        Alternative 12: 94.0% accurate, 1.6× speedup?

                        \[\begin{array}{l} t_0 := 1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\\ \mathbf{if}\;x \leq \frac{5404319552844595}{9007199254740992}:\\ \;\;\;\;\left(t\_0 \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}\\ \end{array} \]
                        (FPCore (x)
                          :precision binary64
                          (let* ((t_0 (+ 1 (* x (+ 1 (* 1/2 x))))))
                          (if (<= x 5404319552844595/9007199254740992)
                            (* (fmod t_0 (sqrt (cos x))) (/ 1 t_0))
                            (* (fmod (+ 1 x) (sqrt 1)) (exp (- x))))))
                        double code(double x) {
                        	double t_0 = 1.0 + (x * (1.0 + (0.5 * x)));
                        	double tmp;
                        	if (x <= 0.6) {
                        		tmp = fmod(t_0, sqrt(cos(x))) * (1.0 / t_0);
                        	} else {
                        		tmp = fmod((1.0 + x), sqrt(1.0)) * exp(-x);
                        	}
                        	return tmp;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(x)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            real(8) :: t_0
                            real(8) :: tmp
                            t_0 = 1.0d0 + (x * (1.0d0 + (0.5d0 * x)))
                            if (x <= 0.6d0) then
                                tmp = mod(t_0, sqrt(cos(x))) * (1.0d0 / t_0)
                            else
                                tmp = mod((1.0d0 + x), sqrt(1.0d0)) * exp(-x)
                            end if
                            code = tmp
                        end function
                        
                        def code(x):
                        	t_0 = 1.0 + (x * (1.0 + (0.5 * x)))
                        	tmp = 0
                        	if x <= 0.6:
                        		tmp = math.fmod(t_0, math.sqrt(math.cos(x))) * (1.0 / t_0)
                        	else:
                        		tmp = math.fmod((1.0 + x), math.sqrt(1.0)) * math.exp(-x)
                        	return tmp
                        
                        function code(x)
                        	t_0 = Float64(1.0 + Float64(x * Float64(1.0 + Float64(0.5 * x))))
                        	tmp = 0.0
                        	if (x <= 0.6)
                        		tmp = Float64(rem(t_0, sqrt(cos(x))) * Float64(1.0 / t_0));
                        	else
                        		tmp = Float64(rem(Float64(1.0 + x), sqrt(1.0)) * exp(Float64(-x)));
                        	end
                        	return tmp
                        end
                        
                        code[x_] := Block[{t$95$0 = N[(1 + N[(x * N[(1 + N[(1/2 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5404319552844595/9007199254740992], N[(N[With[{TMP1 = t$95$0, TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]]
                        
                        \begin{array}{l}
                        t_0 := 1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\\
                        \mathbf{if}\;x \leq \frac{5404319552844595}{9007199254740992}:\\
                        \;\;\;\;\left(t\_0 \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{t\_0}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}\\
                        
                        
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if x < 0.59999999999999998

                          1. Initial program 12.5%

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

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

                              \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                            3. exp-negN/A

                              \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                            4. lift-exp.f64N/A

                              \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
                            5. lower-/.f6412.5%

                              \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                          3. Applied rewrites12.5%

                            \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                          4. Taylor expanded in x around 0

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

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

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

                              \[\leadsto \left(\left(1 + x \cdot \left(1 + \color{blue}{\frac{1}{2} \cdot x}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                            4. lower-*.f6449.9%

                              \[\leadsto \left(\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot \color{blue}{x}\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          6. Applied rewrites49.9%

                            \[\leadsto \left(\color{blue}{\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                          7. Taylor expanded in x around 0

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)}} \]
                          8. Step-by-step derivation
                            1. lower-+.f64N/A

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

                              \[\leadsto \left(\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \color{blue}{\left(1 + \frac{1}{2} \cdot x\right)}} \]
                            3. lower-+.f64N/A

                              \[\leadsto \left(\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + \color{blue}{\frac{1}{2} \cdot x}\right)} \]
                            4. lower-*.f6413.1%

                              \[\leadsto \left(\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x \cdot \left(1 + \frac{1}{2} \cdot \color{blue}{x}\right)} \]
                          9. Applied rewrites13.1%

                            \[\leadsto \left(\left(1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x \cdot \left(1 + \frac{1}{2} \cdot x\right)}} \]

                          if 0.59999999999999998 < x

                          1. Initial program 12.5%

                            \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          2. Taylor expanded in x around 0

                            \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          3. Step-by-step derivation
                            1. lower-+.f6491.4%

                              \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                          4. Applied rewrites91.4%

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

                            \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                          6. Step-by-step derivation
                            1. Applied rewrites91.3%

                              \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                          7. Recombined 2 regimes into one program.
                          8. Add Preprocessing

                          Alternative 13: 93.5% accurate, 1.7× speedup?

                          \[\begin{array}{l} \mathbf{if}\;x \leq \frac{5404319552844595}{9007199254740992}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}\\ \end{array} \]
                          (FPCore (x)
                            :precision binary64
                            (if (<= x 5404319552844595/9007199254740992)
                            (* (fmod (+ 1 x) (sqrt (cos x))) (/ 1 (+ 1 x)))
                            (* (fmod (+ 1 x) (sqrt 1)) (exp (- x)))))
                          double code(double x) {
                          	double tmp;
                          	if (x <= 0.6) {
                          		tmp = fmod((1.0 + x), sqrt(cos(x))) * (1.0 / (1.0 + x));
                          	} else {
                          		tmp = fmod((1.0 + x), sqrt(1.0)) * exp(-x);
                          	}
                          	return tmp;
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(8) function code(x)
                          use fmin_fmax_functions
                              real(8), intent (in) :: x
                              real(8) :: tmp
                              if (x <= 0.6d0) then
                                  tmp = mod((1.0d0 + x), sqrt(cos(x))) * (1.0d0 / (1.0d0 + x))
                              else
                                  tmp = mod((1.0d0 + x), sqrt(1.0d0)) * exp(-x)
                              end if
                              code = tmp
                          end function
                          
                          def code(x):
                          	tmp = 0
                          	if x <= 0.6:
                          		tmp = math.fmod((1.0 + x), math.sqrt(math.cos(x))) * (1.0 / (1.0 + x))
                          	else:
                          		tmp = math.fmod((1.0 + x), math.sqrt(1.0)) * math.exp(-x)
                          	return tmp
                          
                          function code(x)
                          	tmp = 0.0
                          	if (x <= 0.6)
                          		tmp = Float64(rem(Float64(1.0 + x), sqrt(cos(x))) * Float64(1.0 / Float64(1.0 + x)));
                          	else
                          		tmp = Float64(rem(Float64(1.0 + x), sqrt(1.0)) * exp(Float64(-x)));
                          	end
                          	return tmp
                          end
                          
                          code[x_] := If[LessEqual[x, 5404319552844595/9007199254740992], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 / N[(1 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]
                          
                          \begin{array}{l}
                          \mathbf{if}\;x \leq \frac{5404319552844595}{9007199254740992}:\\
                          \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + x}\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}\\
                          
                          
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if x < 0.59999999999999998

                            1. Initial program 12.5%

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

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

                                \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{\color{blue}{\mathsf{neg}\left(x\right)}} \]
                              3. exp-negN/A

                                \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                              4. lift-exp.f64N/A

                                \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{e^{x}}} \]
                              5. lower-/.f6412.5%

                                \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                            3. Applied rewrites12.5%

                              \[\leadsto \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \color{blue}{\frac{1}{e^{x}}} \]
                            4. Taylor expanded in x around 0

                              \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                            5. Step-by-step derivation
                              1. lower-+.f6491.4%

                                \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                            6. Applied rewrites91.4%

                              \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{e^{x}} \]
                            7. Taylor expanded in x around 0

                              \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x}} \]
                            8. Step-by-step derivation
                              1. lower-+.f6415.0%

                                \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{1 + \color{blue}{x}} \]
                            9. Applied rewrites15.0%

                              \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot \frac{1}{\color{blue}{1 + x}} \]

                            if 0.59999999999999998 < x

                            1. Initial program 12.5%

                              \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                            2. Taylor expanded in x around 0

                              \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                            3. Step-by-step derivation
                              1. lower-+.f6491.4%

                                \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                            4. Applied rewrites91.4%

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

                              \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                            6. Step-by-step derivation
                              1. Applied rewrites91.3%

                                \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                            7. Recombined 2 regimes into one program.
                            8. Add Preprocessing

                            Alternative 14: 91.3% accurate, 1.9× speedup?

                            \[\left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x} \]
                            (FPCore (x)
                              :precision binary64
                              (* (fmod (+ 1 x) (sqrt 1)) (exp (- x))))
                            double code(double x) {
                            	return fmod((1.0 + x), sqrt(1.0)) * exp(-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 = mod((1.0d0 + x), sqrt(1.0d0)) * exp(-x)
                            end function
                            
                            def code(x):
                            	return math.fmod((1.0 + x), math.sqrt(1.0)) * math.exp(-x)
                            
                            function code(x)
                            	return Float64(rem(Float64(1.0 + x), sqrt(1.0)) * exp(Float64(-x)))
                            end
                            
                            code[x_] := N[(N[With[{TMP1 = N[(1 + x), $MachinePrecision], TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
                            
                            \left(\left(1 + x\right) \bmod \left(\sqrt{1}\right)\right) \cdot e^{-x}
                            
                            Derivation
                            1. Initial program 12.5%

                              \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                            2. Taylor expanded in x around 0

                              \[\leadsto \left(\color{blue}{\left(1 + x\right)} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                            3. Step-by-step derivation
                              1. lower-+.f6491.4%

                                \[\leadsto \left(\left(1 + \color{blue}{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                            4. Applied rewrites91.4%

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

                              \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                            6. Step-by-step derivation
                              1. Applied rewrites91.3%

                                \[\leadsto \left(\left(1 + x\right) \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                              2. Add Preprocessing

                              Alternative 15: 83.6% accurate, 3.5× speedup?

                              \[\left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right) \]
                              (FPCore (x)
                                :precision binary64
                                (* (fmod 1 (sqrt 1)) (- 1 x)))
                              double code(double x) {
                              	return fmod(1.0, sqrt(1.0)) * (1.0 - 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 = mod(1.0d0, sqrt(1.0d0)) * (1.0d0 - x)
                              end function
                              
                              def code(x):
                              	return math.fmod(1.0, math.sqrt(1.0)) * (1.0 - x)
                              
                              function code(x)
                              	return Float64(rem(1.0, sqrt(1.0)) * Float64(1.0 - x))
                              end
                              
                              code[x_] := N[(N[With[{TMP1 = 1, TMP2 = N[Sqrt[1], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[(1 - x), $MachinePrecision]), $MachinePrecision]
                              
                              \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - x\right)
                              
                              Derivation
                              1. Initial program 12.5%

                                \[\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                              2. Taylor expanded in x around 0

                                \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                              3. Step-by-step derivation
                                1. Applied rewrites84.4%

                                  \[\leadsto \left(\color{blue}{1} \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x} \]
                                2. Taylor expanded in x around 0

                                  \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites83.6%

                                    \[\leadsto \left(1 \bmod \left(\sqrt{\color{blue}{1}}\right)\right) \cdot e^{-x} \]
                                  2. Taylor expanded in x around 0

                                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                                  3. Step-by-step derivation
                                    1. lower-+.f64N/A

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                                    2. lower-*.f6483.6%

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                                  4. Applied rewrites83.6%

                                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \color{blue}{\left(1 + -1 \cdot x\right)} \]
                                  5. Step-by-step derivation
                                    1. lift-+.f64N/A

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \color{blue}{-1 \cdot x}\right) \]
                                    2. lift-*.f64N/A

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + -1 \cdot \color{blue}{x}\right) \]
                                    3. mul-1-negN/A

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 + \left(\mathsf{neg}\left(x\right)\right)\right) \]
                                    4. sub-flip-reverseN/A

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                                    5. lower--.f6483.6%

                                      \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                                  6. Applied rewrites83.6%

                                    \[\leadsto \left(1 \bmod \left(\sqrt{1}\right)\right) \cdot \left(1 - \color{blue}{x}\right) \]
                                  7. Add Preprocessing

                                  Reproduce

                                  ?
                                  herbie shell --seed 2025285 -o generate:evaluate
                                  (FPCore (x)
                                    :name "expfmod (used to be hard to sample)"
                                    :precision binary64
                                    (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))