| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 320 |
\[\left(-2 \cdot x\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
Results
Initial program 58.1
Simplified58.1
Taylor expanded in x around 0 0.8
Final simplification0.8
| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 320 |
| Alternative 2 | |
|---|---|
| Error | 52.0 |
| Cost | 192 |
| Alternative 3 | |
|---|---|
| Error | 60.6 |
| Cost | 64 |

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