| Alternative 1 | |
|---|---|
| Error | 99.3% |
| Cost | 20736.00 |
\[\frac{\left(\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right) + x \cdot 2\right) + \left(\left(2 + 0.0003968253968253968 \cdot {x}^{7}\right) + -2\right)}{2}
\]
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x)
:precision binary64
(/
(+
(+
(+ (* 0.016666666666666666 (pow x 5.0)) (* 0.3333333333333333 (pow x 3.0)))
(* x 2.0))
(+ (exp (log1p (* 0.0003968253968253968 (pow x 7.0)))) -1.0))
2.0))double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
return ((((0.016666666666666666 * pow(x, 5.0)) + (0.3333333333333333 * pow(x, 3.0))) + (x * 2.0)) + (exp(log1p((0.0003968253968253968 * pow(x, 7.0)))) + -1.0)) / 2.0;
}
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / 2.0;
}
public static double code(double x) {
return ((((0.016666666666666666 * Math.pow(x, 5.0)) + (0.3333333333333333 * Math.pow(x, 3.0))) + (x * 2.0)) + (Math.exp(Math.log1p((0.0003968253968253968 * Math.pow(x, 7.0)))) + -1.0)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
def code(x): return ((((0.016666666666666666 * math.pow(x, 5.0)) + (0.3333333333333333 * math.pow(x, 3.0))) + (x * 2.0)) + (math.exp(math.log1p((0.0003968253968253968 * math.pow(x, 7.0)))) + -1.0)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function code(x) return Float64(Float64(Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(0.3333333333333333 * (x ^ 3.0))) + Float64(x * 2.0)) + Float64(exp(log1p(Float64(0.0003968253968253968 * (x ^ 7.0)))) + -1.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[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[Log[1 + N[(0.0003968253968253968 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\frac{e^{x} - e^{-x}}{2}
\frac{\left(\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right) + x \cdot 2\right) + \left(e^{\mathsf{log1p}\left(0.0003968253968253968 \cdot {x}^{7}\right)} + -1\right)}{2}
Results
Initial program 9.3
Taylor expanded in x around 0 99.3
Simplified99.3
[Start]99.3 | \[ \frac{2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}{2}
\] |
|---|---|
associate-+r+ [=>]99.3 | \[ \frac{\color{blue}{\left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right) + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)}}{2}
\] |
+-commutative [=>]99.3 | \[ \frac{\color{blue}{\left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)}{2}
\] |
associate-+l+ [=>]99.3 | \[ \frac{\color{blue}{0.3333333333333333 \cdot {x}^{3} + \left(2 \cdot x + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}}{2}
\] |
fma-def [=>]99.3 | \[ \frac{\color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, 2 \cdot x + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}}{2}
\] |
associate-+r+ [=>]99.3 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\left(2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right) + 0.016666666666666666 \cdot {x}^{5}}\right)}{2}
\] |
+-commutative [<=]99.3 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{2}
\] |
fma-def [=>]99.3 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, 2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{2}
\] |
+-commutative [=>]99.3 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{0.0003968253968253968 \cdot {x}^{7} + 2 \cdot x}\right)\right)}{2}
\] |
fma-def [=>]99.3 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)}\right)\right)}{2}
\] |
Applied egg-rr99.3
[Start]99.3 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)\right)\right)}{2}
\] |
|---|---|
fma-udef [=>]99.3 | \[ \frac{\color{blue}{0.3333333333333333 \cdot {x}^{3} + \mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)\right)}}{2}
\] |
fma-udef [=>]99.3 | \[ \frac{0.3333333333333333 \cdot {x}^{3} + \color{blue}{\left(0.016666666666666666 \cdot {x}^{5} + \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)\right)}}{2}
\] |
associate-+r+ [=>]99.3 | \[ \frac{\color{blue}{\left(0.3333333333333333 \cdot {x}^{3} + 0.016666666666666666 \cdot {x}^{5}\right) + \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)}}{2}
\] |
fma-udef [=>]99.3 | \[ \frac{\left(0.3333333333333333 \cdot {x}^{3} + 0.016666666666666666 \cdot {x}^{5}\right) + \color{blue}{\left(0.0003968253968253968 \cdot {x}^{7} + 2 \cdot x\right)}}{2}
\] |
+-commutative [=>]99.3 | \[ \frac{\left(0.3333333333333333 \cdot {x}^{3} + 0.016666666666666666 \cdot {x}^{5}\right) + \color{blue}{\left(2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}}{2}
\] |
associate-+r+ [=>]99.3 | \[ \frac{\color{blue}{\left(\left(0.3333333333333333 \cdot {x}^{3} + 0.016666666666666666 \cdot {x}^{5}\right) + 2 \cdot x\right) + 0.0003968253968253968 \cdot {x}^{7}}}{2}
\] |
+-commutative [=>]99.3 | \[ \frac{\left(\color{blue}{\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right)} + 2 \cdot x\right) + 0.0003968253968253968 \cdot {x}^{7}}{2}
\] |
*-commutative [=>]99.3 | \[ \frac{\left(\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right) + \color{blue}{x \cdot 2}\right) + 0.0003968253968253968 \cdot {x}^{7}}{2}
\] |
Applied egg-rr99.2
[Start]99.3 | \[ \frac{\left(\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right) + x \cdot 2\right) + 0.0003968253968253968 \cdot {x}^{7}}{2}
\] |
|---|---|
expm1-log1p-u [=>]99.2 | \[ \frac{\left(\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right) + x \cdot 2\right) + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{2}
\] |
expm1-udef [=>]99.2 | \[ \frac{\left(\left(0.016666666666666666 \cdot {x}^{5} + 0.3333333333333333 \cdot {x}^{3}\right) + x \cdot 2\right) + \color{blue}{\left(e^{\mathsf{log1p}\left(0.0003968253968253968 \cdot {x}^{7}\right)} - 1\right)}}{2}
\] |
Final simplification99.2
| Alternative 1 | |
|---|---|
| Error | 99.3% |
| Cost | 20736.00 |
| Alternative 2 | |
|---|---|
| Error | 99.3% |
| Cost | 20480.00 |
| Alternative 3 | |
|---|---|
| Error | 99.3% |
| Cost | 20480.00 |
| Alternative 4 | |
|---|---|
| Error | 99.0% |
| Cost | 7040.00 |
| Alternative 5 | |
|---|---|
| Error | 99.0% |
| Cost | 704.00 |
| Alternative 6 | |
|---|---|
| Error | 98.4% |
| Cost | 320.00 |
| Alternative 7 | |
|---|---|
| Error | 3.8% |
| Cost | 64.00 |
| Alternative 8 | |
|---|---|
| Error | 5.4% |
| Cost | 64.00 |
herbie shell --seed 2023121
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))