| Alternative 1 | |
|---|---|
| Accuracy | 54.5% |
| Cost | 46729 |
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x) :precision binary64 (/ (* x (/ (+ (pow (* 0.3333333333333333 (* x x)) 3.0) 8.0) 4.0)) 2.0))
double code(double x) {
return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
return (x * ((pow((0.3333333333333333 * (x * x)), 3.0) + 8.0) / 4.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 * ((((0.3333333333333333d0 * (x * x)) ** 3.0d0) + 8.0d0) / 4.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 * ((Math.pow((0.3333333333333333 * (x * x)), 3.0) + 8.0) / 4.0)) / 2.0;
}
def code(x): return (math.exp(x) - math.exp(-x)) / 2.0
def code(x): return (x * ((math.pow((0.3333333333333333 * (x * x)), 3.0) + 8.0) / 4.0)) / 2.0
function code(x) return Float64(Float64(exp(x) - exp(Float64(-x))) / 2.0) end
function code(x) return Float64(Float64(x * Float64(Float64((Float64(0.3333333333333333 * Float64(x * x)) ^ 3.0) + 8.0) / 4.0)) / 2.0) end
function tmp = code(x) tmp = (exp(x) - exp(-x)) / 2.0; end
function tmp = code(x) tmp = (x * ((((0.3333333333333333 * (x * x)) ^ 3.0) + 8.0) / 4.0)) / 2.0; end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
code[x_] := N[(N[(x * N[(N[(N[Power[N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision] + 8.0), $MachinePrecision] / 4.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\frac{e^{x} - e^{-x}}{2}
\frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{4}}{2}
Results
Initial program 48.8%
Taylor expanded in x around 0 86.9%
Applied egg-rr35.8%
[Start]86.9 | \[ \frac{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}{2}
\] |
|---|---|
expm1-log1p-u [=>]71.1 | \[ \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right)\right)}}{2}
\] |
expm1-udef [=>]20.0 | \[ \frac{\color{blue}{e^{\mathsf{log1p}\left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right)} - 1}}{2}
\] |
log1p-udef [=>]20.0 | \[ \frac{e^{\color{blue}{\log \left(1 + \left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right)\right)}} - 1}{2}
\] |
rem-exp-log [=>]35.8 | \[ \frac{\color{blue}{\left(1 + \left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right)\right)} - 1}{2}
\] |
+-commutative [=>]35.8 | \[ \frac{\left(1 + \color{blue}{\left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}\right) - 1}{2}
\] |
fma-def [=>]35.8 | \[ \frac{\left(1 + \color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, 2 \cdot x\right)}\right) - 1}{2}
\] |
add-log-exp [=>]48.3 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\log \left(e^{2 \cdot x}\right)}\right)\right) - 1}{2}
\] |
*-commutative [=>]48.3 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \log \left(e^{\color{blue}{x \cdot 2}}\right)\right)\right) - 1}{2}
\] |
exp-lft-sqr [=>]48.3 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \log \color{blue}{\left(e^{x} \cdot e^{x}\right)}\right)\right) - 1}{2}
\] |
log-prod [=>]48.3 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\log \left(e^{x}\right) + \log \left(e^{x}\right)}\right)\right) - 1}{2}
\] |
add-log-exp [<=]48.3 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{x} + \log \left(e^{x}\right)\right)\right) - 1}{2}
\] |
add-log-exp [<=]35.8 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + \color{blue}{x}\right)\right) - 1}{2}
\] |
Simplified86.9%
[Start]35.8 | \[ \frac{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + x\right)\right) - 1}{2}
\] |
|---|---|
+-commutative [=>]35.8 | \[ \frac{\color{blue}{\left(\mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + x\right) + 1\right)} - 1}{2}
\] |
associate--l+ [=>]86.9 | \[ \frac{\color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + x\right) + \left(1 - 1\right)}}{2}
\] |
metadata-eval [=>]86.9 | \[ \frac{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + x\right) + \color{blue}{0}}{2}
\] |
+-rgt-identity [=>]86.9 | \[ \frac{\color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + x\right)}}{2}
\] |
fma-udef [=>]86.9 | \[ \frac{\color{blue}{0.3333333333333333 \cdot {x}^{3} + \left(x + x\right)}}{2}
\] |
*-commutative [=>]86.9 | \[ \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + \left(x + x\right)}{2}
\] |
unpow3 [=>]86.9 | \[ \frac{\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} \cdot 0.3333333333333333 + \left(x + x\right)}{2}
\] |
associate-*r* [<=]86.9 | \[ \frac{\color{blue}{\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333\right)} + \left(x + x\right)}{2}
\] |
*-commutative [<=]86.9 | \[ \frac{\left(x \cdot x\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot x\right)} + \left(x + x\right)}{2}
\] |
associate-*r* [=>]86.9 | \[ \frac{\color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) \cdot x} + \left(x + x\right)}{2}
\] |
count-2 [=>]86.9 | \[ \frac{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) \cdot x + \color{blue}{2 \cdot x}}{2}
\] |
distribute-rgt-out [=>]86.9 | \[ \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2}
\] |
*-commutative [=>]86.9 | \[ \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2}
\] |
fma-def [=>]86.9 | \[ \frac{x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2}
\] |
Applied egg-rr58.0%
[Start]86.9 | \[ \frac{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}{2}
\] |
|---|---|
fma-udef [=>]86.9 | \[ \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2}
\] |
flip3-+ [=>]58.0 | \[ \frac{x \cdot \color{blue}{\frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + {2}^{3}}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) + \left(2 \cdot 2 - \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot 2\right)}}}{2}
\] |
metadata-eval [=>]58.0 | \[ \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + \color{blue}{8}}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) + \left(2 \cdot 2 - \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot 2\right)}}{2}
\] |
metadata-eval [=>]58.0 | \[ \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) + \left(\color{blue}{4} - \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot 2\right)}}{2}
\] |
Simplified58.0%
[Start]58.0 | \[ \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) + \left(4 - \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot 2\right)}}{2}
\] |
|---|---|
swap-sqr [=>]58.0 | \[ \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{\color{blue}{\left(0.3333333333333333 \cdot 0.3333333333333333\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)} + \left(4 - \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot 2\right)}}{2}
\] |
metadata-eval [=>]58.0 | \[ \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{\color{blue}{0.1111111111111111} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \left(4 - \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot 2\right)}}{2}
\] |
*-commutative [=>]58.0 | \[ \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{0.1111111111111111 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + \left(4 - \color{blue}{2 \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}\right)}}{2}
\] |
Taylor expanded in x around 0 92.8%
Final simplification92.8%
| Alternative 1 | |
|---|---|
| Accuracy | 54.5% |
| Cost | 46729 |
| Alternative 2 | |
|---|---|
| Accuracy | 54.5% |
| Cost | 39433 |
| Alternative 3 | |
|---|---|
| Accuracy | 36.7% |
| Cost | 1865 |
| Alternative 4 | |
|---|---|
| Accuracy | 36.7% |
| Cost | 841 |
| Alternative 5 | |
|---|---|
| Accuracy | 83.2% |
| Cost | 832 |
| Alternative 6 | |
|---|---|
| Accuracy | 83.2% |
| Cost | 704 |
| Alternative 7 | |
|---|---|
| Accuracy | 52.0% |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Accuracy | 2.9% |
| Cost | 64 |
| Alternative 9 | |
|---|---|
| Accuracy | 3.4% |
| Cost | 64 |
herbie shell --seed 2023159
(FPCore (x)
:name "Hyperbolic sine"
:precision binary64
(/ (- (exp x) (exp (- x))) 2.0))