Falkner and Boettcher, Appendix B, 1

Percentage Accurate: 99.2% → 99.2%
Time: 19.1s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
double code(double v) {
	return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((1.0d0 - (5.0d0 * (v * v))) / ((v * v) - 1.0d0)))
end function
public static double code(double v) {
	return Math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
def code(v):
	return math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)))
function code(v)
	return acos(Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(v * v) - 1.0)))
end
function tmp = code(v)
	tmp = acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
end
code[v_] := N[ArcCos[N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v * v), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\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 8 alternatives:

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

Initial Program: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
double code(double v) {
	return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((1.0d0 - (5.0d0 * (v * v))) / ((v * v) - 1.0d0)))
end function
public static double code(double v) {
	return Math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
def code(v):
	return math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)))
function code(v)
	return acos(Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(v * v) - 1.0)))
end
function tmp = code(v)
	tmp = acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
end
code[v_] := N[ArcCos[N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(v * v), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\end{array}

Alternative 1: 99.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(v \cdot v\right) \cdot -5\\ t_1 := -1 + v \cdot v\\ \sqrt{\cos^{-1} \left(\frac{25 \cdot {v}^{4} + -1}{t\_1 \cdot \left(-1 + t\_0\right)}\right) \cdot \cos^{-1} \left(\frac{t\_0 + 1}{t\_1}\right)} \end{array} \end{array} \]
(FPCore (v)
 :precision binary64
 (let* ((t_0 (* (* v v) -5.0)) (t_1 (+ -1.0 (* v v))))
   (sqrt
    (*
     (acos (/ (+ (* 25.0 (pow v 4.0)) -1.0) (* t_1 (+ -1.0 t_0))))
     (acos (/ (+ t_0 1.0) t_1))))))
double code(double v) {
	double t_0 = (v * v) * -5.0;
	double t_1 = -1.0 + (v * v);
	return sqrt((acos((((25.0 * pow(v, 4.0)) + -1.0) / (t_1 * (-1.0 + t_0)))) * acos(((t_0 + 1.0) / t_1))));
}
real(8) function code(v)
    real(8), intent (in) :: v
    real(8) :: t_0
    real(8) :: t_1
    t_0 = (v * v) * (-5.0d0)
    t_1 = (-1.0d0) + (v * v)
    code = sqrt((acos((((25.0d0 * (v ** 4.0d0)) + (-1.0d0)) / (t_1 * ((-1.0d0) + t_0)))) * acos(((t_0 + 1.0d0) / t_1))))
end function
public static double code(double v) {
	double t_0 = (v * v) * -5.0;
	double t_1 = -1.0 + (v * v);
	return Math.sqrt((Math.acos((((25.0 * Math.pow(v, 4.0)) + -1.0) / (t_1 * (-1.0 + t_0)))) * Math.acos(((t_0 + 1.0) / t_1))));
}
def code(v):
	t_0 = (v * v) * -5.0
	t_1 = -1.0 + (v * v)
	return math.sqrt((math.acos((((25.0 * math.pow(v, 4.0)) + -1.0) / (t_1 * (-1.0 + t_0)))) * math.acos(((t_0 + 1.0) / t_1))))
function code(v)
	t_0 = Float64(Float64(v * v) * -5.0)
	t_1 = Float64(-1.0 + Float64(v * v))
	return sqrt(Float64(acos(Float64(Float64(Float64(25.0 * (v ^ 4.0)) + -1.0) / Float64(t_1 * Float64(-1.0 + t_0)))) * acos(Float64(Float64(t_0 + 1.0) / t_1))))
end
function tmp = code(v)
	t_0 = (v * v) * -5.0;
	t_1 = -1.0 + (v * v);
	tmp = sqrt((acos((((25.0 * (v ^ 4.0)) + -1.0) / (t_1 * (-1.0 + t_0)))) * acos(((t_0 + 1.0) / t_1))));
end
code[v_] := Block[{t$95$0 = N[(N[(v * v), $MachinePrecision] * -5.0), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[(v * v), $MachinePrecision]), $MachinePrecision]}, N[Sqrt[N[(N[ArcCos[N[(N[(N[(25.0 * N[Power[v, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / N[(t$95$1 * N[(-1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[ArcCos[N[(N[(t$95$0 + 1.0), $MachinePrecision] / t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(v \cdot v\right) \cdot -5\\
t_1 := -1 + v \cdot v\\
\sqrt{\cos^{-1} \left(\frac{25 \cdot {v}^{4} + -1}{t\_1 \cdot \left(-1 + t\_0\right)}\right) \cdot \cos^{-1} \left(\frac{t\_0 + 1}{t\_1}\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Applied egg-rr98.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\pi \cdot \pi}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\pi}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\pi \cdot \left(\pi \cdot \pi\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}}} \]
  4. Step-by-step derivation
    1. inv-powN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\color{blue}{-1}} \]
    2. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{-1}{2} + \color{blue}{\frac{-1}{2}}\right)} \]
    3. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{-2} + \frac{-1}{2}\right)} \]
    4. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(2\right)} + \frac{-1}{2}\right)} \]
    5. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(2\right)} + \frac{1}{\color{blue}{-2}}\right)} \]
    6. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(2\right)} + \frac{1}{\mathsf{neg}\left(2\right)}\right)} \]
  5. Applied egg-rr98.7%

    \[\leadsto \color{blue}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)} \cdot \frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}\right)}^{-0.5}} \]
  6. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\left(\left(v \cdot v\right) \cdot -5 + 1\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    2. flip-+N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\left(\frac{\left(\left(v \cdot v\right) \cdot -5\right) \cdot \left(\left(v \cdot v\right) \cdot -5\right) - 1 \cdot 1}{\left(v \cdot v\right) \cdot -5 - 1}\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\left(\left(v \cdot v\right) \cdot -5\right) \cdot \left(\left(v \cdot v\right) \cdot -5\right) - 1 \cdot 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\left(\left(v \cdot v\right) \cdot -5\right) \cdot \left(\left(v \cdot v\right) \cdot -5\right) - 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\left(\left(v \cdot v\right) \cdot -5\right) \cdot \left(\left(v \cdot v\right) \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    6. swap-sqrN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\left(\left(v \cdot v\right) \cdot \left(v \cdot v\right)\right) \cdot \left(-5 \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(\left(v \cdot v\right) \cdot \left(v \cdot v\right)\right), \left(-5 \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(v \cdot \left(v \cdot \left(v \cdot v\right)\right)\right), \left(-5 \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \left(v \cdot \left(v \cdot v\right)\right)\right), \left(-5 \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, \left(v \cdot v\right)\right)\right), \left(-5 \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, v\right)\right)\right), \left(-5 \cdot -5\right)\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    12. metadata-evalN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, v\right)\right)\right), 25\right), 1\right), \left(\left(v \cdot v\right) \cdot -5 - 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    13. --lowering--.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, v\right)\right)\right), 25\right), 1\right), \mathsf{\_.f64}\left(\left(\left(v \cdot v\right) \cdot -5\right), 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, v\right)\right)\right), 25\right), 1\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\left(v \cdot v\right), -5\right), 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
    15. *-lowering-*.f6498.7%

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, v\right)\right)\right), 25\right), 1\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right), 1\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{acos.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, v\right)\right)\right)\right)\right)\right), \frac{-1}{2}\right) \]
  7. Applied egg-rr98.7%

    \[\leadsto {\left(\frac{1}{\cos^{-1} \left(\frac{\color{blue}{\frac{\left(v \cdot \left(v \cdot \left(v \cdot v\right)\right)\right) \cdot 25 - 1}{\left(v \cdot v\right) \cdot -5 - 1}}}{-1 + v \cdot v}\right)} \cdot \frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}\right)}^{-0.5} \]
  8. Taylor expanded in v around 0

    \[\leadsto \color{blue}{\sqrt{\cos^{-1} \left(\frac{1 + -5 \cdot {v}^{2}}{{v}^{2} - 1}\right) \cdot \cos^{-1} \left(\frac{25 \cdot {v}^{4} - 1}{\left(-5 \cdot {v}^{2} - 1\right) \cdot \left({v}^{2} - 1\right)}\right)}} \]
  9. Simplified98.8%

    \[\leadsto \color{blue}{\sqrt{\cos^{-1} \left(\frac{25 \cdot {v}^{4} + -1}{\left(v \cdot v + -1\right) \cdot \left(-5 \cdot \left(v \cdot v\right) + -1\right)}\right) \cdot \cos^{-1} \left(\frac{1 + -5 \cdot \left(v \cdot v\right)}{v \cdot v + -1}\right)}} \]
  10. Final simplification98.8%

    \[\leadsto \sqrt{\cos^{-1} \left(\frac{25 \cdot {v}^{4} + -1}{\left(-1 + v \cdot v\right) \cdot \left(-1 + \left(v \cdot v\right) \cdot -5\right)}\right) \cdot \cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)} \]
  11. Add Preprocessing

Alternative 2: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ {\left(\frac{1}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + v \cdot \left(v \cdot -5\right)}{-1 + v \cdot v}\right)}\right)}^{-2}}\right)}^{-0.5} \end{array} \]
(FPCore (v)
 :precision binary64
 (pow
  (/
   1.0
   (pow (/ 1.0 (acos (/ (+ 1.0 (* v (* v -5.0))) (+ -1.0 (* v v))))) -2.0))
  -0.5))
double code(double v) {
	return pow((1.0 / pow((1.0 / acos(((1.0 + (v * (v * -5.0))) / (-1.0 + (v * v))))), -2.0)), -0.5);
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = (1.0d0 / ((1.0d0 / acos(((1.0d0 + (v * (v * (-5.0d0)))) / ((-1.0d0) + (v * v))))) ** (-2.0d0))) ** (-0.5d0)
end function
public static double code(double v) {
	return Math.pow((1.0 / Math.pow((1.0 / Math.acos(((1.0 + (v * (v * -5.0))) / (-1.0 + (v * v))))), -2.0)), -0.5);
}
def code(v):
	return math.pow((1.0 / math.pow((1.0 / math.acos(((1.0 + (v * (v * -5.0))) / (-1.0 + (v * v))))), -2.0)), -0.5)
function code(v)
	return Float64(1.0 / (Float64(1.0 / acos(Float64(Float64(1.0 + Float64(v * Float64(v * -5.0))) / Float64(-1.0 + Float64(v * v))))) ^ -2.0)) ^ -0.5
end
function tmp = code(v)
	tmp = (1.0 / ((1.0 / acos(((1.0 + (v * (v * -5.0))) / (-1.0 + (v * v))))) ^ -2.0)) ^ -0.5;
end
code[v_] := N[Power[N[(1.0 / N[Power[N[(1.0 / N[ArcCos[N[(N[(1.0 + N[(v * N[(v * -5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}

\\
{\left(\frac{1}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + v \cdot \left(v \cdot -5\right)}{-1 + v \cdot v}\right)}\right)}^{-2}}\right)}^{-0.5}
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Applied egg-rr98.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\pi \cdot \pi}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\pi}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\pi \cdot \left(\pi \cdot \pi\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}}} \]
  4. Step-by-step derivation
    1. inv-powN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\color{blue}{-1}} \]
    2. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{-1}{2} + \color{blue}{\frac{-1}{2}}\right)} \]
    3. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{-2} + \frac{-1}{2}\right)} \]
    4. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(2\right)} + \frac{-1}{2}\right)} \]
    5. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(2\right)} + \frac{1}{\color{blue}{-2}}\right)} \]
    6. metadata-evalN/A

      \[\leadsto {\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}^{\left(\frac{1}{\mathsf{neg}\left(2\right)} + \frac{1}{\mathsf{neg}\left(2\right)}\right)} \]
  5. Applied egg-rr98.7%

    \[\leadsto \color{blue}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)} \cdot \frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}\right)}^{-0.5}} \]
  6. Step-by-step derivation
    1. un-div-invN/A

      \[\leadsto \mathsf{pow.f64}\left(\left(\frac{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}\right), \frac{-1}{2}\right) \]
    2. clear-numN/A

      \[\leadsto \mathsf{pow.f64}\left(\left(\frac{1}{\frac{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}}}\right), \frac{-1}{2}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}}\right)\right), \frac{-1}{2}\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right), \left(\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}\right)\right)\right), \frac{-1}{2}\right) \]
  7. Applied egg-rr98.7%

    \[\leadsto {\color{blue}{\left(\frac{1}{\frac{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}}}\right)}}^{-0.5} \]
  8. Step-by-step derivation
    1. /-rgt-identityN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{\frac{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}}}{1}\right)\right), \frac{-1}{2}\right) \]
    2. clear-numN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{1}{\frac{1}{\frac{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}}}}\right)\right), \frac{-1}{2}\right) \]
    3. associate-/r/N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{1}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)} \cdot \frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}}\right)\right), \frac{-1}{2}\right) \]
    4. pow2N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{1}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}\right)}^{2}}\right)\right), \frac{-1}{2}\right) \]
    5. pow-flipN/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \left({\left(\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}\right)}^{\left(\mathsf{neg}\left(2\right)\right)}\right)\right), \frac{-1}{2}\right) \]
    6. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{pow.f64}\left(\mathsf{/.f64}\left(1, \mathsf{pow.f64}\left(\left(\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right), \frac{-1}{2}\right) \]
  9. Applied egg-rr98.7%

    \[\leadsto {\left(\frac{1}{\color{blue}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + v \cdot \left(v \cdot -5\right)}{v \cdot v + -1}\right)}\right)}^{-2}}}\right)}^{-0.5} \]
  10. Final simplification98.7%

    \[\leadsto {\left(\frac{1}{{\left(\frac{1}{\cos^{-1} \left(\frac{1 + v \cdot \left(v \cdot -5\right)}{-1 + v \cdot v}\right)}\right)}^{-2}}\right)}^{-0.5} \]
  11. Add Preprocessing

Alternative 3: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \frac{1}{{\left({\cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)}^{-2}\right)}^{0.5}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/
  1.0
  (pow (pow (acos (/ (+ (* (* v v) -5.0) 1.0) (+ -1.0 (* v v)))) -2.0) 0.5)))
double code(double v) {
	return 1.0 / pow(pow(acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))), -2.0), 0.5);
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = 1.0d0 / ((acos(((((v * v) * (-5.0d0)) + 1.0d0) / ((-1.0d0) + (v * v)))) ** (-2.0d0)) ** 0.5d0)
end function
public static double code(double v) {
	return 1.0 / Math.pow(Math.pow(Math.acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))), -2.0), 0.5);
}
def code(v):
	return 1.0 / math.pow(math.pow(math.acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))), -2.0), 0.5)
function code(v)
	return Float64(1.0 / ((acos(Float64(Float64(Float64(Float64(v * v) * -5.0) + 1.0) / Float64(-1.0 + Float64(v * v)))) ^ -2.0) ^ 0.5))
end
function tmp = code(v)
	tmp = 1.0 / ((acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))) ^ -2.0) ^ 0.5);
end
code[v_] := N[(1.0 / N[Power[N[Power[N[ArcCos[N[(N[(N[(N[(v * v), $MachinePrecision] * -5.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(-1.0 + N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], -2.0], $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{{\left({\cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)}^{-2}\right)}^{0.5}}
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Applied egg-rr98.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\pi \cdot \pi}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\pi}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\pi \cdot \left(\pi \cdot \pi\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}}} \]
  4. Step-by-step derivation
    1. rem-cube-cbrtN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({\left(\sqrt[3]{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}\right)}^{3}\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\color{blue}{\mathsf{PI.f64}\left(\right)}, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    2. cbrt-unprodN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{3}\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    3. pow2N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({\left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{2}\right)}^{3}\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    4. pow-powN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\left({\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{\left(2 \cdot 3\right)}\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\color{blue}{\mathsf{PI.f64}\left(\right)}, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    5. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{pow.f64}\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right), \left(2 \cdot 3\right)\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\color{blue}{\mathsf{PI.f64}\left(\right)}, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    6. cbrt-lowering-cbrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{PI}\left(\right)\right), \left(2 \cdot 3\right)\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    7. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{PI.f64}\left(\right)\right), \left(2 \cdot 3\right)\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
    8. metadata-eval96.4%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{cbrt.f64}\left(\mathsf{PI.f64}\left(\right)\right), 6\right), 4\right), \mathsf{*.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right)\right)\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right), 8\right), \mathsf{pow.f64}\left(\mathsf{asin.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), -5\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(v, v\right), -1\right)\right)\right), 3\right)\right)\right)\right) \]
  5. Applied egg-rr96.4%

    \[\leadsto \frac{1}{\frac{\frac{\color{blue}{{\left(\sqrt[3]{\pi}\right)}^{6}}}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\pi}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\pi \cdot \left(\pi \cdot \pi\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}} \]
  6. Applied egg-rr98.7%

    \[\leadsto \frac{1}{\color{blue}{{\left({\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{-2}\right)}^{0.5}}} \]
  7. Final simplification98.7%

    \[\leadsto \frac{1}{{\left({\cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)}^{-2}\right)}^{0.5}} \]
  8. Add Preprocessing

Alternative 4: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{1}{\cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 1.0 (/ 1.0 (acos (/ (+ (* (* v v) -5.0) 1.0) (+ -1.0 (* v v)))))))
double code(double v) {
	return 1.0 / (1.0 / acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = 1.0d0 / (1.0d0 / acos(((((v * v) * (-5.0d0)) + 1.0d0) / ((-1.0d0) + (v * v)))))
end function
public static double code(double v) {
	return 1.0 / (1.0 / Math.acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))));
}
def code(v):
	return 1.0 / (1.0 / math.acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))))
function code(v)
	return Float64(1.0 / Float64(1.0 / acos(Float64(Float64(Float64(Float64(v * v) * -5.0) + 1.0) / Float64(-1.0 + Float64(v * v))))))
end
function tmp = code(v)
	tmp = 1.0 / (1.0 / acos(((((v * v) * -5.0) + 1.0) / (-1.0 + (v * v)))));
end
code[v_] := N[(1.0 / N[(1.0 / N[ArcCos[N[(N[(N[(N[(v * v), $MachinePrecision] * -5.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(-1.0 + N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{1}{\cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)}}
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Applied egg-rr98.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{\frac{\pi \cdot \pi}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\pi}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\pi \cdot \left(\pi \cdot \pi\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}\right)}\right) \]
    2. clear-numN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{\frac{\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}{8} - {\sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)}^{3}}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{v \cdot v + -1}\right)\right)}}}\right)\right) \]
  5. Applied egg-rr98.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right)}}} \]
  6. Final simplification98.7%

    \[\leadsto \frac{1}{\frac{1}{\cos^{-1} \left(\frac{\left(v \cdot v\right) \cdot -5 + 1}{-1 + v \cdot v}\right)}} \]
  7. Add Preprocessing

Alternative 5: 99.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{-1 + v \cdot v}\right) \end{array} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* (* v v) 5.0)) (+ -1.0 (* v v)))))
double code(double v) {
	return acos(((1.0 - ((v * v) * 5.0)) / (-1.0 + (v * v))));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((1.0d0 - ((v * v) * 5.0d0)) / ((-1.0d0) + (v * v))))
end function
public static double code(double v) {
	return Math.acos(((1.0 - ((v * v) * 5.0)) / (-1.0 + (v * v))));
}
def code(v):
	return math.acos(((1.0 - ((v * v) * 5.0)) / (-1.0 + (v * v))))
function code(v)
	return acos(Float64(Float64(1.0 - Float64(Float64(v * v) * 5.0)) / Float64(-1.0 + Float64(v * v))))
end
function tmp = code(v)
	tmp = acos(((1.0 - ((v * v) * 5.0)) / (-1.0 + (v * v))));
end
code[v_] := N[ArcCos[N[(N[(1.0 - N[(N[(v * v), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{-1 + v \cdot v}\right)
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Final simplification98.7%

    \[\leadsto \cos^{-1} \left(\frac{1 - \left(v \cdot v\right) \cdot 5}{-1 + v \cdot v}\right) \]
  4. Add Preprocessing

Alternative 6: 98.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{1}{\cos^{-1} \left(-1 + 4 \cdot \left(v \cdot v\right)\right)}} \end{array} \]
(FPCore (v)
 :precision binary64
 (/ 1.0 (/ 1.0 (acos (+ -1.0 (* 4.0 (* v v)))))))
double code(double v) {
	return 1.0 / (1.0 / acos((-1.0 + (4.0 * (v * v)))));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = 1.0d0 / (1.0d0 / acos(((-1.0d0) + (4.0d0 * (v * v)))))
end function
public static double code(double v) {
	return 1.0 / (1.0 / Math.acos((-1.0 + (4.0 * (v * v)))));
}
def code(v):
	return 1.0 / (1.0 / math.acos((-1.0 + (4.0 * (v * v)))))
function code(v)
	return Float64(1.0 / Float64(1.0 / acos(Float64(-1.0 + Float64(4.0 * Float64(v * v))))))
end
function tmp = code(v)
	tmp = 1.0 / (1.0 / acos((-1.0 + (4.0 * (v * v)))));
end
code[v_] := N[(1.0 / N[(1.0 / N[ArcCos[N[(-1.0 + N[(4.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{1}{\cos^{-1} \left(-1 + 4 \cdot \left(v \cdot v\right)\right)}}
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \mathsf{acos.f64}\left(\color{blue}{\left(4 \cdot {v}^{2} - 1\right)}\right) \]
  4. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \mathsf{acos.f64}\left(\left(4 \cdot {v}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \]
    2. metadata-evalN/A

      \[\leadsto \mathsf{acos.f64}\left(\left(4 \cdot {v}^{2} + -1\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{acos.f64}\left(\left(-1 + 4 \cdot {v}^{2}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \left(4 \cdot {v}^{2}\right)\right)\right) \]
    5. *-commutativeN/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \left({v}^{2} \cdot 4\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left({v}^{2}\right), 4\right)\right)\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(v \cdot v\right), 4\right)\right)\right) \]
    8. *-lowering-*.f6497.4%

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), 4\right)\right)\right) \]
  5. Simplified97.4%

    \[\leadsto \cos^{-1} \color{blue}{\left(-1 + \left(v \cdot v\right) \cdot 4\right)} \]
  6. Step-by-step derivation
    1. acos-asinN/A

      \[\leadsto \frac{\mathsf{PI}\left(\right)}{2} - \color{blue}{\sin^{-1} \left(-1 + \left(v \cdot v\right) \cdot 4\right)} \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{2}\right), \color{blue}{\sin^{-1} \left(-1 + \left(v \cdot v\right) \cdot 4\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI}\left(\right), 2\right), \sin^{-1} \color{blue}{\left(-1 + \left(v \cdot v\right) \cdot 4\right)}\right) \]
    4. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \sin^{-1} \left(\color{blue}{-1} + \left(v \cdot v\right) \cdot 4\right)\right) \]
    5. asin-lowering-asin.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\left(-1 + \left(v \cdot v\right) \cdot 4\right)\right)\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{+.f64}\left(-1, \left(\left(v \cdot v\right) \cdot 4\right)\right)\right)\right) \]
    7. associate-*l*N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{+.f64}\left(-1, \left(v \cdot \left(v \cdot 4\right)\right)\right)\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, \left(v \cdot 4\right)\right)\right)\right)\right) \]
    9. *-lowering-*.f6497.4%

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{asin.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(v, \mathsf{*.f64}\left(v, 4\right)\right)\right)\right)\right) \]
  7. Applied egg-rr97.4%

    \[\leadsto \color{blue}{\frac{\pi}{2} - \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)} \]
  8. Step-by-step derivation
    1. flip--N/A

      \[\leadsto \frac{\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right) \cdot \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}{\color{blue}{\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}} \]
    2. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}{\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{\mathsf{PI}\left(\right)}{2} - \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right) \cdot \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}}} \]
    3. frac-timesN/A

      \[\leadsto \frac{1}{\frac{\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{2 \cdot 2} - \color{blue}{\sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)} \cdot \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}} \]
    4. metadata-evalN/A

      \[\leadsto \frac{1}{\frac{\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} - \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right) \cdot \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}} \]
    5. unpow2N/A

      \[\leadsto \frac{1}{\frac{\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} - {\sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}^{\color{blue}{2}}}} \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right)}{2} + \sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{4} - {\sin^{-1} \left(-1 + v \cdot \left(v \cdot 4\right)\right)}^{2}}\right)}\right) \]
  9. Applied egg-rr97.4%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\cos^{-1} \left(-1 + \left(v \cdot v\right) \cdot 4\right)}}} \]
  10. Final simplification97.4%

    \[\leadsto \frac{1}{\frac{1}{\cos^{-1} \left(-1 + 4 \cdot \left(v \cdot v\right)\right)}} \]
  11. Add Preprocessing

Alternative 7: 98.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \cos^{-1} \left(-1 + 4 \cdot \left(v \cdot v\right)\right) \end{array} \]
(FPCore (v) :precision binary64 (acos (+ -1.0 (* 4.0 (* v v)))))
double code(double v) {
	return acos((-1.0 + (4.0 * (v * v))));
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos(((-1.0d0) + (4.0d0 * (v * v))))
end function
public static double code(double v) {
	return Math.acos((-1.0 + (4.0 * (v * v))));
}
def code(v):
	return math.acos((-1.0 + (4.0 * (v * v))))
function code(v)
	return acos(Float64(-1.0 + Float64(4.0 * Float64(v * v))))
end
function tmp = code(v)
	tmp = acos((-1.0 + (4.0 * (v * v))));
end
code[v_] := N[ArcCos[N[(-1.0 + N[(4.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} \left(-1 + 4 \cdot \left(v \cdot v\right)\right)
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \mathsf{acos.f64}\left(\color{blue}{\left(4 \cdot {v}^{2} - 1\right)}\right) \]
  4. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \mathsf{acos.f64}\left(\left(4 \cdot {v}^{2} + \left(\mathsf{neg}\left(1\right)\right)\right)\right) \]
    2. metadata-evalN/A

      \[\leadsto \mathsf{acos.f64}\left(\left(4 \cdot {v}^{2} + -1\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{acos.f64}\left(\left(-1 + 4 \cdot {v}^{2}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \left(4 \cdot {v}^{2}\right)\right)\right) \]
    5. *-commutativeN/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \left({v}^{2} \cdot 4\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left({v}^{2}\right), 4\right)\right)\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\left(v \cdot v\right), 4\right)\right)\right) \]
    8. *-lowering-*.f6497.4%

      \[\leadsto \mathsf{acos.f64}\left(\mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(v, v\right), 4\right)\right)\right) \]
  5. Simplified97.4%

    \[\leadsto \cos^{-1} \color{blue}{\left(-1 + \left(v \cdot v\right) \cdot 4\right)} \]
  6. Final simplification97.4%

    \[\leadsto \cos^{-1} \left(-1 + 4 \cdot \left(v \cdot v\right)\right) \]
  7. Add Preprocessing

Alternative 8: 98.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \cos^{-1} -1 \end{array} \]
(FPCore (v) :precision binary64 (acos -1.0))
double code(double v) {
	return acos(-1.0);
}
real(8) function code(v)
    real(8), intent (in) :: v
    code = acos((-1.0d0))
end function
public static double code(double v) {
	return Math.acos(-1.0);
}
def code(v):
	return math.acos(-1.0)
function code(v)
	return acos(-1.0)
end
function tmp = code(v)
	tmp = acos(-1.0);
end
code[v_] := N[ArcCos[-1.0], $MachinePrecision]
\begin{array}{l}

\\
\cos^{-1} -1
\end{array}
Derivation
  1. Initial program 98.7%

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in v around 0

    \[\leadsto \mathsf{acos.f64}\left(\color{blue}{-1}\right) \]
  4. Step-by-step derivation
    1. Simplified96.3%

      \[\leadsto \cos^{-1} \color{blue}{-1} \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024161 
    (FPCore (v)
      :name "Falkner and Boettcher, Appendix B, 1"
      :precision binary64
      (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))