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

Percentage Accurate: 99.8% → 99.9%
Time: 6.3s
Alternatives: 6
Speedup: 2.1×

Specification

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

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

\\
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\end{array}

Alternative 1: 99.9% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right) \end{array} \]
(FPCore (x) :precision binary64 (fma (fma 9.0 x -12.0) x 3.0))
double code(double x) {
	return fma(fma(9.0, x, -12.0), x, 3.0);
}
function code(x)
	return fma(fma(9.0, x, -12.0), x, 3.0)
end
code[x_] := N[(N[(9.0 * x + -12.0), $MachinePrecision] * x + 3.0), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

    \[\leadsto \color{blue}{3 + x \cdot \left(9 \cdot x - 12\right)} \]
  4. Step-by-step derivation
    1. remove-double-negN/A

      \[\leadsto 3 + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \cdot \left(9 \cdot x - 12\right) \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \left(9 \cdot x - 12\right) + 3} \]
    3. remove-double-negN/A

      \[\leadsto \color{blue}{x} \cdot \left(9 \cdot x - 12\right) + 3 \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{\left(9 \cdot x - 12\right) \cdot x} + 3 \]
    5. metadata-evalN/A

      \[\leadsto \left(9 \cdot x - \color{blue}{1 \cdot 12}\right) \cdot x + 3 \]
    6. rgt-mult-inverseN/A

      \[\leadsto \left(9 \cdot x - \color{blue}{\left(x \cdot \frac{1}{x}\right)} \cdot 12\right) \cdot x + 3 \]
    7. metadata-evalN/A

      \[\leadsto \left(9 \cdot x - \left(x \cdot \frac{1}{x}\right) \cdot \color{blue}{\left(\mathsf{neg}\left(-12\right)\right)}\right) \cdot x + 3 \]
    8. distribute-rgt-neg-inN/A

      \[\leadsto \left(9 \cdot x - \color{blue}{\left(\mathsf{neg}\left(\left(x \cdot \frac{1}{x}\right) \cdot -12\right)\right)}\right) \cdot x + 3 \]
    9. associate-*r*N/A

      \[\leadsto \left(9 \cdot x - \left(\mathsf{neg}\left(\color{blue}{x \cdot \left(\frac{1}{x} \cdot -12\right)}\right)\right)\right) \cdot x + 3 \]
    10. *-commutativeN/A

      \[\leadsto \left(9 \cdot x - \left(\mathsf{neg}\left(x \cdot \color{blue}{\left(-12 \cdot \frac{1}{x}\right)}\right)\right)\right) \cdot x + 3 \]
    11. metadata-evalN/A

      \[\leadsto \left(9 \cdot x - \left(\mathsf{neg}\left(x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(12\right)\right)} \cdot \frac{1}{x}\right)\right)\right)\right) \cdot x + 3 \]
    12. distribute-lft-neg-outN/A

      \[\leadsto \left(9 \cdot x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right) \cdot x + 3 \]
    13. fp-cancel-sign-sub-invN/A

      \[\leadsto \color{blue}{\left(9 \cdot x + x \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)\right)} \cdot x + 3 \]
    14. *-commutativeN/A

      \[\leadsto \left(\color{blue}{x \cdot 9} + x \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)\right) \cdot x + 3 \]
    15. distribute-lft-inN/A

      \[\leadsto \color{blue}{\left(x \cdot \left(9 + \left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)\right)} \cdot x + 3 \]
    16. fp-cancel-sub-sign-invN/A

      \[\leadsto \left(x \cdot \color{blue}{\left(9 - 12 \cdot \frac{1}{x}\right)}\right) \cdot x + 3 \]
    17. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right), x, 3\right)} \]
  5. Applied rewrites99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(9, x, -12\right), x, 3\right)} \]
  6. Add Preprocessing

Alternative 2: 98.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\ \;\;\;\;3 \cdot \mathsf{fma}\left(-4, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(9, x, -12\right) \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)) 5.0)
   (* 3.0 (fma -4.0 x 1.0))
   (* (fma 9.0 x -12.0) x)))
double code(double x) {
	double tmp;
	if ((3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)) <= 5.0) {
		tmp = 3.0 * fma(-4.0, x, 1.0);
	} else {
		tmp = fma(9.0, x, -12.0) * x;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) <= 5.0)
		tmp = Float64(3.0 * fma(-4.0, x, 1.0));
	else
		tmp = Float64(fma(9.0, x, -12.0) * x);
	end
	return tmp
end
code[x_] := If[LessEqual[N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 5.0], N[(3.0 * N[(-4.0 * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(9.0 * x + -12.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\
\;\;\;\;3 \cdot \mathsf{fma}\left(-4, x, 1\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(9, x, -12\right) \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64))) < 5

    1. Initial program 100.0%

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

      \[\leadsto 3 \cdot \color{blue}{\left(1 + -4 \cdot x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 3 \cdot \color{blue}{\left(-4 \cdot x + 1\right)} \]
      2. rgt-mult-inverseN/A

        \[\leadsto 3 \cdot \left(-4 \cdot x + \color{blue}{x \cdot \frac{1}{x}}\right) \]
      3. *-commutativeN/A

        \[\leadsto 3 \cdot \left(\color{blue}{x \cdot -4} + x \cdot \frac{1}{x}\right) \]
      4. distribute-lft-inN/A

        \[\leadsto 3 \cdot \color{blue}{\left(x \cdot \left(-4 + \frac{1}{x}\right)\right)} \]
      5. metadata-evalN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\color{blue}{1 \cdot -4} + \frac{1}{x}\right)\right) \]
      6. rgt-mult-inverseN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot \frac{1}{x}\right)} \cdot -4 + \frac{1}{x}\right)\right) \]
      7. associate-*r*N/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\color{blue}{x \cdot \left(\frac{1}{x} \cdot -4\right)} + \frac{1}{x}\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(-4 \cdot \frac{1}{x}\right)} + \frac{1}{x}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(4\right)\right)} \cdot \frac{1}{x}\right) + \frac{1}{x}\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\color{blue}{\left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot x} + \frac{1}{x}\right)\right) \]
      11. rgt-mult-inverseN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot x + \frac{\color{blue}{x \cdot \frac{1}{x}}}{x}\right)\right) \]
      12. associate-*r/N/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot x + \color{blue}{x \cdot \frac{\frac{1}{x}}{x}}\right)\right) \]
      13. associate-/r*N/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot x + x \cdot \color{blue}{\frac{1}{x \cdot x}}\right)\right) \]
      14. unpow2N/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot x + x \cdot \frac{1}{\color{blue}{{x}^{2}}}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(\left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot x + \color{blue}{\frac{1}{{x}^{2}} \cdot x}\right)\right) \]
      16. distribute-rgt-inN/A

        \[\leadsto 3 \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x} + \frac{1}{{x}^{2}}\right)\right)}\right) \]
      17. +-commutativeN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(\frac{1}{{x}^{2}} + \left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right)}\right)\right) \]
      18. fp-cancel-sub-sign-invN/A

        \[\leadsto 3 \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(\frac{1}{{x}^{2}} - 4 \cdot \frac{1}{x}\right)}\right)\right) \]
      19. associate-*l*N/A

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

        \[\leadsto 3 \cdot \left(\color{blue}{{x}^{2}} \cdot \left(\frac{1}{{x}^{2}} - 4 \cdot \frac{1}{x}\right)\right) \]
    5. Applied rewrites99.2%

      \[\leadsto 3 \cdot \color{blue}{\mathsf{fma}\left(-4, x, 1\right)} \]

    if 5 < (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64)))

    1. Initial program 99.6%

      \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{{x}^{2} \cdot \left(9 - 12 \cdot \frac{1}{x}\right)} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(9 - 12 \cdot \frac{1}{x}\right) \]
      2. associate-*l*N/A

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right)\right)} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right)\right) \cdot x} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right)\right) \cdot x} \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(x \cdot \color{blue}{\left(9 + \left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right) \cdot x \]
      6. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(9 \cdot x + \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \cdot x \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(9, x, \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \cdot x \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right) \cdot x \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(9, x, x \cdot \left(\color{blue}{-12} \cdot \frac{1}{x}\right)\right) \cdot x \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(9, x, x \cdot \color{blue}{\left(\frac{1}{x} \cdot -12\right)}\right) \cdot x \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{\left(x \cdot \frac{1}{x}\right) \cdot -12}\right) \cdot x \]
      12. rgt-mult-inverseN/A

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{1} \cdot -12\right) \cdot x \]
      13. metadata-eval99.3

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{-12}\right) \cdot x \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(9, x, -12\right) \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 98.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\ \;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(9, x, -12\right) \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)) 5.0)
   (fma -12.0 x 3.0)
   (* (fma 9.0 x -12.0) x)))
double code(double x) {
	double tmp;
	if ((3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)) <= 5.0) {
		tmp = fma(-12.0, x, 3.0);
	} else {
		tmp = fma(9.0, x, -12.0) * x;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) <= 5.0)
		tmp = fma(-12.0, x, 3.0);
	else
		tmp = Float64(fma(9.0, x, -12.0) * x);
	end
	return tmp
end
code[x_] := If[LessEqual[N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 5.0], N[(-12.0 * x + 3.0), $MachinePrecision], N[(N[(9.0 * x + -12.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\
\;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(9, x, -12\right) \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64))) < 5

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{3 + -12 \cdot x} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto 3 + \color{blue}{x \cdot -12} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{3 - \left(\mathsf{neg}\left(x\right)\right) \cdot -12} \]
      3. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(1 \cdot -12\right)} \]
      4. rgt-mult-inverseN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\color{blue}{\left(x \cdot \frac{1}{x}\right)} \cdot -12\right) \]
      5. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(x \cdot \left(\frac{1}{x} \cdot -12\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(x \cdot \color{blue}{\left(-12 \cdot \frac{1}{x}\right)}\right) \]
      7. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(12\right)\right)} \cdot \frac{1}{x}\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)\right)\right)} \]
      10. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right) \cdot x}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot \left(x \cdot x\right)}\right)\right) \]
      12. unpow2N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{{x}^{2} \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left({x}^{2} \cdot \left(\color{blue}{-12} \cdot \frac{1}{x}\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left({x}^{2} \cdot \color{blue}{\left(\frac{1}{x} \cdot -12\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left({x}^{2} \cdot \frac{1}{x}\right) \cdot -12}\right)\right) \]
      17. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left({x}^{2} \cdot \frac{1}{x}\right)\right) \cdot -12} \]
      18. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot \frac{1}{x}\right)} \cdot -12 \]
      19. associate-*r/N/A

        \[\leadsto 3 - \color{blue}{\frac{\left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot 1}{x}} \cdot -12 \]
      20. *-rgt-identityN/A

        \[\leadsto 3 - \frac{\color{blue}{\mathsf{neg}\left({x}^{2}\right)}}{x} \cdot -12 \]
      21. distribute-frac-negN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left(\frac{{x}^{2}}{x}\right)\right)} \cdot -12 \]
      22. distribute-frac-neg2N/A

        \[\leadsto 3 - \color{blue}{\frac{{x}^{2}}{\mathsf{neg}\left(x\right)}} \cdot -12 \]
    5. Applied rewrites99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-12, x, 3\right)} \]

    if 5 < (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64)))

    1. Initial program 99.6%

      \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{{x}^{2} \cdot \left(9 - 12 \cdot \frac{1}{x}\right)} \]
    4. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(9 - 12 \cdot \frac{1}{x}\right) \]
      2. associate-*l*N/A

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right)\right)} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right)\right) \cdot x} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left(9 - 12 \cdot \frac{1}{x}\right)\right) \cdot x} \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(x \cdot \color{blue}{\left(9 + \left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right) \cdot x \]
      6. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(9 \cdot x + \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \cdot x \]
      7. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(9, x, \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \cdot x \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{x \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right) \cdot x \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(9, x, x \cdot \left(\color{blue}{-12} \cdot \frac{1}{x}\right)\right) \cdot x \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(9, x, x \cdot \color{blue}{\left(\frac{1}{x} \cdot -12\right)}\right) \cdot x \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{\left(x \cdot \frac{1}{x}\right) \cdot -12}\right) \cdot x \]
      12. rgt-mult-inverseN/A

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{1} \cdot -12\right) \cdot x \]
      13. metadata-eval99.3

        \[\leadsto \mathsf{fma}\left(9, x, \color{blue}{-12}\right) \cdot x \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(9, x, -12\right) \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\ \;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\ \mathbf{else}:\\ \;\;\;\;\left(9 \cdot x\right) \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)) 5.0)
   (fma -12.0 x 3.0)
   (* (* 9.0 x) x)))
double code(double x) {
	double tmp;
	if ((3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)) <= 5.0) {
		tmp = fma(-12.0, x, 3.0);
	} else {
		tmp = (9.0 * x) * x;
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0)) <= 5.0)
		tmp = fma(-12.0, x, 3.0);
	else
		tmp = Float64(Float64(9.0 * x) * x);
	end
	return tmp
end
code[x_] := If[LessEqual[N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 5.0], N[(-12.0 * x + 3.0), $MachinePrecision], N[(N[(9.0 * x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \leq 5:\\
\;\;\;\;\mathsf{fma}\left(-12, x, 3\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64))) < 5

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{3 + -12 \cdot x} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto 3 + \color{blue}{x \cdot -12} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{3 - \left(\mathsf{neg}\left(x\right)\right) \cdot -12} \]
      3. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(1 \cdot -12\right)} \]
      4. rgt-mult-inverseN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\color{blue}{\left(x \cdot \frac{1}{x}\right)} \cdot -12\right) \]
      5. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(x \cdot \left(\frac{1}{x} \cdot -12\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(x \cdot \color{blue}{\left(-12 \cdot \frac{1}{x}\right)}\right) \]
      7. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(12\right)\right)} \cdot \frac{1}{x}\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)\right)\right)} \]
      10. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right) \cdot x}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot \left(x \cdot x\right)}\right)\right) \]
      12. unpow2N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{{x}^{2} \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left({x}^{2} \cdot \left(\color{blue}{-12} \cdot \frac{1}{x}\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left({x}^{2} \cdot \color{blue}{\left(\frac{1}{x} \cdot -12\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left({x}^{2} \cdot \frac{1}{x}\right) \cdot -12}\right)\right) \]
      17. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left({x}^{2} \cdot \frac{1}{x}\right)\right) \cdot -12} \]
      18. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot \frac{1}{x}\right)} \cdot -12 \]
      19. associate-*r/N/A

        \[\leadsto 3 - \color{blue}{\frac{\left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot 1}{x}} \cdot -12 \]
      20. *-rgt-identityN/A

        \[\leadsto 3 - \frac{\color{blue}{\mathsf{neg}\left({x}^{2}\right)}}{x} \cdot -12 \]
      21. distribute-frac-negN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left(\frac{{x}^{2}}{x}\right)\right)} \cdot -12 \]
      22. distribute-frac-neg2N/A

        \[\leadsto 3 - \color{blue}{\frac{{x}^{2}}{\mathsf{neg}\left(x\right)}} \cdot -12 \]
    5. Applied rewrites99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-12, x, 3\right)} \]

    if 5 < (*.f64 #s(literal 3 binary64) (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 3 binary64)) x) (*.f64 x #s(literal 4 binary64))) #s(literal 1 binary64)))

    1. Initial program 99.6%

      \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{9 \cdot {x}^{2}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{{x}^{2} \cdot 9} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{{x}^{2} \cdot 9} \]
      3. unpow2N/A

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot 9 \]
      4. lower-*.f6498.2

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot 9 \]
    5. Applied rewrites98.2%

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

        \[\leadsto \color{blue}{\left(9 \cdot x\right) \cdot x} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 5: 51.2% accurate, 3.9× speedup?

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

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

      \[\leadsto \color{blue}{3 + -12 \cdot x} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto 3 + \color{blue}{x \cdot -12} \]
      2. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{3 - \left(\mathsf{neg}\left(x\right)\right) \cdot -12} \]
      3. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(1 \cdot -12\right)} \]
      4. rgt-mult-inverseN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\color{blue}{\left(x \cdot \frac{1}{x}\right)} \cdot -12\right) \]
      5. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(x \cdot \left(\frac{1}{x} \cdot -12\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(x \cdot \color{blue}{\left(-12 \cdot \frac{1}{x}\right)}\right) \]
      7. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(12\right)\right)} \cdot \frac{1}{x}\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)} \]
      9. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right)\right)\right)} \]
      10. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot x\right) \cdot x}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot \left(x \cdot x\right)}\right)\right) \]
      12. unpow2N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{{x}^{2} \cdot \left(\left(\mathsf{neg}\left(12\right)\right) \cdot \frac{1}{x}\right)}\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left({x}^{2} \cdot \left(\color{blue}{-12} \cdot \frac{1}{x}\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto 3 - \left(\mathsf{neg}\left({x}^{2} \cdot \color{blue}{\left(\frac{1}{x} \cdot -12\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto 3 - \left(\mathsf{neg}\left(\color{blue}{\left({x}^{2} \cdot \frac{1}{x}\right) \cdot -12}\right)\right) \]
      17. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left({x}^{2} \cdot \frac{1}{x}\right)\right) \cdot -12} \]
      18. distribute-lft-neg-inN/A

        \[\leadsto 3 - \color{blue}{\left(\left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot \frac{1}{x}\right)} \cdot -12 \]
      19. associate-*r/N/A

        \[\leadsto 3 - \color{blue}{\frac{\left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot 1}{x}} \cdot -12 \]
      20. *-rgt-identityN/A

        \[\leadsto 3 - \frac{\color{blue}{\mathsf{neg}\left({x}^{2}\right)}}{x} \cdot -12 \]
      21. distribute-frac-negN/A

        \[\leadsto 3 - \color{blue}{\left(\mathsf{neg}\left(\frac{{x}^{2}}{x}\right)\right)} \cdot -12 \]
      22. distribute-frac-neg2N/A

        \[\leadsto 3 - \color{blue}{\frac{{x}^{2}}{\mathsf{neg}\left(x\right)}} \cdot -12 \]
    5. Applied rewrites53.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-12, x, 3\right)} \]
    6. Add Preprocessing

    Alternative 6: 50.7% accurate, 27.0× speedup?

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

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

      \[\leadsto \color{blue}{3} \]
    4. Step-by-step derivation
      1. Applied rewrites53.4%

        \[\leadsto \color{blue}{3} \]
      2. Add Preprocessing

      Developer Target 1: 99.8% accurate, 1.2× speedup?

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

      Reproduce

      ?
      herbie shell --seed 2024339 
      (FPCore (x)
        :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
        :precision binary64
      
        :alt
        (! :herbie-platform default (+ 3 (- (* (* 9 x) x) (* 12 x))))
      
        (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))