ln(1 + x)

Percentage Accurate: 38.8% → 100.0%
Time: 11.3s
Alternatives: 8
Speedup: 10.4×

Specification

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

\\
\log \left(1 + x\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 38.8% accurate, 1.0× speedup?

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

\\
\log \left(1 + x\right)
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \mathsf{log1p}\left(x\right) \end{array} \]
(FPCore (x) :precision binary64 (log1p x))
double code(double x) {
	return log1p(x);
}
public static double code(double x) {
	return Math.log1p(x);
}
def code(x):
	return math.log1p(x)
function code(x)
	return log1p(x)
end
code[x_] := N[Log[1 + x], $MachinePrecision]
\begin{array}{l}

\\
\mathsf{log1p}\left(x\right)
\end{array}
Derivation
  1. Initial program 42.7%

    \[\log \left(1 + x\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. accelerator-lowering-log1p.f64100.0

      \[\leadsto \color{blue}{\mathsf{log1p}\left(x\right)} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(x\right)} \]
  5. Add Preprocessing

Alternative 2: 71.3% accurate, 3.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x + 1 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot x, x\right)\\

\mathbf{else}:\\
\;\;\;\;2\\


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

    1. Initial program 8.8%

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

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

        \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
      2. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
      7. accelerator-lowering-fma.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
      10. accelerator-lowering-fma.f6498.8

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

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

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

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

        \[\leadsto \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) \cdot \left(x \cdot x\right) + \color{blue}{x} \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}, x \cdot x, x\right)} \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, x \cdot \frac{-1}{4} + \frac{1}{3}, \frac{-1}{2}\right)}, x \cdot x, x\right) \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, \frac{-1}{4}, \frac{1}{3}\right)}, \frac{-1}{2}\right), x \cdot x, x\right) \]
      9. *-lowering-*.f6498.9

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), \color{blue}{x \cdot x}, x\right) \]
    7. Applied egg-rr98.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot x, x\right)} \]

    if 2 < (+.f64 #s(literal 1 binary64) x)

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
      2. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
      7. accelerator-lowering-fma.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
      10. accelerator-lowering-fma.f640.7

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
    5. Simplified0.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
    7. Applied egg-rr0.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
    8. Taylor expanded in x around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
      4. accelerator-lowering-fma.f6414.4

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
    10. Simplified14.4%

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
    11. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2} \]
    12. Step-by-step derivation
      1. Simplified14.4%

        \[\leadsto \color{blue}{2} \]
    13. Recombined 2 regimes into one program.
    14. Final simplification67.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot x, x\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
    15. Add Preprocessing

    Alternative 3: 70.8% accurate, 3.6× speedup?

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
      2. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
      7. accelerator-lowering-fma.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
      10. accelerator-lowering-fma.f6462.4

        \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
    5. Simplified62.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
    7. Applied egg-rr62.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
    8. Taylor expanded in x around 0

      \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
      4. accelerator-lowering-fma.f6467.0

        \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
    10. Simplified67.0%

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
    11. Add Preprocessing

    Alternative 4: 71.2% accurate, 3.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), x \cdot x, x\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \end{array} \]
    (FPCore (x)
     :precision binary64
     (if (<= (+ x 1.0) 2.0) (fma (fma x 0.3333333333333333 -0.5) (* x x) x) 2.0))
    double code(double x) {
    	double tmp;
    	if ((x + 1.0) <= 2.0) {
    		tmp = fma(fma(x, 0.3333333333333333, -0.5), (x * x), x);
    	} else {
    		tmp = 2.0;
    	}
    	return tmp;
    }
    
    function code(x)
    	tmp = 0.0
    	if (Float64(x + 1.0) <= 2.0)
    		tmp = fma(fma(x, 0.3333333333333333, -0.5), Float64(x * x), x);
    	else
    		tmp = 2.0;
    	end
    	return tmp
    end
    
    code[x_] := If[LessEqual[N[(x + 1.0), $MachinePrecision], 2.0], N[(N[(x * 0.3333333333333333 + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + x), $MachinePrecision], 2.0]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x + 1 \leq 2:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), x \cdot x, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;2\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (+.f64 #s(literal 1 binary64) x) < 2

      1. Initial program 8.8%

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

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

          \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{3} \cdot x - \frac{1}{2}\right)\right) + 0} \]
        2. accelerator-lowering-fma.f64N/A

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

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} \cdot x - \frac{1}{2}\right) + 1}, 0\right) \]
        4. accelerator-lowering-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, \frac{1}{3} \cdot x - \frac{1}{2}, 1\right)}, 0\right) \]
        5. sub-negN/A

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

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

          \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \frac{1}{3} + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
        8. accelerator-lowering-fma.f6498.5

          \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, 0.3333333333333333, -0.5\right)}, 1\right), 0\right) \]
      5. Simplified98.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), 1\right), 0\right)} \]
      6. Step-by-step derivation
        1. +-rgt-identityN/A

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

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

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

          \[\leadsto \color{blue}{\left(x \cdot \frac{1}{3} + \frac{-1}{2}\right) \cdot \left(x \cdot x\right)} + 1 \cdot x \]
        5. *-lft-identityN/A

          \[\leadsto \left(x \cdot \frac{1}{3} + \frac{-1}{2}\right) \cdot \left(x \cdot x\right) + \color{blue}{x} \]
        6. accelerator-lowering-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot \frac{1}{3} + \frac{-1}{2}, x \cdot x, x\right)} \]
        7. accelerator-lowering-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, \frac{1}{3}, \frac{-1}{2}\right)}, x \cdot x, x\right) \]
        8. *-lowering-*.f6498.5

          \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), \color{blue}{x \cdot x}, x\right) \]
      7. Applied egg-rr98.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), x \cdot x, x\right)} \]

      if 2 < (+.f64 #s(literal 1 binary64) x)

      1. Initial program 100.0%

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

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

          \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
        2. accelerator-lowering-fma.f64N/A

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

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
        4. accelerator-lowering-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
        5. sub-negN/A

          \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
        6. metadata-evalN/A

          \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
        7. accelerator-lowering-fma.f64N/A

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

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

          \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
        10. accelerator-lowering-fma.f640.7

          \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
      5. Simplified0.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
      6. Step-by-step derivation
        1. +-rgt-identityN/A

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
      7. Applied egg-rr0.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
      8. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
      9. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
        2. +-commutativeN/A

          \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
        3. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
        4. accelerator-lowering-fma.f6414.4

          \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
      10. Simplified14.4%

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
      11. Taylor expanded in x around inf

        \[\leadsto \color{blue}{2} \]
      12. Step-by-step derivation
        1. Simplified14.4%

          \[\leadsto \color{blue}{2} \]
      13. Recombined 2 regimes into one program.
      14. Final simplification67.3%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), x \cdot x, x\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
      15. Add Preprocessing

      Alternative 5: 71.0% accurate, 3.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.25, -0.5\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (if (<= (+ x 1.0) 2.0) (* x (fma x (fma x 0.25 -0.5) 1.0)) 2.0))
      double code(double x) {
      	double tmp;
      	if ((x + 1.0) <= 2.0) {
      		tmp = x * fma(x, fma(x, 0.25, -0.5), 1.0);
      	} else {
      		tmp = 2.0;
      	}
      	return tmp;
      }
      
      function code(x)
      	tmp = 0.0
      	if (Float64(x + 1.0) <= 2.0)
      		tmp = Float64(x * fma(x, fma(x, 0.25, -0.5), 1.0));
      	else
      		tmp = 2.0;
      	end
      	return tmp
      end
      
      code[x_] := If[LessEqual[N[(x + 1.0), $MachinePrecision], 2.0], N[(x * N[(x * N[(x * 0.25 + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], 2.0]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x + 1 \leq 2:\\
      \;\;\;\;x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.25, -0.5\right), 1\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;2\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (+.f64 #s(literal 1 binary64) x) < 2

        1. Initial program 8.8%

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

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

            \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
          2. accelerator-lowering-fma.f64N/A

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

            \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
          4. accelerator-lowering-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
          5. sub-negN/A

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
          6. metadata-evalN/A

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
          7. accelerator-lowering-fma.f64N/A

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

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

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
          10. accelerator-lowering-fma.f6498.8

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
        5. Simplified98.8%

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
        6. Step-by-step derivation
          1. +-rgt-identityN/A

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
          7. /-lowering-/.f64N/A

            \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
        7. Applied egg-rr98.6%

          \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
        8. Taylor expanded in x around 0

          \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
        9. Step-by-step derivation
          1. /-lowering-/.f64N/A

            \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
          2. +-commutativeN/A

            \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
          3. *-commutativeN/A

            \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
          4. accelerator-lowering-fma.f6498.0

            \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
        10. Simplified98.0%

          \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
        11. Taylor expanded in x around 0

          \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(\frac{1}{4} \cdot x - \frac{1}{2}\right)\right)} \]
        12. Step-by-step derivation
          1. *-lowering-*.f64N/A

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

            \[\leadsto x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{4} \cdot x - \frac{1}{2}\right) + 1\right)} \]
          3. accelerator-lowering-fma.f64N/A

            \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{4} \cdot x - \frac{1}{2}, 1\right)} \]
          4. sub-negN/A

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

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

            \[\leadsto x \cdot \mathsf{fma}\left(x, x \cdot \frac{1}{4} + \color{blue}{\frac{-1}{2}}, 1\right) \]
          7. accelerator-lowering-fma.f6498.3

            \[\leadsto x \cdot \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, 0.25, -0.5\right)}, 1\right) \]
        13. Simplified98.3%

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

        if 2 < (+.f64 #s(literal 1 binary64) x)

        1. Initial program 100.0%

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

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

            \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
          2. accelerator-lowering-fma.f64N/A

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

            \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
          4. accelerator-lowering-fma.f64N/A

            \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
          5. sub-negN/A

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
          6. metadata-evalN/A

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
          7. accelerator-lowering-fma.f64N/A

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

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

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
          10. accelerator-lowering-fma.f640.7

            \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
        5. Simplified0.7%

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
        6. Step-by-step derivation
          1. +-rgt-identityN/A

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
          7. /-lowering-/.f64N/A

            \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
        7. Applied egg-rr0.3%

          \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
        8. Taylor expanded in x around 0

          \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
        9. Step-by-step derivation
          1. /-lowering-/.f64N/A

            \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
          2. +-commutativeN/A

            \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
          3. *-commutativeN/A

            \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
          4. accelerator-lowering-fma.f6414.4

            \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
        10. Simplified14.4%

          \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
        11. Taylor expanded in x around inf

          \[\leadsto \color{blue}{2} \]
        12. Step-by-step derivation
          1. Simplified14.4%

            \[\leadsto \color{blue}{2} \]
        13. Recombined 2 regimes into one program.
        14. Final simplification67.2%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.25, -0.5\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
        15. Add Preprocessing

        Alternative 6: 71.0% accurate, 4.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;\mathsf{fma}\left(x \cdot x, -0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \end{array} \]
        (FPCore (x)
         :precision binary64
         (if (<= (+ x 1.0) 2.0) (fma (* x x) -0.5 x) 2.0))
        double code(double x) {
        	double tmp;
        	if ((x + 1.0) <= 2.0) {
        		tmp = fma((x * x), -0.5, x);
        	} else {
        		tmp = 2.0;
        	}
        	return tmp;
        }
        
        function code(x)
        	tmp = 0.0
        	if (Float64(x + 1.0) <= 2.0)
        		tmp = fma(Float64(x * x), -0.5, x);
        	else
        		tmp = 2.0;
        	end
        	return tmp
        end
        
        code[x_] := If[LessEqual[N[(x + 1.0), $MachinePrecision], 2.0], N[(N[(x * x), $MachinePrecision] * -0.5 + x), $MachinePrecision], 2.0]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x + 1 \leq 2:\\
        \;\;\;\;\mathsf{fma}\left(x \cdot x, -0.5, x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;2\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (+.f64 #s(literal 1 binary64) x) < 2

          1. Initial program 8.8%

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

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

              \[\leadsto \color{blue}{x \cdot \left(1 + \frac{-1}{2} \cdot x\right) + 0} \]
            2. accelerator-lowering-fma.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{2}} + 1, 0\right) \]
            5. accelerator-lowering-fma.f6498.2

              \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.5, 1\right)}, 0\right) \]
          5. Simplified98.2%

            \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.5, 1\right), 0\right)} \]
          6. Step-by-step derivation
            1. +-rgt-identityN/A

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

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

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

              \[\leadsto \left(x \cdot x\right) \cdot \frac{-1}{2} + \color{blue}{x} \]
            5. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, \frac{-1}{2}, x\right)} \]
            6. *-lowering-*.f6498.2

              \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot x}, -0.5, x\right) \]
          7. Applied egg-rr98.2%

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

          if 2 < (+.f64 #s(literal 1 binary64) x)

          1. Initial program 100.0%

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

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

              \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
            2. accelerator-lowering-fma.f64N/A

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

              \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
            4. accelerator-lowering-fma.f64N/A

              \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
            5. sub-negN/A

              \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
            6. metadata-evalN/A

              \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
            7. accelerator-lowering-fma.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
            10. accelerator-lowering-fma.f640.7

              \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
          5. Simplified0.7%

            \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
          6. Step-by-step derivation
            1. +-rgt-identityN/A

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
          7. Applied egg-rr0.3%

            \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
          8. Taylor expanded in x around 0

            \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
            2. +-commutativeN/A

              \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
            3. *-commutativeN/A

              \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
            4. accelerator-lowering-fma.f6414.4

              \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
          10. Simplified14.4%

            \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
          11. Taylor expanded in x around inf

            \[\leadsto \color{blue}{2} \]
          12. Step-by-step derivation
            1. Simplified14.4%

              \[\leadsto \color{blue}{2} \]
          13. Recombined 2 regimes into one program.
          14. Final simplification67.1%

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

          Alternative 7: 70.3% accurate, 10.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \end{array} \]
          (FPCore (x) :precision binary64 (if (<= (+ x 1.0) 2.0) x 2.0))
          double code(double x) {
          	double tmp;
          	if ((x + 1.0) <= 2.0) {
          		tmp = x;
          	} else {
          		tmp = 2.0;
          	}
          	return tmp;
          }
          
          real(8) function code(x)
              real(8), intent (in) :: x
              real(8) :: tmp
              if ((x + 1.0d0) <= 2.0d0) then
                  tmp = x
              else
                  tmp = 2.0d0
              end if
              code = tmp
          end function
          
          public static double code(double x) {
          	double tmp;
          	if ((x + 1.0) <= 2.0) {
          		tmp = x;
          	} else {
          		tmp = 2.0;
          	}
          	return tmp;
          }
          
          def code(x):
          	tmp = 0
          	if (x + 1.0) <= 2.0:
          		tmp = x
          	else:
          		tmp = 2.0
          	return tmp
          
          function code(x)
          	tmp = 0.0
          	if (Float64(x + 1.0) <= 2.0)
          		tmp = x;
          	else
          		tmp = 2.0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x)
          	tmp = 0.0;
          	if ((x + 1.0) <= 2.0)
          		tmp = x;
          	else
          		tmp = 2.0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_] := If[LessEqual[N[(x + 1.0), $MachinePrecision], 2.0], x, 2.0]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x + 1 \leq 2:\\
          \;\;\;\;x\\
          
          \mathbf{else}:\\
          \;\;\;\;2\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (+.f64 #s(literal 1 binary64) x) < 2

            1. Initial program 8.8%

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

              \[\leadsto \color{blue}{x} \]
            4. Step-by-step derivation
              1. Simplified97.5%

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

              if 2 < (+.f64 #s(literal 1 binary64) x)

              1. Initial program 100.0%

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

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

                  \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
                2. accelerator-lowering-fma.f64N/A

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

                  \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
                4. accelerator-lowering-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
                5. sub-negN/A

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
                7. accelerator-lowering-fma.f64N/A

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

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

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
                10. accelerator-lowering-fma.f640.7

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
              5. Simplified0.7%

                \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
              6. Step-by-step derivation
                1. +-rgt-identityN/A

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

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

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

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

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

                  \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
              7. Applied egg-rr0.3%

                \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
              8. Taylor expanded in x around 0

                \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
              9. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
                2. +-commutativeN/A

                  \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
                3. *-commutativeN/A

                  \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
                4. accelerator-lowering-fma.f6414.4

                  \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
              10. Simplified14.4%

                \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
              11. Taylor expanded in x around inf

                \[\leadsto \color{blue}{2} \]
              12. Step-by-step derivation
                1. Simplified14.4%

                  \[\leadsto \color{blue}{2} \]
              13. Recombined 2 regimes into one program.
              14. Final simplification66.7%

                \[\leadsto \begin{array}{l} \mathbf{if}\;x + 1 \leq 2:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;2\\ \end{array} \]
              15. Add Preprocessing

              Alternative 8: 7.3% accurate, 104.0× speedup?

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

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

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

                  \[\leadsto \color{blue}{x \cdot \left(1 + x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right)\right) + 0} \]
                2. accelerator-lowering-fma.f64N/A

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

                  \[\leadsto \mathsf{fma}\left(x, \color{blue}{x \cdot \left(x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}\right) + 1}, 0\right) \]
                4. accelerator-lowering-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) - \frac{1}{2}, 1\right)}, 0\right) \]
                5. sub-negN/A

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, 1\right), 0\right) \]
                6. metadata-evalN/A

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot \left(\frac{1}{3} + \frac{-1}{4} \cdot x\right) + \color{blue}{\frac{-1}{2}}, 1\right), 0\right) \]
                7. accelerator-lowering-fma.f64N/A

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

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

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-1}{4}} + \frac{1}{3}, \frac{-1}{2}\right), 1\right), 0\right) \]
                10. accelerator-lowering-fma.f6462.4

                  \[\leadsto \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, -0.25, 0.3333333333333333\right)}, -0.5\right), 1\right), 0\right) \]
              5. Simplified62.4%

                \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), 1\right), 0\right)} \]
              6. Step-by-step derivation
                1. +-rgt-identityN/A

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

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

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

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

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

                  \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \frac{1}{\color{blue}{\frac{x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right) - 1}{\left(\left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \frac{-1}{4} + \frac{1}{3}\right) + \frac{-1}{2}\right)\right) - 1 \cdot 1\right) \cdot x}}} \]
              7. Applied egg-rr62.1%

                \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right)}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.25, 0.3333333333333333\right), -0.5\right), -1\right) \cdot x}}} \]
              8. Taylor expanded in x around 0

                \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
              9. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \frac{1}{\color{blue}{\frac{1 + \frac{1}{2} \cdot x}{x}}} \]
                2. +-commutativeN/A

                  \[\leadsto \frac{1}{\frac{\color{blue}{\frac{1}{2} \cdot x + 1}}{x}} \]
                3. *-commutativeN/A

                  \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \frac{1}{2}} + 1}{x}} \]
                4. accelerator-lowering-fma.f6467.0

                  \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(x, 0.5, 1\right)}}{x}} \]
              10. Simplified67.0%

                \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, 0.5, 1\right)}{x}}} \]
              11. Taylor expanded in x around inf

                \[\leadsto \color{blue}{2} \]
              12. Step-by-step derivation
                1. Simplified7.7%

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

                Developer Target 1: 99.6% accurate, 0.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 + x = 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \log \left(1 + x\right)}{\left(1 + x\right) - 1}\\ \end{array} \end{array} \]
                (FPCore (x)
                 :precision binary64
                 (if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0))))
                double code(double x) {
                	double tmp;
                	if ((1.0 + x) == 1.0) {
                		tmp = x;
                	} else {
                		tmp = (x * log((1.0 + x))) / ((1.0 + x) - 1.0);
                	}
                	return tmp;
                }
                
                real(8) function code(x)
                    real(8), intent (in) :: x
                    real(8) :: tmp
                    if ((1.0d0 + x) == 1.0d0) then
                        tmp = x
                    else
                        tmp = (x * log((1.0d0 + x))) / ((1.0d0 + x) - 1.0d0)
                    end if
                    code = tmp
                end function
                
                public static double code(double x) {
                	double tmp;
                	if ((1.0 + x) == 1.0) {
                		tmp = x;
                	} else {
                		tmp = (x * Math.log((1.0 + x))) / ((1.0 + x) - 1.0);
                	}
                	return tmp;
                }
                
                def code(x):
                	tmp = 0
                	if (1.0 + x) == 1.0:
                		tmp = x
                	else:
                		tmp = (x * math.log((1.0 + x))) / ((1.0 + x) - 1.0)
                	return tmp
                
                function code(x)
                	tmp = 0.0
                	if (Float64(1.0 + x) == 1.0)
                		tmp = x;
                	else
                		tmp = Float64(Float64(x * log(Float64(1.0 + x))) / Float64(Float64(1.0 + x) - 1.0));
                	end
                	return tmp
                end
                
                function tmp_2 = code(x)
                	tmp = 0.0;
                	if ((1.0 + x) == 1.0)
                		tmp = x;
                	else
                		tmp = (x * log((1.0 + x))) / ((1.0 + x) - 1.0);
                	end
                	tmp_2 = tmp;
                end
                
                code[x_] := If[Equal[N[(1.0 + x), $MachinePrecision], 1.0], x, N[(N[(x * N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + x), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;1 + x = 1:\\
                \;\;\;\;x\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{x \cdot \log \left(1 + x\right)}{\left(1 + x\right) - 1}\\
                
                
                \end{array}
                \end{array}
                

                Reproduce

                ?
                herbie shell --seed 2024195 
                (FPCore (x)
                  :name "ln(1 + x)"
                  :precision binary64
                
                  :alt
                  (! :herbie-platform default (if (== (+ 1 x) 1) x (/ (* x (log (+ 1 x))) (- (+ 1 x) 1))))
                
                  (log (+ 1.0 x)))