Message Boards Message Boards

0
|
6115 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Problem with Solve inside a loop

Hi, I wonder why
Do[Solve[x^2 + m x ==  .2,x],{m,0, 1, 0.1}]
doesn't work. I have also tried to do the same thing with 
For[m = 0, m<1.01, m = m+0.01, Solve[x^2 + m x == .2 m,x]]
but I have no answer. Of course I can compute the roots since it's a second order equation but this doesn't change the problem
POSTED BY: Cyrille Piatecki
Dear Cyrille,

the input
Table[Solve[x^2 + m x == 0.2, x], {m, 0, 1, 0.1}]

gives
 {{{x -> -0.447214}, {x -> 0.447214}},
 {{x -> -0.5}, {x -> 0.4}},
 {{x -> -0.558258}, {x -> 0.358258}},
 {{x -> -0.621699}, {x -> 0.321699}},
 {{x -> -0.689898}, {x -> 0.289898}},
 {{x -> -0.762348}, {x -> 0.262348}},
 {{x -> -0.838516}, {x -> 0.238516}},
 {{x -> -0.917891}, {x -> 0.217891}},
 {{x -> -1.}, {x -> 0.2}},
{{x -> -1.08443}, {x -> 0.184429}},
{{x -> -1.17082}, {x -> 0.17082}}}

If you prefer the Do command, this seems to work:
Do[Print[Solve[x^2 + m x == 0.2, x]], {m, 0, 1, 0.1}]

Is that what you want?

Cheers,
Marco
POSTED BY: Marco Thiel
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