Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Can someone please explain to me the logic of this:

In one cell, when writing

eq = D[y[x], x] + a*y[x] - b*Sin[c*x];
sol = DSolve[eq == 0, y[x], x];
TeXForm[sol]
OutputForm[TeXForm[sol]]

I see only the result of OutputForm:

Mathematica graphics

But in separate cells, then I see both outputs

Mathematica graphics

ps. I was trying to find how to remove the "\" at the end of the OutputForm compared to TeXForm output, and that is why I am doing the above, to compare the outputs.

This happens on both V9 and 10. Should not both output show up, even if in the same cell?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It seems like OutputForm always is the first output one gets and all previous Out[..] are removed if they are equal. Here equal means that Out[1]==Out[2], and not necessarily that Out[1]/TeXForm==Out[2]/OutputForm.

You can change the order to:

eq = D[y[x], x] + a*y[x] - b*Sin[c*x];
sol = DSolve[eq == 0, y[x], x];
OutputForm[TeXForm[sol]]
TeXForm[sol]

\left{\left{y(x)\to \frac{b (a \sin (c x)-c \cos (c x))}{a^2+c^2}+c_1 e^{-a x}\right}\right}

\left{\left{y(x)\to \frac{b (a \sin (c x)-c \cos (c x))}{a^2+c^2}+c_1 e^{-a x}\right}\right}

Your "\" at the end of the OutputForm is just a linebreak. It will be removed, if you make Mma window wider.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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