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

Percentage Accurate: 99.8% → 99.8%
Time: 4.5s
Alternatives: 11
Speedup: 1.5×

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 11 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, 1.5× speedup?

\[\left|\frac{1}{\sqrt{\pi}} \cdot \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| \]
(FPCore (x)
  :precision binary64
  (fabs
 (*
  (/ 1.0 (sqrt PI))
  (fma
   (pow (fabs x) 7.0)
   0.047619047619047616
   (fma
    (* 0.2 (fabs x))
    (* (* (* x x) x) x)
    (* (fabs x) (fma (* x x) 0.6666666666666666 2.0)))))))
double code(double x) {
	return fabs(((1.0 / sqrt(((double) M_PI))) * fma(pow(fabs(x), 7.0), 0.047619047619047616, fma((0.2 * fabs(x)), (((x * x) * x) * x), (fabs(x) * fma((x * x), 0.6666666666666666, 2.0))))));
}
function code(x)
	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma((abs(x) ^ 7.0), 0.047619047619047616, fma(Float64(0.2 * abs(x)), Float64(Float64(Float64(x * x) * x) * x), Float64(abs(x) * fma(Float64(x * x), 0.6666666666666666, 2.0))))))
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[(N[(0.2 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\sqrt{\pi}} \cdot \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|
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. Add Preprocessing

Alternative 2: 99.8% accurate, 1.5× speedup?

\[\begin{array}{l} t_0 := \left(x \cdot x\right) \cdot x\\ \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(t\_0 \cdot t\_0\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right| \end{array} \]
(FPCore (x)
  :precision binary64
  (let* ((t_0 (* (* x x) x)))
  (*
   (/ 1.0 (sqrt PI))
   (fabs
    (fma
     (fabs x)
     (fma
      (* 0.2 (* x x))
      (* x x)
      (* (* t_0 t_0) 0.047619047619047616))
     (* (fabs x) (fma (* x x) 0.6666666666666666 2.0)))))))
double code(double x) {
	double t_0 = (x * x) * x;
	return (1.0 / sqrt(((double) M_PI))) * fabs(fma(fabs(x), fma((0.2 * (x * x)), (x * x), ((t_0 * t_0) * 0.047619047619047616)), (fabs(x) * fma((x * x), 0.6666666666666666, 2.0))));
}
function code(x)
	t_0 = Float64(Float64(x * x) * x)
	return Float64(Float64(1.0 / sqrt(pi)) * abs(fma(abs(x), fma(Float64(0.2 * Float64(x * x)), Float64(x * x), Float64(Float64(t_0 * t_0) * 0.047619047619047616)), Float64(abs(x) * fma(Float64(x * x), 0.6666666666666666, 2.0)))))
end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Abs[x], $MachinePrecision] * N[(N[(0.2 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.047619047619047616), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[x], $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.6666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\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(t\_0 \cdot t\_0\right) \cdot 0.047619047619047616\right), \left|x\right| \cdot \mathsf{fma}\left(x \cdot x, 0.6666666666666666, 2\right)\right)\right|
\end{array}
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. Add Preprocessing

Alternative 3: 99.8% accurate, 1.7× speedup?

\[\frac{1}{\sqrt{\pi}} \cdot \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| \]
(FPCore (x)
  :precision binary64
  (*
 (/ 1.0 (sqrt PI))
 (fabs
  (*
   x
   (fma
    (* 0.047619047619047616 (* (* (* (* x x) x) x) x))
    x
    (fma
     (* (* (* x x) 0.2) x)
     x
     (fma 0.6666666666666666 (* x x) 2.0)))))))
double code(double x) {
	return (1.0 / sqrt(((double) M_PI))) * fabs((x * fma((0.047619047619047616 * ((((x * x) * x) * x) * x)), x, fma((((x * x) * 0.2) * x), x, fma(0.6666666666666666, (x * x), 2.0)))));
}
function code(x)
	return Float64(Float64(1.0 / sqrt(pi)) * abs(Float64(x * fma(Float64(0.047619047619047616 * Float64(Float64(Float64(Float64(x * x) * x) * x) * x)), x, fma(Float64(Float64(Float64(x * x) * 0.2) * x), x, fma(0.6666666666666666, Float64(x * x), 2.0))))))
end
code[x_] := N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(x * N[(N[(0.047619047619047616 * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] * 0.2), $MachinePrecision] * x), $MachinePrecision] * x + N[(0.6666666666666666 * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{\pi}} \cdot \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|
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. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
  4. Add Preprocessing

Alternative 4: 99.1% accurate, 2.2× speedup?

\[0.5641895835477563 \cdot \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, 2\right)\right)\right| \]
(FPCore (x)
  :precision binary64
  (*
 0.5641895835477563
 (fabs
  (*
   x
   (fma
    (* 0.047619047619047616 (* (* (* (* x x) x) x) x))
    x
    (fma (* (* (* x x) 0.2) x) x 2.0))))))
double code(double x) {
	return 0.5641895835477563 * fabs((x * fma((0.047619047619047616 * ((((x * x) * x) * x) * x)), x, fma((((x * x) * 0.2) * x), x, 2.0))));
}
function code(x)
	return Float64(0.5641895835477563 * abs(Float64(x * fma(Float64(0.047619047619047616 * Float64(Float64(Float64(Float64(x * x) * x) * x) * x)), x, fma(Float64(Float64(Float64(x * x) * 0.2) * x), x, 2.0)))))
end
code[x_] := N[(0.5641895835477563 * N[Abs[N[(x * N[(N[(0.047619047619047616 * N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] * 0.2), $MachinePrecision] * x), $MachinePrecision] * x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
0.5641895835477563 \cdot \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, 2\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. Applied rewrites99.8%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
  4. Taylor expanded in x around 0

    \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \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, \color{blue}{2}\right)\right)\right| \]
  5. Step-by-step derivation
    1. Applied rewrites99.1%

      \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \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, \color{blue}{2}\right)\right)\right| \]
    2. Evaluated real constant99.1%

      \[\leadsto \color{blue}{0.5641895835477563} \cdot \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, 2\right)\right)\right| \]
    3. Add Preprocessing

    Alternative 5: 98.9% accurate, 2.7× speedup?

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

      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. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
      4. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      5. Step-by-step derivation
        1. lower-*.f6467.7%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|2 \cdot \color{blue}{x}\right| \]
      6. Applied rewrites67.7%

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      7. Evaluated real constant67.7%

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

      if 9.7999999999999997e-5 < 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. Taylor expanded in x around inf

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

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \color{blue}{\left({x}^{6} \cdot \left|x\right|\right)}\right| \]
        2. lower-*.f64N/A

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \color{blue}{\left|x\right|}\right)\right| \]
        3. lower-pow.f64N/A

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|\color{blue}{x}\right|\right)\right| \]
        4. lower-fabs.f6437.0%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|0.047619047619047616 \cdot \left({x}^{6} \cdot \left|x\right|\right)\right| \]
      5. Applied rewrites37.0%

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

          \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right|} \]
        2. *-commutativeN/A

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

          \[\leadsto \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right| \cdot \color{blue}{\frac{1}{\sqrt{\pi}}} \]
        4. mult-flip-revN/A

          \[\leadsto \color{blue}{\frac{\left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right|}{\sqrt{\pi}}} \]
        5. lower-/.f6437.0%

          \[\leadsto \color{blue}{\frac{\left|0.047619047619047616 \cdot \left({x}^{6} \cdot \left|x\right|\right)\right|}{\sqrt{\pi}}} \]
      7. Applied rewrites37.0%

        \[\leadsto \color{blue}{\frac{\left|{\left(\left|x\right|\right)}^{7} \cdot 0.047619047619047616\right|}{\sqrt{\pi}}} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 6: 98.7% accurate, 2.5× speedup?

    \[\left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)\right| \]
    (FPCore (x)
      :precision binary64
      (fabs
     (*
      (/ 1.0 (sqrt PI))
      (fma 0.047619047619047616 (pow (fabs x) 7.0) (* 2.0 (fabs x))))))
    double code(double x) {
    	return fabs(((1.0 / sqrt(((double) M_PI))) * fma(0.047619047619047616, pow(fabs(x), 7.0), (2.0 * fabs(x)))));
    }
    
    function code(x)
    	return abs(Float64(Float64(1.0 / sqrt(pi)) * fma(0.047619047619047616, (abs(x) ^ 7.0), Float64(2.0 * abs(x)))))
    end
    
    code[x_] := N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
    
    \left|\frac{1}{\sqrt{\pi}} \cdot \mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 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 \color{blue}{\left(\frac{1}{21} \cdot {\left(\left|x\right|\right)}^{7} + 2 \cdot \left|x\right|\right)}\right| \]
    4. Step-by-step derivation
      1. lower-fma.f64N/A

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

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

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

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

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

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

    Alternative 7: 98.7% accurate, 3.0× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 9.8 \cdot 10^{-5}:\\ \;\;\;\;0.5641895835477563 \cdot \left|2 \cdot \left|x\right|\right|\\ \mathbf{else}:\\ \;\;\;\;\left|{\left(\left|\left|x\right|\right|\right)}^{7} \cdot 0.047619047619047616\right| \cdot 0.5641895835477563\\ \end{array} \]
    (FPCore (x)
      :precision binary64
      (if (<= (fabs x) 9.8e-5)
      (* 0.5641895835477563 (fabs (* 2.0 (fabs x))))
      (*
       (fabs (* (pow (fabs (fabs x)) 7.0) 0.047619047619047616))
       0.5641895835477563)))
    double code(double x) {
    	double tmp;
    	if (fabs(x) <= 9.8e-5) {
    		tmp = 0.5641895835477563 * fabs((2.0 * fabs(x)));
    	} else {
    		tmp = fabs((pow(fabs(fabs(x)), 7.0) * 0.047619047619047616)) * 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) <= 9.8d-5) then
            tmp = 0.5641895835477563d0 * abs((2.0d0 * abs(x)))
        else
            tmp = abs(((abs(abs(x)) ** 7.0d0) * 0.047619047619047616d0)) * 0.5641895835477563d0
        end if
        code = tmp
    end function
    
    public static double code(double x) {
    	double tmp;
    	if (Math.abs(x) <= 9.8e-5) {
    		tmp = 0.5641895835477563 * Math.abs((2.0 * Math.abs(x)));
    	} else {
    		tmp = Math.abs((Math.pow(Math.abs(Math.abs(x)), 7.0) * 0.047619047619047616)) * 0.5641895835477563;
    	}
    	return tmp;
    }
    
    def code(x):
    	tmp = 0
    	if math.fabs(x) <= 9.8e-5:
    		tmp = 0.5641895835477563 * math.fabs((2.0 * math.fabs(x)))
    	else:
    		tmp = math.fabs((math.pow(math.fabs(math.fabs(x)), 7.0) * 0.047619047619047616)) * 0.5641895835477563
    	return tmp
    
    function code(x)
    	tmp = 0.0
    	if (abs(x) <= 9.8e-5)
    		tmp = Float64(0.5641895835477563 * abs(Float64(2.0 * abs(x))));
    	else
    		tmp = Float64(abs(Float64((abs(abs(x)) ^ 7.0) * 0.047619047619047616)) * 0.5641895835477563);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x)
    	tmp = 0.0;
    	if (abs(x) <= 9.8e-5)
    		tmp = 0.5641895835477563 * abs((2.0 * abs(x)));
    	else
    		tmp = abs(((abs(abs(x)) ^ 7.0) * 0.047619047619047616)) * 0.5641895835477563;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 9.8e-5], N[(0.5641895835477563 * N[Abs[N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[Power[N[Abs[N[Abs[x], $MachinePrecision]], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision] * 0.5641895835477563), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 9.8 \cdot 10^{-5}:\\
    \;\;\;\;0.5641895835477563 \cdot \left|2 \cdot \left|x\right|\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;\left|{\left(\left|\left|x\right|\right|\right)}^{7} \cdot 0.047619047619047616\right| \cdot 0.5641895835477563\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 9.7999999999999997e-5

      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. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
      4. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      5. Step-by-step derivation
        1. lower-*.f6467.7%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|2 \cdot \color{blue}{x}\right| \]
      6. Applied rewrites67.7%

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      7. Evaluated real constant67.7%

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

      if 9.7999999999999997e-5 < 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. Taylor expanded in x around inf

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

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \color{blue}{\left({x}^{6} \cdot \left|x\right|\right)}\right| \]
        2. lower-*.f64N/A

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \color{blue}{\left|x\right|}\right)\right| \]
        3. lower-pow.f64N/A

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|\color{blue}{x}\right|\right)\right| \]
        4. lower-fabs.f6437.0%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|0.047619047619047616 \cdot \left({x}^{6} \cdot \left|x\right|\right)\right| \]
      5. Applied rewrites37.0%

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{0.047619047619047616 \cdot \left({x}^{6} \cdot \left|x\right|\right)}\right| \]
      6. Evaluated real constant37.0%

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

          \[\leadsto \color{blue}{\frac{5081767996463981}{9007199254740992} \cdot \left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right|} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\left|\frac{1}{21} \cdot \left({x}^{6} \cdot \left|x\right|\right)\right| \cdot \frac{5081767996463981}{9007199254740992}} \]
        3. lower-*.f6437.0%

          \[\leadsto \color{blue}{\left|0.047619047619047616 \cdot \left({x}^{6} \cdot \left|x\right|\right)\right| \cdot 0.5641895835477563} \]
      8. Applied rewrites37.0%

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

    Alternative 8: 98.5% 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.5%

        \[\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.5%

      \[\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 9: 93.0% accurate, 3.0× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left|x\right| \leq 9.8 \cdot 10^{-5}:\\ \;\;\;\;0.5641895835477563 \cdot \left|2 \cdot \left|x\right|\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|\left(-0.2 \cdot \left|\left|x\right|\right|\right) \cdot \left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right|}{1.772453850905516}\\ \end{array} \]
    (FPCore (x)
      :precision binary64
      (if (<= (fabs x) 9.8e-5)
      (* 0.5641895835477563 (fabs (* 2.0 (fabs x))))
      (/
       (fabs
        (*
         (* -0.2 (fabs (fabs x)))
         (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x))))
       1.772453850905516)))
    double code(double x) {
    	double tmp;
    	if (fabs(x) <= 9.8e-5) {
    		tmp = 0.5641895835477563 * fabs((2.0 * fabs(x)));
    	} else {
    		tmp = fabs(((-0.2 * fabs(fabs(x))) * (((fabs(x) * fabs(x)) * fabs(x)) * fabs(x)))) / 1.772453850905516;
    	}
    	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) <= 9.8d-5) then
            tmp = 0.5641895835477563d0 * abs((2.0d0 * abs(x)))
        else
            tmp = abs((((-0.2d0) * abs(abs(x))) * (((abs(x) * abs(x)) * abs(x)) * abs(x)))) / 1.772453850905516d0
        end if
        code = tmp
    end function
    
    public static double code(double x) {
    	double tmp;
    	if (Math.abs(x) <= 9.8e-5) {
    		tmp = 0.5641895835477563 * Math.abs((2.0 * Math.abs(x)));
    	} else {
    		tmp = Math.abs(((-0.2 * Math.abs(Math.abs(x))) * (((Math.abs(x) * Math.abs(x)) * Math.abs(x)) * Math.abs(x)))) / 1.772453850905516;
    	}
    	return tmp;
    }
    
    def code(x):
    	tmp = 0
    	if math.fabs(x) <= 9.8e-5:
    		tmp = 0.5641895835477563 * math.fabs((2.0 * math.fabs(x)))
    	else:
    		tmp = math.fabs(((-0.2 * math.fabs(math.fabs(x))) * (((math.fabs(x) * math.fabs(x)) * math.fabs(x)) * math.fabs(x)))) / 1.772453850905516
    	return tmp
    
    function code(x)
    	tmp = 0.0
    	if (abs(x) <= 9.8e-5)
    		tmp = Float64(0.5641895835477563 * abs(Float64(2.0 * abs(x))));
    	else
    		tmp = Float64(abs(Float64(Float64(-0.2 * abs(abs(x))) * Float64(Float64(Float64(abs(x) * abs(x)) * abs(x)) * abs(x)))) / 1.772453850905516);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x)
    	tmp = 0.0;
    	if (abs(x) <= 9.8e-5)
    		tmp = 0.5641895835477563 * abs((2.0 * abs(x)));
    	else
    		tmp = abs(((-0.2 * abs(abs(x))) * (((abs(x) * abs(x)) * abs(x)) * abs(x)))) / 1.772453850905516;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 9.8e-5], N[(0.5641895835477563 * N[Abs[N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[(-0.2 * N[Abs[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 1.772453850905516), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\left|x\right| \leq 9.8 \cdot 10^{-5}:\\
    \;\;\;\;0.5641895835477563 \cdot \left|2 \cdot \left|x\right|\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left|\left(-0.2 \cdot \left|\left|x\right|\right|\right) \cdot \left(\left(\left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right|}{1.772453850905516}\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 9.7999999999999997e-5

      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. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
      4. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      5. Step-by-step derivation
        1. lower-*.f6467.7%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|2 \cdot \color{blue}{x}\right| \]
      6. Applied rewrites67.7%

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      7. Evaluated real constant67.7%

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

      if 9.7999999999999997e-5 < 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 \color{blue}{\left|\frac{-0.047619047619047616 \cdot {\left(\left|x\right|\right)}^{7} - \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)}{-\sqrt{\pi}}\right|} \]
      3. Taylor expanded in x around inf

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

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

          \[\leadsto \left|\frac{\frac{-1}{5} \cdot \left({x}^{4} \cdot \color{blue}{\left|x\right|}\right)}{-\sqrt{\pi}}\right| \]
        3. lower-pow.f64N/A

          \[\leadsto \left|\frac{\frac{-1}{5} \cdot \left({x}^{4} \cdot \left|\color{blue}{x}\right|\right)}{-\sqrt{\pi}}\right| \]
        4. lower-fabs.f6431.4%

          \[\leadsto \left|\frac{-0.2 \cdot \left({x}^{4} \cdot \left|x\right|\right)}{-\sqrt{\pi}}\right| \]
      5. Applied rewrites31.4%

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

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

          \[\leadsto \left|\color{blue}{\frac{\frac{-1}{5} \cdot \left({x}^{4} \cdot \left|x\right|\right)}{-\sqrt{\pi}}}\right| \]
        3. fabs-divN/A

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

          \[\leadsto \frac{\left|\frac{-1}{5} \cdot \left({x}^{4} \cdot \left|x\right|\right)\right|}{\left|\color{blue}{\mathsf{neg}\left(\sqrt{\pi}\right)}\right|} \]
        5. neg-fabsN/A

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

          \[\leadsto \frac{\left|\frac{-1}{5} \cdot \left({x}^{4} \cdot \left|x\right|\right)\right|}{\left|\color{blue}{\sqrt{\pi}}\right|} \]
        7. sqrt-fabs-revN/A

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

          \[\leadsto \frac{\left|\frac{-1}{5} \cdot \left({x}^{4} \cdot \left|x\right|\right)\right|}{\color{blue}{\sqrt{\pi}}} \]
      7. Applied rewrites31.4%

        \[\leadsto \color{blue}{\frac{\left|\left(-0.2 \cdot \left|x\right|\right) \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right)\right|}{\sqrt{\pi}}} \]
      8. Evaluated real constant31.4%

        \[\leadsto \frac{\left|\left(-0.2 \cdot \left|x\right|\right) \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot x\right)\right|}{\color{blue}{1.772453850905516}} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 10: 83.4% accurate, 3.9× speedup?

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

      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. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
      4. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      5. Step-by-step derivation
        1. lower-*.f6467.7%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|2 \cdot \color{blue}{x}\right| \]
      6. Applied rewrites67.7%

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      7. Evaluated real constant67.7%

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

      if 200 < 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 \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. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
      4. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
      5. Step-by-step derivation
        1. lower-*.f6467.7%

          \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|2 \cdot \color{blue}{x}\right| \]
      6. Applied rewrites67.7%

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

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

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

          \[\leadsto \left|2 \cdot x\right| \cdot \color{blue}{\frac{1}{\sqrt{\pi}}} \]
        4. mult-flip-revN/A

          \[\leadsto \color{blue}{\frac{\left|2 \cdot x\right|}{\sqrt{\pi}}} \]
      8. Applied rewrites54.1%

        \[\leadsto \color{blue}{\sqrt{\frac{\left(x + x\right) \cdot \left(x + x\right)}{\pi}}} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 11: 67.7% accurate, 11.7× speedup?

    \[0.5641895835477563 \cdot \left|2 \cdot x\right| \]
    (FPCore (x)
      :precision binary64
      (* 0.5641895835477563 (fabs (* 2.0 x))))
    double code(double x) {
    	return 0.5641895835477563 * fabs((2.0 * x));
    }
    
    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 = 0.5641895835477563d0 * abs((2.0d0 * x))
    end function
    
    public static double code(double x) {
    	return 0.5641895835477563 * Math.abs((2.0 * x));
    }
    
    def code(x):
    	return 0.5641895835477563 * math.fabs((2.0 * x))
    
    function code(x)
    	return Float64(0.5641895835477563 * abs(Float64(2.0 * x)))
    end
    
    function tmp = code(x)
    	tmp = 0.5641895835477563 * abs((2.0 * x));
    end
    
    code[x_] := N[(0.5641895835477563 * N[Abs[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
    
    0.5641895835477563 \cdot \left|2 \cdot x\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. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\pi}} \cdot \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|} \]
    4. Taylor expanded in x around 0

      \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
    5. Step-by-step derivation
      1. lower-*.f6467.7%

        \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|2 \cdot \color{blue}{x}\right| \]
    6. Applied rewrites67.7%

      \[\leadsto \frac{1}{\sqrt{\pi}} \cdot \left|\color{blue}{2 \cdot x}\right| \]
    7. Evaluated real constant67.7%

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

    Reproduce

    ?
    herbie shell --seed 2025214 
    (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)))))))