?

Average Error: 0.17% → 0.16%
Time: 4.8s
Precision: binary64
Cost: 6848

?

\[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
\[1 - x \cdot \mathsf{fma}\left(x, 0.12, 0.253\right) \]
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
(FPCore (x) :precision binary64 (- 1.0 (* x (fma x 0.12 0.253))))
double code(double x) {
	return 1.0 - (x * (0.253 + (x * 0.12)));
}
double code(double x) {
	return 1.0 - (x * fma(x, 0.12, 0.253));
}
function code(x)
	return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12))))
end
function code(x)
	return Float64(1.0 - Float64(x * fma(x, 0.12, 0.253)))
end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(1.0 - N[(x * N[(x * 0.12 + 0.253), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
1 - x \cdot \mathsf{fma}\left(x, 0.12, 0.253\right)

Error?

Derivation?

  1. Initial program 0.17

    \[1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]
  2. Simplified0.16

    \[\leadsto \color{blue}{1 - x \cdot \mathsf{fma}\left(x, 0.12, 0.253\right)} \]
    Proof

    [Start]0.17

    \[ 1 - x \cdot \left(0.253 + x \cdot 0.12\right) \]

    distribute-lft-in [=>]0.17

    \[ 1 - \color{blue}{\left(x \cdot 0.253 + x \cdot \left(x \cdot 0.12\right)\right)} \]

    +-commutative [=>]0.17

    \[ 1 - \color{blue}{\left(x \cdot \left(x \cdot 0.12\right) + x \cdot 0.253\right)} \]

    *-commutative [<=]0.17

    \[ 1 - \left(\color{blue}{\left(x \cdot 0.12\right) \cdot x} + x \cdot 0.253\right) \]

    cancel-sign-sub [<=]0.17

    \[ 1 - \color{blue}{\left(\left(x \cdot 0.12\right) \cdot x - \left(-x\right) \cdot 0.253\right)} \]

    *-commutative [<=]0.17

    \[ 1 - \left(\left(x \cdot 0.12\right) \cdot x - \color{blue}{0.253 \cdot \left(-x\right)}\right) \]

    *-commutative [=>]0.17

    \[ 1 - \left(\left(x \cdot 0.12\right) \cdot x - \color{blue}{\left(-x\right) \cdot 0.253}\right) \]

    cancel-sign-sub [=>]0.17

    \[ 1 - \color{blue}{\left(\left(x \cdot 0.12\right) \cdot x + x \cdot 0.253\right)} \]

    *-commutative [=>]0.17

    \[ 1 - \left(\color{blue}{x \cdot \left(x \cdot 0.12\right)} + x \cdot 0.253\right) \]

    distribute-lft-in [<=]0.17

    \[ 1 - \color{blue}{x \cdot \left(x \cdot 0.12 + 0.253\right)} \]

    fma-def [=>]0.16

    \[ 1 - x \cdot \color{blue}{\mathsf{fma}\left(x, 0.12, 0.253\right)} \]
  3. Final simplification0.16

    \[\leadsto 1 - x \cdot \mathsf{fma}\left(x, 0.12, 0.253\right) \]

Alternatives

Alternative 1
Error3.1%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.1\right):\\ \;\;\;\;\left(x \cdot x\right) \cdot -0.12\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error2.39%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.1\right):\\ \;\;\;\;\left(x \cdot x\right) \cdot -0.12\\ \mathbf{else}:\\ \;\;\;\;1 + x \cdot -0.253\\ \end{array} \]
Alternative 3
Error0.17%
Cost576
\[1 + x \cdot \left(-0.253 + x \cdot -0.12\right) \]
Alternative 4
Error3.11%
Cost448
\[1 - 0.12 \cdot \left(x \cdot x\right) \]
Alternative 5
Error33.96%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (- 1.0 (* x (+ 0.253 (* x 0.12)))))