Suppose that you want to make a report about the golden section algorithm, and you want to explain the process with text in $\LaTeX$, and in every iteration you want to show in that report the values and the correct option, and then you want to continue explaining in $\LaTeX$.
For example in this code, how can you do it?
itmax = 10;
tolerancia = 0.2;
alfa = (-1 + Sqrt[5])/2;
ttheta[Lambda_] = Lambda^2 + 2*Lambda;
a = -3;
b = 5;
La = a + (1 - alfa)*(b - a) // N;
Mu = a + alfa*(b - a) // N;
tthetaLa = ttheta[La];
tLacalc = "*";
tthetaMu = ttheta[Mu];
tMucalc = "*";
Printf["With * we show you that this is an evaluate of theta(t)"]
Printf["With NO* we show you that this is an evaluate of theta(t)"]
Print["iteración_k | a_k b_k | Lambda_k Mu_k | \
theta(Lambda_k) theta(Mu_k)"];
Do[
L = b - a;
Print[" In the iteration "i, " you have the values:",
"\n a= ",a,
"\n b= ",b,
"\n Lamda= ",La,
"\n Mu= ",Mu,
"\n ",
"\n Where the values of theeta are:",
"\n theta (Lambda)= ",tthetaLa,
"\n theta (Mu)= ",tthetaMu,
"os a = | ", a, " ", b, " | ", La, " ", Mu,
" | ", tthetaLa, tLacalc " ", tthetaMu, tMucalc ];
If[tthetaLa > tthetaMu,
If[b - a < tolerancia, Break[]];
a = La;
La = Mu;
Mu = a + alfa (b - a);
tthetaLa = tthetaMu;
tLacalc = " ";
tthetaMu = ttheta[Mu];
tMucalc = " ";,
b = Mu;
Mu = La;
La = a + (1 - alfa) (b - a);
tthetaMu = tthetaLa;
tMucalc = " ";
tthetaLa = ttheta[La];
tLacalc = "*";
]
, {i, 1, itmax}
];
solucionestimada = (Mu + La)/2;
valorestimado = ttheta[solucionestimada];
Print["La solución estimada es ", solucionestimada,
" donde la función toma valor ", valorestimado];



