?

Average Error: 29.7 → 0.6
Time: 25.7s
Precision: binary64
Cost: 26688

?

\[\left(e^{x} - 2\right) + e^{-x} \]
\[\left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right) \]
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x)
 :precision binary64
 (+
  (+ (* 0.08333333333333333 (pow x 4.0)) (* 4.96031746031746e-5 (pow x 8.0)))
  (+ (* 0.002777777777777778 (pow x 6.0)) (pow x 2.0))))
double code(double x) {
	return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
	return ((0.08333333333333333 * pow(x, 4.0)) + (4.96031746031746e-5 * pow(x, 8.0))) + ((0.002777777777777778 * pow(x, 6.0)) + pow(x, 2.0));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (exp(x) - 2.0d0) + exp(-x)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((0.08333333333333333d0 * (x ** 4.0d0)) + (4.96031746031746d-5 * (x ** 8.0d0))) + ((0.002777777777777778d0 * (x ** 6.0d0)) + (x ** 2.0d0))
end function
public static double code(double x) {
	return (Math.exp(x) - 2.0) + Math.exp(-x);
}
public static double code(double x) {
	return ((0.08333333333333333 * Math.pow(x, 4.0)) + (4.96031746031746e-5 * Math.pow(x, 8.0))) + ((0.002777777777777778 * Math.pow(x, 6.0)) + Math.pow(x, 2.0));
}
def code(x):
	return (math.exp(x) - 2.0) + math.exp(-x)
def code(x):
	return ((0.08333333333333333 * math.pow(x, 4.0)) + (4.96031746031746e-5 * math.pow(x, 8.0))) + ((0.002777777777777778 * math.pow(x, 6.0)) + math.pow(x, 2.0))
function code(x)
	return Float64(Float64(exp(x) - 2.0) + exp(Float64(-x)))
end
function code(x)
	return Float64(Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(4.96031746031746e-5 * (x ^ 8.0))) + Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + (x ^ 2.0)))
end
function tmp = code(x)
	tmp = (exp(x) - 2.0) + exp(-x);
end
function tmp = code(x)
	tmp = ((0.08333333333333333 * (x ^ 4.0)) + (4.96031746031746e-5 * (x ^ 8.0))) + ((0.002777777777777778 * (x ^ 6.0)) + (x ^ 2.0));
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(4.96031746031746e-5 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(e^{x} - 2\right) + e^{-x}
\left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.7
Target0.0
Herbie0.6
\[4 \cdot {\sinh \left(\frac{x}{2}\right)}^{2} \]

Derivation?

  1. Initial program 29.7

    \[\left(e^{x} - 2\right) + e^{-x} \]
  2. Taylor expanded in x around 0 0.6

    \[\leadsto \color{blue}{0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)} \]
  3. Simplified0.6

    \[\leadsto \color{blue}{\left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right)} \]
    Proof

    [Start]0.6

    \[ 0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right) \]

    rational.json-simplify-41 [<=]0.6

    \[ \color{blue}{\left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right)} \]
  4. Final simplification0.6

    \[\leadsto \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right) + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right) \]

Alternatives

Alternative 1
Error0.6
Cost19968
\[\left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right) + 0.002777777777777778 \cdot {x}^{6} \]
Alternative 2
Error0.8
Cost13248
\[{x}^{2} + 0.08333333333333333 \cdot {x}^{4} \]
Alternative 3
Error1.1
Cost6528
\[{x}^{2} \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (x)
  :name "exp2 (problem 3.3.7)"
  :precision binary64

  :herbie-target
  (* 4.0 (pow (sinh (/ x 2.0)) 2.0))

  (+ (- (exp x) 2.0) (exp (- x))))