Average Error: 3.6 → 0.4
Time: 8.8s
Precision: binary64
Cost: 26048
\[1.99 \leq x \land x \leq 2.01\]
\[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
\[{\left({\left(e^{20}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \cos x \]
(FPCore (x) :precision binary64 (* (cos x) (exp (* 10.0 (* x x)))))
(FPCore (x) :precision binary64 (* (pow (pow (exp 20.0) x) (/ x 2.0)) (cos x)))
double code(double x) {
	return cos(x) * exp((10.0 * (x * x)));
}
double code(double x) {
	return pow(pow(exp(20.0), x), (x / 2.0)) * cos(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = cos(x) * exp((10.0d0 * (x * x)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((exp(20.0d0) ** x) ** (x / 2.0d0)) * cos(x)
end function
public static double code(double x) {
	return Math.cos(x) * Math.exp((10.0 * (x * x)));
}
public static double code(double x) {
	return Math.pow(Math.pow(Math.exp(20.0), x), (x / 2.0)) * Math.cos(x);
}
def code(x):
	return math.cos(x) * math.exp((10.0 * (x * x)))
def code(x):
	return math.pow(math.pow(math.exp(20.0), x), (x / 2.0)) * math.cos(x)
function code(x)
	return Float64(cos(x) * exp(Float64(10.0 * Float64(x * x))))
end
function code(x)
	return Float64(((exp(20.0) ^ x) ^ Float64(x / 2.0)) * cos(x))
end
function tmp = code(x)
	tmp = cos(x) * exp((10.0 * (x * x)));
end
function tmp = code(x)
	tmp = ((exp(20.0) ^ x) ^ (x / 2.0)) * cos(x);
end
code[x_] := N[(N[Cos[x], $MachinePrecision] * N[Exp[N[(10.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[Power[N[Power[N[Exp[20.0], $MachinePrecision], x], $MachinePrecision], N[(x / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]
\cos x \cdot e^{10 \cdot \left(x \cdot x\right)}
{\left({\left(e^{20}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)} \cdot \cos x

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 3.6

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

    \[\leadsto \color{blue}{e^{10 \cdot {x}^{2}} \cdot \cos x} \]
  3. Simplified1.3

    \[\leadsto \color{blue}{{\left({\left(e^{10}\right)}^{x}\right)}^{x} \cdot \cos x} \]
    Proof
    (*.f64 (pow.f64 (pow.f64 (exp.f64 10) x) x) (cos.f64 x)): 0 points increase in error, 0 points decrease in error
    (*.f64 (pow.f64 (Rewrite<= exp-prod_binary64 (exp.f64 (*.f64 10 x))) x) (cos.f64 x)): 211 points increase in error, 39 points decrease in error
    (*.f64 (Rewrite<= exp-prod_binary64 (exp.f64 (*.f64 (*.f64 10 x) x))) (cos.f64 x)): 169 points increase in error, 78 points decrease in error
    (*.f64 (exp.f64 (Rewrite<= associate-*r*_binary64 (*.f64 10 (*.f64 x x)))) (cos.f64 x)): 38 points increase in error, 48 points decrease in error
    (*.f64 (exp.f64 (*.f64 10 (Rewrite<= unpow2_binary64 (pow.f64 x 2)))) (cos.f64 x)): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr3.0

    \[\leadsto \color{blue}{\sqrt{{\left(e^{20}\right)}^{\left(x \cdot x\right)}}} \cdot \cos x \]
  5. Applied egg-rr0.4

    \[\leadsto \color{blue}{{\left({\left(e^{20}\right)}^{x}\right)}^{\left(\frac{x}{2}\right)}} \cdot \cos x \]
  6. Final simplification0.4

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

Alternatives

Alternative 1
Error2.1
Cost25920
\[\cos x \cdot {\left({\left(e^{x}\right)}^{x}\right)}^{10} \]
Alternative 2
Error1.3
Cost25920
\[\cos x \cdot {\left({\left(e^{10}\right)}^{x}\right)}^{x} \]
Alternative 3
Error3.0
Cost19712
\[\cos x \cdot {\left(e^{20}\right)}^{\left(\frac{x \cdot x}{2}\right)} \]
Alternative 4
Error3.1
Cost19584
\[\cos x \cdot {\left(e^{x \cdot x}\right)}^{10} \]
Alternative 5
Error3.1
Cost19584
\[\cos x \cdot {\left(e^{10}\right)}^{\left(x \cdot x\right)} \]
Alternative 6
Error3.6
Cost13248
\[\cos x \cdot e^{x \cdot \left(x \cdot 10\right)} \]
Alternative 7
Error3.6
Cost13248
\[\cos x \cdot e^{10 \cdot \left(x \cdot x\right)} \]
Alternative 8
Error57.8
Cost6464
\[\cos x \]
Alternative 9
Error63.0
Cost64
\[1 \]

Error

Reproduce

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