Reply to HallsofIvy:
I'm not sure I agree that that will work.
Is that necessarily equal to the desired expression? I'm not sure. I think you're going to have to use some sort of component-wise multiplication. Define the vector
Then you could write the desired expression as
Thank you for all your reply. I think I found a way to work around it. My problem is try to minimize the objective function . and are variable vectors. I tried to solve first then , which gave me the question in this thread. Now I solve first, then has a closed form solution.