Jmat.Real.erfi, branch x less than or equal to 0.5

Percentage Accurate: 99.8% → 99.8%
Time: 4.1s
Alternatives: 9
Speedup: 2.1×

Specification

?
\[x \leq 0.5\]
\[\begin{array}{l} t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\ t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\ \left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
        (t_1 (* (* t_0 (fabs x)) (fabs x))))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (+
      (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
      (* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
	double t_0 = (fabs(x) * fabs(x)) * fabs(x);
	double t_1 = (t_0 * fabs(x)) * fabs(x);
	return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
	double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
	double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
	return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x):
	t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x)
	t_1 = (t_0 * math.fabs(x)) * math.fabs(x)
	return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x)
	t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x))
	t_1 = Float64(Float64(t_0 * abs(x)) * abs(x))
	return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x))))))
end
function tmp = code(x)
	t_0 = (abs(x) * abs(x)) * abs(x);
	t_1 = (t_0 * abs(x)) * abs(x);
	tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x))))));
end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}

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 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\ t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\ \left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
        (t_1 (* (* t_0 (fabs x)) (fabs x))))
   (fabs
    (*
     (/ 1.0 (sqrt PI))
     (+
      (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
      (* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))
double code(double x) {
	double t_0 = (fabs(x) * fabs(x)) * fabs(x);
	double t_1 = (t_0 * fabs(x)) * fabs(x);
	return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
	double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
	double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
	return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x):
	t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x)
	t_1 = (t_0 * math.fabs(x)) * math.fabs(x)
	return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x)
	t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x))
	t_1 = Float64(Float64(t_0 * abs(x)) * abs(x))
	return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x))))))
end
function tmp = code(x)
	t_0 = (abs(x) * abs(x)) * abs(x);
	t_1 = (t_0 * abs(x)) * abs(x);
	tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x))))));
end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}

Alternative 1: 99.8% accurate, 2.0× speedup?

\[\left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right), x, 0.047619047619047616 \cdot {x}^{7}\right)\right| \cdot 0.5641895835477563 \]
(FPCore (x)
 :precision binary64
 (*
  (fabs
   (fma
    (fma (* x x) (fma (* 0.2 x) x 0.6666666666666666) 2.0)
    x
    (* 0.047619047619047616 (pow x 7.0))))
  0.5641895835477563))
double code(double x) {
	return fabs(fma(fma((x * x), fma((0.2 * x), x, 0.6666666666666666), 2.0), x, (0.047619047619047616 * pow(x, 7.0)))) * 0.5641895835477563;
}
function code(x)
	return Float64(abs(fma(fma(Float64(x * x), fma(Float64(0.2 * x), x, 0.6666666666666666), 2.0), x, Float64(0.047619047619047616 * (x ^ 7.0)))) * 0.5641895835477563)
end
code[x_] := N[(N[Abs[N[(N[(N[(x * x), $MachinePrecision] * N[(N[(0.2 * x), $MachinePrecision] * x + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision] * x + N[(0.047619047619047616 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision]
\left|\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right), x, 0.047619047619047616 \cdot {x}^{7}\right)\right| \cdot 0.5641895835477563
Derivation
  1. Initial program 99.8%

    \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
  3. Evaluated real constant99.8%

    \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
  5. Applied rewrites99.8%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right), x, 0.047619047619047616 \cdot {x}^{7}\right)}\right| \cdot 0.5641895835477563 \]
  6. Add Preprocessing

Alternative 2: 99.8% accurate, 2.1× speedup?

\[\left|\mathsf{fma}\left(0.047619047619047616 \cdot \left(x \cdot x\right), \left(\left(x \cdot x\right) \cdot x\right) \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right)\right) \cdot x\right| \cdot 0.5641895835477563 \]
(FPCore (x)
 :precision binary64
 (*
  (fabs
   (*
    (fma
     (* 0.047619047619047616 (* x x))
     (* (* (* x x) x) x)
     (fma (* x x) (fma (* 0.2 x) x 0.6666666666666666) 2.0))
    x))
  0.5641895835477563))
double code(double x) {
	return fabs((fma((0.047619047619047616 * (x * x)), (((x * x) * x) * x), fma((x * x), fma((0.2 * x), x, 0.6666666666666666), 2.0)) * x)) * 0.5641895835477563;
}
function code(x)
	return Float64(abs(Float64(fma(Float64(0.047619047619047616 * Float64(x * x)), Float64(Float64(Float64(x * x) * x) * x), fma(Float64(x * x), fma(Float64(0.2 * x), x, 0.6666666666666666), 2.0)) * x)) * 0.5641895835477563)
end
code[x_] := N[(N[Abs[N[(N[(N[(0.047619047619047616 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * N[(N[(0.2 * x), $MachinePrecision] * x + 0.6666666666666666), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision]
\left|\mathsf{fma}\left(0.047619047619047616 \cdot \left(x \cdot x\right), \left(\left(x \cdot x\right) \cdot x\right) \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right)\right) \cdot x\right| \cdot 0.5641895835477563
Derivation
  1. Initial program 99.8%

    \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
  2. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
  3. Evaluated real constant99.8%

    \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left|\color{blue}{x \cdot \mathsf{fma}\left(\frac{1}{21} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \frac{1}{5}\right) \cdot x, x, \mathsf{fma}\left(\frac{2}{3}, x \cdot x, 2\right)\right)\right)}\right| \cdot \frac{5081767996463981}{9007199254740992} \]
    2. *-commutativeN/A

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(\frac{1}{21} \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \frac{1}{5}\right) \cdot x, x, \mathsf{fma}\left(\frac{2}{3}, x \cdot x, 2\right)\right)\right) \cdot x}\right| \cdot \frac{5081767996463981}{9007199254740992} \]
    3. lower-*.f6499.8%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right) \cdot x}\right| \cdot 0.5641895835477563 \]
  6. Applied rewrites99.8%

    \[\leadsto \left|\color{blue}{\mathsf{fma}\left(0.047619047619047616 \cdot \left(x \cdot x\right), \left(\left(x \cdot x\right) \cdot x\right) \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right), 2\right)\right) \cdot x}\right| \cdot 0.5641895835477563 \]
  7. Add Preprocessing

Alternative 3: 98.8% accurate, 2.5× speedup?

\[\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, 2 \cdot \left|x\right|\right)\right| \]
(FPCore (x)
 :precision binary64
 (fabs
  (*
   (/ 1.0 (sqrt PI))
   (fma (pow (fabs x) 7.0) 0.047619047619047616 (* 2.0 (fabs x))))))
double code(double x) {
	return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, (2.0 * fabs(x)))));
}
function code(x)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, Float64(2.0 * abs(x)))))
end
code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616 + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, 2 \cdot \left|x\right|\right)\right|
Derivation
  1. Initial program 99.8%

    \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
  2. Applied rewrites99.8%

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(0.2 \cdot \left|x\right|, \left(\left(x \cdot x\right) \cdot x\right) \cdot x, \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right)}\right| \]
  3. Taylor expanded in x around 0

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \color{blue}{2 \cdot \left|x\right|}\right)\right| \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, \frac{1}{21}, 2 \cdot \color{blue}{\left|x\right|}\right)\right| \]
    2. lower-fabs.f6498.8%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, 2 \cdot \left|x\right|\right)\right| \]
  5. Applied rewrites98.8%

    \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \color{blue}{2 \cdot \left|x\right|}\right)\right| \]
  6. Add Preprocessing

Alternative 4: 98.4% accurate, 3.1× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 230000000:\\ \;\;\;\;\left|\left|x\right| \cdot 2\right| \cdot 0.5641895835477563\\ \mathbf{else}:\\ \;\;\;\;\left|0.047619047619047616 \cdot {\left(\left|x\right|\right)}^{7}\right| \cdot 0.5641895835477563\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (fabs x) 230000000.0)
   (* (fabs (* (fabs x) 2.0)) 0.5641895835477563)
   (* (fabs (* 0.047619047619047616 (pow (fabs x) 7.0))) 0.5641895835477563)))
double code(double x) {
	double tmp;
	if (fabs(x) <= 230000000.0) {
		tmp = fabs((fabs(x) * 2.0)) * 0.5641895835477563;
	} else {
		tmp = fabs((0.047619047619047616 * pow(fabs(x), 7.0))) * 0.5641895835477563;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8) :: tmp
    if (abs(x) <= 230000000.0d0) then
        tmp = abs((abs(x) * 2.0d0)) * 0.5641895835477563d0
    else
        tmp = abs((0.047619047619047616d0 * (abs(x) ** 7.0d0))) * 0.5641895835477563d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (Math.abs(x) <= 230000000.0) {
		tmp = Math.abs((Math.abs(x) * 2.0)) * 0.5641895835477563;
	} else {
		tmp = Math.abs((0.047619047619047616 * Math.pow(Math.abs(x), 7.0))) * 0.5641895835477563;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if math.fabs(x) <= 230000000.0:
		tmp = math.fabs((math.fabs(x) * 2.0)) * 0.5641895835477563
	else:
		tmp = math.fabs((0.047619047619047616 * math.pow(math.fabs(x), 7.0))) * 0.5641895835477563
	return tmp
function code(x)
	tmp = 0.0
	if (abs(x) <= 230000000.0)
		tmp = Float64(abs(Float64(abs(x) * 2.0)) * 0.5641895835477563);
	else
		tmp = Float64(abs(Float64(0.047619047619047616 * (abs(x) ^ 7.0))) * 0.5641895835477563);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (abs(x) <= 230000000.0)
		tmp = abs((abs(x) * 2.0)) * 0.5641895835477563;
	else
		tmp = abs((0.047619047619047616 * (abs(x) ^ 7.0))) * 0.5641895835477563;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 230000000.0], N[(N[Abs[N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision], N[(N[Abs[N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 230000000:\\
\;\;\;\;\left|\left|x\right| \cdot 2\right| \cdot 0.5641895835477563\\

\mathbf{else}:\\
\;\;\;\;\left|0.047619047619047616 \cdot {\left(\left|x\right|\right)}^{7}\right| \cdot 0.5641895835477563\\


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

    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
    3. Evaluated real constant99.8%

      \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
    5. Taylor expanded in x around 0

      \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]
    6. Step-by-step derivation
      1. Applied rewrites67.8%

        \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]

      if 2.3e8 < x

      1. Initial program 99.8%

        \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
      2. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
      3. Evaluated real constant99.8%

        \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
      4. Applied rewrites99.8%

        \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
      5. Taylor expanded in x around inf

        \[\leadsto \left|\color{blue}{\frac{1}{21} \cdot {x}^{7}}\right| \cdot 0.5641895835477563 \]
      6. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \left|\frac{1}{21} \cdot \color{blue}{{x}^{7}}\right| \cdot \frac{5081767996463981}{9007199254740992} \]
        2. lower-pow.f6436.8%

          \[\leadsto \left|0.047619047619047616 \cdot {x}^{\color{blue}{7}}\right| \cdot 0.5641895835477563 \]
      7. Applied rewrites36.8%

        \[\leadsto \left|\color{blue}{0.047619047619047616 \cdot {x}^{7}}\right| \cdot 0.5641895835477563 \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 5: 98.3% accurate, 2.7× speedup?

    \[\left|\frac{\mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\pi}}\right| \]
    (FPCore (x)
     :precision binary64
     (fabs
      (/
       (fma 0.047619047619047616 (pow (fabs x) 7.0) (* 2.0 (fabs x)))
       (sqrt PI))))
    double code(double x) {
    	return fabs((fma(0.047619047619047616, pow(fabs(x), 7.0), (2.0 * fabs(x))) / sqrt(((double) M_PI))));
    }
    
    function code(x)
    	return abs(Float64(fma(0.047619047619047616, (abs(x) ^ 7.0), Float64(2.0 * abs(x))) / sqrt(pi)))
    end
    
    code[x_] := N[Abs[N[(N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
    
    \left|\frac{\mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\pi}}\right|
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Applied rewrites99.8%

      \[\leadsto \left|\frac{1}{\sqrt{\pi}} \cdot \color{blue}{\mathsf{fma}\left({\left(\left|x\right|\right)}^{7}, 0.047619047619047616, \mathsf{fma}\left(0.2 \cdot \left|x\right|, \left(\left(x \cdot x\right) \cdot x\right) \cdot x, \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right)}\right| \]
    3. Taylor expanded in x around 0

      \[\leadsto \left|\color{blue}{\frac{\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + 2 \cdot \left|x\right|}{\sqrt{\pi}}}\right| \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \left|\frac{\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + 2 \cdot \left|x\right|}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
      2. lower-fma.f64N/A

        \[\leadsto \left|\frac{\mathsf{fma}\left(\frac{1}{21}, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}\right| \]
      3. lower-pow.f64N/A

        \[\leadsto \left|\frac{\mathsf{fma}\left(\frac{1}{21}, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      4. lower-fabs.f64N/A

        \[\leadsto \left|\frac{\mathsf{fma}\left(\frac{1}{21}, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      5. lower-*.f64N/A

        \[\leadsto \left|\frac{\mathsf{fma}\left(\frac{1}{21}, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      6. lower-fabs.f64N/A

        \[\leadsto \left|\frac{\mathsf{fma}\left(\frac{1}{21}, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      7. lower-sqrt.f64N/A

        \[\leadsto \left|\frac{\mathsf{fma}\left(\frac{1}{21}, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
      8. lower-PI.f6498.4%

        \[\leadsto \left|\frac{\mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\pi}}\right| \]
    5. Applied rewrites98.4%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)}{\sqrt{\pi}}}\right| \]
    6. Add Preprocessing

    Alternative 6: 89.1% accurate, 4.7× speedup?

    \[\left|\frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot \left|x\right|}{\sqrt{\pi}}\right| \]
    (FPCore (x)
     :precision binary64
     (fabs (/ (* (fma 0.6666666666666666 (* x x) 2.0) (fabs x)) (sqrt PI))))
    double code(double x) {
    	return fabs(((fma(0.6666666666666666, (x * x), 2.0) * fabs(x)) / sqrt(((double) M_PI))));
    }
    
    function code(x)
    	return abs(Float64(Float64(fma(0.6666666666666666, Float64(x * x), 2.0) * abs(x)) / sqrt(pi)))
    end
    
    code[x_] := N[Abs[N[(N[(N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
    
    \left|\frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot \left|x\right|}{\sqrt{\pi}}\right|
    
    Derivation
    1. Initial program 99.8%

      \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
    2. Applied rewrites99.4%

      \[\leadsto \left|\color{blue}{\frac{1}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}}}\right| \]
    3. Taylor expanded in x around 0

      \[\leadsto \left|\color{blue}{\frac{2}{3} \cdot \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}} + 2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}}\right| \]
    4. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \color{blue}{\frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      2. lower-/.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      3. lower-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      4. lower-pow.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      5. lower-fabs.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      6. lower-sqrt.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      7. lower-PI.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      8. lower-*.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      9. lower-/.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      10. lower-fabs.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      11. lower-sqrt.f64N/A

        \[\leadsto \left|\mathsf{fma}\left(\frac{2}{3}, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right)\right| \]
      12. lower-PI.f6489.1%

        \[\leadsto \left|\mathsf{fma}\left(0.6666666666666666, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right)\right| \]
    5. Applied rewrites89.1%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(0.6666666666666666, \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}}, 2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right)}\right| \]
    6. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left|\frac{2}{3} \cdot \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}} + \color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}}\right| \]
      2. lift-/.f64N/A

        \[\leadsto \left|\frac{2}{3} \cdot \frac{{x}^{2} \cdot \left|x\right|}{\sqrt{\pi}} + 2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right| \]
      3. associate-*r/N/A

        \[\leadsto \left|\frac{\frac{2}{3} \cdot \left({x}^{2} \cdot \left|x\right|\right)}{\sqrt{\pi}} + \color{blue}{2} \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right| \]
      4. lift-*.f64N/A

        \[\leadsto \left|\frac{\frac{2}{3} \cdot \left({x}^{2} \cdot \left|x\right|\right)}{\sqrt{\pi}} + 2 \cdot \color{blue}{\frac{\left|x\right|}{\sqrt{\pi}}}\right| \]
      5. lift-/.f64N/A

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

        \[\leadsto \left|\frac{\frac{2}{3} \cdot \left({x}^{2} \cdot \left|x\right|\right)}{\sqrt{\pi}} + \frac{2 \cdot \left|x\right|}{\color{blue}{\sqrt{\pi}}}\right| \]
      7. lift-*.f64N/A

        \[\leadsto \left|\frac{\frac{2}{3} \cdot \left({x}^{2} \cdot \left|x\right|\right)}{\sqrt{\pi}} + \frac{2 \cdot \left|x\right|}{\sqrt{\color{blue}{\pi}}}\right| \]
      8. div-add-revN/A

        \[\leadsto \left|\frac{\frac{2}{3} \cdot \left({x}^{2} \cdot \left|x\right|\right) + 2 \cdot \left|x\right|}{\color{blue}{\sqrt{\pi}}}\right| \]
    7. Applied rewrites89.1%

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right) \cdot \left|x\right|}{\sqrt{\pi}}}\right| \]
    8. Add Preprocessing

    Alternative 7: 83.6% accurate, 4.6× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 10^{-19}:\\ \;\;\;\;\left|\left|x\right| \cdot 2\right| \cdot 0.5641895835477563\\ \mathbf{else}:\\ \;\;\;\;\left|2 \cdot \sqrt{\frac{\left|x\right| \cdot \left|x\right|}{\pi}}\right|\\ \end{array} \]
    (FPCore (x)
     :precision binary64
     (if (<= (fabs x) 1e-19)
       (* (fabs (* (fabs x) 2.0)) 0.5641895835477563)
       (fabs (* 2.0 (sqrt (/ (* (fabs x) (fabs x)) PI))))))
    double code(double x) {
    	double tmp;
    	if (fabs(x) <= 1e-19) {
    		tmp = fabs((fabs(x) * 2.0)) * 0.5641895835477563;
    	} else {
    		tmp = fabs((2.0 * sqrt(((fabs(x) * fabs(x)) / ((double) M_PI)))));
    	}
    	return tmp;
    }
    
    public static double code(double x) {
    	double tmp;
    	if (Math.abs(x) <= 1e-19) {
    		tmp = Math.abs((Math.abs(x) * 2.0)) * 0.5641895835477563;
    	} else {
    		tmp = Math.abs((2.0 * Math.sqrt(((Math.abs(x) * Math.abs(x)) / Math.PI))));
    	}
    	return tmp;
    }
    
    def code(x):
    	tmp = 0
    	if math.fabs(x) <= 1e-19:
    		tmp = math.fabs((math.fabs(x) * 2.0)) * 0.5641895835477563
    	else:
    		tmp = math.fabs((2.0 * math.sqrt(((math.fabs(x) * math.fabs(x)) / math.pi))))
    	return tmp
    
    function code(x)
    	tmp = 0.0
    	if (abs(x) <= 1e-19)
    		tmp = Float64(abs(Float64(abs(x) * 2.0)) * 0.5641895835477563);
    	else
    		tmp = abs(Float64(2.0 * sqrt(Float64(Float64(abs(x) * abs(x)) / pi))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x)
    	tmp = 0.0;
    	if (abs(x) <= 1e-19)
    		tmp = abs((abs(x) * 2.0)) * 0.5641895835477563;
    	else
    		tmp = abs((2.0 * sqrt(((abs(x) * abs(x)) / pi))));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1e-19], N[(N[Abs[N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision], N[Abs[N[(2.0 * N[Sqrt[N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 10^{-19}:\\
    \;\;\;\;\left|\left|x\right| \cdot 2\right| \cdot 0.5641895835477563\\
    
    \mathbf{else}:\\
    \;\;\;\;\left|2 \cdot \sqrt{\frac{\left|x\right| \cdot \left|x\right|}{\pi}}\right|\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 9.9999999999999998e-20

      1. Initial program 99.8%

        \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
      2. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
      3. Evaluated real constant99.8%

        \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
      4. Applied rewrites99.8%

        \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
      5. Taylor expanded in x around 0

        \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]
      6. Step-by-step derivation
        1. Applied rewrites67.8%

          \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]

        if 9.9999999999999998e-20 < x

        1. Initial program 99.8%

          \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
        2. Applied rewrites99.4%

          \[\leadsto \left|\color{blue}{\frac{1}{\frac{\sqrt{\pi}}{\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)}}}\right| \]
        3. Taylor expanded in x around 0

          \[\leadsto \left|\color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}}\right| \]
        4. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \left|2 \cdot \color{blue}{\frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
          2. lower-/.f64N/A

            \[\leadsto \left|2 \cdot \frac{\left|x\right|}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}\right| \]
          3. lower-fabs.f64N/A

            \[\leadsto \left|2 \cdot \frac{\left|x\right|}{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}\right| \]
          4. lower-sqrt.f64N/A

            \[\leadsto \left|2 \cdot \frac{\left|x\right|}{\sqrt{\mathsf{PI}\left(\right)}}\right| \]
          5. lower-PI.f6467.3%

            \[\leadsto \left|2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}\right| \]
        5. Applied rewrites67.3%

          \[\leadsto \left|\color{blue}{2 \cdot \frac{\left|x\right|}{\sqrt{\pi}}}\right| \]
        6. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \left|2 \cdot \frac{\left|x\right|}{\color{blue}{\sqrt{\pi}}}\right| \]
          2. lift-fabs.f64N/A

            \[\leadsto \left|2 \cdot \frac{\left|x\right|}{\sqrt{\color{blue}{\pi}}}\right| \]
          3. rem-sqrt-square-revN/A

            \[\leadsto \left|2 \cdot \frac{\sqrt{x \cdot x}}{\sqrt{\color{blue}{\pi}}}\right| \]
          4. lift-*.f64N/A

            \[\leadsto \left|2 \cdot \frac{\sqrt{x \cdot x}}{\sqrt{\pi}}\right| \]
          5. lift-sqrt.f64N/A

            \[\leadsto \left|2 \cdot \frac{\sqrt{x \cdot x}}{\sqrt{\pi}}\right| \]
          6. sqrt-undivN/A

            \[\leadsto \left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right| \]
          7. lower-sqrt.f64N/A

            \[\leadsto \left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right| \]
          8. lower-/.f6453.8%

            \[\leadsto \left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right| \]
        7. Applied rewrites53.8%

          \[\leadsto \left|2 \cdot \sqrt{\frac{x \cdot x}{\pi}}\right| \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 8: 83.6% accurate, 4.7× speedup?

      \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 0.0002:\\ \;\;\;\;\left|\left|x\right| \cdot 2\right| \cdot 0.5641895835477563\\ \mathbf{else}:\\ \;\;\;\;0.5641895835477563 \cdot \left|2 \cdot \sqrt{\left|x\right| \cdot \left|x\right|}\right|\\ \end{array} \]
      (FPCore (x)
       :precision binary64
       (if (<= (fabs x) 0.0002)
         (* (fabs (* (fabs x) 2.0)) 0.5641895835477563)
         (* 0.5641895835477563 (fabs (* 2.0 (sqrt (* (fabs x) (fabs x))))))))
      double code(double x) {
      	double tmp;
      	if (fabs(x) <= 0.0002) {
      		tmp = fabs((fabs(x) * 2.0)) * 0.5641895835477563;
      	} else {
      		tmp = 0.5641895835477563 * fabs((2.0 * sqrt((fabs(x) * fabs(x)))));
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8) :: tmp
          if (abs(x) <= 0.0002d0) then
              tmp = abs((abs(x) * 2.0d0)) * 0.5641895835477563d0
          else
              tmp = 0.5641895835477563d0 * abs((2.0d0 * sqrt((abs(x) * abs(x)))))
          end if
          code = tmp
      end function
      
      public static double code(double x) {
      	double tmp;
      	if (Math.abs(x) <= 0.0002) {
      		tmp = Math.abs((Math.abs(x) * 2.0)) * 0.5641895835477563;
      	} else {
      		tmp = 0.5641895835477563 * Math.abs((2.0 * Math.sqrt((Math.abs(x) * Math.abs(x)))));
      	}
      	return tmp;
      }
      
      def code(x):
      	tmp = 0
      	if math.fabs(x) <= 0.0002:
      		tmp = math.fabs((math.fabs(x) * 2.0)) * 0.5641895835477563
      	else:
      		tmp = 0.5641895835477563 * math.fabs((2.0 * math.sqrt((math.fabs(x) * math.fabs(x)))))
      	return tmp
      
      function code(x)
      	tmp = 0.0
      	if (abs(x) <= 0.0002)
      		tmp = Float64(abs(Float64(abs(x) * 2.0)) * 0.5641895835477563);
      	else
      		tmp = Float64(0.5641895835477563 * abs(Float64(2.0 * sqrt(Float64(abs(x) * abs(x))))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x)
      	tmp = 0.0;
      	if (abs(x) <= 0.0002)
      		tmp = abs((abs(x) * 2.0)) * 0.5641895835477563;
      	else
      		tmp = 0.5641895835477563 * abs((2.0 * sqrt((abs(x) * abs(x)))));
      	end
      	tmp_2 = tmp;
      end
      
      code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.0002], N[(N[Abs[N[(N[Abs[x], $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision], N[(0.5641895835477563 * N[Abs[N[(2.0 * N[Sqrt[N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      \mathbf{if}\;\left|x\right| \leq 0.0002:\\
      \;\;\;\;\left|\left|x\right| \cdot 2\right| \cdot 0.5641895835477563\\
      
      \mathbf{else}:\\
      \;\;\;\;0.5641895835477563 \cdot \left|2 \cdot \sqrt{\left|x\right| \cdot \left|x\right|}\right|\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 2.0000000000000001e-4

        1. Initial program 99.8%

          \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
        2. Applied rewrites99.8%

          \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
        3. Evaluated real constant99.8%

          \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
        4. Applied rewrites99.8%

          \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
        5. Taylor expanded in x around 0

          \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]
        6. Step-by-step derivation
          1. Applied rewrites67.8%

            \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]

          if 2.0000000000000001e-4 < x

          1. Initial program 99.8%

            \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
          2. Applied rewrites99.8%

            \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
          3. Evaluated real constant99.8%

            \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
          4. Taylor expanded in x around 0

            \[\leadsto 0.5641895835477563 \cdot \left|\color{blue}{2 \cdot \left|x\right|}\right| \]
          5. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \frac{5081767996463981}{9007199254740992} \cdot \left|2 \cdot \color{blue}{\left|x\right|}\right| \]
            2. lower-fabs.f6467.8%

              \[\leadsto 0.5641895835477563 \cdot \left|2 \cdot \left|x\right|\right| \]
          6. Applied rewrites67.8%

            \[\leadsto 0.5641895835477563 \cdot \left|\color{blue}{2 \cdot \left|x\right|}\right| \]
          7. Step-by-step derivation
            1. lift-fabs.f64N/A

              \[\leadsto \frac{5081767996463981}{9007199254740992} \cdot \left|2 \cdot \left|x\right|\right| \]
            2. rem-sqrt-square-revN/A

              \[\leadsto \frac{5081767996463981}{9007199254740992} \cdot \left|2 \cdot \sqrt{x \cdot x}\right| \]
            3. lift-*.f64N/A

              \[\leadsto \frac{5081767996463981}{9007199254740992} \cdot \left|2 \cdot \sqrt{x \cdot x}\right| \]
            4. lower-sqrt.f6453.9%

              \[\leadsto 0.5641895835477563 \cdot \left|2 \cdot \sqrt{x \cdot x}\right| \]
          8. Applied rewrites53.9%

            \[\leadsto 0.5641895835477563 \cdot \left|2 \cdot \sqrt{x \cdot x}\right| \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 9: 67.8% accurate, 11.7× speedup?

        \[\left|x \cdot 2\right| \cdot 0.5641895835477563 \]
        (FPCore (x) :precision binary64 (* (fabs (* x 2.0)) 0.5641895835477563))
        double code(double x) {
        	return fabs((x * 2.0)) * 0.5641895835477563;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(x)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            code = abs((x * 2.0d0)) * 0.5641895835477563d0
        end function
        
        public static double code(double x) {
        	return Math.abs((x * 2.0)) * 0.5641895835477563;
        }
        
        def code(x):
        	return math.fabs((x * 2.0)) * 0.5641895835477563
        
        function code(x)
        	return Float64(abs(Float64(x * 2.0)) * 0.5641895835477563)
        end
        
        function tmp = code(x)
        	tmp = abs((x * 2.0)) * 0.5641895835477563;
        end
        
        code[x_] := N[(N[Abs[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision]
        
        \left|x \cdot 2\right| \cdot 0.5641895835477563
        
        Derivation
        1. Initial program 99.8%

          \[\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot \left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{5} \cdot \left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right) + \frac{1}{21} \cdot \left(\left(\left(\left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right| \]
        2. Applied rewrites99.8%

          \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|} \]
        3. Evaluated real constant99.8%

          \[\leadsto \color{blue}{0.5641895835477563} \cdot \left|\mathsf{fma}\left(\left|x\right|, \mathsf{fma}\left(0.2 \cdot \left(x \cdot x\right), x \cdot x, \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \]
        4. Applied rewrites99.8%

          \[\leadsto \color{blue}{\left|x \cdot \mathsf{fma}\left(0.047619047619047616 \cdot \left(\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right), x, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot 0.2\right) \cdot x, x, \mathsf{fma}\left(0.6666666666666666, x \cdot x, 2\right)\right)\right)\right| \cdot 0.5641895835477563} \]
        5. Taylor expanded in x around 0

          \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]
        6. Step-by-step derivation
          1. Applied rewrites67.8%

            \[\leadsto \left|x \cdot \color{blue}{2}\right| \cdot 0.5641895835477563 \]
          2. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025205 
          (FPCore (x)
            :name "Jmat.Real.erfi, branch x less than or equal to 0.5"
            :precision binary64
            :pre (<= x 0.5)
            (fabs (* (/ 1.0 (sqrt PI)) (+ (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* (fabs x) (fabs x)) (fabs x)))) (* (/ 1.0 5.0) (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)))) (* (/ 1.0 21.0) (* (* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)))))))