-1
$\begingroup$

I have one boring problem with changing parameters in printing output. If I have equation

    eq = Plus[Times[a1,Derivative[2,0][q2][x,y]],Times[a2,Derivative[3,1][q1][x,y]]];

I want to replace all derivatives with new variables, for example this

      Derivative[2, 0][q2][x, y]

I want to replace it with $C_{\mathrm{q2}}^{2,0}$ and for all of them on the same way to get eq output automatically in this form

$\mathrm{a1}\,C_{\mathrm{q2}}^{2,0}+\mathrm{a2}\,C_{\mathrm{q1}}^{3,1}$

$\endgroup$
3
  • $\begingroup$ Check SubsuperscriptBox. $\endgroup$
    – Silvia
    Commented Jun 18, 2013 at 21:18
  • $\begingroup$ there is not explanation hoe to change them automatically $\endgroup$ Commented Jun 18, 2013 at 21:26
  • $\begingroup$ I'm not sure about what you mean by changing parameters. But you might also be interested in RuleDelayed (:>). $\endgroup$
    – Silvia
    Commented Jun 18, 2013 at 21:26

1 Answer 1

3
$\begingroup$

If I understand you correctly, this might be what you're looking for:

eq /. Derivative[n__][q_][__] :>
            RawBoxes[
                 SubsuperscriptBox["C",
                                   ToString[q],
                                   RowBox[Riffle[{n}, ","]]
              ]]

formatted box

Please note the using of SubsuperscriptBox and RawBoxes, which will prevent superscript being evaluated as Power.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.