Message Boards Message Boards

combining solve and for

Posted 9 years ago

Hello

I am trying to find the solution of an equation for many values in a sequence this is the code that i am using but it doesnt give any result.

eq = x^2 - 5;
c = Last[Solve[eq == 1, x]]
Do[Last[Solve[eq == a, x]], {a, 10}]
For[i = 1, i < 11, i++, Solve[eq == a, x]]

I have tried to do the loop with the function For and the function Do but still i dont get anywhere, also afterwards i would like to save just the positive solution and plot it.

i hope you could help me

Thanks and Regards

Gregorio

3 Replies

Hello again

i did a small step , i got the solutions but now i am getting everything as an object instead as a number, i would like to have the numbers, i have tried using Table instead of print but it doesnt work

eq = x^2 - 5;
For[i = 1, i < 11, i++, f = Last[Solve[eq == i, x]]; 
  h = Print[{i,N[x /. f]}]]

So now i would like to save those values (h) in a table and then plot them

Regards

Posted 9 years ago

never use for loop in Mathematica :) see attachment..

Attachments:
POSTED BY: Okkes Dulgerci

Thanks a lot this work perfect!

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