Average Error: 0.1 → 0.1
Time: 6.9s
Precision: binary64
Cost: 6592
\[\frac{841}{108} \cdot x + \frac{4}{29} \]
\[\mathsf{fma}\left(7.787037037037037, x, 0.13793103448275862\right) \]
(FPCore (x) :precision binary64 (+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))
(FPCore (x) :precision binary64 (fma 7.787037037037037 x 0.13793103448275862))
double code(double x) {
	return ((841.0 / 108.0) * x) + (4.0 / 29.0);
}
double code(double x) {
	return fma(7.787037037037037, x, 0.13793103448275862);
}
function code(x)
	return Float64(Float64(Float64(841.0 / 108.0) * x) + Float64(4.0 / 29.0))
end
function code(x)
	return fma(7.787037037037037, x, 0.13793103448275862)
end
code[x_] := N[(N[(N[(841.0 / 108.0), $MachinePrecision] * x), $MachinePrecision] + N[(4.0 / 29.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(7.787037037037037 * x + 0.13793103448275862), $MachinePrecision]
\frac{841}{108} \cdot x + \frac{4}{29}
\mathsf{fma}\left(7.787037037037037, x, 0.13793103448275862\right)

Error

Derivation

  1. Initial program 0.1

    \[\frac{841}{108} \cdot x + \frac{4}{29} \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(7.787037037037037, x, 0.13793103448275862\right)} \]
    Proof

    [Start]0.1

    \[ \frac{841}{108} \cdot x + \frac{4}{29} \]

    fma-def [=>]0.1

    \[ \color{blue}{\mathsf{fma}\left(\frac{841}{108}, x, \frac{4}{29}\right)} \]

    metadata-eval [=>]0.1

    \[ \mathsf{fma}\left(\color{blue}{7.787037037037037}, x, \frac{4}{29}\right) \]

    metadata-eval [=>]0.1

    \[ \mathsf{fma}\left(7.787037037037037, x, \color{blue}{0.13793103448275862}\right) \]
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(7.787037037037037, x, 0.13793103448275862\right) \]

Alternatives

Alternative 1
Error1.3
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -0.018:\\ \;\;\;\;7.787037037037037 \cdot x\\ \mathbf{elif}\;x \leq 0.0175:\\ \;\;\;\;0.13793103448275862\\ \mathbf{else}:\\ \;\;\;\;7.787037037037037 \cdot x\\ \end{array} \]
Alternative 2
Error0.1
Cost320
\[0.13793103448275862 + 7.787037037037037 \cdot x \]
Alternative 3
Error31.3
Cost64
\[0.13793103448275862 \]

Error

Reproduce

herbie shell --seed 2023011 
(FPCore (x)
  :name "Data.Colour.CIE:cieLABView from colour-2.3.3, A"
  :precision binary64
  (+ (* (/ 841.0 108.0) x) (/ 4.0 29.0)))