Rosa's Benchmark

Percentage Accurate: 99.7% → 99.8%
Time: 6.2s
Alternatives: 4
Speedup: 1.4×

Specification

?
\[\begin{array}{l} \\ 0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))
double code(double x) {
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (0.954929658551372d0 * x) - (0.12900613773279798d0 * ((x * x) * x))
end function
public static double code(double x) {
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
def code(x):
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x))
function code(x)
	return Float64(Float64(0.954929658551372 * x) - Float64(0.12900613773279798 * Float64(Float64(x * x) * x)))
end
function tmp = code(x)
	tmp = (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
end
code[x_] := N[(N[(0.954929658551372 * x), $MachinePrecision] - N[(0.12900613773279798 * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))
double code(double x) {
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (0.954929658551372d0 * x) - (0.12900613773279798d0 * ((x * x) * x))
end function
public static double code(double x) {
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
}
def code(x):
	return (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x))
function code(x)
	return Float64(Float64(0.954929658551372 * x) - Float64(0.12900613773279798 * Float64(Float64(x * x) * x)))
end
function tmp = code(x)
	tmp = (0.954929658551372 * x) - (0.12900613773279798 * ((x * x) * x));
end
code[x_] := N[(N[(0.954929658551372 * x), $MachinePrecision] - N[(0.12900613773279798 * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right)
\end{array}

Alternative 1: 99.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, \left(-0.12900613773279798 \cdot x\right) \cdot x, 0.954929658551372 \cdot x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (fma x (* (* -0.12900613773279798 x) x) (* 0.954929658551372 x)))
double code(double x) {
	return fma(x, ((-0.12900613773279798 * x) * x), (0.954929658551372 * x));
}
function code(x)
	return fma(x, Float64(Float64(-0.12900613773279798 * x) * x), Float64(0.954929658551372 * x))
end
code[x_] := N[(x * N[(N[(-0.12900613773279798 * x), $MachinePrecision] * x), $MachinePrecision] + N[(0.954929658551372 * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, \left(-0.12900613773279798 \cdot x\right) \cdot x, 0.954929658551372 \cdot x\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift--.f64N/A

      \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x - \frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)} \]
    2. sub-negN/A

      \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x + \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right)} \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000} \cdot x} \]
    4. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
    5. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
    6. associate-*r*N/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right) \cdot x}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
    7. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) \cdot x} + \frac{238732414637843}{250000000000000} \cdot x \]
    8. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) \cdot x + \color{blue}{\frac{238732414637843}{250000000000000} \cdot x} \]
    9. distribute-rgt-outN/A

      \[\leadsto \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000}\right)} \]
    10. lower-*.f64N/A

      \[\leadsto \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000}\right)} \]
    11. distribute-lft-neg-inN/A

      \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \left(x \cdot x\right)} + \frac{238732414637843}{250000000000000}\right) \]
    12. lift-*.f64N/A

      \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \color{blue}{\left(x \cdot x\right)} + \frac{238732414637843}{250000000000000}\right) \]
    13. associate-*r*N/A

      \[\leadsto x \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x\right) \cdot x} + \frac{238732414637843}{250000000000000}\right) \]
    14. lower-fma.f64N/A

      \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x, x, \frac{238732414637843}{250000000000000}\right)} \]
    15. lower-*.f64N/A

      \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x}, x, \frac{238732414637843}{250000000000000}\right) \]
    16. metadata-eval99.8

      \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{-0.12900613773279798} \cdot x, x, 0.954929658551372\right) \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(-0.12900613773279798 \cdot x, x, 0.954929658551372\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(\frac{-6450306886639899}{50000000000000000} \cdot x, x, \frac{238732414637843}{250000000000000}\right)} \]
    2. lift-fma.f64N/A

      \[\leadsto x \cdot \color{blue}{\left(\left(\frac{-6450306886639899}{50000000000000000} \cdot x\right) \cdot x + \frac{238732414637843}{250000000000000}\right)} \]
    3. distribute-rgt-inN/A

      \[\leadsto \color{blue}{\left(\left(\frac{-6450306886639899}{50000000000000000} \cdot x\right) \cdot x\right) \cdot x + \frac{238732414637843}{250000000000000} \cdot x} \]
    4. lift-*.f64N/A

      \[\leadsto \left(\color{blue}{\left(\frac{-6450306886639899}{50000000000000000} \cdot x\right)} \cdot x\right) \cdot x + \frac{238732414637843}{250000000000000} \cdot x \]
    5. associate-*l*N/A

      \[\leadsto \color{blue}{\left(\frac{-6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)} \cdot x + \frac{238732414637843}{250000000000000} \cdot x \]
    6. lift-*.f64N/A

      \[\leadsto \left(\frac{-6450306886639899}{50000000000000000} \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot x + \frac{238732414637843}{250000000000000} \cdot x \]
    7. associate-*r*N/A

      \[\leadsto \color{blue}{\frac{-6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)} + \frac{238732414637843}{250000000000000} \cdot x \]
    8. metadata-evalN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right)} \cdot \left(\left(x \cdot x\right) \cdot x\right) + \frac{238732414637843}{250000000000000} \cdot x \]
    9. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) + \frac{238732414637843}{250000000000000} \cdot x \]
    10. distribute-lft-neg-inN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right)} + \frac{238732414637843}{250000000000000} \cdot x \]
    11. *-commutativeN/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) + \color{blue}{x \cdot \frac{238732414637843}{250000000000000}} \]
    12. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) + \color{blue}{x \cdot \frac{238732414637843}{250000000000000}} \]
    13. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot x\right)\right)\right) + x \cdot \frac{238732414637843}{250000000000000} \]
    14. associate-*r*N/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right) \cdot x}\right)\right) + x \cdot \frac{238732414637843}{250000000000000} \]
    15. *-commutativeN/A

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\left(x \cdot x\right) \cdot \frac{6450306886639899}{50000000000000000}\right)} \cdot x\right)\right) + x \cdot \frac{238732414637843}{250000000000000} \]
    16. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \frac{6450306886639899}{50000000000000000}\right) \cdot \left(\mathsf{neg}\left(x\right)\right)} + x \cdot \frac{238732414637843}{250000000000000} \]
    17. lift-neg.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot \frac{6450306886639899}{50000000000000000}\right) \cdot \color{blue}{\left(-x\right)} + x \cdot \frac{238732414637843}{250000000000000} \]
    18. lift-*.f64N/A

      \[\leadsto \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{6450306886639899}{50000000000000000}\right) \cdot \left(-x\right) + x \cdot \frac{238732414637843}{250000000000000} \]
    19. associate-*l*N/A

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot \frac{6450306886639899}{50000000000000000}\right)\right)} \cdot \left(-x\right) + x \cdot \frac{238732414637843}{250000000000000} \]
    20. associate-*l*N/A

      \[\leadsto \color{blue}{x \cdot \left(\left(x \cdot \frac{6450306886639899}{50000000000000000}\right) \cdot \left(-x\right)\right)} + x \cdot \frac{238732414637843}{250000000000000} \]
  6. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \left(0.12900613773279798 \cdot x\right) \cdot \left(-x\right), 0.954929658551372 \cdot x\right)} \]
  7. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\frac{6450306886639899}{50000000000000000} \cdot x\right) \cdot \left(-x\right)}, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    2. lift-neg.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \left(\frac{6450306886639899}{50000000000000000} \cdot x\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    3. distribute-rgt-neg-outN/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{neg}\left(\left(\frac{6450306886639899}{50000000000000000} \cdot x\right) \cdot x\right)}, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    4. distribute-lft-neg-inN/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot x\right)\right) \cdot x}, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    5. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \left(\mathsf{neg}\left(\color{blue}{\frac{6450306886639899}{50000000000000000} \cdot x}\right)\right) \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x\right)} \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(x, \left(\color{blue}{\frac{-6450306886639899}{50000000000000000}} \cdot x\right) \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(x \cdot \frac{-6450306886639899}{50000000000000000}\right)} \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    9. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(x \cdot \frac{-6450306886639899}{50000000000000000}\right)} \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    10. lower-*.f6499.8

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(x \cdot -0.12900613773279798\right) \cdot x}, 0.954929658551372 \cdot x\right) \]
    11. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(x \cdot \frac{-6450306886639899}{50000000000000000}\right)} \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\frac{-6450306886639899}{50000000000000000} \cdot x\right)} \cdot x, \frac{238732414637843}{250000000000000} \cdot x\right) \]
    13. lower-*.f6499.8

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(-0.12900613773279798 \cdot x\right)} \cdot x, 0.954929658551372 \cdot x\right) \]
  8. Applied rewrites99.8%

    \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(-0.12900613773279798 \cdot x\right) \cdot x}, 0.954929658551372 \cdot x\right) \]
  9. Add Preprocessing

Alternative 2: 74.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;0.954929658551372 \cdot x - \left(\left(x \cdot x\right) \cdot x\right) \cdot 0.12900613773279798 \leq -1000000000000:\\ \;\;\;\;\left(\left(-0.12900613773279798 \cdot x\right) \cdot x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;0.954929658551372 \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<=
      (- (* 0.954929658551372 x) (* (* (* x x) x) 0.12900613773279798))
      -1000000000000.0)
   (* (* (* -0.12900613773279798 x) x) x)
   (* 0.954929658551372 x)))
double code(double x) {
	double tmp;
	if (((0.954929658551372 * x) - (((x * x) * x) * 0.12900613773279798)) <= -1000000000000.0) {
		tmp = ((-0.12900613773279798 * x) * x) * x;
	} else {
		tmp = 0.954929658551372 * x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (((0.954929658551372d0 * x) - (((x * x) * x) * 0.12900613773279798d0)) <= (-1000000000000.0d0)) then
        tmp = (((-0.12900613773279798d0) * x) * x) * x
    else
        tmp = 0.954929658551372d0 * x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (((0.954929658551372 * x) - (((x * x) * x) * 0.12900613773279798)) <= -1000000000000.0) {
		tmp = ((-0.12900613773279798 * x) * x) * x;
	} else {
		tmp = 0.954929658551372 * x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if ((0.954929658551372 * x) - (((x * x) * x) * 0.12900613773279798)) <= -1000000000000.0:
		tmp = ((-0.12900613773279798 * x) * x) * x
	else:
		tmp = 0.954929658551372 * x
	return tmp
function code(x)
	tmp = 0.0
	if (Float64(Float64(0.954929658551372 * x) - Float64(Float64(Float64(x * x) * x) * 0.12900613773279798)) <= -1000000000000.0)
		tmp = Float64(Float64(Float64(-0.12900613773279798 * x) * x) * x);
	else
		tmp = Float64(0.954929658551372 * x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (((0.954929658551372 * x) - (((x * x) * x) * 0.12900613773279798)) <= -1000000000000.0)
		tmp = ((-0.12900613773279798 * x) * x) * x;
	else
		tmp = 0.954929658551372 * x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[(N[(0.954929658551372 * x), $MachinePrecision] - N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * 0.12900613773279798), $MachinePrecision]), $MachinePrecision], -1000000000000.0], N[(N[(N[(-0.12900613773279798 * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], N[(0.954929658551372 * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;0.954929658551372 \cdot x - \left(\left(x \cdot x\right) \cdot x\right) \cdot 0.12900613773279798 \leq -1000000000000:\\
\;\;\;\;\left(\left(-0.12900613773279798 \cdot x\right) \cdot x\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;0.954929658551372 \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 #s(literal 238732414637843/250000000000000 binary64) x) (*.f64 #s(literal 6450306886639899/50000000000000000 binary64) (*.f64 (*.f64 x x) x))) < -1e12

    1. Initial program 99.8%

      \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x - \frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x + \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000} \cdot x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
      5. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
      6. associate-*r*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right) \cdot x}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) \cdot x} + \frac{238732414637843}{250000000000000} \cdot x \]
      8. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) \cdot x + \color{blue}{\frac{238732414637843}{250000000000000} \cdot x} \]
      9. distribute-rgt-outN/A

        \[\leadsto \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000}\right)} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \left(x \cdot x\right)} + \frac{238732414637843}{250000000000000}\right) \]
      12. lift-*.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \color{blue}{\left(x \cdot x\right)} + \frac{238732414637843}{250000000000000}\right) \]
      13. associate-*r*N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x\right) \cdot x} + \frac{238732414637843}{250000000000000}\right) \]
      14. lower-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x, x, \frac{238732414637843}{250000000000000}\right)} \]
      15. lower-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x}, x, \frac{238732414637843}{250000000000000}\right) \]
      16. metadata-eval99.8

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{-0.12900613773279798} \cdot x, x, 0.954929658551372\right) \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(-0.12900613773279798 \cdot x, x, 0.954929658551372\right)} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \color{blue}{\left(\frac{-6450306886639899}{50000000000000000} \cdot {x}^{2}\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \frac{-6450306886639899}{50000000000000000}\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \frac{-6450306886639899}{50000000000000000}\right)} \]
      3. unpow2N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{-6450306886639899}{50000000000000000}\right) \]
      4. lower-*.f6499.8

        \[\leadsto x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot -0.12900613773279798\right) \]
    7. Applied rewrites99.8%

      \[\leadsto x \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot -0.12900613773279798\right)} \]
    8. Step-by-step derivation
      1. Applied rewrites99.8%

        \[\leadsto x \cdot \left(\left(-0.12900613773279798 \cdot x\right) \cdot \color{blue}{x}\right) \]

      if -1e12 < (-.f64 (*.f64 #s(literal 238732414637843/250000000000000 binary64) x) (*.f64 #s(literal 6450306886639899/50000000000000000 binary64) (*.f64 (*.f64 x x) x)))

      1. Initial program 99.8%

        \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{x \cdot \frac{238732414637843}{250000000000000}} \]
        2. lower-*.f6462.5

          \[\leadsto \color{blue}{x \cdot 0.954929658551372} \]
      5. Applied rewrites62.5%

        \[\leadsto \color{blue}{x \cdot 0.954929658551372} \]
    9. Recombined 2 regimes into one program.
    10. Final simplification71.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;0.954929658551372 \cdot x - \left(\left(x \cdot x\right) \cdot x\right) \cdot 0.12900613773279798 \leq -1000000000000:\\ \;\;\;\;\left(\left(-0.12900613773279798 \cdot x\right) \cdot x\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;0.954929658551372 \cdot x\\ \end{array} \]
    11. Add Preprocessing

    Alternative 3: 99.8% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(-0.12900613773279798 \cdot x, x, 0.954929658551372\right) \cdot x \end{array} \]
    (FPCore (x)
     :precision binary64
     (* (fma (* -0.12900613773279798 x) x 0.954929658551372) x))
    double code(double x) {
    	return fma((-0.12900613773279798 * x), x, 0.954929658551372) * x;
    }
    
    function code(x)
    	return Float64(fma(Float64(-0.12900613773279798 * x), x, 0.954929658551372) * x)
    end
    
    code[x_] := N[(N[(N[(-0.12900613773279798 * x), $MachinePrecision] * x + 0.954929658551372), $MachinePrecision] * x), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(-0.12900613773279798 \cdot x, x, 0.954929658551372\right) \cdot x
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x - \frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)} \]
      2. sub-negN/A

        \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x + \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000} \cdot x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\frac{6450306886639899}{50000000000000000} \cdot \left(\left(x \cdot x\right) \cdot x\right)}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
      5. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
      6. associate-*r*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right) \cdot x}\right)\right) + \frac{238732414637843}{250000000000000} \cdot x \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) \cdot x} + \frac{238732414637843}{250000000000000} \cdot x \]
      8. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) \cdot x + \color{blue}{\frac{238732414637843}{250000000000000} \cdot x} \]
      9. distribute-rgt-outN/A

        \[\leadsto \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000} \cdot \left(x \cdot x\right)\right)\right) + \frac{238732414637843}{250000000000000}\right)} \]
      11. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \left(x \cdot x\right)} + \frac{238732414637843}{250000000000000}\right) \]
      12. lift-*.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot \color{blue}{\left(x \cdot x\right)} + \frac{238732414637843}{250000000000000}\right) \]
      13. associate-*r*N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x\right) \cdot x} + \frac{238732414637843}{250000000000000}\right) \]
      14. lower-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x, x, \frac{238732414637843}{250000000000000}\right)} \]
      15. lower-*.f64N/A

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right) \cdot x}, x, \frac{238732414637843}{250000000000000}\right) \]
      16. metadata-eval99.8

        \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{-0.12900613773279798} \cdot x, x, 0.954929658551372\right) \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(-0.12900613773279798 \cdot x, x, 0.954929658551372\right)} \]
    5. Final simplification99.8%

      \[\leadsto \mathsf{fma}\left(-0.12900613773279798 \cdot x, x, 0.954929658551372\right) \cdot x \]
    6. Add Preprocessing

    Alternative 4: 49.3% accurate, 4.0× speedup?

    \[\begin{array}{l} \\ 0.954929658551372 \cdot x \end{array} \]
    (FPCore (x) :precision binary64 (* 0.954929658551372 x))
    double code(double x) {
    	return 0.954929658551372 * x;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 0.954929658551372d0 * x
    end function
    
    public static double code(double x) {
    	return 0.954929658551372 * x;
    }
    
    def code(x):
    	return 0.954929658551372 * x
    
    function code(x)
    	return Float64(0.954929658551372 * x)
    end
    
    function tmp = code(x)
    	tmp = 0.954929658551372 * x;
    end
    
    code[x_] := N[(0.954929658551372 * x), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    0.954929658551372 \cdot x
    \end{array}
    
    Derivation
    1. Initial program 99.8%

      \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{238732414637843}{250000000000000} \cdot x} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot \frac{238732414637843}{250000000000000}} \]
      2. lower-*.f6446.7

        \[\leadsto \color{blue}{x \cdot 0.954929658551372} \]
    5. Applied rewrites46.7%

      \[\leadsto \color{blue}{x \cdot 0.954929658551372} \]
    6. Final simplification46.7%

      \[\leadsto 0.954929658551372 \cdot x \]
    7. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024268 
    (FPCore (x)
      :name "Rosa's Benchmark"
      :precision binary64
      (- (* 0.954929658551372 x) (* 0.12900613773279798 (* (* x x) x))))