?

Average Error: 58.8 → 0.5
Time: 6.3s
Precision: binary64
Cost: 13504

?

\[-0.00017 < x\]
\[e^{x} - 1 \]
\[x + \left(0.5 \cdot {x}^{2} + 0.16666666666666666 \cdot {x}^{3}\right) \]
(FPCore (x) :precision binary64 (- (exp x) 1.0))
(FPCore (x)
 :precision binary64
 (+ x (+ (* 0.5 (pow x 2.0)) (* 0.16666666666666666 (pow x 3.0)))))
double code(double x) {
	return exp(x) - 1.0;
}
double code(double x) {
	return x + ((0.5 * pow(x, 2.0)) + (0.16666666666666666 * pow(x, 3.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = exp(x) - 1.0d0
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = x + ((0.5d0 * (x ** 2.0d0)) + (0.16666666666666666d0 * (x ** 3.0d0)))
end function
public static double code(double x) {
	return Math.exp(x) - 1.0;
}
public static double code(double x) {
	return x + ((0.5 * Math.pow(x, 2.0)) + (0.16666666666666666 * Math.pow(x, 3.0)));
}
def code(x):
	return math.exp(x) - 1.0
def code(x):
	return x + ((0.5 * math.pow(x, 2.0)) + (0.16666666666666666 * math.pow(x, 3.0)))
function code(x)
	return Float64(exp(x) - 1.0)
end
function code(x)
	return Float64(x + Float64(Float64(0.5 * (x ^ 2.0)) + Float64(0.16666666666666666 * (x ^ 3.0))))
end
function tmp = code(x)
	tmp = exp(x) - 1.0;
end
function tmp = code(x)
	tmp = x + ((0.5 * (x ^ 2.0)) + (0.16666666666666666 * (x ^ 3.0)));
end
code[x_] := N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]
code[x_] := N[(x + N[(N[(0.5 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
e^{x} - 1
x + \left(0.5 \cdot {x}^{2} + 0.16666666666666666 \cdot {x}^{3}\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original58.8
Target0.5
Herbie0.5
\[x \cdot \left(\left(1 + \frac{x}{2}\right) + \frac{x \cdot x}{6}\right) \]

Derivation?

  1. Initial program 58.8

    \[e^{x} - 1 \]
  2. Taylor expanded in x around 0 0.5

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{3} + \left(0.5 \cdot {x}^{2} + x\right)} \]
  3. Simplified0.5

    \[\leadsto \color{blue}{x + \left(0.5 \cdot {x}^{2} + 0.16666666666666666 \cdot {x}^{3}\right)} \]
    Proof

    [Start]0.5

    \[ 0.16666666666666666 \cdot {x}^{3} + \left(0.5 \cdot {x}^{2} + x\right) \]

    rational.json-simplify-1 [=>]0.5

    \[ 0.16666666666666666 \cdot {x}^{3} + \color{blue}{\left(x + 0.5 \cdot {x}^{2}\right)} \]

    rational.json-simplify-41 [=>]0.5

    \[ \color{blue}{x + \left(0.5 \cdot {x}^{2} + 0.16666666666666666 \cdot {x}^{3}\right)} \]
  4. Final simplification0.5

    \[\leadsto x + \left(0.5 \cdot {x}^{2} + 0.16666666666666666 \cdot {x}^{3}\right) \]

Alternatives

Alternative 1
Error0.6
Cost6784
\[0.5 \cdot {x}^{2} + x \]
Alternative 2
Error1.2
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023074 
(FPCore (x)
  :name "expm1 (example 3.7)"
  :precision binary64
  :pre (< -0.00017 x)

  :herbie-target
  (* x (+ (+ 1.0 (/ x 2.0)) (/ (* x x) 6.0)))

  (- (exp x) 1.0))