Produce a bifurcation diagram using mathematica

Click For Summary

Discussion Overview

The discussion revolves around producing a bifurcation diagram using Mathematica, specifically focusing on representing equilibrium points of a variable p1 based on recursion equations. Participants explore the necessary code and methods for generating the diagram, as well as potential issues and solutions related to data handling and visualization in both Mathematica and MATLAB.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Experimental/applied

Main Points Raised

  • One participant shares a Mathematica code snippet intended to generate a bifurcation diagram by solving a set of equations and collecting results in a series.
  • Another participant, familiar with MATLAB, offers to help if the original poster provides pseudocode and specifies the issues faced.
  • A participant suggests using ListPlot in Mathematica to create the bifurcation diagram, referencing an example from the Wolfram Demonstrations Project.
  • Discussion includes MATLAB-specific advice on extracting data from matrices and plotting stable points without connecting them, emphasizing the use of specific plot commands.
  • One participant expresses satisfaction with the provided MATLAB plotting advice, indicating it works well for their needs.
  • A follow-up question arises regarding adjusting line width and using different colors for plotted points, with participants providing suggestions and clarifications on MATLAB syntax.
  • Another participant offers troubleshooting tips for issues related to line width and color specifications in MATLAB plots.

Areas of Agreement / Disagreement

Participants generally agree on the methods for plotting in both Mathematica and MATLAB, but there are varying levels of familiarity with the specific syntax and capabilities of each software. The discussion remains open regarding the best practices for achieving desired visual outcomes in MATLAB.

Contextual Notes

Some participants express uncertainty about specific MATLAB commands and their effects, indicating a need for further exploration of documentation and examples. The discussion does not resolve all questions regarding the implementation details in either software.

Who May Find This Useful

This discussion may be useful for individuals interested in computational methods for bifurcation analysis, particularly those using Mathematica or MATLAB for data visualization in mathematical modeling.

jemma
Messages
35
Reaction score
0
I want to produce a bifurcation diagram using mathematica to represent equilibrium points of p1 using the data obtained from the following code, where pn1, pn2, pn3 are recrusion exquations. i.e. x-axis will be the paramter t (ranging from 0-0.3) and y-axis will be the values of p1 this code produces.

series = {};
For[i = 0, i ≤ 300, ++i, p1sol = Sort[
p1 /. NSolve[{pn1 == 0, pn2 == 0, pn3 == 0} /. t -> i/1000.0, {p1, p2, p3}]];
series = Join[p1series, {Join[{i/1000.0}, p1sol]}]]

Thanks if you can help me.
 
Physics news on Phys.org


I've made bifurcation diagrams in Matlab, but I'm not familiar with mathematica's language.

If you want to write it as pseudocode and specifically tell me the issue you're having, I might be able to offer some advice.
 


In mathematica I can export this as a table so I just have the data. I could use MATLAB to generate the actual plot using these data. Would this be possible? Do you have an example of this?

% a prompt for generating a list
series = {};

For[i = 0, i ≤ 300, ++i, p1sol = Sort[
p1 /. NSolve[{pn1 == 0, pn2 == 0, pn3 == 0} /. t -> i/1000.0, {p1, p2, p3}]];

%NSolve gives a list of numerical approximations for all of the roots of the polynomial
%equation, (maybe the root function in matlab?)

% /.t this just evaluates the equations at t
% t (plotted on the x-axis) ranges from 0-0.3 (since 300/1000)

series = Join[p1series, {Join[{i/1000.0}, p1sol]}]]

%The series is a list of the values of p1 at specific values of t.
 
Last edited by a moderator:


%Matlab is relatively simple to plot in. You have a matrix of data, you just rip out vectors from it:

%for instance, a matrix S, with size MxN, you just declare a vector to be a slice of the matrix:

parameter = S(:,n) %the whole row in the nth column becomes a vector called 'parameter')

%Do the same with your stable points, pulling them out of the appropriate row (or column, depending on you shaped your data).

stablepoints = S(:,n+1) %or wherever your stable points are (there's no guarantee it will be n+1, I just mean this as an example)
stablepoints2 = S(:,n+2) %if you have a second set of stable points

%Then to plot, just:

plot(parameter,stablepoints,'*') %the * ensures a point will be plotted. By default, MATLAB will connect the points which is no what you want in a bifurcation diagram.

%If you have more than one vector of stable points you can add:

hold on
%so that it won't clear your last plot and will add any additional plots right into the current figure

plot(parameter,stablepoints2,'*')
plot(parameter,stablepoints3,'*')

%making it look pretty:

title 'this is your title'
xlabel 'bifurcation parameter, r'
ylabel 'stable points'

%Is this what you're asking for?
 


Yes! Thank you so much, this works well!
 


Hi, just one more question... I want to adjust the line width to make it more clear. From what I've read online it suggests the code would look something like this...

plot(parameter,stablepoints2,'*', 'LineWidth', 2)

Is this right? I've tried lots of different line width points but it doesn't seem to be working.

Also, I'd like to plot each set of points in a different colour?

Thanks again!
 
Last edited:


For colors:

plot(x,y,'r*')

would be a red star

on my iPhone, would have to research the other question on matlab, maybe tomorrow.
 


So I'm not haveing any problems with that 'LineWidth' line. It thickens the line and plots it. Maybe if you post your code and the error I can trouble shoot.

type 'doc LineSpec' at the MATLAB command line for the color and marker shape codes (i.e r is red, k is black, etc.)

I would also suggest using 'doc' instead of 'help' in general when you're first learning a command.
 
  • #10


cheers for the colour tip!
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K