I was wondering if anyone could help format my code:

I want to have a diagonal matrix Q and flipped diagonal matrix R where optim runs through values for the diagonal components for the optimization procedure. This is what I have so far but its not quite right obviously because I have R and Q as functions not matrices:

using Optim
N=2
L=100000
R(R1,R2) = flipdim(Matrix(Diagonal(R1:R2)),2)
Q(Q1,Q2) = Diagonal(R1:R2)

Unfortunately I am doing this in University (this is not homework it is an outside project I am working with faculty on) and I am on a strict timeline which is why I dived right in. I have been taking your advice and searching on that page but the variable definition and specifically linear algebra portion of using optim I still do not quite get and it may be helpful to see some examples. I have looked through it for many hours and for some reason it is not clicking, I will keep trying though.