1
$\begingroup$

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, ...)?

$\endgroup$
2
  • $\begingroup$ Have you tried wrapping those functions in HoldForm or Unevaluated? $\endgroup$
    – Markhaim
    Commented Nov 29, 2019 at 5:48
  • $\begingroup$ I have tried but it does not seem to solve my problem. Can you provide an example of how you intend using them? $\endgroup$ Commented Dec 20, 2019 at 15:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.