Hi everyone,
I wanna to solve the equation below. Could you please show me how I can write the commands in the Mathematica.
Thank you in advance,
The equation is : NSolve[x^5 - A[i]*x - 1 ==0,x]
where A[i] = i/10, {i=1,10,1]
Hi everyone,
I wanna to solve the equation below. Could you please show me how I can write the commands in the Mathematica.
Thank you in advance,
The equation is : NSolve[x^5 - A[i]*x - 1 ==0,x]
where A[i] = i/10, {i=1,10,1]
In[13]:= a = Range[10]/10
Out[13]= {1/10, 1/5, 3/10, 2/5, 1/2, 3/5, 7/10, 4/5, 9/10, 1}
In[14]:= Table[NSolve[x^5 - a[[i]]*x - 1 == 0, x], {i, 10}]
Out[14]= {{{x -> -0.802967 - 0.568379 I}, {x -> -0.802967 +
0.568379 I}, {x -> 0.293163 - 0.96304 I}, {x ->
0.293163 + 0.96304 I}, {x ->
1.01961}}, {{x -> -0.797202 - 0.548183 I}, {x -> -0.797202 +
0.548183 I}, {x -> 0.27797 - 0.975447 I}, {x ->
0.27797 + 0.975447 I}, {x ->
1.03846}}, {{x -> -0.79176 - 0.527168 I}, {x -> -0.79176 +
0.527168 I}, {x -> 0.263454 - 0.988232 I}, {x ->
0.263454 + 0.988232 I}, {x ->
1.05661}}, {{x -> -0.786675 - 0.5053 I}, {x -> -0.786675 +
0.5053 I}, {x -> 0.249625 - 1.00134 I}, {x ->
0.249625 + 1.00134 I}, {x ->
1.0741}}, {{x -> -0.781977 - 0.482538 I}, {x -> -0.781977 +
0.482538 I}, {x -> 0.236492 - 1.01473 I}, {x ->
0.236492 + 1.01473 I}, {x ->
1.09097}}, {{x -> -0.77769 - 0.458827 I}, {x -> -0.77769 +
0.458827 I}, {x -> 0.22406 - 1.02834 I}, {x ->
0.22406 + 1.02834 I}, {x ->
1.10726}}, {{x -> -0.77383 - 0.434095 I}, {x -> -0.77383 +
0.434095 I}, {x -> 0.212328 - 1.04213 I}, {x ->
0.212328 + 1.04213 I}, {x ->
1.123}}, {{x -> -0.770409 - 0.408237 I}, {x -> -0.770409 +
0.408237 I}, {x -> 0.201289 - 1.05602 I}, {x ->
0.201289 + 1.05602 I}, {x ->
1.13824}}, {{x -> -0.767428 - 0.381103 I}, {x -> -0.767428 +
0.381103 I}, {x -> 0.19093 - 1.06998 I}, {x ->
0.19093 + 1.06998 I}, {x ->
1.153}}, {{x -> -0.764884 - 0.352472 I}, {x -> -0.764884 +
0.352472 I}, {x -> 0.181232 - 1.08395 I}, {x ->
0.181232 + 1.08395 I}, {x -> 1.1673}}}
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.
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}}}
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.
It works :). Thank you very much.
After, Is it possible to print x[i] and A[i] by two colones as?
A[1] x[1]
A[2] x[2]
…
A[10] x[10]
You can modify the Table command:
Table[{A[i], NSolve[x^5 - 2 x/5 - 1 == 0, x, Reals]}, {i, 1, 5}]
But Is it possible to write x[i] as a table like [x[1],x[2],…,x[5]]. Because actually it gives:
{{{x → 1.01961}}, {{x → 1.03846}}, {{x → 1.05661}}, {{x → 1.0741}}, {{x → 1.09097}}}
I wanna only :{1.01961,1.03846,1.05661,1.0741,1.09097}
Thank you in advance,
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
In[1]:= A[i_] := i/10
In[6]:= Table[{A[i],
x /. NSolve[x^5 - 2 A[i]*x - 1 == 0, x, Reals][[1]]}, {i, 1, 10}]
Out[6]= {{1/10, 1.03846}, {1/5, 1.0741}, {3/10, 1.10726}, {2/5,
1.13824}, {1/2, 1.1673}, {3/5, 1.19468}, {7/10, 1.22055}, {4/5,
1.24508}, {9/10, -0.918257}, {1, -1.}}