| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 64 |
\[x
\]
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x) :precision binary64 (/ (+ (* x (* x (* x 0.3333333333333333))) (* x 2.0)) 2.0))
double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
return ((x * (x * (x * 0.3333333333333333))) + (x * 2.0)) / 2.0;
}
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 = ((x * (x * (x * 0.3333333333333333d0))) + (x * 2.0d0)) / 2.0d0
end function
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
public static double code(double x) {
return ((x * (x * (x * 0.3333333333333333))) + (x * 2.0)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
def code(x): return ((x * (x * (x * 0.3333333333333333))) + (x * 2.0)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function code(x) return Float64(Float64(Float64(x * Float64(x * Float64(x * 0.3333333333333333))) + Float64(x * 2.0)) / 2.0) end
function tmp = code(x) tmp = (exp(x) - exp(-x)) / 2.0; end
function tmp = code(x) tmp = ((x * (x * (x * 0.3333333333333333))) + (x * 2.0)) / 2.0; end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
code[x_] := N[(N[(N[(x * N[(x * N[(x * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\frac{e^{x} - e^{-x}}{2}
\frac{x \cdot \left(x \cdot \left(x \cdot 0.3333333333333333\right)\right) + x \cdot 2}{2}
Results
Initial program 9.1%
Taylor expanded in x around 0 98.9%
Simplified98.9%
[Start]98.9 | \[ \frac{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}{2}
\] |
|---|---|
unpow3 [=>]98.9 | \[ \frac{2 \cdot x + 0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}}{2}
\] |
associate-*r* [=>]98.9 | \[ \frac{2 \cdot x + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x}}{2}
\] |
distribute-rgt-out [=>]98.9 | \[ \frac{\color{blue}{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}}{2}
\] |
*-commutative [<=]98.9 | \[ \frac{x \cdot \left(2 + \color{blue}{\left(x \cdot x\right) \cdot 0.3333333333333333}\right)}{2}
\] |
+-commutative [<=]98.9 | \[ \frac{x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2}
\] |
associate-*l* [=>]98.9 | \[ \frac{x \cdot \left(\color{blue}{x \cdot \left(x \cdot 0.3333333333333333\right)} + 2\right)}{2}
\] |
fma-def [=>]98.9 | \[ \frac{x \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot 0.3333333333333333, 2\right)}}{2}
\] |
Applied egg-rr98.9%
[Start]98.9 | \[ \frac{x \cdot \mathsf{fma}\left(x, x \cdot 0.3333333333333333, 2\right)}{2}
\] |
|---|---|
fma-udef [=>]98.9 | \[ \frac{x \cdot \color{blue}{\left(x \cdot \left(x \cdot 0.3333333333333333\right) + 2\right)}}{2}
\] |
distribute-rgt-in [=>]98.9 | \[ \frac{\color{blue}{\left(x \cdot \left(x \cdot 0.3333333333333333\right)\right) \cdot x + 2 \cdot x}}{2}
\] |
Final simplification98.9%
| Alternative 1 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 64 |
herbie shell --seed 2023151
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))