% Show basic Cusp diagram
% f(x,gamma,mu)=gamma+mu*x-x^3=0 

clear gamma;
clear mu;

whitebg('white')

x=linspace(-2,2,81);
gamma=x.^3+2*x;
plot3(gamma,-2*ones(size(gamma)),x,'r');
box;
%grid
hold on
mu=linspace(-1.875,2,32);
for i=1:32;
    gamma=x.^3-mu(i).*x;
    plot3(gamma,mu(i)*ones(size(gamma)),x,'b');
        xlabel('\gamma');
        ylabel('\mu');
        zlabel('x');
        title('Cusp Diagram');
        axis([-12 12 -2 2 -2 2])
end
view(15,-30);


% "Complex and Chaotic Nonlinear Dynamics. 
% Advances in Economics and Finance, 
% Mathematics and Statistics" 
% T.Vialar, Springer 2009
% Copyright(c).