How Can I Solve This Equation in Mathematica?

  • Context: Mathematica 
  • Thread starter Thread starter Physics_rocks
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
Physics_rocks
Messages
12
Reaction score
0
Hi ,

I'm trying to solve the following equation:
e^x=x^3 + x^2 -1/4* x -4

using this code :
NSolve[Exp[x] = x^3 + x^2 - 0.25 * x - 4, x]

but it doesn't work .

In addition I'm trying to solve it graphically by plotting the left and right functions simultaneously . but how ? with PLOT ?

And when I try with FindRoot , it also says that something is wrong :
FindRoot[Exp[x] == x^3 + x^2 - 0.25 * x - 4, {x, 0}]

can you please help ? thanks
 
Physics news on Phys.org
Physics_rocks said:
Hi ,

I'm trying to solve the following equation:
e^x=x^3 + x^2 -1/4* x -4

using this code :
NSolve[Exp[x] = x^3 + x^2 - 0.25 * x - 4, x]

but it doesn't work .

In addition I'm trying to solve it graphically by plotting the left and right functions simultaneously . but how ? with PLOT ?

And when I try with FindRoot , it also says that something is wrong :
FindRoot[Exp[x] == x^3 + x^2 - 0.25 * x - 4, {x, 0}]

can you please help ? thanks

I don't use mathematica any more but try something like

Code:
F[x_] = - Exp[x] + x^3 + x^2 - 0.25 * x - 4;
NSolve[F[x] == 0,x];
FingRoot[F[x] ==0,{x,0}];
 
Physics_rocks said:
NSolve[Exp[x] = x^3 + x^2 - 0.25 * x - 4, x]
Here there are two problems. First, you need to use == instead of = and second NSolve is for solving polynomials and won't work for your expression. Use FindRoot instead.

Physics_rocks said:
In addition I'm trying to solve it graphically by plotting the left and right functions simultaneously . but how ? with PLOT ?
This is a good approach in general, one I usually use when I cannot easily solve something. Use Plot[{Exp[x], x^3 + x^2 - 0.25*x - 4}, {x, 1, 5}] and you can clearly see that there are two solutions, one near x=2 and one near x=5.

Physics_rocks said:
And when I try with FindRoot , it also says that something is wrong :
FindRoot[Exp[x] == x^3 + x^2 - 0.25 * x - 4, {x, 0}]
Remember, FindRoot is a numerical search that depends on the starting position. If you do the Plot above and know that the intersections are near x=2 and x=5 then use those as your starting points: FindRoot[Exp[x] == x^3 + x^2 - 0.25*x - 4, {x, 2}] gives x->1.98666
FindRoot[Exp[x] == x^3 + x^2 - 0.25*x - 4, {x, 5}] gives x->4.93916
 
Last edited: