With the given code for ODE analytical solutions, I get a TEX error :
(* Define the system of ODEs with ρ21 = ρ12^* *) eq1 = rho11'[t] == -rho11[t] - I (Conjugate[rho12[t]] - rho12[t]) + 1; eq2 = rho12'[t] == -rho12[t]/2 - I (1 - 2 rho11[t]); (* Display the system of ODEs in LaTeX *) Print["System of ODEs:"]; Print[TeXForm[eq1]]; Print[TeXForm[eq2]]; (* Define initial conditions *) ics = {rho11[0] == 1/10, rho12[0] == -I/10}; (* Display the initial conditions in LaTeX *) Print["Initial conditions:"]; Print[TeXForm[ics]]; (* Attempt to solve the system analytically *) Print["Attempting analytical solution using DSolve..."]; solutions = DSolve[{eq1, eq2, ics}, {rho11[t], rho12[t]}, t]; (* Display the analytical solution attempt in LaTeX *) If[solutions === {}, Print["No analytical solution found."], Print["Analytical solution found:"]; Print["rho11[t]:"]; Print[TeXForm[rho11[t] /. solutions[[1]]]]; Print["rho12[t]:"]; Print[TeXForm[rho12[t] /. solutions[[1]]]] ]; (* Solve the system numerically *) Print["Solving the system numerically using NDSolve..."]; ndsol = NDSolveValue[{eq1, eq2, ics}, {rho11[t], rho12[t]}, {t, 0, 10}]; (* Extract numerical solutions as static expressions *) rho11Num = ndsol[[1]]; rho12Num = ndsol[[2]]; (* Display the numerical solution in LaTeX *) Print["Numerical solution:"]; Print["rho11[t]:"]; Print[TeXForm[rho11Num]]; Print["rho12[t]:"]; Print[TeXForm[rho12Num]]; (* Define legend for plots *) legend = {"rho11", "rho12"}; (* Plot the real components of the numerical solution *) Print["Plotting the real components of the numerical solution..."]; Plot[Re@ndsol // Evaluate, {t, 0, 10}, PlotRange -> All, PlotLegends -> legend, PlotLabel -> "Real Component"]; (* Plot the imaginary components of the numerical solution *) Print["Plotting the imaginary components of the numerical solution..."]; Plot[Im@ndsol // Evaluate, {t, 0, 10}, PlotRange -> All, PlotLegends -> legend, PlotLabel -> "Imaginary Component"]; (* Compute and plot the linear entropy evolution *) Print["Computing linear entropy evolution..."]; linearEntropy[rho11_, rho12_] := 1 - (rho11^2 + (1 - rho11)^2 + 2 Abs[rho12]^2); entropyEvolution = linearEntropy[rho11Num, rho12Num]; Print["Plotting linear entropy evolution..."]; Plot[entropyEvolution, {t, 0, 10}, AxesLabel -> {"t", "Linear Entropy S_L"}, PlotLabel -> "Linear Entropy Evolution", PlotRange -> All] It seems it is associated with the export of the analytical solution to TEX code. Any chance of making this work without that error?
Thanks