Rosa's Benchmark

Percentage Accurate: 99.8% → 99.8%
Time: 6.6s
Alternatives: 4
Speedup: 1.2×

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.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} \\ 0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(x \cdot \left(x \cdot x\right)\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(x * Float64(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[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

Alternative 2: 74.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8:\\
\;\;\;\;0.954929658551372 \cdot x\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(x \cdot x\right) \cdot -0.12900613773279798\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.7999999999999998

    1. Initial program 99.8%

      \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
    2. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \left(\mathsf{neg}\left(x \cdot \left(\frac{6450306886639899}{50000000000000000} \cdot x\right)\right)\right)\right)\right) \]
      8. distribute-rgt-neg-inN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right)}\right)\right)\right)\right) \]
      13. metadata-eval99.8%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{-6450306886639899}{50000000000000000}\right)\right)\right)\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x \cdot \left(0.954929658551372 + x \cdot \left(x \cdot -0.12900613773279798\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\frac{238732414637843}{250000000000000}}\right) \]
    6. Step-by-step derivation
      1. Simplified65.8%

        \[\leadsto x \cdot \color{blue}{0.954929658551372} \]

      if 2.7999999999999998 < x

      1. Initial program 99.9%

        \[0.954929658551372 \cdot x - 0.12900613773279798 \cdot \left(\left(x \cdot x\right) \cdot x\right) \]
      2. Step-by-step derivation
        1. associate-*r*N/A

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \left(\mathsf{neg}\left(x \cdot \left(\frac{6450306886639899}{50000000000000000} \cdot x\right)\right)\right)\right)\right) \]
        8. distribute-rgt-neg-inN/A

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right)}\right)\right)\right)\right) \]
        13. metadata-eval99.8%

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{-6450306886639899}{50000000000000000}\right)\right)\right)\right) \]
      3. Simplified99.8%

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

        \[\leadsto \color{blue}{\frac{-6450306886639899}{50000000000000000} \cdot {x}^{3}} \]
      6. Step-by-step derivation
        1. unpow3N/A

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

          \[\leadsto \frac{-6450306886639899}{50000000000000000} \cdot \left({x}^{2} \cdot x\right) \]
        3. associate-*r*N/A

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

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

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

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\frac{-6450306886639899}{50000000000000000}, \color{blue}{\left({x}^{2}\right)}\right)\right) \]
        7. unpow2N/A

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\frac{-6450306886639899}{50000000000000000}, \left(x \cdot \color{blue}{x}\right)\right)\right) \]
        8. *-lowering-*.f6499.0%

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\frac{-6450306886639899}{50000000000000000}, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right) \]
      7. Simplified99.0%

        \[\leadsto \color{blue}{x \cdot \left(-0.12900613773279798 \cdot \left(x \cdot x\right)\right)} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification73.9%

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

    Alternative 3: 99.8% accurate, 1.2× speedup?

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \left(\mathsf{neg}\left(x \cdot \left(\frac{6450306886639899}{50000000000000000} \cdot x\right)\right)\right)\right)\right) \]
      8. distribute-rgt-neg-inN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right)}\right)\right)\right)\right) \]
      13. metadata-eval99.8%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{-6450306886639899}{50000000000000000}\right)\right)\right)\right) \]
    3. Simplified99.8%

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

    Alternative 4: 49.5% accurate, 3.7× 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. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \left(\mathsf{neg}\left(x \cdot \left(\frac{6450306886639899}{50000000000000000} \cdot x\right)\right)\right)\right)\right) \]
      8. distribute-rgt-neg-inN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left(\mathsf{neg}\left(\frac{6450306886639899}{50000000000000000}\right)\right)}\right)\right)\right)\right) \]
      13. metadata-eval99.8%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{238732414637843}{250000000000000}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{-6450306886639899}{50000000000000000}\right)\right)\right)\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x \cdot \left(0.954929658551372 + x \cdot \left(x \cdot -0.12900613773279798\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\frac{238732414637843}{250000000000000}}\right) \]
    6. Step-by-step derivation
      1. Simplified49.7%

        \[\leadsto x \cdot \color{blue}{0.954929658551372} \]
      2. Final simplification49.7%

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

      Reproduce

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