Octave 3.8, jcobi/4, as called

Percentage Accurate: 27.5% → 100.0%
Time: 6.8s
Alternatives: 5
Speedup: 25.0×

Specification

?
\[i > 0\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t\_0}}{t\_0 - 1} \end{array} \end{array} \]
(FPCore (i)
 :precision binary64
 (let* ((t_0 (* (* 2.0 i) (* 2.0 i))))
   (/ (/ (* (* i i) (* i i)) t_0) (- t_0 1.0))))
double code(double i) {
	double t_0 = (2.0 * i) * (2.0 * i);
	return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
real(8) function code(i)
    real(8), intent (in) :: i
    real(8) :: t_0
    t_0 = (2.0d0 * i) * (2.0d0 * i)
    code = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0d0)
end function
public static double code(double i) {
	double t_0 = (2.0 * i) * (2.0 * i);
	return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
def code(i):
	t_0 = (2.0 * i) * (2.0 * i)
	return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0)
function code(i)
	t_0 = Float64(Float64(2.0 * i) * Float64(2.0 * i))
	return Float64(Float64(Float64(Float64(i * i) * Float64(i * i)) / t_0) / Float64(t_0 - 1.0))
end
function tmp = code(i)
	t_0 = (2.0 * i) * (2.0 * i);
	tmp = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
end
code[i_] := Block[{t$95$0 = N[(N[(2.0 * i), $MachinePrecision] * N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(i * i), $MachinePrecision] * N[(i * i), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t\_0}}{t\_0 - 1}
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\ \frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t\_0}}{t\_0 - 1} \end{array} \end{array} \]
(FPCore (i)
 :precision binary64
 (let* ((t_0 (* (* 2.0 i) (* 2.0 i))))
   (/ (/ (* (* i i) (* i i)) t_0) (- t_0 1.0))))
double code(double i) {
	double t_0 = (2.0 * i) * (2.0 * i);
	return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
real(8) function code(i)
    real(8), intent (in) :: i
    real(8) :: t_0
    t_0 = (2.0d0 * i) * (2.0d0 * i)
    code = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0d0)
end function
public static double code(double i) {
	double t_0 = (2.0 * i) * (2.0 * i);
	return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
}
def code(i):
	t_0 = (2.0 * i) * (2.0 * i)
	return (((i * i) * (i * i)) / t_0) / (t_0 - 1.0)
function code(i)
	t_0 = Float64(Float64(2.0 * i) * Float64(2.0 * i))
	return Float64(Float64(Float64(Float64(i * i) * Float64(i * i)) / t_0) / Float64(t_0 - 1.0))
end
function tmp = code(i)
	t_0 = (2.0 * i) * (2.0 * i);
	tmp = (((i * i) * (i * i)) / t_0) / (t_0 - 1.0);
end
code[i_] := Block[{t$95$0 = N[(N[(2.0 * i), $MachinePrecision] * N[(2.0 * i), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(i * i), $MachinePrecision] * N[(i * i), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$0 - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\\
\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{t\_0}}{t\_0 - 1}
\end{array}
\end{array}

Alternative 1: 100.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 10000:\\ \;\;\;\;\frac{{i}^{2} \cdot 0.25}{\left(i \cdot 2\right) \cdot \left(i \cdot 2\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\ \end{array} \end{array} \]
(FPCore (i)
 :precision binary64
 (if (<= i 10000.0)
   (/ (* (pow i 2.0) 0.25) (+ (* (* i 2.0) (* i 2.0)) -1.0))
   (+ 0.0625 (/ (/ 0.015625 i) i))))
double code(double i) {
	double tmp;
	if (i <= 10000.0) {
		tmp = (pow(i, 2.0) * 0.25) / (((i * 2.0) * (i * 2.0)) + -1.0);
	} else {
		tmp = 0.0625 + ((0.015625 / i) / i);
	}
	return tmp;
}
real(8) function code(i)
    real(8), intent (in) :: i
    real(8) :: tmp
    if (i <= 10000.0d0) then
        tmp = ((i ** 2.0d0) * 0.25d0) / (((i * 2.0d0) * (i * 2.0d0)) + (-1.0d0))
    else
        tmp = 0.0625d0 + ((0.015625d0 / i) / i)
    end if
    code = tmp
end function
public static double code(double i) {
	double tmp;
	if (i <= 10000.0) {
		tmp = (Math.pow(i, 2.0) * 0.25) / (((i * 2.0) * (i * 2.0)) + -1.0);
	} else {
		tmp = 0.0625 + ((0.015625 / i) / i);
	}
	return tmp;
}
def code(i):
	tmp = 0
	if i <= 10000.0:
		tmp = (math.pow(i, 2.0) * 0.25) / (((i * 2.0) * (i * 2.0)) + -1.0)
	else:
		tmp = 0.0625 + ((0.015625 / i) / i)
	return tmp
function code(i)
	tmp = 0.0
	if (i <= 10000.0)
		tmp = Float64(Float64((i ^ 2.0) * 0.25) / Float64(Float64(Float64(i * 2.0) * Float64(i * 2.0)) + -1.0));
	else
		tmp = Float64(0.0625 + Float64(Float64(0.015625 / i) / i));
	end
	return tmp
end
function tmp_2 = code(i)
	tmp = 0.0;
	if (i <= 10000.0)
		tmp = ((i ^ 2.0) * 0.25) / (((i * 2.0) * (i * 2.0)) + -1.0);
	else
		tmp = 0.0625 + ((0.015625 / i) / i);
	end
	tmp_2 = tmp;
end
code[i_] := If[LessEqual[i, 10000.0], N[(N[(N[Power[i, 2.0], $MachinePrecision] * 0.25), $MachinePrecision] / N[(N[(N[(i * 2.0), $MachinePrecision] * N[(i * 2.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(0.0625 + N[(N[(0.015625 / i), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 10000:\\
\;\;\;\;\frac{{i}^{2} \cdot 0.25}{\left(i \cdot 2\right) \cdot \left(i \cdot 2\right) + -1}\\

\mathbf{else}:\\
\;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\


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

    1. Initial program 27.9%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Add Preprocessing
    3. Taylor expanded in i around 0 100.0%

      \[\leadsto \frac{\color{blue}{0.25 \cdot {i}^{2}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    4. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \frac{\color{blue}{{i}^{2} \cdot 0.25}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    5. Simplified100.0%

      \[\leadsto \frac{\color{blue}{{i}^{2} \cdot 0.25}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]

    if 1e4 < i

    1. Initial program 27.4%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Step-by-step derivation
      1. sqr-neg27.4%

        \[\leadsto \frac{\frac{\color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      2. sqr-neg27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      3. swap-sqr27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)} - 1} \]
      4. sqr-neg27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
      5. swap-sqr27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      6. associate-/r*27.0%

        \[\leadsto \color{blue}{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)}} \]
      7. sqr-neg27.0%

        \[\leadsto \frac{\color{blue}{\left(i \cdot i\right)} \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      8. associate-*l*26.8%

        \[\leadsto \frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      9. sqr-neg26.8%

        \[\leadsto \frac{i \cdot \left(i \cdot \color{blue}{\left(i \cdot i\right)}\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      10. cube-unmult26.8%

        \[\leadsto \frac{i \cdot \color{blue}{{i}^{3}}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    3. Simplified26.8%

      \[\leadsto \color{blue}{\frac{i \cdot {i}^{3}}{\left(i \cdot \left(i \cdot 4\right)\right) \cdot \mathsf{fma}\left(i \cdot 4, i, -1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in i around inf 100.0%

      \[\leadsto \color{blue}{0.0625 + 0.015625 \cdot \frac{1}{{i}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/100.0%

        \[\leadsto 0.0625 + \color{blue}{\frac{0.015625 \cdot 1}{{i}^{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{\color{blue}{0.015625}}{{i}^{2}} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{0.0625 + \frac{0.015625}{{i}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt100.0%

        \[\leadsto 0.0625 + \color{blue}{\sqrt{\frac{0.015625}{{i}^{2}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}}} \]
      2. sqrt-div100.0%

        \[\leadsto 0.0625 + \color{blue}{\frac{\sqrt{0.015625}}{\sqrt{{i}^{2}}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      3. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{\color{blue}{0.125}}{\sqrt{{i}^{2}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      4. sqrt-pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{\color{blue}{{i}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      5. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{0.125}{{i}^{\color{blue}{1}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      6. pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{\color{blue}{i}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      7. sqrt-div100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \color{blue}{\frac{\sqrt{0.015625}}{\sqrt{{i}^{2}}}} \]
      8. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{\color{blue}{0.125}}{\sqrt{{i}^{2}}} \]
      9. sqrt-pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{\color{blue}{{i}^{\left(\frac{2}{2}\right)}}} \]
      10. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{{i}^{\color{blue}{1}}} \]
      11. pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{\color{blue}{i}} \]
    9. Applied egg-rr100.0%

      \[\leadsto 0.0625 + \color{blue}{\frac{0.125}{i} \cdot \frac{0.125}{i}} \]
    10. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto 0.0625 + \color{blue}{\frac{0.125 \cdot \frac{0.125}{i}}{i}} \]
      2. associate-*r/100.0%

        \[\leadsto 0.0625 + \frac{\color{blue}{\frac{0.125 \cdot 0.125}{i}}}{i} \]
      3. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{\frac{\color{blue}{0.015625}}{i}}{i} \]
    11. Applied egg-rr100.0%

      \[\leadsto 0.0625 + \color{blue}{\frac{\frac{0.015625}{i}}{i}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 10000:\\ \;\;\;\;\frac{{i}^{2} \cdot 0.25}{\left(i \cdot 2\right) \cdot \left(i \cdot 2\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 100.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 4000:\\ \;\;\;\;0.25 \cdot \left(i \cdot \frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\ \end{array} \end{array} \]
(FPCore (i)
 :precision binary64
 (if (<= i 4000.0)
   (* 0.25 (* i (/ i (fma i (* i 4.0) -1.0))))
   (+ 0.0625 (/ (/ 0.015625 i) i))))
double code(double i) {
	double tmp;
	if (i <= 4000.0) {
		tmp = 0.25 * (i * (i / fma(i, (i * 4.0), -1.0)));
	} else {
		tmp = 0.0625 + ((0.015625 / i) / i);
	}
	return tmp;
}
function code(i)
	tmp = 0.0
	if (i <= 4000.0)
		tmp = Float64(0.25 * Float64(i * Float64(i / fma(i, Float64(i * 4.0), -1.0))));
	else
		tmp = Float64(0.0625 + Float64(Float64(0.015625 / i) / i));
	end
	return tmp
end
code[i_] := If[LessEqual[i, 4000.0], N[(0.25 * N[(i * N[(i / N[(i * N[(i * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0625 + N[(N[(0.015625 / i), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 4000:\\
\;\;\;\;0.25 \cdot \left(i \cdot \frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if i < 4e3

    1. Initial program 27.9%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{0.25 \cdot \left(i \cdot \frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right)}\right)} \]
    3. Add Preprocessing

    if 4e3 < i

    1. Initial program 27.4%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Step-by-step derivation
      1. sqr-neg27.4%

        \[\leadsto \frac{\frac{\color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      2. sqr-neg27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      3. swap-sqr27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)} - 1} \]
      4. sqr-neg27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
      5. swap-sqr27.4%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      6. associate-/r*27.0%

        \[\leadsto \color{blue}{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)}} \]
      7. sqr-neg27.0%

        \[\leadsto \frac{\color{blue}{\left(i \cdot i\right)} \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      8. associate-*l*26.8%

        \[\leadsto \frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      9. sqr-neg26.8%

        \[\leadsto \frac{i \cdot \left(i \cdot \color{blue}{\left(i \cdot i\right)}\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      10. cube-unmult26.8%

        \[\leadsto \frac{i \cdot \color{blue}{{i}^{3}}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    3. Simplified26.8%

      \[\leadsto \color{blue}{\frac{i \cdot {i}^{3}}{\left(i \cdot \left(i \cdot 4\right)\right) \cdot \mathsf{fma}\left(i \cdot 4, i, -1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in i around inf 100.0%

      \[\leadsto \color{blue}{0.0625 + 0.015625 \cdot \frac{1}{{i}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/100.0%

        \[\leadsto 0.0625 + \color{blue}{\frac{0.015625 \cdot 1}{{i}^{2}}} \]
      2. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{\color{blue}{0.015625}}{{i}^{2}} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{0.0625 + \frac{0.015625}{{i}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt100.0%

        \[\leadsto 0.0625 + \color{blue}{\sqrt{\frac{0.015625}{{i}^{2}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}}} \]
      2. sqrt-div100.0%

        \[\leadsto 0.0625 + \color{blue}{\frac{\sqrt{0.015625}}{\sqrt{{i}^{2}}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      3. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{\color{blue}{0.125}}{\sqrt{{i}^{2}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      4. sqrt-pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{\color{blue}{{i}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      5. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{0.125}{{i}^{\color{blue}{1}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      6. pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{\color{blue}{i}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      7. sqrt-div100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \color{blue}{\frac{\sqrt{0.015625}}{\sqrt{{i}^{2}}}} \]
      8. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{\color{blue}{0.125}}{\sqrt{{i}^{2}}} \]
      9. sqrt-pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{\color{blue}{{i}^{\left(\frac{2}{2}\right)}}} \]
      10. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{{i}^{\color{blue}{1}}} \]
      11. pow1100.0%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{\color{blue}{i}} \]
    9. Applied egg-rr100.0%

      \[\leadsto 0.0625 + \color{blue}{\frac{0.125}{i} \cdot \frac{0.125}{i}} \]
    10. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto 0.0625 + \color{blue}{\frac{0.125 \cdot \frac{0.125}{i}}{i}} \]
      2. associate-*r/100.0%

        \[\leadsto 0.0625 + \frac{\color{blue}{\frac{0.125 \cdot 0.125}{i}}}{i} \]
      3. metadata-eval100.0%

        \[\leadsto 0.0625 + \frac{\frac{\color{blue}{0.015625}}{i}}{i} \]
    11. Applied egg-rr100.0%

      \[\leadsto 0.0625 + \color{blue}{\frac{\frac{0.015625}{i}}{i}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 4000:\\ \;\;\;\;0.25 \cdot \left(i \cdot \frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.2% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\ \end{array} \end{array} \]
(FPCore (i)
 :precision binary64
 (if (<= i 0.5) (* 0.25 (* i (- i))) (+ 0.0625 (/ (/ 0.015625 i) i))))
double code(double i) {
	double tmp;
	if (i <= 0.5) {
		tmp = 0.25 * (i * -i);
	} else {
		tmp = 0.0625 + ((0.015625 / i) / i);
	}
	return tmp;
}
real(8) function code(i)
    real(8), intent (in) :: i
    real(8) :: tmp
    if (i <= 0.5d0) then
        tmp = 0.25d0 * (i * -i)
    else
        tmp = 0.0625d0 + ((0.015625d0 / i) / i)
    end if
    code = tmp
end function
public static double code(double i) {
	double tmp;
	if (i <= 0.5) {
		tmp = 0.25 * (i * -i);
	} else {
		tmp = 0.0625 + ((0.015625 / i) / i);
	}
	return tmp;
}
def code(i):
	tmp = 0
	if i <= 0.5:
		tmp = 0.25 * (i * -i)
	else:
		tmp = 0.0625 + ((0.015625 / i) / i)
	return tmp
function code(i)
	tmp = 0.0
	if (i <= 0.5)
		tmp = Float64(0.25 * Float64(i * Float64(-i)));
	else
		tmp = Float64(0.0625 + Float64(Float64(0.015625 / i) / i));
	end
	return tmp
end
function tmp_2 = code(i)
	tmp = 0.0;
	if (i <= 0.5)
		tmp = 0.25 * (i * -i);
	else
		tmp = 0.0625 + ((0.015625 / i) / i);
	end
	tmp_2 = tmp;
end
code[i_] := If[LessEqual[i, 0.5], N[(0.25 * N[(i * (-i)), $MachinePrecision]), $MachinePrecision], N[(0.0625 + N[(N[(0.015625 / i), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\


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

    1. Initial program 26.9%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{0.25 \cdot \left(i \cdot \frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right)}\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in i around 0 98.4%

      \[\leadsto 0.25 \cdot \left(i \cdot \color{blue}{\left(-1 \cdot i\right)}\right) \]
    5. Step-by-step derivation
      1. neg-mul-198.4%

        \[\leadsto 0.25 \cdot \left(i \cdot \color{blue}{\left(-i\right)}\right) \]
    6. Simplified98.4%

      \[\leadsto 0.25 \cdot \left(i \cdot \color{blue}{\left(-i\right)}\right) \]

    if 0.5 < i

    1. Initial program 28.7%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Step-by-step derivation
      1. sqr-neg28.7%

        \[\leadsto \frac{\frac{\color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      2. sqr-neg28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      3. swap-sqr28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)} - 1} \]
      4. sqr-neg28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
      5. swap-sqr28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      6. associate-/r*28.3%

        \[\leadsto \color{blue}{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)}} \]
      7. sqr-neg28.3%

        \[\leadsto \frac{\color{blue}{\left(i \cdot i\right)} \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      8. associate-*l*28.1%

        \[\leadsto \frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      9. sqr-neg28.1%

        \[\leadsto \frac{i \cdot \left(i \cdot \color{blue}{\left(i \cdot i\right)}\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      10. cube-unmult28.1%

        \[\leadsto \frac{i \cdot \color{blue}{{i}^{3}}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    3. Simplified28.1%

      \[\leadsto \color{blue}{\frac{i \cdot {i}^{3}}{\left(i \cdot \left(i \cdot 4\right)\right) \cdot \mathsf{fma}\left(i \cdot 4, i, -1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in i around inf 99.4%

      \[\leadsto \color{blue}{0.0625 + 0.015625 \cdot \frac{1}{{i}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto 0.0625 + \color{blue}{\frac{0.015625 \cdot 1}{{i}^{2}}} \]
      2. metadata-eval99.4%

        \[\leadsto 0.0625 + \frac{\color{blue}{0.015625}}{{i}^{2}} \]
    7. Simplified99.4%

      \[\leadsto \color{blue}{0.0625 + \frac{0.015625}{{i}^{2}}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt99.4%

        \[\leadsto 0.0625 + \color{blue}{\sqrt{\frac{0.015625}{{i}^{2}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}}} \]
      2. sqrt-div99.4%

        \[\leadsto 0.0625 + \color{blue}{\frac{\sqrt{0.015625}}{\sqrt{{i}^{2}}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      3. metadata-eval99.4%

        \[\leadsto 0.0625 + \frac{\color{blue}{0.125}}{\sqrt{{i}^{2}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      4. sqrt-pow199.4%

        \[\leadsto 0.0625 + \frac{0.125}{\color{blue}{{i}^{\left(\frac{2}{2}\right)}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      5. metadata-eval99.4%

        \[\leadsto 0.0625 + \frac{0.125}{{i}^{\color{blue}{1}}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      6. pow199.4%

        \[\leadsto 0.0625 + \frac{0.125}{\color{blue}{i}} \cdot \sqrt{\frac{0.015625}{{i}^{2}}} \]
      7. sqrt-div99.4%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \color{blue}{\frac{\sqrt{0.015625}}{\sqrt{{i}^{2}}}} \]
      8. metadata-eval99.4%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{\color{blue}{0.125}}{\sqrt{{i}^{2}}} \]
      9. sqrt-pow199.4%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{\color{blue}{{i}^{\left(\frac{2}{2}\right)}}} \]
      10. metadata-eval99.4%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{{i}^{\color{blue}{1}}} \]
      11. pow199.4%

        \[\leadsto 0.0625 + \frac{0.125}{i} \cdot \frac{0.125}{\color{blue}{i}} \]
    9. Applied egg-rr99.4%

      \[\leadsto 0.0625 + \color{blue}{\frac{0.125}{i} \cdot \frac{0.125}{i}} \]
    10. Step-by-step derivation
      1. associate-*l/99.4%

        \[\leadsto 0.0625 + \color{blue}{\frac{0.125 \cdot \frac{0.125}{i}}{i}} \]
      2. associate-*r/99.4%

        \[\leadsto 0.0625 + \frac{\color{blue}{\frac{0.125 \cdot 0.125}{i}}}{i} \]
      3. metadata-eval99.4%

        \[\leadsto 0.0625 + \frac{\frac{\color{blue}{0.015625}}{i}}{i} \]
    11. Applied egg-rr99.4%

      \[\leadsto 0.0625 + \color{blue}{\frac{\frac{0.015625}{i}}{i}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625 + \frac{\frac{0.015625}{i}}{i}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.8% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625\\ \end{array} \end{array} \]
(FPCore (i) :precision binary64 (if (<= i 0.5) (* 0.25 (* i (- i))) 0.0625))
double code(double i) {
	double tmp;
	if (i <= 0.5) {
		tmp = 0.25 * (i * -i);
	} else {
		tmp = 0.0625;
	}
	return tmp;
}
real(8) function code(i)
    real(8), intent (in) :: i
    real(8) :: tmp
    if (i <= 0.5d0) then
        tmp = 0.25d0 * (i * -i)
    else
        tmp = 0.0625d0
    end if
    code = tmp
end function
public static double code(double i) {
	double tmp;
	if (i <= 0.5) {
		tmp = 0.25 * (i * -i);
	} else {
		tmp = 0.0625;
	}
	return tmp;
}
def code(i):
	tmp = 0
	if i <= 0.5:
		tmp = 0.25 * (i * -i)
	else:
		tmp = 0.0625
	return tmp
function code(i)
	tmp = 0.0
	if (i <= 0.5)
		tmp = Float64(0.25 * Float64(i * Float64(-i)));
	else
		tmp = 0.0625;
	end
	return tmp
end
function tmp_2 = code(i)
	tmp = 0.0;
	if (i <= 0.5)
		tmp = 0.25 * (i * -i);
	else
		tmp = 0.0625;
	end
	tmp_2 = tmp;
end
code[i_] := If[LessEqual[i, 0.5], N[(0.25 * N[(i * (-i)), $MachinePrecision]), $MachinePrecision], 0.0625]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;0.0625\\


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

    1. Initial program 26.9%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{0.25 \cdot \left(i \cdot \frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right)}\right)} \]
    3. Add Preprocessing
    4. Taylor expanded in i around 0 98.4%

      \[\leadsto 0.25 \cdot \left(i \cdot \color{blue}{\left(-1 \cdot i\right)}\right) \]
    5. Step-by-step derivation
      1. neg-mul-198.4%

        \[\leadsto 0.25 \cdot \left(i \cdot \color{blue}{\left(-i\right)}\right) \]
    6. Simplified98.4%

      \[\leadsto 0.25 \cdot \left(i \cdot \color{blue}{\left(-i\right)}\right) \]

    if 0.5 < i

    1. Initial program 28.7%

      \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. Step-by-step derivation
      1. sqr-neg28.7%

        \[\leadsto \frac{\frac{\color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      2. sqr-neg28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      3. swap-sqr28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)} - 1} \]
      4. sqr-neg28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
      5. swap-sqr28.7%

        \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      6. associate-/r*28.3%

        \[\leadsto \color{blue}{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)}} \]
      7. sqr-neg28.3%

        \[\leadsto \frac{\color{blue}{\left(i \cdot i\right)} \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      8. associate-*l*28.1%

        \[\leadsto \frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      9. sqr-neg28.1%

        \[\leadsto \frac{i \cdot \left(i \cdot \color{blue}{\left(i \cdot i\right)}\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
      10. cube-unmult28.1%

        \[\leadsto \frac{i \cdot \color{blue}{{i}^{3}}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    3. Simplified28.1%

      \[\leadsto \color{blue}{\frac{i \cdot {i}^{3}}{\left(i \cdot \left(i \cdot 4\right)\right) \cdot \mathsf{fma}\left(i \cdot 4, i, -1\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in i around inf 98.3%

      \[\leadsto \color{blue}{0.0625} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;0.25 \cdot \left(i \cdot \left(-i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 50.4% accurate, 25.0× speedup?

\[\begin{array}{l} \\ 0.0625 \end{array} \]
(FPCore (i) :precision binary64 0.0625)
double code(double i) {
	return 0.0625;
}
real(8) function code(i)
    real(8), intent (in) :: i
    code = 0.0625d0
end function
public static double code(double i) {
	return 0.0625;
}
def code(i):
	return 0.0625
function code(i)
	return 0.0625
end
function tmp = code(i)
	tmp = 0.0625;
end
code[i_] := 0.0625
\begin{array}{l}

\\
0.0625
\end{array}
Derivation
  1. Initial program 27.7%

    \[\frac{\frac{\left(i \cdot i\right) \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
  2. Step-by-step derivation
    1. sqr-neg27.7%

      \[\leadsto \frac{\frac{\color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} \cdot \left(i \cdot i\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    2. sqr-neg27.7%

      \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    3. swap-sqr27.7%

      \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot 2\right) \cdot \left(i \cdot i\right)} - 1} \]
    4. sqr-neg27.7%

      \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
    5. swap-sqr27.7%

      \[\leadsto \frac{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
    6. associate-/r*27.5%

      \[\leadsto \color{blue}{\frac{\left(\left(-i\right) \cdot \left(-i\right)\right) \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)}} \]
    7. sqr-neg27.5%

      \[\leadsto \frac{\color{blue}{\left(i \cdot i\right)} \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    8. associate-*l*27.4%

      \[\leadsto \frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\right)\right)}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    9. sqr-neg27.4%

      \[\leadsto \frac{i \cdot \left(i \cdot \color{blue}{\left(i \cdot i\right)}\right)}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
    10. cube-unmult27.3%

      \[\leadsto \frac{i \cdot \color{blue}{{i}^{3}}}{\left(\left(2 \cdot i\right) \cdot \left(2 \cdot i\right)\right) \cdot \left(\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right) - 1\right)} \]
  3. Simplified27.3%

    \[\leadsto \color{blue}{\frac{i \cdot {i}^{3}}{\left(i \cdot \left(i \cdot 4\right)\right) \cdot \mathsf{fma}\left(i \cdot 4, i, -1\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in i around inf 44.9%

    \[\leadsto \color{blue}{0.0625} \]
  6. Final simplification44.9%

    \[\leadsto 0.0625 \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024130 
(FPCore (i)
  :name "Octave 3.8, jcobi/4, as called"
  :precision binary64
  :pre (> i 0.0)
  (/ (/ (* (* i i) (* i i)) (* (* 2.0 i) (* 2.0 i))) (- (* (* 2.0 i) (* 2.0 i)) 1.0)))