Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

A few questions in Mathematica

  1. Jan 14, 2010 #1
    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
     
  2. jcsd
  3. Jan 14, 2010 #2
    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}];
     
     
  4. Jan 17, 2010 #3

    Dale

    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
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: A few questions in Mathematica
  1. Mathematica questions (Replies: 10)

  2. Mathematica question (Replies: 10)

  3. Mathematica question (Replies: 1)

  4. Mathematica question (Replies: 4)

Loading...