Message Boards Message Boards

0
|
10420 Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Solve a nonlinear equation

Posted 9 years ago
POSTED BY: Minh-Ngoc Vu
9 Replies
POSTED BY: Frank Kampas
Posted 9 years ago

Dear,

Could you show me how I can write the solution under format: {x[1], x[2], x[3], x[4], x[5]} after solving the following equation

Thank you in advance

A[i_] := i/10

Table[NSolve[x^5 - A[i]x/ - 1 == 0, x, Reals], {i, 1, 5}]

The results are:

{{{x -> 1.01961}}, {{x -> 1.03846}}, {{x -> 1.05661}}, {{x -> 1.0741}}, {{x -> 1.09097}}} But I want to write only {1.01961, 1.03846, 1.05661, 1.0741, 1.09097} to faciliate the copy and paste in excel

POSTED BY: Minh-Ngoc Vu
Posted 9 years ago
POSTED BY: Minh-Ngoc Vu

You can modify the Table command:

Table[{A[i], NSolve[x^5 - 2 x/5 - 1 == 0, x, Reals]}, {i, 1, 5}]
POSTED BY: Sean Clarke

You are using "A" as a variable name. I strongly suggest changing the name of it. Single letter variable or function names are a bad idea.

The error message is complaining that "A" is already defined. Try running your code in a clean kernel. That is, run Quit and then try running the code.

POSTED BY: Sean Clarke
Posted 9 years ago
POSTED BY: Minh-Ngoc Vu

First, define the function "A". I strongly recommend creating more expressive names than this.

A[i_] := i/10

Use Table to create a list of functions

Table[x^5 - A[i]*x - 1 == 0, {i, 1 , 10}]

Tables like this can be used with NSolve. The set of equations may or may not have a solution.

POSTED BY: Sean Clarke
Posted 9 years ago

Dear Sean Clarke,

According to your help, I wrote the following commands but I think it does not work. Can you explain me please.

(Debug) In[28]:= NSolve[x^5 - x/10 - 1 == 0, x, Reals]

(Debug) Out[28]= {{x -> 1.01961}}

(Debug) In[29]:= NSolve[x^5 - x/5 - 1 == 0, x, Reals]

(Debug) Out[29]= {{x -> 1.03846}}

(Debug) In[30]:= NSolve[x^5 - 3 x/10 - 1 == 0, x, Reals]

(Debug) Out[30]= {{x -> 1.05661}}

(Debug) In[31]:= NSolve[x^5 - 2 x/5 - 1 == 0, x, Reals]

(Debug) Out[31]= {{x -> 1.0741}}

(Debug) In[43]:= Clear[x];

A[i_] := i/10; Table[NSolve[x^5 - 2 x/5 - 1 == 0, x, Reals], {i, 1, 5}]

(Debug) During evaluation of In[43]:= SetDelayed::write: Tag List in {1/10,1/5,3/10,2/5,1/2,3/5,7/10,4/5,9/10,1}[i_] is Protected. >>

(Debug) Out[45]= {{{x -> 1.0741}}, {{x -> 1.0741}}, {{x -> 1.0741}}, {{x -> 1.0741}}, {{x -> 1.0741}}}

POSTED BY: Minh-Ngoc Vu
POSTED BY: Frank Kampas
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