I am computing some derivatives in Wolfram Mathematica 11.3. The functions that I have to differentiate (with respect to the state variables) are the equations of motion of a rocket in the atmosphere. They involve some terms such as the thrust and atmospheric drag that are functions of the state variables. Therefore, I have defined thrust, relative velocity, and drag functions:
(* Thrust *) thrustb[r_] := thrustbvac - p[r] ae; (* Relative velocity *) vrel[r_, phi_, vr_, vt_, vn_] := (vr^2 + (vt - omegae r Cos[phi])^2 + vn^2)^(1 / 2); (* Drag *) drag[r_, phi_, vr_, vt_, vn_] := (1 / 2) cd s rho[r] vrel[r, phi, vr, vt, vn]^2
The differentiation works fine, for example the ODE of the radial velocity component vr is differentiated wrt to the radius (r) as follows:
(* vr *) dvr[r_, phi_, vr_, vt_, vn_, z_] := ((vt^2 + vn^2) / r - mu / (r^2) + ur + (( thrustb[r] - drag[r, phi, vr, vt, vn] ) Exp[-z] vr / vrel[r, phi, vr, vt, vn])); der := D[dvr[r, phi, vr, vt, vn, z], r];
Once the derivative is computed, I print it out to a (blank) TeX file:
filename = "derivatives.tex"; stream = OpenWrite[filename]; Write[stream, "der = ", TeXForm[der]]
However, the output is a very long expression because all the functions that I defined (drag, relative velocity, ...) are explicitly expanded. Instead, I would like to keep them "unexpanded". So, is there a way to print the output in a compact way, that is, in terms of the higher-level functions (drag, thrust, ...)?