How Can I Solve This Equation in Mathematica?

  • Mathematica
  • Thread starter Physics_rocks
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses attempting to solve an equation using mathematica code, specifically NSolve and FindRoot. However, there are some errors in the code and it is suggested to try using Plot to graphically find the solutions. FindRoot can also be used, but it is important to choose appropriate starting points.
  • #1
Physics_rocks
12
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
  • #2
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}];
 
  • #3
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:

FAQ: How Can I Solve This Equation in Mathematica?

1. What is Mathematica and what does it do?

Mathematica is a computational software program used for mathematical, scientific, and engineering calculations. It allows users to perform a wide range of tasks, including numerical and symbolic computations, data analysis, visualization, and programming. It is commonly used in fields such as mathematics, physics, economics, and engineering.

2. How does Mathematica differ from other mathematical software programs?

Unlike other mathematical software programs, Mathematica uses a symbolic language that allows users to manipulate mathematical expressions and perform calculations with variables, rather than just numerical values. It also has a vast library of built-in functions and algorithms for various mathematical and scientific tasks.

3. Can Mathematica be used for data analysis and visualization?

Yes, Mathematica has powerful tools for data analysis and visualization. It can import and manipulate data from various sources, such as spreadsheets and databases, and has built-in functions for statistical analysis, curve fitting, and data visualization. It also has interactive graphics capabilities for creating dynamic and interactive visualizations.

4. Is Mathematica suitable for beginners?

While Mathematica can be intimidating for beginners due to its extensive capabilities and complex syntax, it also has a user-friendly interface and comprehensive documentation to help new users get started. There are also many online resources and tutorials available to help beginners learn how to use Mathematica effectively.

5. Can I use Mathematica for programming?

Yes, Mathematica has a powerful programming language called Wolfram Language, which can be used to write programs for a wide range of tasks. It also supports other programming languages, such as Python, Java, and C, allowing users to combine Mathematica's capabilities with those of other languages.

Similar threads

Replies
3
Views
2K
Replies
1
Views
692
Replies
5
Views
2K
Replies
4
Views
396
Replies
2
Views
195
Replies
1
Views
537
Replies
1
Views
2K
Replies
1
Views
2K
Replies
4
Views
1K
Back
Top