  The purpose of this paper is to investigate the invariance of the arithmetic
mean with respect to two weighted Bajraktarevi\'c means, i.e., to solve the
functional equation $$
  \bigg(\frac{f}{g}\bigg)^{\!\!-1}\!\!\bigg(\frac{tf(x)+sf(y)}{tg(x)+sg(y)}\bigg)
  +\bigg(\frac{h}{k}\bigg)^{\!\!-1}\!\!\bigg(\frac{sh(x)+th(y)}{sk(x)+tk(y)}\bigg)=x+y
\qquad(x,y\in I), $$ where $f,g,h,k:I\to\mathbb{R}$ are unknown continuous
functions such that $g,k$ are nowhere zero on $I$, the ratio functions $f/g$,
$h/k$ are strictly monotone on $I$, and $t,s\in\mathbb{R}_+$ are constants
different from each other. By the main result of this paper, the solutions of
the above invariance equation can be expressed either in terms of hyperbolic
functions or in terms of trigonometric functions and an additional weight
function. For the necessity part of this result, we will assume that
$f,g,h,k:I\to\mathbb{R}$ are four times continuously differentiable.

Classical Analysis and ODEs