Skip to main content
2 of 4
Added use of Solve vice SolveValues
Bob Hanlon
  • 162.6k
  • 7
  • 81
  • 205
$Version

"13.2.1 for Mac OS X ARM (64-bit) (January 27, 2023)"

Clear["Global`*"]

b = 2.6666;
Pr = 10;

(table = Prepend[
    Table[{r, Sequence @@
       SolveValues[
        x^3 + x^2 (1 + b + Pr) + x (b + b (r - 1) + Pr*b) + 
          2*Pr*b (r - 1) == 0, x, Reals]},
     {r, 0, 0.03, 0.01}],
    {"r", "x1", "x2", "x3"}]) // Grid

EDIT: Or, for earlier versions without SolveValues, use

(table = 
   Prepend[Table[{r, 
      Sequence @@ (x /. 
         Solve[x^3 + x^2 (1 + b + Pr) + x (b + b (r - 1) + Pr*b) + 
            2*Pr*b (r - 1) == 0, x, Reals])}, {r, 0, 0.03, 
      0.01}], {"r", "x1", "x2", "x3"}]) // Grid

enter image description here

Export["test.csv", table];

Import["test.csv"] // Grid

enter image description here

Bob Hanlon
  • 162.6k
  • 7
  • 81
  • 205