ENA, Section 1.4, Exercise 1

Percentage Accurate: 94.4% → 99.4%
Time: 12.7s
Alternatives: 23
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 23 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 94.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \cos x \cdot {\left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(-x\right)}\right)}^{-0.5} \end{array} \]
(FPCore (x)
 :precision binary64
 (* (cos x) (pow (pow (pow (exp 20.0) x) (- x)) -0.5)))
double code(double x) {
	return cos(x) * pow(pow(pow(exp(20.0), x), -x), -0.5);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = cos(x) * (((exp(20.0d0) ** x) ** -x) ** (-0.5d0))
end function
public static double code(double x) {
	return Math.cos(x) * Math.pow(Math.pow(Math.pow(Math.exp(20.0), x), -x), -0.5);
}
def code(x):
	return math.cos(x) * math.pow(math.pow(math.pow(math.exp(20.0), x), -x), -0.5)
function code(x)
	return Float64(cos(x) * (((exp(20.0) ^ x) ^ Float64(-x)) ^ -0.5))
end
function tmp = code(x)
	tmp = cos(x) * (((exp(20.0) ^ x) ^ -x) ^ -0.5);
end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], (-x)], $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos x \cdot {\left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(-x\right)}\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 94.3%

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

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

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

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

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

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

      \[\leadsto \cos x \cdot {\left(e^{10} \cdot e^{10}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(2\right)}\right)}} \]
    7. div-invN/A

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

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

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

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

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

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

      \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}\right)}^{\frac{-1}{2}} \]
    4. distribute-rgt-neg-outN/A

      \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\color{blue}{\left(\mathsf{neg}\left(x \cdot x\right)\right)}}\right)}^{\frac{-1}{2}} \]
    5. neg-mul-1N/A

      \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\color{blue}{\left(-1 \cdot \left(x \cdot x\right)\right)}}\right)}^{\frac{-1}{2}} \]
    6. pow-unpowN/A

      \[\leadsto \cos x \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(x \cdot x\right)}\right)}}^{\frac{-1}{2}} \]
    7. remove-double-negN/A

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)\right)}}\right)}^{\frac{-1}{2}} \]
    8. distribute-rgt-neg-outN/A

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

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

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(x\right)\right)}\right)\right)}\right)}^{\frac{-1}{2}} \]
    11. lift-*.f64N/A

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(x\right)\right)}\right)\right)}\right)}^{\frac{-1}{2}} \]
    12. distribute-lft-neg-inN/A

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

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)\right)}\right)}^{\frac{-1}{2}} \]
    14. pow-unpowN/A

      \[\leadsto \cos x \cdot {\color{blue}{\left({\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}}^{\frac{-1}{2}} \]
    15. lower-pow.f64N/A

      \[\leadsto \cos x \cdot {\color{blue}{\left({\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}}^{\frac{-1}{2}} \]
  6. Applied rewrites99.3%

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

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

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

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

      \[\leadsto \cos x \cdot {\left({\left(e^{-20 \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    5. neg-mul-1N/A

      \[\leadsto \cos x \cdot {\left({\left(e^{-20 \cdot \color{blue}{\left(-1 \cdot x\right)}}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    6. associate-*r*N/A

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

      \[\leadsto \cos x \cdot {\left({\left(e^{\color{blue}{20} \cdot x}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    8. rem-log-expN/A

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

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

      \[\leadsto \cos x \cdot {\left({\color{blue}{\left({\left(e^{20}\right)}^{x}\right)}}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    11. rem-log-expN/A

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{\color{blue}{\log \left(e^{20}\right)}}\right)}^{x}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    12. lower-exp.f64N/A

      \[\leadsto \cos x \cdot {\left({\left({\color{blue}{\left(e^{\log \left(e^{20}\right)}\right)}}^{x}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    13. rem-log-exp99.4

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{\color{blue}{20}}\right)}^{x}\right)}^{\left(-x\right)}\right)}^{-0.5} \]
  8. Applied rewrites99.4%

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

Alternative 2: 99.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \cos x \cdot {\left({\left(e^{-20}\right)}^{\left(-x\right)}\right)}^{\left(x \cdot 0.5\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (* (cos x) (pow (pow (exp -20.0) (- x)) (* x 0.5))))
double code(double x) {
	return cos(x) * pow(pow(exp(-20.0), -x), (x * 0.5));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = cos(x) * ((exp((-20.0d0)) ** -x) ** (x * 0.5d0))
end function
public static double code(double x) {
	return Math.cos(x) * Math.pow(Math.pow(Math.exp(-20.0), -x), (x * 0.5));
}
def code(x):
	return math.cos(x) * math.pow(math.pow(math.exp(-20.0), -x), (x * 0.5))
function code(x)
	return Float64(cos(x) * ((exp(-20.0) ^ Float64(-x)) ^ Float64(x * 0.5)))
end
function tmp = code(x)
	tmp = cos(x) * ((exp(-20.0) ^ -x) ^ (x * 0.5));
end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Power[N[Power[N[Exp[-20.0], $MachinePrecision], (-x)], $MachinePrecision], N[(x * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos x \cdot {\left({\left(e^{-20}\right)}^{\left(-x\right)}\right)}^{\left(x \cdot 0.5\right)}
\end{array}
Derivation
  1. Initial program 94.4%

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

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

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

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

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

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

      \[\leadsto \cos x \cdot {\left(e^{10} \cdot e^{10}\right)}^{\color{blue}{\left(\frac{\mathsf{neg}\left(x \cdot x\right)}{\mathsf{neg}\left(2\right)}\right)}} \]
    7. div-invN/A

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

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

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

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

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

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

      \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}\right)}^{\frac{-1}{2}} \]
    4. distribute-rgt-neg-outN/A

      \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\color{blue}{\left(\mathsf{neg}\left(x \cdot x\right)\right)}}\right)}^{\frac{-1}{2}} \]
    5. neg-mul-1N/A

      \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\color{blue}{\left(-1 \cdot \left(x \cdot x\right)\right)}}\right)}^{\frac{-1}{2}} \]
    6. pow-unpowN/A

      \[\leadsto \cos x \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(x \cdot x\right)}\right)}}^{\frac{-1}{2}} \]
    7. remove-double-negN/A

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x \cdot x\right)\right)\right)\right)}}\right)}^{\frac{-1}{2}} \]
    8. distribute-rgt-neg-outN/A

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

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

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(x\right)\right)}\right)\right)}\right)}^{\frac{-1}{2}} \]
    11. lift-*.f64N/A

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(x\right)\right)}\right)\right)}\right)}^{\frac{-1}{2}} \]
    12. distribute-lft-neg-inN/A

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

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)\right)}\right)}^{\frac{-1}{2}} \]
    14. pow-unpowN/A

      \[\leadsto \cos x \cdot {\color{blue}{\left({\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}}^{\frac{-1}{2}} \]
    15. lower-pow.f64N/A

      \[\leadsto \cos x \cdot {\color{blue}{\left({\left({\left({\left(e^{20}\right)}^{-1}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}}^{\frac{-1}{2}} \]
  6. Applied rewrites99.3%

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

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

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

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

      \[\leadsto \cos x \cdot {\left({\left(e^{-20 \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    5. neg-mul-1N/A

      \[\leadsto \cos x \cdot {\left({\left(e^{-20 \cdot \color{blue}{\left(-1 \cdot x\right)}}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    6. associate-*r*N/A

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

      \[\leadsto \cos x \cdot {\left({\left(e^{\color{blue}{20} \cdot x}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    8. rem-log-expN/A

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

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

      \[\leadsto \cos x \cdot {\left({\color{blue}{\left({\left(e^{20}\right)}^{x}\right)}}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    11. rem-log-expN/A

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{\color{blue}{\log \left(e^{20}\right)}}\right)}^{x}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    12. lower-exp.f64N/A

      \[\leadsto \cos x \cdot {\left({\left({\color{blue}{\left(e^{\log \left(e^{20}\right)}\right)}}^{x}\right)}^{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\frac{-1}{2}} \]
    13. rem-log-exp99.4

      \[\leadsto \cos x \cdot {\left({\left({\left(e^{\color{blue}{20}}\right)}^{x}\right)}^{\left(-x\right)}\right)}^{-0.5} \]
  8. Applied rewrites99.4%

    \[\leadsto \cos x \cdot {\left({\color{blue}{\left({\left(e^{20}\right)}^{x}\right)}}^{\left(-x\right)}\right)}^{-0.5} \]
  9. Applied rewrites99.3%

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

Reproduce

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