Let G be a topological group, and let C(G) denote the algebra of continuous, complex valued functions on G. We determine the solutions \(f,g,h \in C(G)\) of the Levi-Civita equation \(\begin{aligned} g(xy) = g(x)g(y) + f(x)h(y), \ x,y \in G, \end{aligned}\) that extends the cosine addition law. As a corollary we obtain the solutions \(f,g \in C(G)\) of the cosine subtraction law \(g(xy^*) = g(x)g(y) + f(x)f(y)\) , \(x,y \in G\) where \(x \mapsto x^*\) is a continuous involution of G. That \(x \mapsto x^*\) is an involution, means that \((xy)^* = y^*x^*\) and \(x^{**} = x\) for all \(x,y \in G\) .