Average Error: 58.1 → 0.8
Time: 6.7s
Precision: binary64
Cost: 7040
\[\frac{e^{x} - e^{-x}}{2} \]
\[\left(-2 \cdot x + -0.3333333333333333 \cdot {x}^{3}\right) \cdot -0.5 \]
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x)
 :precision binary64
 (* (+ (* -2.0 x) (* -0.3333333333333333 (pow x 3.0))) -0.5))
double code(double x) {
	return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
	return ((-2.0 * x) + (-0.3333333333333333 * pow(x, 3.0))) * -0.5;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (exp(x) - exp(-x)) / 2.0d0
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = (((-2.0d0) * x) + ((-0.3333333333333333d0) * (x ** 3.0d0))) * (-0.5d0)
end function
public static double code(double x) {
	return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
public static double code(double x) {
	return ((-2.0 * x) + (-0.3333333333333333 * Math.pow(x, 3.0))) * -0.5;
}
def code(x):
	return (math.exp(x) - math.exp(-x)) / 2.0
def code(x):
	return ((-2.0 * x) + (-0.3333333333333333 * math.pow(x, 3.0))) * -0.5
function code(x)
	return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0)
end
function code(x)
	return Float64(Float64(Float64(-2.0 * x) + Float64(-0.3333333333333333 * (x ^ 3.0))) * -0.5)
end
function tmp = code(x)
	tmp = (exp(x) - exp(-x)) / 2.0;
end
function tmp = code(x)
	tmp = ((-2.0 * x) + (-0.3333333333333333 * (x ^ 3.0))) * -0.5;
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
code[x_] := N[(N[(N[(-2.0 * x), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]
\frac{e^{x} - e^{-x}}{2}
\left(-2 \cdot x + -0.3333333333333333 \cdot {x}^{3}\right) \cdot -0.5

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.1

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Simplified58.1

    \[\leadsto \color{blue}{\left(e^{-x} - e^{x}\right) \cdot -0.5} \]
    Proof
    (*.f64 (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x)) -1/2): 0 points increase in error, 0 points decrease in error
    (*.f64 (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x)) (Rewrite<= metadata-eval (/.f64 -1 2))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 -1 2) (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-/r/_binary64 (/.f64 -1 (/.f64 2 (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 -1 (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x))) 2)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x)))) 2): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 (exp.f64 (neg.f64 x)) (exp.f64 x)))) 2): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (exp.f64 (neg.f64 x))) (exp.f64 x))) 2): 0 points increase in error, 0 points decrease in error
    (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (exp.f64 (neg.f64 x)))) (exp.f64 x)) 2): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 (exp.f64 x) (neg.f64 (exp.f64 (neg.f64 x))))) 2): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= sub-neg_binary64 (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x)))) 2): 0 points increase in error, 0 points decrease in error
  3. Taylor expanded in x around 0 0.8

    \[\leadsto \color{blue}{\left(-2 \cdot x + -0.3333333333333333 \cdot {x}^{3}\right)} \cdot -0.5 \]
  4. Final simplification0.8

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

Alternatives

Alternative 1
Error1.1
Cost320
\[\left(-2 \cdot x\right) \cdot -0.5 \]
Alternative 2
Error52.0
Cost192
\[x \cdot 0.5 \]
Alternative 3
Error60.6
Cost64
\[0 \]

Error

Reproduce

herbie shell --seed 2022318 
(FPCore (x)
  :name "Hyperbolic sine"
  :precision binary64
  (/ (- (exp x) (exp (- x))) 2.0))