This is exercise P5.2.6 from Matrix Computations 4ed, Golub and Van Loan:
Suppose $A \in \mathbb{R}^{n \times n}$ and $D = \mathrm{diag}(d_1, \cdots, d_n) \in \mathbb{R}^{n \times n}$. Give a procedure to calculate an orthogonal $Q \in \mathbb{R}^{n \times n}$ s.t. $$ R := Q^TA - DQ^T $$ is upper triangular.
I tried different ideas:
Use induction on the dimension $n$, where in each step the Householder reflection / Givens rotation is applied;
Split $Q = [q_1 | q_2 | \cdots | q_n]$ into column vectors, substitute into $Q^TA - DQ^T = R$ , then solve for $Q$ and $R$;
Make use of the original QR decomposition;
but none of them seems the right path. Any hint is appreciated !
Rewrite the equation
$$ R = Q^{T}A - DQ^{T}$$ $$ QR = A - QDQ^{T} $$ $$ A = QR + QDQ^{T}$$
Then the basic $QR$ decomposition corresponds to when $D = \mathbb{0}$.