?

Average Error: 0.78% → 0.78%
Time: 14.9s
Precision: binary64
Cost: 20032

?

\[\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right) \]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + v \cdot \left(v \cdot 5\right)}{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
 (expm1 (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 expm1(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.expm1(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.expm1(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 expm1(log1p(acos(Float64(Float64(-1.0 + Float64(v * Float64(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[1 + 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]] - 1), $MachinePrecision]
\cos^{-1} \left(\frac{1 - 5 \cdot \left(v \cdot v\right)}{v \cdot v - 1}\right)
\mathsf{expm1}\left(\mathsf{log1p}\left(\cos^{-1} \left(\frac{-1 + v \cdot \left(v \cdot 5\right)}{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.78

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

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

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

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

    [Start]0.78

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

    distribute-neg-frac [=>]0.78

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

    neg-sub0 [=>]0.78

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

    fma-udef [=>]0.78

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

    +-commutative [<=]0.78

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

    associate-*r* [=>]0.78

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

    *-commutative [<=]0.78

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

    metadata-eval [<=]0.78

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

    cancel-sign-sub-inv [<=]0.78

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

    associate--r- [=>]0.78

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

    metadata-eval [=>]0.78

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

    *-commutative [=>]0.78

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

    associate-*l* [=>]0.78

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

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

Alternatives

Alternative 1
Error0.78%
Cost13760
\[\frac{1}{\frac{1}{\cos^{-1} \left(\frac{\mathsf{fma}\left(v, v \cdot 5, -1\right)}{1 - v \cdot v}\right)}} \]
Alternative 2
Error0.78%
Cost7232
\[\cos^{-1} \left(\frac{1 + \left(v \cdot v\right) \cdot -5}{-1 + v \cdot v}\right) \]
Alternative 3
Error1.91%
Cost6720
\[\cos^{-1} \left(-1 + v \cdot v\right) \]
Alternative 4
Error1.95%
Cost6464
\[\cos^{-1} -1 \]

Error

Reproduce?

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