# Solving Real Roots with NSolve and Plotting a Bifurcation Diagram

• Mathematica
• jemma
In summary, the person is asking for help with using NSolve in Mathematica to find only real roots and then plotting a bifurcation diagram using a table of data. They have provided a link to a forum question for reference.
jemma
Hi, I'm using NSolve in Mathematica but I only want to find the roots that are real numbers as my answer gives a lot of imaginary numbers. How can I do this?

I want to then plot a birfucation diagram using a table of data. Is there a function to do this?

Thanks!

In[1]:=x /. NSolve[(x - 1)(x^2 + 3)(x^4 + 5) == 0, x]
Out[1]={-1.05737 - 1.05737*I, -1.05737 + 1.05737*I, -3.81167*^-27 - 1.73205*I,
-3.81167*^-27 + 1.73205*I, 1., 1.05737 - 1.05737*I, 1.05737 + 1.05737*I}

In[2]:=Cases[x /. NSolve[(x - 1)(x^2 + 3)(x^4 + 5) == 0, x], _Real]
Out[2]={1.}

http://search.wolfram.com/?query=bifurcation&x=5&y=4

## 1. How do I use NSolve to find real roots?

To use NSolve, you need to first define your equation using the syntax "eqn = 0". Then, use the command "NSolve[eqn, variable]" to solve for the real roots of the equation. Make sure to assign a value to the variable you are solving for. For example, if you are solving for x in the equation x^2 - 4 == 0, you would use the command "NSolve[x^2 - 4 == 0, x]".

## 2. Can I plot a bifurcation diagram using NSolve?

No, NSolve is used for finding numerical solutions to equations and cannot be used for plotting. To plot a bifurcation diagram, you will need to use a different software or programming language, such as Mathematica or Python, and input the values of the parameters in your equation to generate the diagram.

## 3. How do I interpret a bifurcation diagram?

A bifurcation diagram shows the behavior of a system as a parameter in the equation is varied. The points on the diagram represent the values of the variable at which a change in behavior occurs. For example, a bifurcation diagram for the logistic map shows the values of a population at which the population either stabilizes or undergoes chaotic behavior.

## 4. Can I use NSolve for equations with multiple variables?

Yes, NSolve can handle equations with multiple variables. However, you will need to specify the values of all other variables except for the one you are solving for. For example, if your equation is x^2 + y^2 == 25, and you want to solve for y, you would use the command "NSolve[x^2 + y^2 == 25, y]".

## 5. How can I improve the accuracy of the solutions obtained from NSolve?

One way to improve the accuracy of NSolve is to specify a range of values for the variable you are solving for. This can be done by using the syntax "NSolve[eqn, {variable, lower bound, upper bound}]". You can also use the option "WorkingPrecision" to specify the number of digits of accuracy you want in the solutions. For example, "NSolve[x^2 - 4 == 0, x, WorkingPrecision -> 20]" will give you solutions with 20 digits of accuracy.

• MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
415
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
0
Views
187
• MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
12K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
697
• MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K