?

Average Error: 32.8 → 0.2
Time: 28.3s
Precision: binary64
Cost: 65664

?

\[\left(0 \leq a \land a \leq 1000000000\right) \land \left(0 \leq x \land x \leq 1000000000\right)\]
\[\left(\left(4 \cdot e^{\left(-a\right) \cdot x} - 3\right) - e^{\left(-2\right) \cdot \left(a \cdot x\right)}\right) + 2 \cdot \left(a \cdot x\right) \]
\[\mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({a}^{3}, {x}^{3} \cdot 0.6666666666666666, \log \left(e^{0.23333333333333334 \cdot {\left(x \cdot a\right)}^{5}}\right)\right)\right)\right) \]
(FPCore (a x)
 :precision binary64
 (+
  (- (- (* 4.0 (exp (* (- a) x))) 3.0) (exp (* (- 2.0) (* a x))))
  (* 2.0 (* a x))))
(FPCore (a x)
 :precision binary64
 (fma
  (* (pow x 4.0) -0.5)
  (pow a 4.0)
  (fma
   (+ (* x -2.0) (* x 2.0))
   a
   (fma
    (pow a 3.0)
    (* (pow x 3.0) 0.6666666666666666)
    (log (exp (* 0.23333333333333334 (pow (* x a) 5.0))))))))
double code(double a, double x) {
	return (((4.0 * exp((-a * x))) - 3.0) - exp((-2.0 * (a * x)))) + (2.0 * (a * x));
}
double code(double a, double x) {
	return fma((pow(x, 4.0) * -0.5), pow(a, 4.0), fma(((x * -2.0) + (x * 2.0)), a, fma(pow(a, 3.0), (pow(x, 3.0) * 0.6666666666666666), log(exp((0.23333333333333334 * pow((x * a), 5.0)))))));
}
function code(a, x)
	return Float64(Float64(Float64(Float64(4.0 * exp(Float64(Float64(-a) * x))) - 3.0) - exp(Float64(Float64(-2.0) * Float64(a * x)))) + Float64(2.0 * Float64(a * x)))
end
function code(a, x)
	return fma(Float64((x ^ 4.0) * -0.5), (a ^ 4.0), fma(Float64(Float64(x * -2.0) + Float64(x * 2.0)), a, fma((a ^ 3.0), Float64((x ^ 3.0) * 0.6666666666666666), log(exp(Float64(0.23333333333333334 * (Float64(x * a) ^ 5.0)))))))
end
code[a_, x_] := N[(N[(N[(N[(4.0 * N[Exp[N[((-a) * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision] - N[Exp[N[((-2.0) * N[(a * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(a * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[a_, x_] := N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.5), $MachinePrecision] * N[Power[a, 4.0], $MachinePrecision] + N[(N[(N[(x * -2.0), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision] * a + N[(N[Power[a, 3.0], $MachinePrecision] * N[(N[Power[x, 3.0], $MachinePrecision] * 0.6666666666666666), $MachinePrecision] + N[Log[N[Exp[N[(0.23333333333333334 * N[Power[N[(x * a), $MachinePrecision], 5.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(4 \cdot e^{\left(-a\right) \cdot x} - 3\right) - e^{\left(-2\right) \cdot \left(a \cdot x\right)}\right) + 2 \cdot \left(a \cdot x\right)
\mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({a}^{3}, {x}^{3} \cdot 0.6666666666666666, \log \left(e^{0.23333333333333334 \cdot {\left(x \cdot a\right)}^{5}}\right)\right)\right)\right)

Error?

Derivation?

  1. Initial program 32.8

    \[\left(\left(4 \cdot e^{\left(-a\right) \cdot x} - 3\right) - e^{\left(-2\right) \cdot \left(a \cdot x\right)}\right) + 2 \cdot \left(a \cdot x\right) \]
  2. Taylor expanded in a around 0 0.1

    \[\leadsto \color{blue}{\left(0.16666666666666666 \cdot {x}^{4} - 0.6666666666666666 \cdot {x}^{4}\right) \cdot {a}^{4} + \left(\left(\left(2 \cdot x + -4 \cdot x\right) - -2 \cdot x\right) \cdot a + \left({a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right)} \]
  3. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({a}^{3}, {x}^{3} \cdot 0.6666666666666666, {x}^{5} \cdot \left({a}^{5} \cdot 0.23333333333333334\right)\right)\right)\right)} \]
    Proof

    [Start]0.1

    \[ \left(0.16666666666666666 \cdot {x}^{4} - 0.6666666666666666 \cdot {x}^{4}\right) \cdot {a}^{4} + \left(\left(\left(2 \cdot x + -4 \cdot x\right) - -2 \cdot x\right) \cdot a + \left({a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    fma-def [=>]0.1

    \[ \color{blue}{\mathsf{fma}\left(0.16666666666666666 \cdot {x}^{4} - 0.6666666666666666 \cdot {x}^{4}, {a}^{4}, \left(\left(2 \cdot x + -4 \cdot x\right) - -2 \cdot x\right) \cdot a + \left({a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right)} \]

    distribute-rgt-out-- [=>]0.1

    \[ \mathsf{fma}\left(\color{blue}{{x}^{4} \cdot \left(0.16666666666666666 - 0.6666666666666666\right)}, {a}^{4}, \left(\left(2 \cdot x + -4 \cdot x\right) - -2 \cdot x\right) \cdot a + \left({a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    metadata-eval [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot \color{blue}{-0.5}, {a}^{4}, \left(\left(2 \cdot x + -4 \cdot x\right) - -2 \cdot x\right) \cdot a + \left({a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    fma-def [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \color{blue}{\mathsf{fma}\left(\left(2 \cdot x + -4 \cdot x\right) - -2 \cdot x, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)}\right) \]

    distribute-rgt-out [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(\color{blue}{x \cdot \left(2 + -4\right)} - -2 \cdot x, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    metadata-eval [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot \color{blue}{-2} - -2 \cdot x, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    *-commutative [<=]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(\color{blue}{-2 \cdot x} - -2 \cdot x, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    cancel-sign-sub-inv [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(\color{blue}{-2 \cdot x + \left(--2\right) \cdot x}, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    *-commutative [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(\color{blue}{x \cdot -2} + \left(--2\right) \cdot x, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    metadata-eval [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + \color{blue}{2} \cdot x, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]

    *-commutative [=>]0.1

    \[ \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + \color{blue}{x \cdot 2}, a, {a}^{3} \cdot \left(-0.6666666666666666 \cdot {x}^{3} - -1.3333333333333333 \cdot {x}^{3}\right) + \left(-0.03333333333333333 \cdot {x}^{5} - -0.26666666666666666 \cdot {x}^{5}\right) \cdot {a}^{5}\right)\right) \]
  4. Applied egg-rr0.2

    \[\leadsto \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({a}^{3}, {x}^{3} \cdot 0.6666666666666666, \color{blue}{\log \left(e^{0.23333333333333334 \cdot {\left(x \cdot a\right)}^{5}}\right)}\right)\right)\right) \]
  5. Final simplification0.2

    \[\leadsto \mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({a}^{3}, {x}^{3} \cdot 0.6666666666666666, \log \left(e^{0.23333333333333334 \cdot {\left(x \cdot a\right)}^{5}}\right)\right)\right)\right) \]

Alternatives

Alternative 1
Error0.1
Cost59328
\[\mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({a}^{3}, {x}^{3} \cdot 0.6666666666666666, {x}^{5} \cdot \left(0.23333333333333334 \cdot {a}^{5}\right)\right)\right)\right) \]
Alternative 2
Error0.1
Cost52864
\[\mathsf{fma}\left({x}^{4} \cdot -0.5, {a}^{4}, \mathsf{fma}\left(x \cdot -2 + x \cdot 2, a, \mathsf{fma}\left({x}^{3}, {a}^{3} \cdot 0.6666666666666666, 0.23333333333333334 \cdot {\left(x \cdot a\right)}^{5}\right)\right)\right) \]
Alternative 3
Error0.1
Cost46080
\[0.6666666666666666 \cdot {\left(x \cdot a\right)}^{3} + \mathsf{fma}\left(-0.5 \cdot {a}^{4}, {x}^{4}, \mathsf{fma}\left(0.23333333333333334 \cdot {a}^{5}, {x}^{5}, 0\right)\right) \]
Alternative 4
Error0.2
Cost27456
\[\mathsf{fma}\left(x \cdot x, 2 \cdot \left(a \cdot a\right) + -2 \cdot \left(a \cdot a\right), \left(x \cdot x\right) \cdot \left(x \cdot \mathsf{fma}\left(-4, {a}^{3} \cdot 0.16666666666666666, {a}^{3} \cdot 1.3333333333333333\right)\right)\right) \]
Alternative 5
Error0.2
Cost7040
\[x \cdot \left(\left(x \cdot x\right) \cdot \left({a}^{3} \cdot 0.6666666666666666\right)\right) \]
Alternative 6
Error0.2
Cost6784
\[0.6666666666666666 \cdot {\left(x \cdot a\right)}^{3} \]
Alternative 7
Error4.2
Cost64
\[0 \]

Error

Reproduce?

herbie shell --seed 1 
(FPCore (a x)
  :name "( 4 * exp(-a * x) - 3 - exp( -2a * x ) + 2a * x )"
  :precision binary64
  :pre (and (and (<= 0.0 a) (<= a 1000000000.0)) (and (<= 0.0 x) (<= x 1000000000.0)))
  (+ (- (- (* 4.0 (exp (* (- a) x))) 3.0) (exp (* (- 2.0) (* a x)))) (* 2.0 (* a x))))