Octave 3.8, jcobi/4, as called

Percentage Accurate: 27.6% → 99.2%
Time: 3.1s
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.6% 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.2% accurate, 2.8× speedup?

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

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

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


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

    1. Initial program 24.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. times-frac99.9%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.25}{4 - \frac{i}{{i}^{3}}}} \]
    4. Taylor expanded in i around 0 99.3%

      \[\leadsto \color{blue}{-0.25 \cdot {i}^{2}} \]
    5. Step-by-step derivation
      1. unpow299.3%

        \[\leadsto -0.25 \cdot \color{blue}{\left(i \cdot i\right)} \]
      2. *-commutative99.3%

        \[\leadsto \color{blue}{\left(i \cdot i\right) \cdot -0.25} \]
      3. associate-*l*99.3%

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

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

    if 0.5 < i

    1. Initial program 25.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. times-frac48.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.25}{4 - \frac{i}{{i}^{3}}}} \]
    4. Taylor expanded in i around inf 99.4%

      \[\leadsto \color{blue}{0.0625 + 0.015625 \cdot \frac{1}{{i}^{2}}} \]
    5. Step-by-step derivation
      1. unpow299.4%

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

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

        \[\leadsto 0.0625 + \frac{\color{blue}{0.015625}}{i \cdot i} \]
    6. Simplified99.4%

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

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

Alternative 2: 99.4% accurate, 2.8× speedup?

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

\\
\frac{0.25}{4 - \frac{1}{i \cdot i}}
\end{array}
Derivation
  1. Initial program 25.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. times-frac74.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.25}{4 - \frac{i}{{i}^{3}}}} \]
  4. Taylor expanded in i around 0 99.2%

    \[\leadsto \frac{0.25}{4 - \color{blue}{\frac{1}{{i}^{2}}}} \]
  5. Step-by-step derivation
    1. unpow299.2%

      \[\leadsto \frac{0.25}{4 - \frac{1}{\color{blue}{i \cdot i}}} \]
  6. Simplified99.2%

    \[\leadsto \frac{0.25}{4 - \color{blue}{\frac{1}{i \cdot i}}} \]
  7. Final simplification99.2%

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

Alternative 3: 98.9% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;i \leq 0.5:\\ \;\;\;\;i \cdot \left(i \cdot -0.25\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 * -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 -0.25\right)\\

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


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

    1. Initial program 24.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. times-frac99.9%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.25}{4 - \frac{i}{{i}^{3}}}} \]
    4. Taylor expanded in i around 0 99.3%

      \[\leadsto \color{blue}{-0.25 \cdot {i}^{2}} \]
    5. Step-by-step derivation
      1. unpow299.3%

        \[\leadsto -0.25 \cdot \color{blue}{\left(i \cdot i\right)} \]
      2. *-commutative99.3%

        \[\leadsto \color{blue}{\left(i \cdot i\right) \cdot -0.25} \]
      3. associate-*l*99.3%

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

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

    if 0.5 < i

    1. Initial program 25.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. times-frac48.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.25}{4 - \frac{i}{{i}^{3}}}} \]
    4. Taylor expanded in i around inf 98.9%

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

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

Alternative 4: 50.6% 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 25.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. times-frac74.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.25}{4 - \frac{i}{{i}^{3}}}} \]
  4. Taylor expanded in i around inf 50.5%

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

    \[\leadsto 0.0625 \]

Reproduce

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