ENA, Section 1.4, Exercise 1

Percentage Accurate: 94.4% → 99.3%
Time: 13.0s
Alternatives: 14
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 14 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.3% accurate, 0.5× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}^{x} \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
  6. Step-by-step derivation
    1. sqrt-unprod98.0%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
    2. pow1/298.0%

      \[\leadsto {\color{blue}{\left({\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{0.5}\right)}}^{x} \cdot \cos x \]
    3. pow-prod-down98.0%

      \[\leadsto {\left({\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{0.5}\right)}^{x} \cdot \cos x \]
    4. pow-pow98.0%

      \[\leadsto {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
    5. prod-exp99.2%

      \[\leadsto {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
    6. metadata-eval99.2%

      \[\leadsto {\left({\left(e^{\color{blue}{20}}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
  7. Applied egg-rr99.2%

    \[\leadsto {\color{blue}{\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
  8. Step-by-step derivation
    1. sqr-pow99.1%

      \[\leadsto \color{blue}{\left({\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos x \]
    2. pow-unpow99.1%

      \[\leadsto \left({\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    3. pow-pow99.2%

      \[\leadsto \left(\color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    4. pow-unpow99.2%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    5. pow-pow99.1%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}}\right) \cdot \cos x \]
    6. pow-prod-down99.4%

      \[\leadsto \color{blue}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot \cos x \]
    7. metadata-eval99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\color{blue}{\frac{1}{2}} \cdot \frac{x}{2}\right)} \cdot \cos x \]
    8. associate-/r/96.9%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{1}{\frac{2}{\frac{x}{2}}}\right)}} \cdot \cos x \]
    9. clear-num99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{\frac{x}{2}}{2}\right)}} \cdot \cos x \]
    10. frac-2neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    11. distribute-frac-neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(-\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    12. pow-neg99.2%

      \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}}} \cdot \cos x \]
    13. pow-prod-down99.2%

      \[\leadsto \frac{1}{{\color{blue}{\left({\left(e^{20} \cdot e^{20}\right)}^{x}\right)}}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    14. prod-exp99.2%

      \[\leadsto \frac{1}{{\left({\color{blue}{\left(e^{20 + 20}\right)}}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    15. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{\color{blue}{40}}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    16. frac-2neg99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-\left(-2\right)}\right)}}} \cdot \cos x \]
    17. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{-\color{blue}{-2}}\right)}} \cdot \cos x \]
    18. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{\color{blue}{2}}\right)}} \cdot \cos x \]
  9. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}}} \cdot \cos x \]
  10. Taylor expanded in x around inf 94.1%

    \[\leadsto \color{blue}{\frac{\cos x}{e^{-0.25 \cdot \left(x \cdot \log \left({\left(e^{40}\right)}^{x}\right)\right)}}} \]
  11. Step-by-step derivation
    1. associate-*r*94.1%

      \[\leadsto \frac{\cos x}{e^{\color{blue}{\left(-0.25 \cdot x\right) \cdot \log \left({\left(e^{40}\right)}^{x}\right)}}} \]
    2. *-commutative94.1%

      \[\leadsto \frac{\cos x}{e^{\color{blue}{\left(x \cdot -0.25\right)} \cdot \log \left({\left(e^{40}\right)}^{x}\right)}} \]
    3. log-pow94.6%

      \[\leadsto \frac{\cos x}{e^{\color{blue}{\log \left({\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}\right)}}} \]
    4. rem-exp-log99.3%

      \[\leadsto \frac{\cos x}{\color{blue}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}}} \]
  12. Simplified99.3%

    \[\leadsto \color{blue}{\frac{\cos x}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}}} \]
  13. Final simplification99.3%

    \[\leadsto \frac{\cos x}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}} \]

Alternative 2: 99.2% accurate, 0.5× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}^{x} \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
  6. Step-by-step derivation
    1. sqrt-unprod98.0%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
    2. pow1/298.0%

      \[\leadsto {\color{blue}{\left({\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{0.5}\right)}}^{x} \cdot \cos x \]
    3. pow-prod-down98.0%

      \[\leadsto {\left({\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{0.5}\right)}^{x} \cdot \cos x \]
    4. pow-pow98.0%

      \[\leadsto {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
    5. prod-exp99.2%

      \[\leadsto {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
    6. metadata-eval99.2%

      \[\leadsto {\left({\left(e^{\color{blue}{20}}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
  7. Applied egg-rr99.2%

    \[\leadsto {\color{blue}{\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
  8. Final simplification99.2%

    \[\leadsto \cos x \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \]

Alternative 3: 99.3% accurate, 0.5× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}^{x} \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
  6. Step-by-step derivation
    1. sqrt-unprod98.0%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
    2. pow1/298.0%

      \[\leadsto {\color{blue}{\left({\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{0.5}\right)}}^{x} \cdot \cos x \]
    3. pow-prod-down98.0%

      \[\leadsto {\left({\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{0.5}\right)}^{x} \cdot \cos x \]
    4. pow-pow98.0%

      \[\leadsto {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
    5. prod-exp99.2%

      \[\leadsto {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
    6. metadata-eval99.2%

      \[\leadsto {\left({\left(e^{\color{blue}{20}}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
  7. Applied egg-rr99.2%

    \[\leadsto {\color{blue}{\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
  8. Step-by-step derivation
    1. sqr-pow99.1%

      \[\leadsto \color{blue}{\left({\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos x \]
    2. pow-unpow99.1%

      \[\leadsto \left({\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    3. pow-pow99.2%

      \[\leadsto \left(\color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    4. pow-unpow99.2%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    5. pow-pow99.1%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}}\right) \cdot \cos x \]
    6. pow-prod-down99.4%

      \[\leadsto \color{blue}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot \cos x \]
    7. *-commutative99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x}{2} \cdot 0.5\right)}} \cdot \cos x \]
    8. associate-*l/99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{x \cdot 0.5}{2}\right)}} \cdot \cos x \]
    9. pow-to-exp94.1%

      \[\leadsto \color{blue}{e^{\log \left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right) \cdot \frac{x \cdot 0.5}{2}}} \cdot \cos x \]
    10. pow-prod-down94.1%

      \[\leadsto e^{\log \color{blue}{\left({\left(e^{20} \cdot e^{20}\right)}^{x}\right)} \cdot \frac{x \cdot 0.5}{2}} \cdot \cos x \]
    11. prod-exp94.1%

      \[\leadsto e^{\log \left({\color{blue}{\left(e^{20 + 20}\right)}}^{x}\right) \cdot \frac{x \cdot 0.5}{2}} \cdot \cos x \]
    12. metadata-eval94.1%

      \[\leadsto e^{\log \left({\left(e^{\color{blue}{40}}\right)}^{x}\right) \cdot \frac{x \cdot 0.5}{2}} \cdot \cos x \]
    13. associate-/l*94.1%

      \[\leadsto e^{\log \left({\left(e^{40}\right)}^{x}\right) \cdot \color{blue}{\frac{x}{\frac{2}{0.5}}}} \cdot \cos x \]
    14. div-inv94.1%

      \[\leadsto e^{\log \left({\left(e^{40}\right)}^{x}\right) \cdot \color{blue}{\left(x \cdot \frac{1}{\frac{2}{0.5}}\right)}} \cdot \cos x \]
    15. metadata-eval94.1%

      \[\leadsto e^{\log \left({\left(e^{40}\right)}^{x}\right) \cdot \left(x \cdot \frac{1}{\color{blue}{4}}\right)} \cdot \cos x \]
    16. metadata-eval94.1%

      \[\leadsto e^{\log \left({\left(e^{40}\right)}^{x}\right) \cdot \left(x \cdot \color{blue}{0.25}\right)} \cdot \cos x \]
  9. Applied egg-rr94.1%

    \[\leadsto \color{blue}{e^{\log \left({\left(e^{40}\right)}^{x}\right) \cdot \left(x \cdot 0.25\right)}} \cdot \cos x \]
  10. Step-by-step derivation
    1. exp-to-pow99.2%

      \[\leadsto \color{blue}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot 0.25\right)}} \cdot \cos x \]
  11. Simplified99.2%

    \[\leadsto \color{blue}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot 0.25\right)}} \cdot \cos x \]
  12. Final simplification99.2%

    \[\leadsto \cos x \cdot {\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot 0.25\right)} \]

Alternative 4: 97.9% accurate, 0.5× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

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

    \[\leadsto \cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x} \]

Alternative 5: 95.3% accurate, 0.7× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{\left(\sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \cdot \sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}}\right) \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto \color{blue}{\left(\sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \cdot \sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}}\right)} \cdot \cos x \]
  6. Step-by-step derivation
    1. rem-square-sqrt98.0%

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

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

      \[\leadsto \color{blue}{e^{10 \cdot \left(x \cdot x\right)}} \cdot \cos x \]
    4. *-commutative94.3%

      \[\leadsto e^{\color{blue}{\left(x \cdot x\right) \cdot 10}} \cdot \cos x \]
    5. pow-exp95.4%

      \[\leadsto \color{blue}{{\left(e^{x \cdot x}\right)}^{10}} \cdot \cos x \]
    6. sqr-pow95.4%

      \[\leadsto \color{blue}{\left({\left(e^{x \cdot x}\right)}^{\left(\frac{10}{2}\right)} \cdot {\left(e^{x \cdot x}\right)}^{\left(\frac{10}{2}\right)}\right)} \cdot \cos x \]
    7. pow-prod-down95.4%

      \[\leadsto \color{blue}{{\left(e^{x \cdot x} \cdot e^{x \cdot x}\right)}^{\left(\frac{10}{2}\right)}} \cdot \cos x \]
    8. exp-prod96.4%

      \[\leadsto {\left(\color{blue}{{\left(e^{x}\right)}^{x}} \cdot e^{x \cdot x}\right)}^{\left(\frac{10}{2}\right)} \cdot \cos x \]
    9. exp-prod96.7%

      \[\leadsto {\left({\left(e^{x}\right)}^{x} \cdot \color{blue}{{\left(e^{x}\right)}^{x}}\right)}^{\left(\frac{10}{2}\right)} \cdot \cos x \]
    10. pow-prod-up96.8%

      \[\leadsto {\color{blue}{\left({\left(e^{x}\right)}^{\left(x + x\right)}\right)}}^{\left(\frac{10}{2}\right)} \cdot \cos x \]
    11. metadata-eval96.8%

      \[\leadsto {\left({\left(e^{x}\right)}^{\left(x + x\right)}\right)}^{\color{blue}{5}} \cdot \cos x \]
  7. Applied egg-rr96.8%

    \[\leadsto \color{blue}{{\left({\left(e^{x}\right)}^{\left(x + x\right)}\right)}^{5}} \cdot \cos x \]
  8. Taylor expanded in x around inf 95.5%

    \[\leadsto \color{blue}{{\left(e^{2 \cdot {x}^{2}}\right)}^{5}} \cdot \cos x \]
  9. Step-by-step derivation
    1. exp-prod94.3%

      \[\leadsto \color{blue}{e^{\left(2 \cdot {x}^{2}\right) \cdot 5}} \cdot \cos x \]
    2. unpow294.3%

      \[\leadsto e^{\left(2 \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot 5} \cdot \cos x \]
    3. associate-*r*94.3%

      \[\leadsto e^{\color{blue}{\left(\left(2 \cdot x\right) \cdot x\right)} \cdot 5} \cdot \cos x \]
    4. count-294.3%

      \[\leadsto e^{\left(\color{blue}{\left(x + x\right)} \cdot x\right) \cdot 5} \cdot \cos x \]
    5. rem-log-exp94.3%

      \[\leadsto e^{\left(\left(x + x\right) \cdot \color{blue}{\log \left(e^{x}\right)}\right) \cdot 5} \cdot \cos x \]
    6. log-pow94.3%

      \[\leadsto e^{\color{blue}{\log \left({\left(e^{x}\right)}^{\left(x + x\right)}\right)} \cdot 5} \cdot \cos x \]
    7. *-commutative94.3%

      \[\leadsto e^{\color{blue}{5 \cdot \log \left({\left(e^{x}\right)}^{\left(x + x\right)}\right)}} \cdot \cos x \]
    8. exp-prod95.3%

      \[\leadsto \color{blue}{{\left(e^{5}\right)}^{\log \left({\left(e^{x}\right)}^{\left(x + x\right)}\right)}} \cdot \cos x \]
    9. log-pow95.4%

      \[\leadsto {\left(e^{5}\right)}^{\color{blue}{\left(\left(x + x\right) \cdot \log \left(e^{x}\right)\right)}} \cdot \cos x \]
    10. rem-log-exp95.4%

      \[\leadsto {\left(e^{5}\right)}^{\left(\left(x + x\right) \cdot \color{blue}{x}\right)} \cdot \cos x \]
    11. *-commutative95.4%

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

    \[\leadsto \color{blue}{{\left(e^{5}\right)}^{\left(x \cdot \left(x + x\right)\right)}} \cdot \cos x \]
  11. Final simplification95.4%

    \[\leadsto \cos x \cdot {\left(e^{5}\right)}^{\left(x \cdot \left(x + x\right)\right)} \]

Alternative 6: 95.3% accurate, 0.7× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

      \[\leadsto \color{blue}{e^{10 \cdot \left(x \cdot x\right)} \cdot \cos \left(-x\right)} \]
    3. sqr-neg94.3%

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

      \[\leadsto \color{blue}{{\left(e^{10}\right)}^{\left(\left(-x\right) \cdot \left(-x\right)\right)}} \cdot \cos \left(-x\right) \]
    5. sqr-pow95.4%

      \[\leadsto \color{blue}{\left({\left(e^{10}\right)}^{\left(\frac{\left(-x\right) \cdot \left(-x\right)}{2}\right)} \cdot {\left(e^{10}\right)}^{\left(\frac{\left(-x\right) \cdot \left(-x\right)}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow95.4%

      \[\leadsto \color{blue}{{\left(e^{10}\right)}^{\left(\left(-x\right) \cdot \left(-x\right)\right)}} \cdot \cos \left(-x\right) \]
    7. sqr-neg95.4%

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

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

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

    \[\leadsto \cos x \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]

Alternative 7: 95.3% accurate, 0.7× speedup?

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

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

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

      \[\leadsto \color{blue}{e^{10 \cdot \left(x \cdot x\right)} \cdot \cos \left(-x\right)} \]
    3. sqr-neg94.3%

      \[\leadsto e^{10 \cdot \color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}} \cdot \cos \left(-x\right) \]
    4. *-commutative94.3%

      \[\leadsto e^{\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right) \cdot 10}} \cdot \cos \left(-x\right) \]
    5. exp-prod95.4%

      \[\leadsto \color{blue}{{\left(e^{\left(-x\right) \cdot \left(-x\right)}\right)}^{10}} \cdot \cos \left(-x\right) \]
    6. sqr-neg95.4%

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

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

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

    \[\leadsto \cos x \cdot {\left(e^{x \cdot x}\right)}^{10} \]

Alternative 8: 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}
Derivation
  1. Initial program 94.3%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Final simplification94.3%

    \[\leadsto \cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]

Alternative 9: 9.8% accurate, 2.0× speedup?

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

\\
-20 - \cos -20
\end{array}
Derivation
  1. Initial program 94.3%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}^{x} \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
  6. Step-by-step derivation
    1. sqrt-unprod98.0%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
    2. pow1/298.0%

      \[\leadsto {\color{blue}{\left({\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{0.5}\right)}}^{x} \cdot \cos x \]
    3. pow-prod-down98.0%

      \[\leadsto {\left({\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{0.5}\right)}^{x} \cdot \cos x \]
    4. pow-pow98.0%

      \[\leadsto {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
    5. prod-exp99.2%

      \[\leadsto {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
    6. metadata-eval99.2%

      \[\leadsto {\left({\left(e^{\color{blue}{20}}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
  7. Applied egg-rr99.2%

    \[\leadsto {\color{blue}{\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
  8. Step-by-step derivation
    1. sqr-pow99.1%

      \[\leadsto \color{blue}{\left({\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos x \]
    2. pow-unpow99.1%

      \[\leadsto \left({\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    3. pow-pow99.2%

      \[\leadsto \left(\color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    4. pow-unpow99.2%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    5. pow-pow99.1%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}}\right) \cdot \cos x \]
    6. pow-prod-down99.4%

      \[\leadsto \color{blue}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot \cos x \]
    7. metadata-eval99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\color{blue}{\frac{1}{2}} \cdot \frac{x}{2}\right)} \cdot \cos x \]
    8. associate-/r/96.9%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{1}{\frac{2}{\frac{x}{2}}}\right)}} \cdot \cos x \]
    9. clear-num99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{\frac{x}{2}}{2}\right)}} \cdot \cos x \]
    10. frac-2neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    11. distribute-frac-neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(-\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    12. pow-neg99.2%

      \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}}} \cdot \cos x \]
    13. pow-prod-down99.2%

      \[\leadsto \frac{1}{{\color{blue}{\left({\left(e^{20} \cdot e^{20}\right)}^{x}\right)}}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    14. prod-exp99.2%

      \[\leadsto \frac{1}{{\left({\color{blue}{\left(e^{20 + 20}\right)}}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    15. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{\color{blue}{40}}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    16. frac-2neg99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-\left(-2\right)}\right)}}} \cdot \cos x \]
    17. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{-\color{blue}{-2}}\right)}} \cdot \cos x \]
    18. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{\color{blue}{2}}\right)}} \cdot \cos x \]
  9. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}}} \cdot \cos x \]
  10. Applied egg-rr9.8%

    \[\leadsto \color{blue}{-20 - \cos -20} \]
  11. Final simplification9.8%

    \[\leadsto -20 - \cos -20 \]

Alternative 10: 9.6% accurate, 2.0× speedup?

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

\\
-\cos -20
\end{array}
Derivation
  1. Initial program 94.3%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}^{x} \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
  6. Step-by-step derivation
    1. sqrt-unprod98.0%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
    2. pow1/298.0%

      \[\leadsto {\color{blue}{\left({\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{0.5}\right)}}^{x} \cdot \cos x \]
    3. pow-prod-down98.0%

      \[\leadsto {\left({\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{0.5}\right)}^{x} \cdot \cos x \]
    4. pow-pow98.0%

      \[\leadsto {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
    5. prod-exp99.2%

      \[\leadsto {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
    6. metadata-eval99.2%

      \[\leadsto {\left({\left(e^{\color{blue}{20}}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
  7. Applied egg-rr99.2%

    \[\leadsto {\color{blue}{\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
  8. Step-by-step derivation
    1. sqr-pow99.1%

      \[\leadsto \color{blue}{\left({\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos x \]
    2. pow-unpow99.1%

      \[\leadsto \left({\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    3. pow-pow99.2%

      \[\leadsto \left(\color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    4. pow-unpow99.2%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    5. pow-pow99.1%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}}\right) \cdot \cos x \]
    6. pow-prod-down99.4%

      \[\leadsto \color{blue}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot \cos x \]
    7. metadata-eval99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\color{blue}{\frac{1}{2}} \cdot \frac{x}{2}\right)} \cdot \cos x \]
    8. associate-/r/96.9%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{1}{\frac{2}{\frac{x}{2}}}\right)}} \cdot \cos x \]
    9. clear-num99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{\frac{x}{2}}{2}\right)}} \cdot \cos x \]
    10. frac-2neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    11. distribute-frac-neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(-\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    12. pow-neg99.2%

      \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}}} \cdot \cos x \]
    13. pow-prod-down99.2%

      \[\leadsto \frac{1}{{\color{blue}{\left({\left(e^{20} \cdot e^{20}\right)}^{x}\right)}}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    14. prod-exp99.2%

      \[\leadsto \frac{1}{{\left({\color{blue}{\left(e^{20 + 20}\right)}}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    15. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{\color{blue}{40}}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    16. frac-2neg99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-\left(-2\right)}\right)}}} \cdot \cos x \]
    17. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{-\color{blue}{-2}}\right)}} \cdot \cos x \]
    18. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{\color{blue}{2}}\right)}} \cdot \cos x \]
  9. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}}} \cdot \cos x \]
  10. Applied egg-rr9.6%

    \[\leadsto \color{blue}{\frac{-20}{-\frac{-20}{\cos -20}}} \]
  11. Step-by-step derivation
    1. distribute-neg-frac9.6%

      \[\leadsto \frac{-20}{\color{blue}{\frac{--20}{\cos -20}}} \]
    2. metadata-eval9.6%

      \[\leadsto \frac{-20}{\frac{\color{blue}{20}}{\cos -20}} \]
    3. associate-/r/9.6%

      \[\leadsto \color{blue}{\frac{-20}{20} \cdot \cos -20} \]
    4. metadata-eval9.6%

      \[\leadsto \color{blue}{-1} \cdot \cos -20 \]
    5. neg-mul-19.6%

      \[\leadsto \color{blue}{-\cos -20} \]
  12. Simplified9.6%

    \[\leadsto \color{blue}{-\cos -20} \]
  13. Final simplification9.6%

    \[\leadsto -\cos -20 \]

Alternative 11: 1.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \cos -20 \end{array} \]
(FPCore (x) :precision binary64 (cos -20.0))
double code(double x) {
	return cos(-20.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = cos((-20.0d0))
end function
public static double code(double x) {
	return Math.cos(-20.0);
}
def code(x):
	return math.cos(-20.0)
function code(x)
	return cos(-20.0)
end
function tmp = code(x)
	tmp = cos(-20.0);
end
code[x_] := N[Cos[-20.0], $MachinePrecision]
\begin{array}{l}

\\
\cos -20
\end{array}
Derivation
  1. Initial program 94.3%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}^{x} \cdot \cos x} \]
  5. Applied rewrite-once98.0%

    \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x}} \cdot \sqrt{{\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
  6. Step-by-step derivation
    1. sqrt-unprod98.0%

      \[\leadsto {\color{blue}{\left(\sqrt{{\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}}\right)}}^{x} \cdot \cos x \]
    2. pow1/298.0%

      \[\leadsto {\color{blue}{\left({\left({\left(e^{10}\right)}^{x} \cdot {\left(e^{10}\right)}^{x}\right)}^{0.5}\right)}}^{x} \cdot \cos x \]
    3. pow-prod-down98.0%

      \[\leadsto {\left({\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{x}\right)}}^{0.5}\right)}^{x} \cdot \cos x \]
    4. pow-pow98.0%

      \[\leadsto {\color{blue}{\left({\left(e^{10} \cdot e^{10}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
    5. prod-exp99.2%

      \[\leadsto {\left({\color{blue}{\left(e^{10 + 10}\right)}}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
    6. metadata-eval99.2%

      \[\leadsto {\left({\left(e^{\color{blue}{20}}\right)}^{\left(x \cdot 0.5\right)}\right)}^{x} \cdot \cos x \]
  7. Applied egg-rr99.2%

    \[\leadsto {\color{blue}{\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}}^{x} \cdot \cos x \]
  8. Step-by-step derivation
    1. sqr-pow99.1%

      \[\leadsto \color{blue}{\left({\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos x \]
    2. pow-unpow99.1%

      \[\leadsto \left({\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    3. pow-pow99.2%

      \[\leadsto \left(\color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot {\left({\left(e^{20}\right)}^{\left(x \cdot 0.5\right)}\right)}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    4. pow-unpow99.2%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot {\color{blue}{\left({\left({\left(e^{20}\right)}^{x}\right)}^{0.5}\right)}}^{\left(\frac{x}{2}\right)}\right) \cdot \cos x \]
    5. pow-pow99.1%

      \[\leadsto \left({\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)} \cdot \color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}}\right) \cdot \cos x \]
    6. pow-prod-down99.4%

      \[\leadsto \color{blue}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(0.5 \cdot \frac{x}{2}\right)}} \cdot \cos x \]
    7. metadata-eval99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\color{blue}{\frac{1}{2}} \cdot \frac{x}{2}\right)} \cdot \cos x \]
    8. associate-/r/96.9%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{1}{\frac{2}{\frac{x}{2}}}\right)}} \cdot \cos x \]
    9. clear-num99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{\frac{x}{2}}{2}\right)}} \cdot \cos x \]
    10. frac-2neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    11. distribute-frac-neg99.4%

      \[\leadsto {\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\color{blue}{\left(-\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    12. pow-neg99.2%

      \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{20}\right)}^{x} \cdot {\left(e^{20}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}}} \cdot \cos x \]
    13. pow-prod-down99.2%

      \[\leadsto \frac{1}{{\color{blue}{\left({\left(e^{20} \cdot e^{20}\right)}^{x}\right)}}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    14. prod-exp99.2%

      \[\leadsto \frac{1}{{\left({\color{blue}{\left(e^{20 + 20}\right)}}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    15. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{\color{blue}{40}}\right)}^{x}\right)}^{\left(\frac{\frac{x}{2}}{-2}\right)}} \cdot \cos x \]
    16. frac-2neg99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\color{blue}{\left(\frac{-\frac{x}{2}}{-\left(-2\right)}\right)}}} \cdot \cos x \]
    17. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{-\color{blue}{-2}}\right)}} \cdot \cos x \]
    18. metadata-eval99.2%

      \[\leadsto \frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(\frac{-\frac{x}{2}}{\color{blue}{2}}\right)}} \cdot \cos x \]
  9. Applied egg-rr99.2%

    \[\leadsto \color{blue}{\frac{1}{{\left({\left(e^{40}\right)}^{x}\right)}^{\left(x \cdot -0.25\right)}}} \cdot \cos x \]
  10. Applied egg-rr1.5%

    \[\leadsto \color{blue}{\frac{-20}{\frac{-20}{\cos -20}}} \]
  11. Step-by-step derivation
    1. associate-/r/1.5%

      \[\leadsto \color{blue}{\frac{-20}{-20} \cdot \cos -20} \]
    2. metadata-eval1.5%

      \[\leadsto \color{blue}{1} \cdot \cos -20 \]
    3. *-lft-identity1.5%

      \[\leadsto \color{blue}{\cos -20} \]
  12. Simplified1.5%

    \[\leadsto \color{blue}{\cos -20} \]
  13. Final simplification1.5%

    \[\leadsto \cos -20 \]

Alternative 12: 9.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \cos x \end{array} \]
(FPCore (x) :precision binary64 (cos x))
double code(double x) {
	return cos(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = cos(x)
end function
public static double code(double x) {
	return Math.cos(x);
}
def code(x):
	return math.cos(x)
function code(x)
	return cos(x)
end
function tmp = code(x)
	tmp = cos(x);
end
code[x_] := N[Cos[x], $MachinePrecision]
\begin{array}{l}

\\
\cos x
\end{array}
Derivation
  1. Initial program 94.3%

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

    \[\leadsto \cos x \cdot \color{blue}{1} \]
  3. Final simplification9.6%

    \[\leadsto \cos x \]

Alternative 13: 1.5% accurate, 18.8× speedup?

\[\begin{array}{l} \\ 1 + \left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot 9.5 + 3.1666666666666665\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (+ 1.0 (+ (* (* (* x x) 0.6666666666666666) 9.5) 3.1666666666666665)))
double code(double x) {
	return 1.0 + ((((x * x) * 0.6666666666666666) * 9.5) + 3.1666666666666665);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 + ((((x * x) * 0.6666666666666666d0) * 9.5d0) + 3.1666666666666665d0)
end function
public static double code(double x) {
	return 1.0 + ((((x * x) * 0.6666666666666666) * 9.5) + 3.1666666666666665);
}
def code(x):
	return 1.0 + ((((x * x) * 0.6666666666666666) * 9.5) + 3.1666666666666665)
function code(x)
	return Float64(1.0 + Float64(Float64(Float64(Float64(x * x) * 0.6666666666666666) * 9.5) + 3.1666666666666665))
end
function tmp = code(x)
	tmp = 1.0 + ((((x * x) * 0.6666666666666666) * 9.5) + 3.1666666666666665);
end
code[x_] := N[(1.0 + N[(N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision] * 9.5), $MachinePrecision] + 3.1666666666666665), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot 9.5 + 3.1666666666666665\right)
\end{array}
Derivation
  1. Initial program 94.3%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{\left(\sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \cdot \sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}}\right) \cdot \cos x} \]
  5. Applied rewrite-once98.0%

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

    \[\leadsto \color{blue}{1 + 9.5 \cdot {x}^{2}} \]
  7. Step-by-step derivation
    1. *-commutative1.5%

      \[\leadsto 1 + \color{blue}{{x}^{2} \cdot 9.5} \]
    2. unpow21.5%

      \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot 9.5 \]
    3. associate-*l*1.5%

      \[\leadsto 1 + \color{blue}{x \cdot \left(x \cdot 9.5\right)} \]
  8. Simplified1.5%

    \[\leadsto \color{blue}{1 + x \cdot \left(x \cdot 9.5\right)} \]
  9. Step-by-step derivation
    1. associate-*r*1.5%

      \[\leadsto 1 + \color{blue}{\left(x \cdot x\right) \cdot 9.5} \]
    2. rem-log-exp1.5%

      \[\leadsto 1 + \color{blue}{\log \left(e^{x \cdot x}\right)} \cdot 9.5 \]
    3. rem-3cbrt-lft1.5%

      \[\leadsto 1 + \log \color{blue}{\left(\left(\sqrt[3]{e^{x \cdot x}} \cdot \sqrt[3]{e^{x \cdot x}}\right) \cdot \sqrt[3]{e^{x \cdot x}}\right)} \cdot 9.5 \]
    4. *-commutative1.5%

      \[\leadsto 1 + \color{blue}{9.5 \cdot \log \left(\left(\sqrt[3]{e^{x \cdot x}} \cdot \sqrt[3]{e^{x \cdot x}}\right) \cdot \sqrt[3]{e^{x \cdot x}}\right)} \]
    5. log-prod1.5%

      \[\leadsto 1 + 9.5 \cdot \color{blue}{\left(\log \left(\sqrt[3]{e^{x \cdot x}} \cdot \sqrt[3]{e^{x \cdot x}}\right) + \log \left(\sqrt[3]{e^{x \cdot x}}\right)\right)} \]
    6. distribute-rgt-in1.5%

      \[\leadsto 1 + \color{blue}{\left(\log \left(\sqrt[3]{e^{x \cdot x}} \cdot \sqrt[3]{e^{x \cdot x}}\right) \cdot 9.5 + \log \left(\sqrt[3]{e^{x \cdot x}}\right) \cdot 9.5\right)} \]
  10. Applied egg-rr1.5%

    \[\leadsto 1 + \color{blue}{\left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot 9.5 + \left(x \cdot \left(x \cdot 0.3333333333333333\right)\right) \cdot 9.5\right)} \]
  11. Applied egg-rr1.5%

    \[\leadsto 1 + \left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot 9.5 + \color{blue}{3.1666666666666665}\right) \]
  12. Final simplification1.5%

    \[\leadsto 1 + \left(\left(\left(x \cdot x\right) \cdot 0.6666666666666666\right) \cdot 9.5 + 3.1666666666666665\right) \]

Alternative 14: 1.5% accurate, 29.6× speedup?

\[\begin{array}{l} \\ 1 + x \cdot \left(x \cdot 9.5\right) \end{array} \]
(FPCore (x) :precision binary64 (+ 1.0 (* x (* x 9.5))))
double code(double x) {
	return 1.0 + (x * (x * 9.5));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 + (x * (x * 9.5d0))
end function
public static double code(double x) {
	return 1.0 + (x * (x * 9.5));
}
def code(x):
	return 1.0 + (x * (x * 9.5))
function code(x)
	return Float64(1.0 + Float64(x * Float64(x * 9.5)))
end
function tmp = code(x)
	tmp = 1.0 + (x * (x * 9.5));
end
code[x_] := N[(1.0 + N[(x * N[(x * 9.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + x \cdot \left(x \cdot 9.5\right)
\end{array}
Derivation
  1. Initial program 94.3%

    \[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
  2. Step-by-step derivation
    1. cos-neg94.3%

      \[\leadsto \color{blue}{\cos \left(-x\right)} \cdot e^{10 \cdot \left(x \cdot x\right)} \]
    2. *-commutative94.3%

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

      \[\leadsto e^{\color{blue}{\left(10 \cdot x\right) \cdot x}} \cdot \cos \left(-x\right) \]
    4. exp-prod94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    5. sqr-pow94.8%

      \[\leadsto \color{blue}{\left({\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{10 \cdot x}\right)}^{\left(\frac{x}{2}\right)}\right)} \cdot \cos \left(-x\right) \]
    6. sqr-pow94.9%

      \[\leadsto \color{blue}{{\left(e^{10 \cdot x}\right)}^{x}} \cdot \cos \left(-x\right) \]
    7. exp-prod98.0%

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

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

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt_binary6498.0%

      \[\leadsto \color{blue}{\left(\sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}} \cdot \sqrt{{\left({\left(e^{10}\right)}^{x}\right)}^{x}}\right) \cdot \cos x} \]
  5. Applied rewrite-once98.0%

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

    \[\leadsto \color{blue}{1 + 9.5 \cdot {x}^{2}} \]
  7. Step-by-step derivation
    1. *-commutative1.5%

      \[\leadsto 1 + \color{blue}{{x}^{2} \cdot 9.5} \]
    2. unpow21.5%

      \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot 9.5 \]
    3. associate-*l*1.5%

      \[\leadsto 1 + \color{blue}{x \cdot \left(x \cdot 9.5\right)} \]
  8. Simplified1.5%

    \[\leadsto \color{blue}{1 + x \cdot \left(x \cdot 9.5\right)} \]
  9. Final simplification1.5%

    \[\leadsto 1 + x \cdot \left(x \cdot 9.5\right) \]

Reproduce

?
herbie shell --seed 2023297 
(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)))))