Skip to main content
added 41 characters in body
Source Link
Anjan Kumar
  • 5k
  • 1
  • 17
  • 29
A = {1, 2, 3, 1/2} /. ({Rational[x_, y_] :>  If[x > 0, HoldForm[x/y]), 
-HoldForm@Evaluate[-x/y]]};
B = MapAt[HoldForm, {1, Sqrt[2], Sqrt[3], Sqrt[6]}, 2 ;;]
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]

A = {1, 2, 3, 1/2} /. (Rational[x_, y_] :> HoldForm[x/y]);
B = MapAt[HoldForm, {1, Sqrt[2], Sqrt[3], Sqrt[6]}, 2 ;;]
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]

A = {1, 2, 3, 1/2} /. {Rational[x_, y_] :>  If[x > 0, HoldForm[x/y], 
-HoldForm@Evaluate[-x/y]]};
B = MapAt[HoldForm, {1, Sqrt[2], Sqrt[3], Sqrt[6]}, 2 ;;]
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]

added 15 characters in body
Source Link
Anjan Kumar
  • 5k
  • 1
  • 17
  • 29
A = {1, 2, 3, 1/2} /. (Rational[x_, y_] :> HoldForm[x/y]);
B = HoldForm /@MapAt[HoldForm, {1, Sqrt[2], Sqrt[3], Sqrt[6]}, 2 ;;]
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]

A = {1, 2, 3, 1/2} /. (Rational[x_, y_] :> HoldForm[x/y]);
B = HoldForm /@ {1, Sqrt[2], Sqrt[3], Sqrt[6]}
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]

A = {1, 2, 3, 1/2} /. (Rational[x_, y_] :> HoldForm[x/y]);
B = MapAt[HoldForm, {1, Sqrt[2], Sqrt[3], Sqrt[6]}, 2 ;;]
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]

Source Link
Anjan Kumar
  • 5k
  • 1
  • 17
  • 29

A = {1, 2, 3, 1/2} /. (Rational[x_, y_] :> HoldForm[x/y]);
B = HoldForm /@ {1, Sqrt[2], Sqrt[3], Sqrt[6]}
A.B

1+2 Sqrt[2]+3 Sqrt[3]+1/2 Sqrt[6]