# Solve a nonlinear equation

**URL:** <https://community.wolfram.com/t/solve-a-nonlinear-equation/7176>\
**Category:** Questions\
**Tags:** computer-science, engineering, physics, mathematica\
**Created:** [November 11, 2015, 2:31pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176 "2015-11-11T14:31:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhngocvu](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@minhngocvu](https://community.wolfram.com/u/minhngocvu)\
**Post date:** [November 11, 2015, 2:31pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/1 "2015-11-11T14:31:29Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [November 11, 2015, 2:45pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/2 "2015-11-11T14:45:19Z")

</div>

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}}}

```

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [November 11, 2015, 2:47pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/3 "2015-11-11T14:47:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![minhngocvu](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@minhngocvu](https://community.wolfram.com/u/minhngocvu)\
**Post date:** [November 11, 2015, 3:29pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/4 "2015-11-11T15:29:22Z")

</div>

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}}}

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [November 11, 2015, 4:21pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/5 "2015-11-11T16:21:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![minhngocvu](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@minhngocvu](https://community.wolfram.com/u/minhngocvu)\
**Post date:** [November 11, 2015, 6:53pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/6 "2015-11-11T18:53:01Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![seanc](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/seanc/32/34005_2.png) [@seanc](https://community.wolfram.com/u/seanc)\
**Post date:** [November 11, 2015, 7:41pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/7 "2015-11-11T19:41:35Z")

</div>

You can modify the Table command:

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

```

---

<div class="post-metadata">

**Author:** ![minhngocvu](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@minhngocvu](https://community.wolfram.com/u/minhngocvu)\
**Post date:** [November 11, 2015, 9:06pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/8 "2015-11-11T21:06:02Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![minhngocvu](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@minhngocvu](https://community.wolfram.com/u/minhngocvu)\
**Post date:** [November 12, 2015, 9:19am UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/9 "2015-11-12T09:19:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [November 12, 2015, 2:38pm UTC](https://community.wolfram.com/t/solve-a-nonlinear-equation/7176/10 "2015-11-12T14:38:27Z")

</div>

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.}}
