?

Average Accuracy: 54.5% → 92.5%
Time: 6.6s
Precision: binary64
Cost: 7296

?

\[\frac{e^{x} - e^{-x}}{2} \]
\[\frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{4}}{2} \]
(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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 48.8%

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Taylor expanded in x around 0 86.9%

    \[\leadsto \frac{\color{blue}{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}}{2} \]
  3. Applied egg-rr35.8%

    \[\leadsto \frac{\color{blue}{\left(1 + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, x + x\right)\right) - 1}}{2} \]
    Step-by-step derivation

    [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} \]
  4. Simplified86.9%

    \[\leadsto \frac{\color{blue}{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
    Step-by-step derivation

    [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} \]
  5. Applied egg-rr58.0%

    \[\leadsto \frac{x \cdot \color{blue}{\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} \]
    Step-by-step derivation

    [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} \]
  6. Simplified58.0%

    \[\leadsto \frac{x \cdot \color{blue}{\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 - 2 \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)\right)}}}{2} \]
    Step-by-step derivation

    [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} \]
  7. Taylor expanded in x around 0 92.8%

    \[\leadsto \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{\color{blue}{4}}}{2} \]
  8. Final simplification92.8%

    \[\leadsto \frac{x \cdot \frac{{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}^{3} + 8}{4}}{2} \]

Alternatives

Alternative 1
Accuracy54.5%
Cost46729
\[\begin{array}{l} t_0 := e^{x} - e^{-x}\\ \mathbf{if}\;t_0 \leq 0.0005 \lor \neg \left(t_0 \leq 0.1\right):\\ \;\;\;\;\frac{t_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2 + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}{2}\\ \end{array} \]
Alternative 2
Accuracy54.5%
Cost39433
\[\begin{array}{l} t_0 := e^{x} - e^{-x}\\ \mathbf{if}\;t_0 \leq 0.0005 \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{t_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2 + x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]
Alternative 3
Accuracy36.7%
Cost1865
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq 10^{+153} \lor \neg \left(x \leq 2 \cdot 10^{+102}\right):\\ \;\;\;\;\frac{x \cdot t_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{t_0 \cdot t_0 - 4}{t_0 - 2}}{2}\\ \end{array} \]
Alternative 4
Accuracy36.7%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq 2.4 \lor \neg \left(x \leq 2.5\right):\\ \;\;\;\;\frac{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{2}\\ \end{array} \]
Alternative 5
Accuracy83.2%
Cost832
\[\frac{x \cdot 2 + x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2} \]
Alternative 6
Accuracy83.2%
Cost704
\[\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2} \]
Alternative 7
Accuracy52.0%
Cost320
\[\frac{x \cdot 2}{2} \]
Alternative 8
Accuracy2.9%
Cost64
\[-1 \]
Alternative 9
Accuracy3.4%
Cost64
\[0 \]

Error

Reproduce?

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