Rosa's Benchmark

Percentage Accurate: 99.8% → 99.8%
Time: 6.0s
Alternatives: 6
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 6 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.8% 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.0× speedup?

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

\\
x \cdot 0.954929658551372 - \left(\left(x \cdot x\right) \cdot x\right) \cdot 0.12900613773279798
\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. Final simplification99.8%

    \[\leadsto x \cdot 0.954929658551372 - \left(\left(x \cdot x\right) \cdot x\right) \cdot 0.12900613773279798 \]
  4. Add Preprocessing

Alternative 2: 73.8% accurate, 0.5× speedup?

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

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

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


\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))) < -5e4

    1. Initial program 99.9%

      \[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. lift-*.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{238732414637843}{250000000000000} - \color{blue}{\left(x \cdot x\right) \cdot \frac{6450306886639899}{50000000000000000}}\right) \cdot x \]
      11. lower-*.f6499.9

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

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

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

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

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

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

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

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

    if -5e4 < (-.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. lower-*.f6468.6

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

      \[\leadsto \color{blue}{0.954929658551372 \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.0%

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

Alternative 3: 73.8% accurate, 0.5× speedup?

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

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

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


\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))) < -5e4

    1. Initial program 99.9%

      \[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. lift-*.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{238732414637843}{250000000000000} - \color{blue}{\left(x \cdot x\right) \cdot \frac{6450306886639899}{50000000000000000}}\right) \cdot x \]
      11. lower-*.f6499.9

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

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

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

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

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

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

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

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

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

      if -5e4 < (-.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. lower-*.f6468.6

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

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

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

    Alternative 4: 99.8% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \left(0.954929658551372 - \left(x \cdot x\right) \cdot 0.12900613773279798\right) \cdot x \end{array} \]
    (FPCore (x)
     :precision binary64
     (* (- 0.954929658551372 (* (* x x) 0.12900613773279798)) x))
    double code(double x) {
    	return (0.954929658551372 - ((x * x) * 0.12900613773279798)) * x;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = (0.954929658551372d0 - ((x * x) * 0.12900613773279798d0)) * x
    end function
    
    public static double code(double x) {
    	return (0.954929658551372 - ((x * x) * 0.12900613773279798)) * x;
    }
    
    def code(x):
    	return (0.954929658551372 - ((x * x) * 0.12900613773279798)) * x
    
    function code(x)
    	return Float64(Float64(0.954929658551372 - Float64(Float64(x * x) * 0.12900613773279798)) * x)
    end
    
    function tmp = code(x)
    	tmp = (0.954929658551372 - ((x * x) * 0.12900613773279798)) * x;
    end
    
    code[x_] := N[(N[(0.954929658551372 - N[(N[(x * x), $MachinePrecision] * 0.12900613773279798), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \left(0.954929658551372 - \left(x \cdot x\right) \cdot 0.12900613773279798\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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 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 6: 49.8% accurate, 4.0× speedup?

    \[\begin{array}{l} \\ x \cdot 0.954929658551372 \end{array} \]
    (FPCore (x) :precision binary64 (* x 0.954929658551372))
    double code(double x) {
    	return x * 0.954929658551372;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = x * 0.954929658551372d0
    end function
    
    public static double code(double x) {
    	return x * 0.954929658551372;
    }
    
    def code(x):
    	return x * 0.954929658551372
    
    function code(x)
    	return Float64(x * 0.954929658551372)
    end
    
    function tmp = code(x)
    	tmp = x * 0.954929658551372;
    end
    
    code[x_] := N[(x * 0.954929658551372), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    x \cdot 0.954929658551372
    \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. lower-*.f6456.3

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

      \[\leadsto \color{blue}{0.954929658551372 \cdot x} \]
    6. Final simplification56.3%

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

    Reproduce

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