?

Average Error: 0.9% → 0.9%
Time: 21.6s
Precision: binary64
Cost: 32960

?

\[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
\[e^{\log \left(-1 + e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + \left(v \cdot v\right) \cdot 5}{1 - v \cdot v}\right)\right)}\right)} \]
(FPCore (v)
 :precision binary64
 (acos (/ (- 1.0 (* 5.0 (* v v))) (- (* v v) 1.0))))
(FPCore (v)
 :precision binary64
 (exp
  (log
   (+
    -1.0
    (exp (log1p (acos (/ (+ -1.0 (* (* v v) 5.0)) (- 1.0 (* v v))))))))))
double code(double v) {
	return acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
double code(double v) {
	return exp(log((-1.0 + exp(log1p(acos(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v)))))))));
}
public static double code(double v) {
	return Math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)));
}
public static double code(double v) {
	return Math.exp(Math.log((-1.0 + Math.exp(Math.log1p(Math.acos(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v)))))))));
}
def code(v):
	return math.acos(((1.0 - (5.0 * (v * v))) / ((v * v) - 1.0)))
def code(v):
	return math.exp(math.log((-1.0 + math.exp(math.log1p(math.acos(((-1.0 + ((v * v) * 5.0)) / (1.0 - (v * v)))))))))
function code(v)
	return acos(Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(v * v) - 1.0)))
end
function code(v)
	return exp(log(Float64(-1.0 + exp(log1p(acos(Float64(Float64(-1.0 + Float64(Float64(v * v) * 5.0)) / Float64(1.0 - Float64(v * v)))))))))
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]
code[v_] := N[Exp[N[Log[N[(-1.0 + N[Exp[N[Log[1 + 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]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
e^{\log \left(-1 + e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + \left(v \cdot v\right) \cdot 5}{1 - v \cdot v}\right)\right)}\right)}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.9

    \[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
  2. Applied egg-rr0.9

    \[\leadsto \color{blue}{e^{\log \cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{\mathsf{fma}\left(v, v, -1\right)}\right)}} \]
  3. Applied egg-rr0.9

    \[\leadsto e^{\log \color{blue}{\left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{\mathsf{fma}\left(v, v, -1\right)}\right)\right)} - 1\right)}} \]
  4. Applied egg-rr0.9

    \[\leadsto e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \color{blue}{\left(-\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{1 - v \cdot v}\right)}\right)} - 1\right)} \]
  5. Simplified0.9

    \[\leadsto e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \color{blue}{\left(\frac{-1 + \left(v \cdot v\right) \cdot 5}{1 - v \cdot v}\right)}\right)} - 1\right)} \]
    Proof

    [Start]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(-\frac{\mathsf{fma}\left(v, v \cdot -5, 1\right)}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    distribute-frac-neg [<=]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \color{blue}{\left(\frac{-\mathsf{fma}\left(v, v \cdot -5, 1\right)}{1 - v \cdot v}\right)}\right)} - 1\right)} \]

    fma-udef [=>]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-\color{blue}{\left(v \cdot \left(v \cdot -5\right) + 1\right)}}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    distribute-neg-in [=>]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\color{blue}{\left(-v \cdot \left(v \cdot -5\right)\right) + \left(-1\right)}}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    metadata-eval [=>]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\left(-v \cdot \left(v \cdot -5\right)\right) + \color{blue}{-1}}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    +-commutative [<=]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{\color{blue}{-1 + \left(-v \cdot \left(v \cdot -5\right)\right)}}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    associate-*r* [=>]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + \left(-\color{blue}{\left(v \cdot v\right) \cdot -5}\right)}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    distribute-rgt-neg-in [=>]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + \color{blue}{\left(v \cdot v\right) \cdot \left(--5\right)}}{1 - v \cdot v}\right)\right)} - 1\right)} \]

    metadata-eval [=>]0.9

    \[ e^{\log \left(e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + \left(v \cdot v\right) \cdot \color{blue}{5}}{1 - v \cdot v}\right)\right)} - 1\right)} \]
  6. Final simplification0.9

    \[\leadsto e^{\log \left(-1 + e^{\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + \left(v \cdot v\right) \cdot 5}{1 - v \cdot v}\right)\right)}\right)} \]

Alternatives

Alternative 1
Error0.9%
Cost20032
\[e^{\log \cos^{-1} \left(\frac{-1 + v \cdot \left(v \cdot 5\right)}{1 - v \cdot v}\right)} \]
Alternative 2
Error0.9%
Cost7232
\[\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right) \]
Alternative 3
Error2.2%
Cost6464
\[\cos^{-1} -1 \]

Error

Reproduce?

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