Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with Solve and NSolve

1,548 views
Skip to first unread message

V. Williams

unread,
Oct 28, 2011, 5:41:18 AM10/28/11
to
I've recently tried Mathematica 8.0.1, and I've found that it's unable to compute Solve[x^3*Sin[x]==1,x] (and the same with NSolve), which gives an error:
Solve::nsmet: This system cannot be solved with the methods available to Solve

WolframAlpha solves it without problems, so what's wrong with Mathematica?

David Park

unread,
Oct 29, 2011, 7:11:54 AM10/29/11
to
There are an infinite number of roots so Mathematica can't give a solution.
However, if you use an inequality to specify the x domain, Mathematica will
find the solutions. The equation is even so one only needs the positive
roots but I include the first few negative roots. Copy and evaluate the
following in one cell.

rootequation = x^3 Sin[x] == 1;
Solve[{rootequation, -5 < x < 20}, x]
% // N
roots = x /. %


For those who have the Presentations application the following will plot the
roots on the curve and graduate the x axis using the root values.

<< Presentations`

xticks = CustomTicks[Identity, databased[roots]];
Draw2D[
{Draw[x^3*Sin[x], {x, -5, 20}],
Aliasing@Draw[1, {x, -5, 20}],
CirclePoint[{#, 1}, 2, Black, ColorData["Crayola"]["TealBlue"]] & /@
roots},
AspectRatio -> 1/4,
PlotRange -> {-10, 20},
Frame -> True,
FrameTicks -> {{Automatic, Automatic}, {xticks,
xticks // NoTickLabels}},
PlotLabel -> Style[phrase["Roots of ", rootequation], 16],
ImageSize -> 600]


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

Alois Steindl

unread,
Oct 29, 2011, 7:07:47 AM10/29/11
to
Hello,
Solve tries to give an analytical solution, whereas Wolfram Alpha
returns numerical approximations.
I am wondering why NSolve doesn't work, but you could try FindRoot.

Alois

Daniel Lichtblau

unread,
Oct 29, 2011, 7:17:31 AM10/29/11
to
On 10/28/2011 04:35 AM, V. Williams wrote:
> I've recently tried Mathematica 8.0.1, and I've found that it's unable to compute Solve[x^3*Sin[x]==1,x] (and the same with NSolve), which gives an error:
> Solve::nsmet: This system cannot be solved with the methods available to Solve
>
> WolframAlpha solves it without problems, so what's wrong with Mathematica?

Solve and NSolve work with global methods to find all solutions. None
apply in the case where there are no restrictions on ranges.

W|A is (probably) using FindRoot in clever ways. You can get solutions
in a similar manner.

In[2]:= Union[
x /. Table[FindRoot[x^3*Sin[x] == 1, {x, n}], {n, -20, 20}],
SameTest -> (Abs[#1 - #2]/(Abs[#1] + Abs[#2]) < .01 &)]

During evaluation of In[2]:= FindRoot::jsing: Encountered a singular
Jacobian at the point {x} = {0.}. Try perturbing the initial point(s). >>

Out[2]= {-18.8497, -15.7077, -12.5669, -9.42358, -6.28721, -3.10829, \
-1.04879, 0., 1.04879, 3.10829, 6.28721, 9.42358, 12.5669, 15.7077, \
18.8497}

Alternatively, tell N/Solve there is a range restriction.

In[3]:= Solve[x^3*Sin[x] == 1 && -20 <= x <= 20, x]

Out[3]= {{x ->
Root[{-1 + Sin[#1] #1^3 &, -18.8497052306506243533}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, -15.7077052429555957752}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, -12.5668744839930992344}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, -9.4235830047464065106}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, -6.2872090246108708029}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, -3.1082870794604030006}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, -1.04879348372390196188}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 1.04879348372390196188}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 3.1082870794604030006}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 6.2872090246108708029}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 9.4235830047464065106}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 12.5668744839930992344}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 15.7077052429555957752}]}, {x ->
Root[{-1 + Sin[#1] #1^3 &, 18.8497052306506243533}]}}

In[4]:= NSolve[x^3*Sin[x] == 1 && -20 <= x <= 20, x]

Out[4]= {{x -> -18.8497}, {x -> -15.7077}, {x -> -12.5669}, {x -> \
-9.42358}, {x -> -6.28721}, {x -> -3.10829}, {x -> -1.04879}, {x ->
1.04879}, {x -> 3.10829}, {x -> 6.28721}, {x -> 9.42358}, {x ->
12.5669}, {x -> 15.7077}, {x -> 18.8497}}

Daniel Lichtblau
Wolfram Research

Heike Gramberg

unread,
Oct 29, 2011, 7:20:35 AM10/29/11
to
Solve and NSolve are used to find closed form solutions of equations.
Since your equation because it is a transcendental equation which
doesn't have an explicit close form solution Solve returns an error. To
find numerical approximations of the solutions you can use FindRoot
instead, e.g.

FindRoot[x^3*Sin[x] == 1, {x, 1}]

output: {x -> 1.04879}

see =
http://reference.wolfram.com/mathematica/tutorial/SolvingEquations.html
for more information about solving equations in Mathematica.

Heike.

Andrzej Kozlowski

unread,
Oct 29, 2011, 7:23:08 AM10/29/11
to

On 28 Oct 2011, at 12:53, Andrzej Kozlowski wrote:

>
> On 28 Oct 2011, at 11:35, V. Williams wrote:
>
>> I've recently tried Mathematica 8.0.1, and I've found that it's
unable to compute Solve[x^3*Sin[x]==1,x] (and the same with NSolve),
which gives an error:
>> Solve::nsmet: This system cannot be solved with the methods available
to Solve
>>
>> WolframAlpha solves it without problems, so what's wrong with Mathematica?
>>
>
> WolframAlpha gives you only a few roots in an interval chosen by itself (and assumes that you only want the real ones). You can get as many roots as you like with:
>
> N[Solve[x^3*Sin[x] == 1 && Abs[x] < 100, x, Reals]]
>
> =
{{x->-97.3894},{x->-94.2478},{x->-91.1062},{x->-87.9646},{x->-84.823},{x->=
-81.6814},{x->-78.5398},{x->-75.3982},{x->-72.2566},{x->-69.115},{x->-65.9=
734},{x->-62.8319},{x->-59.6903},{x->-56.5487},{x->-53.4071},{x->-50.2655}=
,{x->-47.1239},{x->-43.9823},{x->-40.8407},{x->-37.6991},{x->-34.5575},{x-=
>-31.416},{x->-28.2743},{x->-25.1328},{x->-21.9911},{x->-18.8497},{x->-15.=
7077},{x->-12.5669},{x->-9.42358},{x->-6.28721},{x->-3.10829},{x->-1.04879=
},{x->1.04879},{x->3.10829},{x->6.28721},{x->9.42358},{x->12.5669},{x->15.=
7077},{x->18.8497},{x->21.9911},{x->25.1328},{x->28.2743},{x->31.416},{x->=
34.5575},{x->37.6991},{x->40.8407},{x->43.9823},{x->47.1239},{x->50.2655},=
{x->53.4071},{x->56.5487},{x->59.6903},{x->62.8319},{x->65.9734},{x->69.11=
5},{x->72.2566},{x->75.3982},{x->78.5398},{x->81.6814},{x->84.823},{x->87.=
9646},{x->91.1062},{x->94.2478},{x->97.3894}}
>
> or if you want complex roots:
>
> N[Solve[x^3*Sin[x] == 1 && Abs[x] < 100, x, Reals]]
>
> =
{{x->-97.3894},{x->-94.2478},{x->-91.1062},{x->-87.9646},{x->-84.823},{x->=
-81.6814},{x->-78.5398},{x->-75.3982},{x->-72.2566},{x->-69.115},{x->-65.9=
734},{x->-62.8319},{x->-59.6903},{x->-56.5487},{x->-53.4071},{x->-50.2655}=
,{x->-47.1239},{x->-43.9823},{x->-40.8407},{x->-37.6991},{x->-34.5575},{x-=
>-31.416},{x->-28.2743},{x->-25.1328},{x->-21.9911},{x->-18.8497},{x->-15.=
7077},{x->-12.5669},{x->-9.42358},{x->-6.28721},{x->-3.10829},{x->-1.04879=
},{x->1.04879},{x->3.10829},{x->6.28721},{x->9.42358},{x->12.5669},{x->15.=
7077},{x->18.8497},{x->21.9911},{x->25.1328},{x->28.2743},{x->31.416},{x->=
34.5575},{x->37.6991},{x->40.8407},{x->43.9823},{x->47.1239},{x->50.2655},=
{x->53.4071},{x->56.5487},{x->59.6903},{x->62.8319},{x->65.9734},{x->69.11=
5},{x->72.2566},{x->75.3982},{x->78.5398},{x->81.6814},{x->84.823},{x->87.=
9646},{x->91.1062},{x->94.2478},{x->97.3894}}
>
> Andrzej Kozlowski
>
>

Of course the last part was a copy and paste mistake. What I should have posted is:


N[Solve[x^3*Sin[x] == 1 && Abs[x] < 100, x]]

{{x -> -97.38937117869034}, {x -> -94.24778080219502},
{x -> -91.10618563172359}, {x -> -87.96459576969846},
{x -> -84.82300000837662}, {x -> -81.68141082831029},
{x -> -78.53981427564646}, {x -> -75.39822601916512},
{x -> -72.25662838182653}, {x -> -69.11504140785695},
{x -> -65.9734422428741}, {x -> -62.83185710323689},
{x -> -59.69025571612967}, {x -> -56.548673294713154},
{x -> -53.40706854649436}, {x -> -50.26549033134277},
{x -> -47.12388024783088}, {x -> -43.982308903722334},
{x -> -40.840689816845185}, {x -> -37.699130507132224},
{x -> -34.55749495838158}, {x -> -31.415958787333043},
{x -> -28.27428964131248}, {x -> -25.13280421952295},
{x -> -21.9910545461251}, {x -> -18.849705230650624},
{x -> -15.707705242955596}, {x -> -12.566874483993098},
{x -> -9.423583004746407}, {x -> -6.2872090246108705},
{x -> -3.108287079460403}, {x -> -1.048793483723902},
{x -> 0. + 0.9631707107308479*I},
{x -> 0. - 0.9631707107308479*I}, {x -> 1.048793483723902},
{x -> 3.108287079460403}, {x -> 6.2872090246108705},
{x -> 9.423583004746407}, {x -> 12.566874483993098},
{x -> 15.707705242955596}, {x -> 18.849705230650624},
{x -> 21.9910545461251}, {x -> 25.13280421952295},
{x -> 28.27428964131248}, {x -> 31.415958787333043},
{x -> 34.55749495838158}, {x -> 37.699130507132224},
{x -> 40.840689816845185}, {x -> 43.982308903722334},
{x -> 47.12388024783088}, {x -> 50.26549033134277},
{x -> 53.40706854649436}, {x -> 56.548673294713154},
{x -> 59.69025571612967}, {x -> 62.83185710323689},
{x -> 65.9734422428741}, {x -> 69.11504140785695},
{x -> 72.25662838182653}, {x -> 75.39822601916512},
{x -> 78.53981427564646}, {x -> 81.68141082831029},
{x -> 84.82300000837662}, {x -> 87.96459576969846},
{x -> 91.10618563172359}, {x -> 94.24778080219502},
{x -> 97.38937117869034}}



Bill Rowe

unread,
Oct 29, 2011, 7:24:10 AM10/29/11
to
On 10/28/11 at 5:35 AM, gvic...@gmail.com (V. Williams) wrote:

>I've recently tried Mathematica 8.0.1, and I've found that it's
>unable to compute Solve[x^3*Sin[x]==1,x] (and the same with NSolve),
>which gives an error: Solve::nsmet: This system cannot be solved
>with the methods available to Solve

>WolframAlpha solves it without problems, so what's wrong with
>Mathematica?

NSolve and Solve are primarily designed to address polynomial
problems. They will solve *some* non-polynomial problems but far
from all. This particular problem is easily solved by
Mathematica using FindRoot. That is:

In[9]:= FindRoot[x^3*Sin[x] - 1, {x, 1}]

Out[9]= {x->1.04879}

So, I would guess WolframAlpha is using methods similar to what
are used in FindRoot.


Andrzej Kozlowski

unread,
Oct 29, 2011, 7:28:46 AM10/29/11
to

On 28 Oct 2011, at 11:35, V. Williams wrote:

> I've recently tried Mathematica 8.0.1, and I've found that it's unable
to compute Solve[x^3*Sin[x]==1,x] (and the same with NSolve), which
gives an error:
> Solve::nsmet: This system cannot be solved with the methods available to Solve
>
> WolframAlpha solves it without problems, so what's wrong with Mathematica?
>

WolframAlpha gives you only a few roots in an interval chosen by itself (and assumes that you only want the real ones). You can get as many roots as you like with:

N[Solve[x^3*Sin[x] == 1 && Abs[x] < 100, x, Reals]]


{{x->-97.3894},{x->-94.2478},{x->-91.1062},{x->-87.9646},{x->-84.823},{x->-81.6814},{x->-78.5398},{x->-75.3982},{x->-72.2566},{x->-69.115},{x->-65.9734},{x->-62.8319},{x->-59.6903},{x->-56.5487},{x->-53.4071},{x->-50.2655},{x->-47.1239},{x->-43.9823},{x->-40.8407},{x->-37.6991},{x->-34.5575},{x->-31.416},{x->-28.2743},{x->-25.1328},{x->-21.9911},{x->-18.8497},{x->-15.7077},{x->-12.5669},{x->-9.42358},{x->-6.28721},{x->-3.10829},{x->-1.04879},{x->1.04879},{x->3.10829},{x->6.28721},{x->9.42358},{x->12.5669},{x->15.7077},{x->18.8497},{x->21.9911},{x->25.1328},{x->28.2743},{x->31.416},{x->34.5575},{x->37.6991},{x->40.8407},{x->43.9823},{x->47.1239},{x->50.2655}, {x->53.4071},{x->56.5487},{x->59.6903},{x->62.8319},{x->65.9734},{x->69.115},{x->72.2566},{x->75.3982},{x->78.5398},{x->81.6814},{x->84.823},{x->87.9646},{x->91.1062},{x->94.2478},{x->97.3894}}

or if you want complex roots:

N[Solve[x^3*Sin[x] == 1 && Abs[x] < 100, x, Reals]]

=
{{x->-97.3894},{x->-94.2478},{x->-91.1062},{x->-87.9646},{x->-84.823},{x->-81.6814},{x->-78.5398},{x->-75.3982},{x->-72.2566},{x->-69.115},{x->-65.9734},{x->-62.8319},{x->-59.6903},{x->-56.5487},{x->-53.4071},{x->-50.2655},{x->-47.1239},{x->-43.9823},{x->-40.8407},{x->-37.6991},{x->-34.5575},{x->-31.416},{x->-28.2743},{x->-25.1328},{x->-21.9911},{x->-18.8497},{x->-15.7077},{x->-12.5669},{x->-9.42358},{x->-6.28721},{x->-3.10829},{x->-1.04879},{x->1.04879},{x->3.10829},{x->6.28721},{x->9.42358},{x->12.5669},{x->15.7077},{x->18.8497},{x->21.9911},{x->25.1328},{x->28.2743},{x->31.416},{x->34.5575},{x->37.6991},{x->40.8407},{x->43.9823},{x->47.1239},{x->50.2655},{x->53.4071},{x->56.5487},{x->59.6903},{x->62.8319},{x->65.9734},{x->69.115},{x->72.2566},{x->75.3982},{x->78.5398},{x->81.6814},{x->84.823},{x->87.9646},{x->91.1062},{x->94.2478},{x->97.3894}}

Andrzej Kozlowski



Bob Hanlon

unread,
Oct 29, 2011, 7:30:18 AM10/29/11
to
Plot[x^3*Sin[x] - 1, {x, -10, 10}, PlotRange -> {-5, 5}]

FindRoot[x^3*Sin[x] == 1, {x, #}] & /@ {-9, -6, -3, -1, 1, 3, 6, 9}

{{x -> -9.42358}, {x -> -6.28721}, {x -> -3.10829}, {x -> -1.04879}, \
{x -> 1.04879}, {x -> 3.10829}, {x -> 6.28721}, {x -> 9.42358}}


Bob Hanlon

Andrzej Kozlowski

unread,
Oct 30, 2011, 5:36:30 AM10/30/11
to

On 29 Oct 2011, at 13:10, Daniel Lichtblau wrote:

> W|A is (probably) using FindRoot in clever ways. You can get solutions
> in a similar manner.


Wolfram Alpha certainly uses Reduce (or Solve) to solve non-algebraic equations, e.g. try

WolframAlpha["Solve[x Exp[x] == 2 Sin[x]&&Abs[x]<=10,x]"] in Mathematica (or directly in a browser).

It will show real roots only but if you ask for more you also get the complex ones. If you do not give a bounding condition it will choose one by itself

WolframAlpha["Solve[x Exp[x] == 2 Sin[x],x]"]

and asssume that you want only real roots. I don't see any evidence that it "is using FindRoot in clever ways".

Andrzej Kozlowski

Andrzej Kozlowski

unread,
Oct 30, 2011, 5:37:00 AM10/30/11
to
I forgot the add that unlike Mathematica, Wolfram Alpha does not return exact solutions to any equations whose roots cannot be expressed in radicals, e.g. WolframAlpha["Solve[x^6+3x^2+x +1 == 0,x]"] will give only numerical solutions (however WolframAlpha["Solve[x^6+x^2+ 3 == 0,x]"] will return one exact solution as it can be expressed in terms of radicals). Perhaps this makes it look like FindRoot is being used but undoubtedly it is Solve (or Reduce - they seem to mean the same thing to WolframAlpha).

Andrzej Kozlowski


V. Williams

unread,
Oct 30, 2011, 5:37:31 AM10/30/11
to
Thank you for your answers!

0 new messages