We determine the general solution of the functional equation
\[
f
(
x
+
y
)
+
f
(
x
−
y
)
=
A
(
y
)
f
(
x
)
(
x
,
y
∈
G
)
,
f(x+y)+f(x-y) =A(y)f(x)\qquad (x,y\in G),
\]
where
G
G
is a 2-divisible abelian group,
f
f
is a vector-valued function and
A
A
is a matrix-valued function. Using this result we solve the scalar equation
\[
f
(
x
+
y
)
+
f
(
x
−
y
)
=
g
1
(
x
)
h
1
(
y
)
+
g
2
(
x
)
h
2
(
y
)
(
x
,
y
∈
G
)
,
f(x+y)+f(x-y)=g_1(x)h_1(y)+g_2(x) h_2(y)\qquad (x,y\in G),
\]
which contains as special cases, among others, the d’Alembert and Wilson equations and the parallelogram law.