Octave 3.8, jcobi/4, as called

Percentage Accurate: 27.4% → 99.8%
Time: 3.9s
Alternatives: 4
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 4 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.4% 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: 99.8% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \frac{i}{i \cdot 16 + 4 \cdot \frac{-1}{i}} \end{array} \]
(FPCore (i) :precision binary64 (/ i (+ (* i 16.0) (* 4.0 (/ -1.0 i)))))
double code(double i) {
	return i / ((i * 16.0) + (4.0 * (-1.0 / i)));
}
real(8) function code(i)
    real(8), intent (in) :: i
    code = i / ((i * 16.0d0) + (4.0d0 * ((-1.0d0) / i)))
end function
public static double code(double i) {
	return i / ((i * 16.0) + (4.0 * (-1.0 / i)));
}
def code(i):
	return i / ((i * 16.0) + (4.0 * (-1.0 / i)))
function code(i)
	return Float64(i / Float64(Float64(i * 16.0) + Float64(4.0 * Float64(-1.0 / i))))
end
function tmp = code(i)
	tmp = i / ((i * 16.0) + (4.0 * (-1.0 / i)));
end
code[i_] := N[(i / N[(N[(i * 16.0), $MachinePrecision] + N[(4.0 * N[(-1.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{i}{i \cdot 16 + 4 \cdot \frac{-1}{i}}
\end{array}
Derivation
  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{\left(i \cdot i\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} \]
    2. associate-*l*28.5%

      \[\leadsto \frac{\frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\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.5%

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

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

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

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

      \[\leadsto \frac{\frac{i}{2 \cdot 2} \cdot \frac{i}{\color{blue}{1}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    8. /-rgt-identity76.2%

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

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

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

      \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
    12. swap-sqr76.0%

      \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
    13. associate-/l/76.7%

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

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

    \[\leadsto \frac{i}{\color{blue}{16 \cdot i - 4 \cdot \frac{1}{i}}} \]
  5. Final simplification99.9%

    \[\leadsto \frac{i}{i \cdot 16 + 4 \cdot \frac{-1}{i}} \]

Alternative 2: 98.9% accurate, 3.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;i \cdot \left(i \cdot \left(-0.25\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.5%

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

        \[\leadsto \frac{\frac{\left(i \cdot i\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} \]
      2. associate-*l*26.3%

        \[\leadsto \frac{\frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\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-sqr26.3%

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

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

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

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

        \[\leadsto \frac{\frac{i}{2 \cdot 2} \cdot \frac{i}{\color{blue}{1}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      8. /-rgt-identity100.0%

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

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

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

        \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
      12. swap-sqr99.8%

        \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      13. associate-/l/99.8%

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

      \[\leadsto \color{blue}{\frac{i}{\mathsf{fma}\left(i, i \cdot 4, -1\right) \cdot \frac{4}{i}}} \]
    4. Step-by-step derivation
      1. frac-2neg99.8%

        \[\leadsto \color{blue}{\frac{-i}{-\mathsf{fma}\left(i, i \cdot 4, -1\right) \cdot \frac{4}{i}}} \]
      2. div-inv99.9%

        \[\leadsto \color{blue}{\left(-i\right) \cdot \frac{1}{-\mathsf{fma}\left(i, i \cdot 4, -1\right) \cdot \frac{4}{i}}} \]
      3. *-commutative99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{-\color{blue}{\frac{4}{i} \cdot \mathsf{fma}\left(i, i \cdot 4, -1\right)}} \]
      4. distribute-rgt-neg-in99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\color{blue}{\frac{4}{i} \cdot \left(-\mathsf{fma}\left(i, i \cdot 4, -1\right)\right)}} \]
      5. fma-udef99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(-\color{blue}{\left(i \cdot \left(i \cdot 4\right) + -1\right)}\right)} \]
      6. associate-*r*99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(-\left(\color{blue}{\left(i \cdot i\right) \cdot 4} + -1\right)\right)} \]
      7. *-commutative99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(-\left(\color{blue}{4 \cdot \left(i \cdot i\right)} + -1\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(-\color{blue}{\left(-1 + 4 \cdot \left(i \cdot i\right)\right)}\right)} \]
      9. distribute-neg-in99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \color{blue}{\left(\left(--1\right) + \left(-4 \cdot \left(i \cdot i\right)\right)\right)}} \]
      10. metadata-eval99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(\color{blue}{1} + \left(-4 \cdot \left(i \cdot i\right)\right)\right)} \]
      11. *-commutative99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(1 + \left(-\color{blue}{\left(i \cdot i\right) \cdot 4}\right)\right)} \]
      12. distribute-rgt-neg-in99.9%

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(1 + \color{blue}{\left(i \cdot i\right) \cdot \left(-4\right)}\right)} \]
      13. pow299.9%

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

        \[\leadsto \left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(1 + {i}^{2} \cdot \color{blue}{-4}\right)} \]
    5. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(-i\right) \cdot \frac{1}{\frac{4}{i} \cdot \left(1 + {i}^{2} \cdot -4\right)}} \]
    6. Step-by-step derivation
      1. associate-/r*99.9%

        \[\leadsto \left(-i\right) \cdot \color{blue}{\frac{\frac{1}{\frac{4}{i}}}{1 + {i}^{2} \cdot -4}} \]
      2. *-commutative99.9%

        \[\leadsto \left(-i\right) \cdot \frac{\frac{1}{\frac{4}{i}}}{1 + \color{blue}{-4 \cdot {i}^{2}}} \]
    7. Simplified99.9%

      \[\leadsto \color{blue}{\left(-i\right) \cdot \frac{\frac{1}{\frac{4}{i}}}{1 + -4 \cdot {i}^{2}}} \]
    8. Taylor expanded in i around 0 99.6%

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

    if 0.5 < i

    1. Initial program 30.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. Step-by-step derivation
      1. sqr-neg30.9%

        \[\leadsto \frac{\frac{\left(i \cdot i\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} \]
      2. associate-*l*30.7%

        \[\leadsto \frac{\frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\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-sqr30.7%

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

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

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

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

        \[\leadsto \frac{\frac{i}{2 \cdot 2} \cdot \frac{i}{\color{blue}{1}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      8. /-rgt-identity52.7%

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

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

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

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

        \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      13. associate-/l/54.0%

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

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

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

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

Alternative 3: 98.8% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;\frac{i}{\frac{-4}{i}}\\ \mathbf{else}:\\ \;\;\;\;0.0625\\ \end{array} \end{array} \]
(FPCore (i) :precision binary64 (if (<= i 0.5) (/ i (/ -4.0 i)) 0.0625))
double code(double i) {
	double tmp;
	if (i <= 0.5) {
		tmp = i / (-4.0 / 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 = i / ((-4.0d0) / i)
    else
        tmp = 0.0625d0
    end if
    code = tmp
end function
public static double code(double i) {
	double tmp;
	if (i <= 0.5) {
		tmp = i / (-4.0 / i);
	} else {
		tmp = 0.0625;
	}
	return tmp;
}
def code(i):
	tmp = 0
	if i <= 0.5:
		tmp = i / (-4.0 / i)
	else:
		tmp = 0.0625
	return tmp
function code(i)
	tmp = 0.0
	if (i <= 0.5)
		tmp = Float64(i / Float64(-4.0 / i));
	else
		tmp = 0.0625;
	end
	return tmp
end
function tmp_2 = code(i)
	tmp = 0.0;
	if (i <= 0.5)
		tmp = i / (-4.0 / i);
	else
		tmp = 0.0625;
	end
	tmp_2 = tmp;
end
code[i_] := If[LessEqual[i, 0.5], N[(i / N[(-4.0 / i), $MachinePrecision]), $MachinePrecision], 0.0625]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;i \leq 0.5:\\
\;\;\;\;\frac{i}{\frac{-4}{i}}\\

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


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

    1. Initial program 26.5%

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

        \[\leadsto \frac{\frac{\left(i \cdot i\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} \]
      2. associate-*l*26.3%

        \[\leadsto \frac{\frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\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-sqr26.3%

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

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

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

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

        \[\leadsto \frac{\frac{i}{2 \cdot 2} \cdot \frac{i}{\color{blue}{1}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      8. /-rgt-identity100.0%

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

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

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

        \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
      12. swap-sqr99.8%

        \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      13. associate-/l/99.8%

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

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

      \[\leadsto \frac{i}{\color{blue}{\frac{-4}{i}}} \]

    if 0.5 < i

    1. Initial program 30.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. Step-by-step derivation
      1. sqr-neg30.9%

        \[\leadsto \frac{\frac{\left(i \cdot i\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} \]
      2. associate-*l*30.7%

        \[\leadsto \frac{\frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\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-sqr30.7%

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

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

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

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

        \[\leadsto \frac{\frac{i}{2 \cdot 2} \cdot \frac{i}{\color{blue}{1}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
      8. /-rgt-identity52.7%

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

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

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

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

        \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
      13. associate-/l/54.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;\frac{i}{\frac{-4}{i}}\\ \mathbf{else}:\\ \;\;\;\;0.0625\\ \end{array} \]

Alternative 4: 50.9% 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 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{\left(i \cdot i\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} \]
    2. associate-*l*28.5%

      \[\leadsto \frac{\frac{\color{blue}{i \cdot \left(i \cdot \left(\left(-i\right) \cdot \left(-i\right)\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.5%

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

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

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

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

      \[\leadsto \frac{\frac{i}{2 \cdot 2} \cdot \frac{i}{\color{blue}{1}}}{\left(2 \cdot i\right) \cdot \left(2 \cdot i\right) - 1} \]
    8. /-rgt-identity76.2%

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

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

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

      \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\left(2 \cdot 2\right) \cdot \color{blue}{\left(\left(-i\right) \cdot \left(-i\right)\right)} - 1} \]
    12. swap-sqr76.0%

      \[\leadsto \frac{\frac{i}{\frac{2 \cdot 2}{i}}}{\color{blue}{\left(2 \cdot \left(-i\right)\right) \cdot \left(2 \cdot \left(-i\right)\right)} - 1} \]
    13. associate-/l/76.7%

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

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

    \[\leadsto \color{blue}{0.0625} \]
  5. Final simplification51.7%

    \[\leadsto 0.0625 \]

Reproduce

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