Message Boards Message Boards

GROUPS:

Solve an equation inside a loop

Posted 2 months ago
300 Views
|
1 Reply
|
1 Total Likes
|

Hello all,

I am trying to solve a polynomial equation in each loop:

For[i = 0,
i < 21,
i++,
y = i; R[i] = Solve[x + x^5*y + y == x, x]
]

I am not sure how to store the solutions in a vector R since there are several solutions. Is it correct?

For simplicity, I am even interested only in the largest real solution

POSTED BY: O L
Answer
Posted 2 months ago

Try

R={};
For[i = 0,i < 21,i++,
  AppendTo[R,x/.Solve[x + x^5*i +i == x, x][[1]]]];
R

or perhaps more simply

R=Table[x/.Solve[x + x^5*i +i == x, x,Reals][[1]],{i,0,21}]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract