Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A

Percentage Accurate: 99.9% → 99.8%
Time: 7.5s
Alternatives: 8
Speedup: 1.3×

Specification

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

\\
1 - x \cdot \left(0.253 + x \cdot 0.12\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 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.9% accurate, 1.0× speedup?

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

\\
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\end{array}

Alternative 1: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{-\mathsf{fma}\left(x, 0.12, -0.253\right)}, \mathsf{fma}\left(x, x \cdot 0.0144, -0.064009\right), 1\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (fma (/ x (- (fma x 0.12 -0.253))) (fma x (* x 0.0144) -0.064009) 1.0))
double code(double x) {
	return fma((x / -fma(x, 0.12, -0.253)), fma(x, (x * 0.0144), -0.064009), 1.0);
}
function code(x)
	return fma(Float64(x / Float64(-fma(x, 0.12, -0.253))), fma(x, Float64(x * 0.0144), -0.064009), 1.0)
end
code[x_] := N[(N[(x / (-N[(x * 0.12 + -0.253), $MachinePrecision])), $MachinePrecision] * N[(x * N[(x * 0.0144), $MachinePrecision] + -0.064009), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{x}{-\mathsf{fma}\left(x, 0.12, -0.253\right)}, \mathsf{fma}\left(x, x \cdot 0.0144, -0.064009\right), 1\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

      \[\leadsto 1 - x \cdot \left(\frac{253}{1000} + \color{blue}{x \cdot \frac{3}{25}}\right) \]
    2. lift-+.f64N/A

      \[\leadsto 1 - x \cdot \color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
    3. lift-*.f64N/A

      \[\leadsto 1 - \color{blue}{x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
    4. sub-negN/A

      \[\leadsto \color{blue}{1 + \left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right)} \]
    5. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right) + 1} \]
    6. lift-*.f64N/A

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

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right) \cdot x}\right)\right) + 1 \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right), x, 1\right)} \]
    10. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)}\right), x, 1\right) \]
    11. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \frac{3}{25} + \frac{253}{1000}\right)}\right), x, 1\right) \]
    12. distribute-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{3}{25}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
    13. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{x \cdot \frac{3}{25}}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    14. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(\frac{3}{25}\right)\right)} + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    15. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, \mathsf{neg}\left(\frac{3}{25}\right), \mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
    16. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{\frac{-3}{25}}, \mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    17. metadata-eval99.8

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, \color{blue}{-0.253}\right), x, 1\right) \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, -0.253\right), x, 1\right)} \]
  5. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-x}{\mathsf{fma}\left(x, 0.12, -0.253\right)}, \mathsf{fma}\left(x, x \cdot 0.0144, -0.064009\right), 1\right)} \]
  6. Final simplification99.9%

    \[\leadsto \mathsf{fma}\left(\frac{x}{-\mathsf{fma}\left(x, 0.12, -0.253\right)}, \mathsf{fma}\left(x, x \cdot 0.0144, -0.064009\right), 1\right) \]
  7. Add Preprocessing

Alternative 2: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot \left(x \cdot 0.12 + 0.253\right) \leq 0.002:\\ \;\;\;\;\mathsf{fma}\left(-0.253, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, -0.12, -0.253\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (* x (+ (* x 0.12) 0.253)) 0.002)
   (fma -0.253 x 1.0)
   (* x (fma x -0.12 -0.253))))
double code(double x) {
	double tmp;
	if ((x * ((x * 0.12) + 0.253)) <= 0.002) {
		tmp = fma(-0.253, x, 1.0);
	} else {
		tmp = x * fma(x, -0.12, -0.253);
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(x * Float64(Float64(x * 0.12) + 0.253)) <= 0.002)
		tmp = fma(-0.253, x, 1.0);
	else
		tmp = Float64(x * fma(x, -0.12, -0.253));
	end
	return tmp
end
code[x_] := If[LessEqual[N[(x * N[(N[(x * 0.12), $MachinePrecision] + 0.253), $MachinePrecision]), $MachinePrecision], 0.002], N[(-0.253 * x + 1.0), $MachinePrecision], N[(x * N[(x * -0.12 + -0.253), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot \left(x \cdot 0.12 + 0.253\right) \leq 0.002:\\
\;\;\;\;\mathsf{fma}\left(-0.253, x, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (+.f64 #s(literal 253/1000 binary64) (*.f64 x #s(literal 3/25 binary64)))) < 2e-3

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{1 + \frac{-253}{1000} \cdot x} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-253}{1000} \cdot x + 1} \]
      2. lower-fma.f6499.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.253, x, 1\right)} \]
    5. Simplified99.3%

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

    if 2e-3 < (*.f64 x (+.f64 #s(literal 253/1000 binary64) (*.f64 x #s(literal 3/25 binary64))))

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{-1 \cdot \left({x}^{2} \cdot \left(\frac{3}{25} + \frac{253}{1000} \cdot \frac{1}{x}\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left({x}^{2} \cdot \left(\frac{3}{25} + \frac{253}{1000} \cdot \frac{1}{x}\right)\right)} \]
      2. unpow2N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{3}{25} + \frac{253}{1000} \cdot \frac{1}{x}\right)\right) \]
      3. associate-*l*N/A

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

        \[\leadsto \color{blue}{x \cdot \left(\mathsf{neg}\left(x \cdot \left(\frac{3}{25} + \frac{253}{1000} \cdot \frac{1}{x}\right)\right)\right)} \]
      5. lower-*.f64N/A

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

        \[\leadsto x \cdot \color{blue}{\left(x \cdot \left(\mathsf{neg}\left(\left(\frac{3}{25} + \frac{253}{1000} \cdot \frac{1}{x}\right)\right)\right)\right)} \]
      7. distribute-neg-inN/A

        \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{3}{25}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000} \cdot \frac{1}{x}\right)\right)\right)}\right) \]
      8. metadata-evalN/A

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{-3}{25} \cdot x + \left(\mathsf{neg}\left(\frac{253}{1000} \cdot \frac{1}{x}\right)\right) \cdot x\right)} \]
      10. distribute-lft-neg-inN/A

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

        \[\leadsto x \cdot \left(\frac{-3}{25} \cdot x + \left(\color{blue}{\frac{-253}{1000}} \cdot \frac{1}{x}\right) \cdot x\right) \]
      12. associate-*l*N/A

        \[\leadsto x \cdot \left(\frac{-3}{25} \cdot x + \color{blue}{\frac{-253}{1000} \cdot \left(\frac{1}{x} \cdot x\right)}\right) \]
      13. lft-mult-inverseN/A

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

        \[\leadsto x \cdot \left(\frac{-3}{25} \cdot x + \color{blue}{\frac{-253}{1000}}\right) \]
      15. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-3}{25} \cdot x + \color{blue}{\left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)}\right) \]
      16. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-3}{25} \cdot x + \color{blue}{\frac{-253}{1000}}\right) \]
      17. *-commutativeN/A

        \[\leadsto x \cdot \left(\color{blue}{x \cdot \frac{-3}{25}} + \frac{-253}{1000}\right) \]
      18. lower-fma.f6498.8

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(x, -0.12, -0.253\right)} \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(x, -0.12, -0.253\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(x \cdot 0.12 + 0.253\right) \leq 0.002:\\ \;\;\;\;\mathsf{fma}\left(-0.253, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, -0.12, -0.253\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 98.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot \left(x \cdot 0.12 + 0.253\right) \leq 0.002:\\ \;\;\;\;\mathsf{fma}\left(-0.253, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (* x (+ (* x 0.12) 0.253)) 0.002)
   (fma -0.253 x 1.0)
   (* x (* x -0.12))))
double code(double x) {
	double tmp;
	if ((x * ((x * 0.12) + 0.253)) <= 0.002) {
		tmp = fma(-0.253, x, 1.0);
	} else {
		tmp = x * (x * -0.12);
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(x * Float64(Float64(x * 0.12) + 0.253)) <= 0.002)
		tmp = fma(-0.253, x, 1.0);
	else
		tmp = Float64(x * Float64(x * -0.12));
	end
	return tmp
end
code[x_] := If[LessEqual[N[(x * N[(N[(x * 0.12), $MachinePrecision] + 0.253), $MachinePrecision]), $MachinePrecision], 0.002], N[(-0.253 * x + 1.0), $MachinePrecision], N[(x * N[(x * -0.12), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot \left(x \cdot 0.12 + 0.253\right) \leq 0.002:\\
\;\;\;\;\mathsf{fma}\left(-0.253, x, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (+.f64 #s(literal 253/1000 binary64) (*.f64 x #s(literal 3/25 binary64)))) < 2e-3

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{1 + \frac{-253}{1000} \cdot x} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-253}{1000} \cdot x + 1} \]
      2. lower-fma.f6499.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.253, x, 1\right)} \]
    5. Simplified99.3%

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

    if 2e-3 < (*.f64 x (+.f64 #s(literal 253/1000 binary64) (*.f64 x #s(literal 3/25 binary64))))

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{\frac{-3}{25} \cdot {x}^{2}} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(x \cdot \frac{-3}{25}\right)} \]
      6. lower-*.f6498.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(x \cdot 0.12 + 0.253\right) \leq 0.002:\\ \;\;\;\;\mathsf{fma}\left(-0.253, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot -0.12\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.9% accurate, 1.1× speedup?

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

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

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

      \[\leadsto 1 - x \cdot \left(\frac{253}{1000} + \color{blue}{x \cdot \frac{3}{25}}\right) \]
    2. lift-+.f64N/A

      \[\leadsto 1 - x \cdot \color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
    3. lift-*.f64N/A

      \[\leadsto 1 - \color{blue}{x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
    4. sub-negN/A

      \[\leadsto \color{blue}{1 + \left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right)} \]
    5. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right) + 1} \]
    6. lift-*.f64N/A

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

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right) \cdot x}\right)\right) + 1 \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right), x, 1\right)} \]
    10. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)}\right), x, 1\right) \]
    11. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \frac{3}{25} + \frac{253}{1000}\right)}\right), x, 1\right) \]
    12. distribute-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{3}{25}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
    13. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{x \cdot \frac{3}{25}}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    14. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(\frac{3}{25}\right)\right)} + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    15. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, \mathsf{neg}\left(\frac{3}{25}\right), \mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
    16. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{\frac{-3}{25}}, \mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    17. metadata-eval99.8

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, \color{blue}{-0.253}\right), x, 1\right) \]
  4. Applied egg-rr99.8%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot \frac{-3}{25}} + \frac{-253}{1000}, x, 1\right) \]
    2. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-253}{1000} + x \cdot \frac{-3}{25}}, x, 1\right) \]
    3. lift-*.f64N/A

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

      \[\leadsto \mathsf{fma}\left(\frac{-253}{1000} + \color{blue}{\frac{-3}{25} \cdot x}, x, 1\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\frac{-253}{1000} + \color{blue}{\left(\mathsf{neg}\left(\frac{3}{25}\right)\right)} \cdot x, x, 1\right) \]
    6. cancel-sign-sub-invN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-253}{1000} - \frac{3}{25} \cdot x}, x, 1\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\frac{-253}{1000} - \color{blue}{x \cdot \frac{3}{25}}, x, 1\right) \]
    8. lower--.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-253}{1000} - x \cdot \frac{3}{25}}, x, 1\right) \]
    9. lower-*.f6499.8

      \[\leadsto \mathsf{fma}\left(-0.253 - \color{blue}{x \cdot 0.12}, x, 1\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto \mathsf{fma}\left(\color{blue}{-0.253 - x \cdot 0.12}, x, 1\right) \]
  7. Add Preprocessing

Alternative 5: 99.9% accurate, 1.3× speedup?

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

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

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

      \[\leadsto 1 - x \cdot \left(\frac{253}{1000} + \color{blue}{x \cdot \frac{3}{25}}\right) \]
    2. lift-+.f64N/A

      \[\leadsto 1 - x \cdot \color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
    3. lift-*.f64N/A

      \[\leadsto 1 - \color{blue}{x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
    4. sub-negN/A

      \[\leadsto \color{blue}{1 + \left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right)} \]
    5. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right) + 1} \]
    6. lift-*.f64N/A

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

      \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right) \cdot x}\right)\right) + 1 \]
    8. distribute-lft-neg-inN/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right), x, 1\right)} \]
    10. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)}\right), x, 1\right) \]
    11. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \frac{3}{25} + \frac{253}{1000}\right)}\right), x, 1\right) \]
    12. distribute-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{3}{25}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
    13. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{x \cdot \frac{3}{25}}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    14. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(\frac{3}{25}\right)\right)} + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    15. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, \mathsf{neg}\left(\frac{3}{25}\right), \mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
    16. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{\frac{-3}{25}}, \mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
    17. metadata-eval99.8

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, \color{blue}{-0.253}\right), x, 1\right) \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, -0.253\right), x, 1\right)} \]
  5. Add Preprocessing

Alternative 6: 51.6% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;x \cdot -0.253\\


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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{1} \]
    4. Step-by-step derivation
      1. Simplified69.8%

        \[\leadsto \color{blue}{1} \]

      if 2 < x

      1. Initial program 99.7%

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

          \[\leadsto 1 - x \cdot \left(\frac{253}{1000} + \color{blue}{x \cdot \frac{3}{25}}\right) \]
        2. lift-+.f64N/A

          \[\leadsto 1 - x \cdot \color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
        3. lift-*.f64N/A

          \[\leadsto 1 - \color{blue}{x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)} \]
        4. sub-negN/A

          \[\leadsto \color{blue}{1 + \left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right)} \]
        5. +-commutativeN/A

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x \cdot \left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right)\right) + 1} \]
        6. lift-*.f64N/A

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

          \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right) \cdot x}\right)\right) + 1 \]
        8. distribute-lft-neg-inN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)\right), x, 1\right)} \]
        10. lift-+.f64N/A

          \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\frac{253}{1000} + x \cdot \frac{3}{25}\right)}\right), x, 1\right) \]
        11. +-commutativeN/A

          \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \frac{3}{25} + \frac{253}{1000}\right)}\right), x, 1\right) \]
        12. distribute-neg-inN/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{3}{25}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
        13. lift-*.f64N/A

          \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(\color{blue}{x \cdot \frac{3}{25}}\right)\right) + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
        14. distribute-rgt-neg-inN/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot \left(\mathsf{neg}\left(\frac{3}{25}\right)\right)} + \left(\mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
        15. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, \mathsf{neg}\left(\frac{3}{25}\right), \mathsf{neg}\left(\frac{253}{1000}\right)\right)}, x, 1\right) \]
        16. metadata-evalN/A

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{\frac{-3}{25}}, \mathsf{neg}\left(\frac{253}{1000}\right)\right), x, 1\right) \]
        17. metadata-eval99.7

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, \color{blue}{-0.253}\right), x, 1\right) \]
      4. Applied egg-rr99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, -0.12, -0.253\right), x, 1\right)} \]
      5. Taylor expanded in x around 0

        \[\leadsto \color{blue}{1 + \frac{-253}{1000} \cdot x} \]
      6. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto 1 + \color{blue}{\left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)} \cdot x \]
        2. distribute-lft-neg-inN/A

          \[\leadsto 1 + \color{blue}{\left(\mathsf{neg}\left(\frac{253}{1000} \cdot x\right)\right)} \]
        3. unsub-negN/A

          \[\leadsto \color{blue}{1 - \frac{253}{1000} \cdot x} \]
        4. *-lft-identityN/A

          \[\leadsto 1 - \frac{253}{1000} \cdot \color{blue}{\left(1 \cdot x\right)} \]
        5. lft-mult-inverseN/A

          \[\leadsto 1 - \frac{253}{1000} \cdot \left(\color{blue}{\left(\frac{1}{x} \cdot x\right)} \cdot x\right) \]
        6. associate-*r*N/A

          \[\leadsto 1 - \frac{253}{1000} \cdot \color{blue}{\left(\frac{1}{x} \cdot \left(x \cdot x\right)\right)} \]
        7. unpow2N/A

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

          \[\leadsto 1 - \color{blue}{\left(\frac{253}{1000} \cdot \frac{1}{x}\right) \cdot {x}^{2}} \]
        9. *-commutativeN/A

          \[\leadsto 1 - \color{blue}{{x}^{2} \cdot \left(\frac{253}{1000} \cdot \frac{1}{x}\right)} \]
        10. cancel-sign-sub-invN/A

          \[\leadsto \color{blue}{1 + \left(\mathsf{neg}\left({x}^{2}\right)\right) \cdot \left(\frac{253}{1000} \cdot \frac{1}{x}\right)} \]
        11. lft-mult-inverseN/A

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

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

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

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

          \[\leadsto \frac{1}{x} \cdot x + \left(\mathsf{neg}\left(\color{blue}{\left(\left(\frac{253}{1000} \cdot \frac{1}{x}\right) \cdot x\right) \cdot x}\right)\right) \]
        16. distribute-lft-neg-inN/A

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

          \[\leadsto \color{blue}{x \cdot \left(\frac{1}{x} + \left(\mathsf{neg}\left(\left(\frac{253}{1000} \cdot \frac{1}{x}\right) \cdot x\right)\right)\right)} \]
        18. +-commutativeN/A

          \[\leadsto x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(\frac{253}{1000} \cdot \frac{1}{x}\right) \cdot x\right)\right) + \frac{1}{x}\right)} \]
        19. distribute-lft-inN/A

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{neg}\left(\left(\frac{253}{1000} \cdot \frac{1}{x}\right) \cdot x\right), 1\right)} \]
      7. Simplified6.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -0.253, 1\right)} \]
      8. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{-253}{1000} \cdot x} \]
      9. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{x \cdot \frac{-253}{1000}} \]
        2. metadata-evalN/A

          \[\leadsto x \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{253}{1000}\right)\right)} \]
        3. distribute-rgt-neg-inN/A

          \[\leadsto \color{blue}{\mathsf{neg}\left(x \cdot \frac{253}{1000}\right)} \]
        4. distribute-lft-neg-outN/A

          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \frac{253}{1000}} \]
        5. metadata-evalN/A

          \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\frac{253}{1000} \cdot 1\right)} \]
        6. lft-mult-inverseN/A

          \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\frac{253}{1000} \cdot \color{blue}{\left(\frac{1}{x} \cdot x\right)}\right) \]
        7. associate-*l*N/A

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

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

          \[\leadsto \color{blue}{x \cdot \left(\mathsf{neg}\left(\left(\frac{253}{1000} \cdot \frac{1}{x}\right) \cdot x\right)\right)} \]
        10. lower-*.f64N/A

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

          \[\leadsto x \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{253}{1000} \cdot \left(\frac{1}{x} \cdot x\right)}\right)\right) \]
        12. lft-mult-inverseN/A

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

          \[\leadsto x \cdot \left(\mathsf{neg}\left(\color{blue}{\frac{253}{1000}}\right)\right) \]
        14. metadata-eval6.8

          \[\leadsto x \cdot \color{blue}{-0.253} \]
      10. Simplified6.8%

        \[\leadsto \color{blue}{x \cdot -0.253} \]
    5. Recombined 2 regimes into one program.
    6. Add Preprocessing

    Alternative 7: 51.9% accurate, 2.4× speedup?

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

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

      \[\leadsto \color{blue}{1 + \frac{-253}{1000} \cdot x} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{-253}{1000} \cdot x + 1} \]
      2. lower-fma.f6453.9

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.253, x, 1\right)} \]
    5. Simplified53.9%

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

    Alternative 8: 50.1% accurate, 17.0× speedup?

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

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

      \[\leadsto \color{blue}{1} \]
    4. Step-by-step derivation
      1. Simplified51.7%

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

      Reproduce

      ?
      herbie shell --seed 2024207 
      (FPCore (x)
        :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
        :precision binary64
        (- 1.0 (* x (+ 0.253 (* x 0.12)))))