# copy paste merging expressions

I ran a solve to evaluate a few linear equations,

Solve[{some eqns},{A0,B0,c0,d0,e0}]


and then in the output I got:

{{A0-> stuff+ 1/rho F (stuff) , B0->..,...,e0->..}}.


Now when when I selected, copied and pasted the expression I got for A0. I wound up getting :

stuff+ 1/rhoF (stuff)


My subsequent ContourPlot was giving me nothing and it took me the longest time to notice that two of my variables, $\rho$ and F had been made into a new variable rhoF somehow during the copy paste process.

I've found this to be a bit unnerving. Is there some way to guarantee that this never happens? I've been doing ctrl-C and ctrl-v. Should I do "copy as" and pick one of the options to avoid this formatting issue. Right now I don't have two variables that might merge together to become an pre-existing variable, but if for example rhoF had indeed been something I had defined earlier, I would never have found out about this error and I would've been in deep trouble doing some corrupted analysis.

Any help will be greatly appreciated.

EDIT: I tried the replace rule /. but I still have the same problem. This is what I have actually done:

{{A0, B0, L0, M0, c0, S}} = {A0, B0, L0, M0, c0, S} /. Solve[{
A0*(H0D)^(k1) +  B0*(H0D)^(k2) + (delta/(delta + rho - r))*(H0D)
+ u/rho-  c0*F/rho ==-CF,
k1*A0*(H0D)^(k1 - 1) + k2*B0*(H0D)^(k2 - 1) == -((delta)/(delta + rho - r)),
L0*(H0S)^(k1) + M0*(H0S)^(k2) + c0*F/r == F,
L0*(H0D)^(k1) + M0*(H0D)^k2 + c0*F/r == H0D - CFL,
L0*H1R^(k1) + M0*H1R^k2 + c0*F/r -CRL == H1R - CFL + gamma*S,
A0*(H1R)^(k1) + B0*(H1R)^(k2) + (delta/(delta + rho - r))*(H1R) +
u/rho - c0*F/rho -CR == -CF + (1 - gamma)*S}, {A0, B0, L0, M0, c0, S}]


and then when I tried to get the value for shift+enter A0, again rho and F were combined in line 16 to form rhoF. I tried to boldface it but I guess boldface does not work inside the code format. Please help!

-(-1/(delta - r + rho)
delta (-H0D^
k2 (-(-(-1 + gamma) H0S^k2 H1R^k1 + (-1 + gamma) H0S^k1 H1R^
k2) (-((F H0D^k2)/r) + (F H0S^k2)/
r) + (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) ((
F (-1 + gamma) H1R^k2)/r +
H0S^k2 (-((F (-1 + gamma))/r) + (F gamma)/rho))) + (
F gamma H0S^k2 (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) H1R^k2)/rho) +
H0D^(-1 + k2)
k2 (-(-(-(-1 + gamma) H0S^k2 H1R^k1 + (-1 + gamma) H0S^k1 H1R^
k2) (-((F H0D^k2)/r) + (F H0S^k2)/
r) + (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) ((
F (-1 + gamma) H1R^k2)/r +
H0S^k2 (-((F (-1 + gamma))/r) + (F gamma)/rho))) (CF + (
delta H0D)/(delta - r + rho) + u/rho) -
**1/rhoF** (-(F H0D^k2 + (CFL - H0D) H0S^k2) (-(-1 + gamma) H0S^
k2 H1R^k1 + (-1 + gamma) H0S^k1 H1R^k2) + (-H0D^k2 H0S^
k1 + H0D^k1 H0S^k2) (-F (-1 + gamma) H1R^k2 +
H0S^k2 (-(-1 + gamma) (CFL - CRL - H1R) -
gamma (CF - CR + (delta H1R)/(delta - r + rho) + u/
rho))))))/(H0D^(-1 + k2)
k2 (-H0D^
k1 (-(-(-1 + gamma) H0S^k2 H1R^k1 + (-1 + gamma) H0S^k1 H1R^
k2) (-((F H0D^k2)/r) + (F H0S^k2)/
r) + (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) ((
F (-1 + gamma) H1R^k2)/r +
H0S^k2 (-((F (-1 + gamma))/r) + (F gamma)/rho))) + (
F gamma H0S^k2 (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) H1R^k1)/rho) -
H0D^(-1 + k1)
k1 (-H0D^
k2 (-(-(-1 + gamma) H0S^k2 H1R^k1 + (-1 + gamma) H0S^k1 H1R^
k2) (-((F H0D^k2)/r) + (F H0S^k2)/
r) + (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) ((
F (-1 + gamma) H1R^k2)/r +
H0S^k2 (-((F (-1 + gamma))/r) + (F gamma)/rho))) + (
F gamma H0S^k2 (-H0D^k2 H0S^k1 + H0D^k1 H0S^k2) H1R^k2)/rho))

-
Welcome to Mathematica.SE, Amatya! I have formatted your post so it is a bit easier to read. If you would like to know how to do this yourself, this page explains how. – Verbeia Aug 16 '12 at 23:42
Hi Verbeia, thanks a lot for fixing my post and linking to the guide! – Amatya Aug 17 '12 at 0:05
Hi Nasser, Something strange is happening. The merge of the two variable remained after I tried your /. replace rule. – Amatya Aug 17 '12 at 0:07
HI Nasser, please see my edited question, the stuff in the end. I have written the actual Solve and the actual expression where the weirdness is happening. – Amatya Aug 17 '12 at 0:21
I don't seem to have this problem with version 7 but that sure sounds nasty! Before you conclude it is a bug, please try clearing your preferences. – Mr.Wizard Aug 17 '12 at 10:30

The apparent concatenation of symbols seems to be related to the page width (window width) at the time when the output expression is generated.

Using

A0 /. Solve[{ A0*(H0D)^(k1) +  B0*(H0D)^(k2) + (delta/(delta + rho - r))*(H0D)  + u/rho-  c0*F/rho ==-CF, k1*A0*(H0D)^(k1 - 1) + k2*B0*(H0D)^(k2 - 1) == -((delta)/(delta + rho - r)), L0*(H0S)^(k1) + M0*(H0S)^(k2) + c0*F/r == F, L0*(H0D)^(k1) + M0*(H0D)^k2 + c0*F/r == H0D - CFL, L0*H1R^(k1) + M0*H1R^k2 + c0*F/r -CRL == H1R - CFL + gamma*S, A0*(H1R)^(k1) + B0*(H1R)^(k2) + (delta/(delta + rho - r))*(H1R) +  u/rho - c0*F/rho -CR == -CF + (1 - gamma)*S}, {A0, B0, L0, M0, c0, S}]


one can replicate OP's issue (on Windows Vista 64bit MMA 8.0.4) by changing the window width between evaluations of the above expression.

Starting with a wide enough window (e.g., 1550 pixels), I get the following:

If the window width at the time the input cell is evaluated is smaller (e.g., 1000 pixels) I get

However, what appears as 1/rhoF is actually 1/rho F. This can be seen by copying the larger term containing it and then processing it with ToBoxes, InputForm, FullForm, StandardForm or TraditionalForm:

Finally, depending on whether or not the white space to the right of F is included in the copied expression, copy-paste using Ctrl-C Ctrl-V gives two different results:

When the white space is not highlighted,

you get the two symbols rho and F concatenated into a new symbol rhoF; using ToBoxes on the pasted expression:

 1/rhoF // ToBoxes
(* FractionBox["1", "rhoF"]  *)


If the copied piece includes the white space to the right of F:

copy-paste gives the correct result:

 1/rho F // ToBoxes
(* FractionBox["F", "rho"] *)

-
Thanks for responding Kguler. I tried ClearAll[A0, B0, L0, M0, c0, S] and Solve but it still produces rhoF on my machine. I guess this is some quirk of my particular machine or my particular mathematica. I will try restarting my computer to see if anything changes. – Amatya Aug 17 '12 at 1:27
Amatya, I get the same result as you do if I don't start from a fresh kernel. This seems to be a bug in typesetting routines: The output of Solve is typeset with rhoF even without copy-paste. Starting from fresh kernel solved the issue on my system (Vista 64bit, 8G mem, MMA 8.0.4). – kglr Aug 17 '12 at 1:40
Amatya, please see the updated post. It turns out the puzzling behavior has nothing to do with restarting MMA or fresh kernel (it so happened that I resized the window at the same time as re-started the kernel). – kglr Aug 17 '12 at 15:57
Oh man! That's pretty cool that you spotted that Kguler!! Thanks a lot. I will keep my windows maxed from here on. When I was copying and pasting, I was copying the entire expression and not just the rhoF part but I guess somehow somewhere the copying was literal and the information, that mathematica was saving on space by writing them next to each other, was lost. – Amatya Aug 17 '12 at 20:47