Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, E

Percentage Accurate: 99.7% → 99.8%
Time: 5.3s
Alternatives: 8
Speedup: 1.3×

Specification

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

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

\\
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\end{array}

Alternative 1: 99.8% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right) \end{array} \]
(FPCore (x) :precision binary64 (fma x 6.0 (* -9.0 (pow x 2.0))))
double code(double x) {
	return fma(x, 6.0, (-9.0 * pow(x, 2.0)));
}
function code(x)
	return fma(x, 6.0, Float64(-9.0 * (x ^ 2.0)))
end
code[x_] := N[(x * 6.0 + N[(-9.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
  2. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
    2. cancel-sign-sub-inv99.7%

      \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
    3. distribute-rgt-in99.7%

      \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
    4. metadata-eval99.7%

      \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
    5. distribute-lft-neg-out99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
    6. distribute-rgt-neg-in99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
    7. associate-*l*99.8%

      \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
    8. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
    9. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
  4. Step-by-step derivation
    1. distribute-rgt-in99.7%

      \[\leadsto \color{blue}{6 \cdot x + \left(x \cdot -9\right) \cdot x} \]
    2. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot 6} + \left(x \cdot -9\right) \cdot x \]
    3. fma-def99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 6, \left(x \cdot -9\right) \cdot x\right)} \]
    4. *-commutative99.8%

      \[\leadsto \mathsf{fma}\left(x, 6, \color{blue}{\left(-9 \cdot x\right)} \cdot x\right) \]
    5. associate-*l*99.9%

      \[\leadsto \mathsf{fma}\left(x, 6, \color{blue}{-9 \cdot \left(x \cdot x\right)}\right) \]
    6. pow299.9%

      \[\leadsto \mathsf{fma}\left(x, 6, -9 \cdot \color{blue}{{x}^{2}}\right) \]
  5. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)} \]
  6. Final simplification99.9%

    \[\leadsto \mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right) \]

Alternative 2: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ -9 \cdot {x}^{2} + x \cdot 6 \end{array} \]
(FPCore (x) :precision binary64 (+ (* -9.0 (pow x 2.0)) (* x 6.0)))
double code(double x) {
	return (-9.0 * pow(x, 2.0)) + (x * 6.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((-9.0d0) * (x ** 2.0d0)) + (x * 6.0d0)
end function
public static double code(double x) {
	return (-9.0 * Math.pow(x, 2.0)) + (x * 6.0);
}
def code(x):
	return (-9.0 * math.pow(x, 2.0)) + (x * 6.0)
function code(x)
	return Float64(Float64(-9.0 * (x ^ 2.0)) + Float64(x * 6.0))
end
function tmp = code(x)
	tmp = (-9.0 * (x ^ 2.0)) + (x * 6.0);
end
code[x_] := N[(N[(-9.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(x * 6.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
-9 \cdot {x}^{2} + x \cdot 6
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
  2. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
    2. cancel-sign-sub-inv99.7%

      \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
    3. distribute-rgt-in99.7%

      \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
    4. metadata-eval99.7%

      \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
    5. distribute-lft-neg-out99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
    6. distribute-rgt-neg-in99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
    7. associate-*l*99.8%

      \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
    8. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
    9. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
  4. Step-by-step derivation
    1. distribute-rgt-in99.7%

      \[\leadsto \color{blue}{6 \cdot x + \left(x \cdot -9\right) \cdot x} \]
    2. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot 6} + \left(x \cdot -9\right) \cdot x \]
    3. *-commutative99.7%

      \[\leadsto x \cdot 6 + \color{blue}{\left(-9 \cdot x\right)} \cdot x \]
    4. associate-*l*99.8%

      \[\leadsto x \cdot 6 + \color{blue}{-9 \cdot \left(x \cdot x\right)} \]
    5. pow299.8%

      \[\leadsto x \cdot 6 + -9 \cdot \color{blue}{{x}^{2}} \]
  5. Applied egg-rr99.8%

    \[\leadsto \color{blue}{x \cdot 6 + -9 \cdot {x}^{2}} \]
  6. Final simplification99.8%

    \[\leadsto -9 \cdot {x}^{2} + x \cdot 6 \]

Alternative 3: 97.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.66 \lor \neg \left(x \leq 0.68\right):\\ \;\;\;\;x \cdot \left(x \cdot -9\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 6\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (or (<= x -0.66) (not (<= x 0.68))) (* x (* x -9.0)) (* x 6.0)))
double code(double x) {
	double tmp;
	if ((x <= -0.66) || !(x <= 0.68)) {
		tmp = x * (x * -9.0);
	} else {
		tmp = x * 6.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-0.66d0)) .or. (.not. (x <= 0.68d0))) then
        tmp = x * (x * (-9.0d0))
    else
        tmp = x * 6.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if ((x <= -0.66) || !(x <= 0.68)) {
		tmp = x * (x * -9.0);
	} else {
		tmp = x * 6.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if (x <= -0.66) or not (x <= 0.68):
		tmp = x * (x * -9.0)
	else:
		tmp = x * 6.0
	return tmp
function code(x)
	tmp = 0.0
	if ((x <= -0.66) || !(x <= 0.68))
		tmp = Float64(x * Float64(x * -9.0));
	else
		tmp = Float64(x * 6.0);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if ((x <= -0.66) || ~((x <= 0.68)))
		tmp = x * (x * -9.0);
	else
		tmp = x * 6.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[Or[LessEqual[x, -0.66], N[Not[LessEqual[x, 0.68]], $MachinePrecision]], N[(x * N[(x * -9.0), $MachinePrecision]), $MachinePrecision], N[(x * 6.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.66 \lor \neg \left(x \leq 0.68\right):\\
\;\;\;\;x \cdot \left(x \cdot -9\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.660000000000000031 or 0.680000000000000049 < x

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.8%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.8%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.8%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Taylor expanded in x around inf 98.4%

      \[\leadsto x \cdot \color{blue}{\left(-9 \cdot x\right)} \]
    5. Step-by-step derivation
      1. *-commutative98.4%

        \[\leadsto x \cdot \color{blue}{\left(x \cdot -9\right)} \]
    6. Simplified98.4%

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

    if -0.660000000000000031 < x < 0.680000000000000049

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Taylor expanded in x around 0 98.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.66 \lor \neg \left(x \leq 0.68\right):\\ \;\;\;\;x \cdot \left(x \cdot -9\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 6\\ \end{array} \]

Alternative 4: 97.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.66:\\ \;\;\;\;x \cdot \frac{x}{-0.1111111111111111}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;x \cdot 6\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -9\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -0.66)
   (* x (/ x -0.1111111111111111))
   (if (<= x 0.68) (* x 6.0) (* x (* x -9.0)))))
double code(double x) {
	double tmp;
	if (x <= -0.66) {
		tmp = x * (x / -0.1111111111111111);
	} else if (x <= 0.68) {
		tmp = x * 6.0;
	} else {
		tmp = x * (x * -9.0);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-0.66d0)) then
        tmp = x * (x / (-0.1111111111111111d0))
    else if (x <= 0.68d0) then
        tmp = x * 6.0d0
    else
        tmp = x * (x * (-9.0d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -0.66) {
		tmp = x * (x / -0.1111111111111111);
	} else if (x <= 0.68) {
		tmp = x * 6.0;
	} else {
		tmp = x * (x * -9.0);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -0.66:
		tmp = x * (x / -0.1111111111111111)
	elif x <= 0.68:
		tmp = x * 6.0
	else:
		tmp = x * (x * -9.0)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -0.66)
		tmp = Float64(x * Float64(x / -0.1111111111111111));
	elseif (x <= 0.68)
		tmp = Float64(x * 6.0);
	else
		tmp = Float64(x * Float64(x * -9.0));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -0.66)
		tmp = x * (x / -0.1111111111111111);
	elseif (x <= 0.68)
		tmp = x * 6.0;
	else
		tmp = x * (x * -9.0);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -0.66], N[(x * N[(x / -0.1111111111111111), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.68], N[(x * 6.0), $MachinePrecision], N[(x * N[(x * -9.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.66:\\
\;\;\;\;x \cdot \frac{x}{-0.1111111111111111}\\

\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;x \cdot 6\\

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


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

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{\left(6 + x \cdot -9\right) \cdot x} \]
      2. flip-+99.7%

        \[\leadsto \color{blue}{\frac{6 \cdot 6 - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)}{6 - x \cdot -9}} \cdot x \]
      3. associate-*l/85.9%

        \[\leadsto \color{blue}{\frac{\left(6 \cdot 6 - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)\right) \cdot x}{6 - x \cdot -9}} \]
      4. metadata-eval85.9%

        \[\leadsto \frac{\left(\color{blue}{36} - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)\right) \cdot x}{6 - x \cdot -9} \]
      5. swap-sqr85.9%

        \[\leadsto \frac{\left(36 - \color{blue}{\left(x \cdot x\right) \cdot \left(-9 \cdot -9\right)}\right) \cdot x}{6 - x \cdot -9} \]
      6. pow285.9%

        \[\leadsto \frac{\left(36 - \color{blue}{{x}^{2}} \cdot \left(-9 \cdot -9\right)\right) \cdot x}{6 - x \cdot -9} \]
      7. metadata-eval85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot \color{blue}{81}\right) \cdot x}{6 - x \cdot -9} \]
      8. *-commutative85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 - \color{blue}{-9 \cdot x}} \]
      9. cancel-sign-sub-inv85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{\color{blue}{6 + \left(--9\right) \cdot x}} \]
      10. metadata-eval85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + \color{blue}{9} \cdot x} \]
    5. Applied egg-rr85.9%

      \[\leadsto \color{blue}{\frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + 9 \cdot x}} \]
    6. Step-by-step derivation
      1. clear-num86.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{6 + 9 \cdot x}{\left(36 - {x}^{2} \cdot 81\right) \cdot x}}} \]
      2. inv-pow86.0%

        \[\leadsto \color{blue}{{\left(\frac{6 + 9 \cdot x}{\left(36 - {x}^{2} \cdot 81\right) \cdot x}\right)}^{-1}} \]
      3. clear-num85.9%

        \[\leadsto {\color{blue}{\left(\frac{1}{\frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + 9 \cdot x}}\right)}}^{-1} \]
      4. associate-/l*99.6%

        \[\leadsto {\left(\frac{1}{\color{blue}{\frac{36 - {x}^{2} \cdot 81}{\frac{6 + 9 \cdot x}{x}}}}\right)}^{-1} \]
      5. associate-/r/99.7%

        \[\leadsto {\left(\frac{1}{\color{blue}{\frac{36 - {x}^{2} \cdot 81}{6 + 9 \cdot x} \cdot x}}\right)}^{-1} \]
      6. metadata-eval99.7%

        \[\leadsto {\left(\frac{1}{\frac{\color{blue}{6 \cdot 6} - {x}^{2} \cdot 81}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      7. *-commutative99.7%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \color{blue}{81 \cdot {x}^{2}}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      8. metadata-eval99.7%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \color{blue}{\left(9 \cdot 9\right)} \cdot {x}^{2}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      9. unpow299.7%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \left(9 \cdot 9\right) \cdot \color{blue}{\left(x \cdot x\right)}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      10. swap-sqr99.5%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \color{blue}{\left(9 \cdot x\right) \cdot \left(9 \cdot x\right)}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      11. flip--99.6%

        \[\leadsto {\left(\frac{1}{\color{blue}{\left(6 - 9 \cdot x\right)} \cdot x}\right)}^{-1} \]
      12. *-commutative99.6%

        \[\leadsto {\left(\frac{1}{\left(6 - \color{blue}{x \cdot 9}\right) \cdot x}\right)}^{-1} \]
    7. Applied egg-rr99.6%

      \[\leadsto \color{blue}{{\left(\frac{1}{\left(6 - x \cdot 9\right) \cdot x}\right)}^{-1}} \]
    8. Taylor expanded in x around inf 98.6%

      \[\leadsto {\color{blue}{\left(\frac{-0.1111111111111111}{{x}^{2}}\right)}}^{-1} \]
    9. Step-by-step derivation
      1. unpow-198.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{-0.1111111111111111}{{x}^{2}}}} \]
      2. clear-num98.7%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{-0.1111111111111111}} \]
      3. unpow298.7%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{-0.1111111111111111} \]
      4. associate-/l*98.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{-0.1111111111111111}{x}}} \]
    10. Applied egg-rr98.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{-0.1111111111111111}{x}}} \]
    11. Step-by-step derivation
      1. associate-/r/98.8%

        \[\leadsto \color{blue}{\frac{x}{-0.1111111111111111} \cdot x} \]
    12. Simplified98.8%

      \[\leadsto \color{blue}{\frac{x}{-0.1111111111111111} \cdot x} \]

    if -0.660000000000000031 < x < 0.680000000000000049

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Taylor expanded in x around 0 98.3%

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

    if 0.680000000000000049 < x

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.9%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.9%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.9%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Taylor expanded in x around inf 97.8%

      \[\leadsto x \cdot \color{blue}{\left(-9 \cdot x\right)} \]
    5. Step-by-step derivation
      1. *-commutative97.8%

        \[\leadsto x \cdot \color{blue}{\left(x \cdot -9\right)} \]
    6. Simplified97.8%

      \[\leadsto x \cdot \color{blue}{\left(x \cdot -9\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.66:\\ \;\;\;\;x \cdot \frac{x}{-0.1111111111111111}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;x \cdot 6\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -9\right)\\ \end{array} \]

Alternative 5: 97.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.66:\\ \;\;\;\;\frac{x}{\frac{-0.1111111111111111}{x}}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;x \cdot 6\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -9\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -0.66)
   (/ x (/ -0.1111111111111111 x))
   (if (<= x 0.68) (* x 6.0) (* x (* x -9.0)))))
double code(double x) {
	double tmp;
	if (x <= -0.66) {
		tmp = x / (-0.1111111111111111 / x);
	} else if (x <= 0.68) {
		tmp = x * 6.0;
	} else {
		tmp = x * (x * -9.0);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-0.66d0)) then
        tmp = x / ((-0.1111111111111111d0) / x)
    else if (x <= 0.68d0) then
        tmp = x * 6.0d0
    else
        tmp = x * (x * (-9.0d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -0.66) {
		tmp = x / (-0.1111111111111111 / x);
	} else if (x <= 0.68) {
		tmp = x * 6.0;
	} else {
		tmp = x * (x * -9.0);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -0.66:
		tmp = x / (-0.1111111111111111 / x)
	elif x <= 0.68:
		tmp = x * 6.0
	else:
		tmp = x * (x * -9.0)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -0.66)
		tmp = Float64(x / Float64(-0.1111111111111111 / x));
	elseif (x <= 0.68)
		tmp = Float64(x * 6.0);
	else
		tmp = Float64(x * Float64(x * -9.0));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -0.66)
		tmp = x / (-0.1111111111111111 / x);
	elseif (x <= 0.68)
		tmp = x * 6.0;
	else
		tmp = x * (x * -9.0);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -0.66], N[(x / N[(-0.1111111111111111 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.68], N[(x * 6.0), $MachinePrecision], N[(x * N[(x * -9.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.66:\\
\;\;\;\;\frac{x}{\frac{-0.1111111111111111}{x}}\\

\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;x \cdot 6\\

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


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

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{\left(6 + x \cdot -9\right) \cdot x} \]
      2. flip-+99.7%

        \[\leadsto \color{blue}{\frac{6 \cdot 6 - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)}{6 - x \cdot -9}} \cdot x \]
      3. associate-*l/85.9%

        \[\leadsto \color{blue}{\frac{\left(6 \cdot 6 - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)\right) \cdot x}{6 - x \cdot -9}} \]
      4. metadata-eval85.9%

        \[\leadsto \frac{\left(\color{blue}{36} - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)\right) \cdot x}{6 - x \cdot -9} \]
      5. swap-sqr85.9%

        \[\leadsto \frac{\left(36 - \color{blue}{\left(x \cdot x\right) \cdot \left(-9 \cdot -9\right)}\right) \cdot x}{6 - x \cdot -9} \]
      6. pow285.9%

        \[\leadsto \frac{\left(36 - \color{blue}{{x}^{2}} \cdot \left(-9 \cdot -9\right)\right) \cdot x}{6 - x \cdot -9} \]
      7. metadata-eval85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot \color{blue}{81}\right) \cdot x}{6 - x \cdot -9} \]
      8. *-commutative85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 - \color{blue}{-9 \cdot x}} \]
      9. cancel-sign-sub-inv85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{\color{blue}{6 + \left(--9\right) \cdot x}} \]
      10. metadata-eval85.9%

        \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + \color{blue}{9} \cdot x} \]
    5. Applied egg-rr85.9%

      \[\leadsto \color{blue}{\frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + 9 \cdot x}} \]
    6. Step-by-step derivation
      1. clear-num86.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{6 + 9 \cdot x}{\left(36 - {x}^{2} \cdot 81\right) \cdot x}}} \]
      2. inv-pow86.0%

        \[\leadsto \color{blue}{{\left(\frac{6 + 9 \cdot x}{\left(36 - {x}^{2} \cdot 81\right) \cdot x}\right)}^{-1}} \]
      3. clear-num85.9%

        \[\leadsto {\color{blue}{\left(\frac{1}{\frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + 9 \cdot x}}\right)}}^{-1} \]
      4. associate-/l*99.6%

        \[\leadsto {\left(\frac{1}{\color{blue}{\frac{36 - {x}^{2} \cdot 81}{\frac{6 + 9 \cdot x}{x}}}}\right)}^{-1} \]
      5. associate-/r/99.7%

        \[\leadsto {\left(\frac{1}{\color{blue}{\frac{36 - {x}^{2} \cdot 81}{6 + 9 \cdot x} \cdot x}}\right)}^{-1} \]
      6. metadata-eval99.7%

        \[\leadsto {\left(\frac{1}{\frac{\color{blue}{6 \cdot 6} - {x}^{2} \cdot 81}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      7. *-commutative99.7%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \color{blue}{81 \cdot {x}^{2}}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      8. metadata-eval99.7%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \color{blue}{\left(9 \cdot 9\right)} \cdot {x}^{2}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      9. unpow299.7%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \left(9 \cdot 9\right) \cdot \color{blue}{\left(x \cdot x\right)}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      10. swap-sqr99.5%

        \[\leadsto {\left(\frac{1}{\frac{6 \cdot 6 - \color{blue}{\left(9 \cdot x\right) \cdot \left(9 \cdot x\right)}}{6 + 9 \cdot x} \cdot x}\right)}^{-1} \]
      11. flip--99.6%

        \[\leadsto {\left(\frac{1}{\color{blue}{\left(6 - 9 \cdot x\right)} \cdot x}\right)}^{-1} \]
      12. *-commutative99.6%

        \[\leadsto {\left(\frac{1}{\left(6 - \color{blue}{x \cdot 9}\right) \cdot x}\right)}^{-1} \]
    7. Applied egg-rr99.6%

      \[\leadsto \color{blue}{{\left(\frac{1}{\left(6 - x \cdot 9\right) \cdot x}\right)}^{-1}} \]
    8. Taylor expanded in x around inf 98.6%

      \[\leadsto {\color{blue}{\left(\frac{-0.1111111111111111}{{x}^{2}}\right)}}^{-1} \]
    9. Step-by-step derivation
      1. unpow-198.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{-0.1111111111111111}{{x}^{2}}}} \]
      2. clear-num98.7%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{-0.1111111111111111}} \]
      3. unpow298.7%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{-0.1111111111111111} \]
      4. associate-/l*98.9%

        \[\leadsto \color{blue}{\frac{x}{\frac{-0.1111111111111111}{x}}} \]
    10. Applied egg-rr98.9%

      \[\leadsto \color{blue}{\frac{x}{\frac{-0.1111111111111111}{x}}} \]

    if -0.660000000000000031 < x < 0.680000000000000049

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.7%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Taylor expanded in x around 0 98.3%

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

    if 0.680000000000000049 < x

    1. Initial program 99.7%

      \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
    2. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
      2. cancel-sign-sub-inv99.7%

        \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
      3. distribute-rgt-in99.7%

        \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
      4. metadata-eval99.7%

        \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
      5. distribute-lft-neg-out99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
      7. associate-*l*99.9%

        \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
      8. metadata-eval99.9%

        \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
      9. metadata-eval99.9%

        \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
    4. Taylor expanded in x around inf 97.8%

      \[\leadsto x \cdot \color{blue}{\left(-9 \cdot x\right)} \]
    5. Step-by-step derivation
      1. *-commutative97.8%

        \[\leadsto x \cdot \color{blue}{\left(x \cdot -9\right)} \]
    6. Simplified97.8%

      \[\leadsto x \cdot \color{blue}{\left(x \cdot -9\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.66:\\ \;\;\;\;\frac{x}{\frac{-0.1111111111111111}{x}}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;x \cdot 6\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -9\right)\\ \end{array} \]

Alternative 6: 99.8% accurate, 1.3× speedup?

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

\\
x \cdot \left(6 + x \cdot -9\right)
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
  2. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
    2. cancel-sign-sub-inv99.7%

      \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
    3. distribute-rgt-in99.7%

      \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
    4. metadata-eval99.7%

      \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
    5. distribute-lft-neg-out99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
    6. distribute-rgt-neg-in99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
    7. associate-*l*99.8%

      \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
    8. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
    9. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
  4. Final simplification99.8%

    \[\leadsto x \cdot \left(6 + x \cdot -9\right) \]

Alternative 7: 51.7% accurate, 3.0× speedup?

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

\\
x \cdot 6
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
  2. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
    2. cancel-sign-sub-inv99.7%

      \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
    3. distribute-rgt-in99.7%

      \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
    4. metadata-eval99.7%

      \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
    5. distribute-lft-neg-out99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
    6. distribute-rgt-neg-in99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
    7. associate-*l*99.8%

      \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
    8. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
    9. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
  4. Taylor expanded in x around 0 48.5%

    \[\leadsto x \cdot \color{blue}{6} \]
  5. Final simplification48.5%

    \[\leadsto x \cdot 6 \]

Alternative 8: 2.4% accurate, 9.0× speedup?

\[\begin{array}{l} \\ 4 \end{array} \]
(FPCore (x) :precision binary64 4.0)
double code(double x) {
	return 4.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 4.0d0
end function
public static double code(double x) {
	return 4.0;
}
def code(x):
	return 4.0
function code(x)
	return 4.0
end
function tmp = code(x)
	tmp = 4.0;
end
code[x_] := 4.0
\begin{array}{l}

\\
4
\end{array}
Derivation
  1. Initial program 99.7%

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x \]
  2. Step-by-step derivation
    1. *-commutative99.7%

      \[\leadsto \color{blue}{x \cdot \left(3 \cdot \left(2 - x \cdot 3\right)\right)} \]
    2. cancel-sign-sub-inv99.7%

      \[\leadsto x \cdot \left(3 \cdot \color{blue}{\left(2 + \left(-x\right) \cdot 3\right)}\right) \]
    3. distribute-rgt-in99.7%

      \[\leadsto x \cdot \color{blue}{\left(2 \cdot 3 + \left(\left(-x\right) \cdot 3\right) \cdot 3\right)} \]
    4. metadata-eval99.7%

      \[\leadsto x \cdot \left(\color{blue}{6} + \left(\left(-x\right) \cdot 3\right) \cdot 3\right) \]
    5. distribute-lft-neg-out99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(-x \cdot 3\right)} \cdot 3\right) \]
    6. distribute-rgt-neg-in99.7%

      \[\leadsto x \cdot \left(6 + \color{blue}{\left(x \cdot \left(-3\right)\right)} \cdot 3\right) \]
    7. associate-*l*99.8%

      \[\leadsto x \cdot \left(6 + \color{blue}{x \cdot \left(\left(-3\right) \cdot 3\right)}\right) \]
    8. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \left(\color{blue}{-3} \cdot 3\right)\right) \]
    9. metadata-eval99.8%

      \[\leadsto x \cdot \left(6 + x \cdot \color{blue}{-9}\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x \cdot \left(6 + x \cdot -9\right)} \]
  4. Step-by-step derivation
    1. *-commutative99.8%

      \[\leadsto \color{blue}{\left(6 + x \cdot -9\right) \cdot x} \]
    2. flip-+99.7%

      \[\leadsto \color{blue}{\frac{6 \cdot 6 - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)}{6 - x \cdot -9}} \cdot x \]
    3. associate-*l/92.1%

      \[\leadsto \color{blue}{\frac{\left(6 \cdot 6 - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)\right) \cdot x}{6 - x \cdot -9}} \]
    4. metadata-eval92.1%

      \[\leadsto \frac{\left(\color{blue}{36} - \left(x \cdot -9\right) \cdot \left(x \cdot -9\right)\right) \cdot x}{6 - x \cdot -9} \]
    5. swap-sqr92.1%

      \[\leadsto \frac{\left(36 - \color{blue}{\left(x \cdot x\right) \cdot \left(-9 \cdot -9\right)}\right) \cdot x}{6 - x \cdot -9} \]
    6. pow292.1%

      \[\leadsto \frac{\left(36 - \color{blue}{{x}^{2}} \cdot \left(-9 \cdot -9\right)\right) \cdot x}{6 - x \cdot -9} \]
    7. metadata-eval92.1%

      \[\leadsto \frac{\left(36 - {x}^{2} \cdot \color{blue}{81}\right) \cdot x}{6 - x \cdot -9} \]
    8. *-commutative92.1%

      \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 - \color{blue}{-9 \cdot x}} \]
    9. cancel-sign-sub-inv92.1%

      \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{\color{blue}{6 + \left(--9\right) \cdot x}} \]
    10. metadata-eval92.1%

      \[\leadsto \frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + \color{blue}{9} \cdot x} \]
  5. Applied egg-rr92.1%

    \[\leadsto \color{blue}{\frac{\left(36 - {x}^{2} \cdot 81\right) \cdot x}{6 + 9 \cdot x}} \]
  6. Taylor expanded in x around 0 47.2%

    \[\leadsto \frac{\color{blue}{36 \cdot x}}{6 + 9 \cdot x} \]
  7. Step-by-step derivation
    1. *-commutative47.2%

      \[\leadsto \frac{\color{blue}{x \cdot 36}}{6 + 9 \cdot x} \]
  8. Simplified47.2%

    \[\leadsto \frac{\color{blue}{x \cdot 36}}{6 + 9 \cdot x} \]
  9. Taylor expanded in x around inf 2.2%

    \[\leadsto \color{blue}{4} \]
  10. Final simplification2.2%

    \[\leadsto 4 \]

Developer target: 99.7% accurate, 1.0× speedup?

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

\\
6 \cdot x - 9 \cdot \left(x \cdot x\right)
\end{array}

Reproduce

?
herbie shell --seed 2023340 
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, E"
  :precision binary64

  :herbie-target
  (- (* 6.0 x) (* 9.0 (* x x)))

  (* (* 3.0 (- 2.0 (* x 3.0))) x))