Avoid condensing and use original terms in result of RowReduce

[Note: The given 2 solutions deal only with a simple example but not with the real problem]

Can I force MMA to use original expressions in a result of RowReduce instead of displaying only the condensed result?

For better understanding I give a simple example with Solve instead of RowReduce:

Solve[5x-2==3,x]
x->1


I want a result that includes original terms, e.g.

x->(3+2)/5


My code with RowReduce:

RowReduce[{{-1/(
2 Sqrt[2]) (√(Sqrt[(s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))^2 -
4 (s1^2 s3^2 + s1^2 s5^2 + s3^2 s5^2) (s2^2 s4^2 +
s2^2 s6^2 + s4^2 s6^2)] + s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))), 0, 0, (s1 s4)/2,
0, -(1/2) (s1 s6)}, {0, -1/(
2 Sqrt[2]) (√(Sqrt[(s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))^2 -
4 (s1^2 s3^2 + s1^2 s5^2 + s3^2 s5^2) (s2^2 s4^2 +
s2^2 s6^2 + s4^2 s6^2)] + s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))), -(1/2) (s2 s3),
0, (s2 s5)/2,
0}, {0, -(1/2) (s2 s3), -1/(
2 Sqrt[2]) (√(Sqrt[(s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))^2 -
4 (s1^2 s3^2 + s1^2 s5^2 + s3^2 s5^2) (s2^2 s4^2 +
s2^2 s6^2 + s4^2 s6^2)] + s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))), 0, 0, (s3 s6)/
2}, {(s1 s4)/2, 0,
0, -1/(2 Sqrt[
2]) (√(Sqrt[(s6^2 (s1^2 + s3^2) + s4^2 (s1^2 + s5^2) +
s2^2 (s3^2 + s5^2))^2 -
4 (s1^2 s3^2 + s1^2 s5^2 + s3^2 s5^2) (s2^2 s4^2 +
s2^2 s6^2 + s4^2 s6^2)] + s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))), -(1/2) (s4 s5),
0}, {0, (s2 s5)/2,
0, -(1/2) (s4 s5), -1/(
2 Sqrt[2]) (√(Sqrt[(s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))^2 -
4 (s1^2 s3^2 + s1^2 s5^2 + s3^2 s5^2) (s2^2 s4^2 +
s2^2 s6^2 + s4^2 s6^2)] + s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2))),
0}, {-(1/2) (s1 s6), 0, (s3 s6)/2, 0,
0, -1/(2 Sqrt[
2]) (√(Sqrt[(s6^2 (s1^2 + s3^2) + s4^2 (s1^2 + s5^2) +
s2^2 (s3^2 + s5^2))^2 -
4 (s1^2 s3^2 + s1^2 s5^2 + s3^2 s5^2) (s2^2 s4^2 +
s2^2 s6^2 + s4^2 s6^2)] + s6^2 (s1^2 + s3^2) +
s4^2 (s1^2 + s5^2) + s2^2 (s3^2 + s5^2)))}}]


In the solution I would like to see all roots as they appear in the above expression so that I can easily associate the terms.

This answer about RowReduce does not work in my case.

• I don't think can be achieved for Solve without rewriting Solve by yourself. Also, you should specify more precisely what you mean by "any other operation" because there are thousands of different "operations" in Mathematica, working very differently from each other. You probably have some particular problem in mind – show it explicitly. Mar 22, 2023 at 14:22
• It is of no use if you give some completely different example with Solve when you actually want a solution for RowReduce. Show the actual problem you have. It can be simplified (like using a smaller, simpler matrix), but not completely different. Mar 22, 2023 at 14:33
• @granularbastard, then show a smaller matrix. If you have mat, post mat[[1;;2, 1;;2]], or make up a simpler matrix! Stop other people wasting time, and answering your question by using Solve. Mar 22, 2023 at 17:09

Clear["Global*"]

eqn = 5 x - 2 == 3;

eqn2 = eqn /. n_Integer :> Sign[n]*ToString[Abs[n]];

sol = Solve[eqn2, x][[1]]


sol2 = sol /. str_String :> ToExpression[str]

{x -> 1}


EDIT: For a slightly more complicated equation

eqn = 5 x - 2 == 3 x^2;

eqn2 = eqn /. a_Integer*x^n_. :> Sign[a]*ToString[a]*x^n;

sol = Solve[eqn2, x]


sol2 = sol /. str_String :> ToExpression[str]

(* {{x -> 2/3}, {x -> 1}} *)

eqn /. sol2

(* {True, True} *)


I think you're going to need to decide ahead of time which parts of your equation are the terms in which you want your solution to appear. Then you can use dummy variables for those terms. You will also need some way to stop evaluation of your final expression, and some form of Hold* is appropriate for that.

For example

eq1 = a x - b == c;
sols1 = Solve[eq1, x];
MapAt[HoldForm, sols1, {All, All, 2}] /. {a -> 5, b -> 2, c -> 3}


{{x -> (2 + 3)/5}} (the HoldForm is there, just suppressed in the display).

Or

eq2 = a x - b == c x^2;
sols2 = Solve[eq, x];
MapAt[HoldForm, sols2, {All, All, 2}] /. {a -> 5, b -> 2, c -> 3}


{{x ->-1/2*(-1*5 + Sqrt[5^2 - 4*2*3])/3}, {x ->(5 + Sqrt[5^2 - 4*2*3])/(2*3)}}

Or even just apply the HoldForm from the beginning to the terms you want to preserve:

eq3 = HoldForm[5] x - HoldForm[2] == HoldForm[3] x^2;
sols3 = Solve[eq3, x]


(Same result in appearance, but the HoldForm is in different places.)

• I don't know what result you want, so I don't know. At the time I posted this answer, there was no RowReduce example, so you've moved the goalposts. But the principle is that to get the structure you want in the result you need to determine which symbols to hold. If that doesn't work with RowReduce, or if it just doesn't work in your context, well, then, it doesn't work. Sorry. I answered the question that was originally asked. Mar 22, 2023 at 17:38
• At the time of asking the question it is not clear if a solution for a simple example can be applied in general. Mar 22, 2023 at 17:40
• The burden is on the asker to ask a well-formed and relevant question. The burden is not on the answerer to guess what generalizations the asker is keeping secret. Mar 22, 2023 at 17:50
• The original question states "My question concerns not only Solve but any operation." This also includes RowReduce`. Actually I thought there is an option that works for any operation. Mar 22, 2023 at 22:10