Average Error: 0.1 → 0.1
Time: 5.2s
Precision: binary64
Cost: 13120
\[\left(1 - x\right) + y \cdot \sqrt{x} \]
\[\mathsf{fma}\left(\sqrt{x}, y, 1 - x\right) \]
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
(FPCore (x y) :precision binary64 (fma (sqrt x) y (- 1.0 x)))
double code(double x, double y) {
	return (1.0 - x) + (y * sqrt(x));
}
double code(double x, double y) {
	return fma(sqrt(x), y, (1.0 - x));
}
function code(x, y)
	return Float64(Float64(1.0 - x) + Float64(y * sqrt(x)))
end
function code(x, y)
	return fma(sqrt(x), y, Float64(1.0 - x))
end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * y + N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\left(1 - x\right) + y \cdot \sqrt{x}
\mathsf{fma}\left(\sqrt{x}, y, 1 - x\right)

Error

Derivation

  1. Initial program 0.1

    \[\left(1 - x\right) + y \cdot \sqrt{x} \]
  2. Applied egg-rr0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1 - x\right)} \]
  3. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(\sqrt{x}, y, 1 - x\right) \]

Alternatives

Alternative 1
Error4.9
Cost6856
\[\begin{array}{l} t_0 := \sqrt{x} \cdot y\\ \mathbf{if}\;y \leq -5.491909915916374 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.792653805016995 \cdot 10^{+85}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.1
Cost6848
\[\left(1 - x\right) + \sqrt{x} \cdot y \]
Alternative 3
Error21.8
Cost260
\[\begin{array}{l} \mathbf{if}\;x \leq 0.0034595146748791915:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
Alternative 4
Error21.0
Cost192
\[1 - x \]
Alternative 5
Error42.4
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022308 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, E"
  :precision binary64
  (+ (- 1.0 x) (* y (sqrt x))))