# A few questions in Mathematica

1. Jan 14, 2010

### Physics_rocks

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

2. Jan 14, 2010

### nbo10

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

Code (Text):

F[x_] = - Exp[x] + x^3 + x^2 - 0.25 * x - 4;
NSolve[F[x] == 0,x];
FingRoot[F[x] ==0,{x,0}];

3. Jan 17, 2010

### Staff: Mentor

Here there are two problems. First, you need to use == instead of = and second NSolve is for solving polynomials and wont work for your expression. Use FindRoot instead.

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.

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: Jan 17, 2010