Jump to content

File:Cubic equation with three real roots.gif

From Wikipedia, the free encyclopedia

Cubic_equation_with_three_real_roots.gif (450 × 450 pixels, file size: 3.2 MB, MIME type: image/gif, looped, 210 frames, 11 s)

Summary

[edit]
File information
Description

This animation shows the roots of x^3-3*x=cos(3*t) for different values of t; the roots are [2*cos(t), 2*cos(t+2*pi/3), -2*cos(t+2*pi/3)]

Source

This animation was made using a code written in MATLAB which is entirely my own work.

Date

2016-10-12

Author

Mnshahri

Permission
(Reusing this file)

See below.


Other information

%MATLAB Source code

clc clear all


opengl software filename = 'cubicanimation.gif'; myfig=figure; set(gcf, 'Position', [1 1 640 480]); i=0; for alpha=0:0.01:2*pi/3

   hold off
   x=-2.1:0.01:2.1;
   y=x.^3-3*x;
   plot3(x,y,0*x,'LineSmoothing','on','LineWidth',2);
   hold on
   plot3(0*x,y,0*x,'LineSmoothing','on','LineWidth',2);
   set(gca,'FontSize',15,'FontWeight','bold')
   alph=0:0.01:2*pi;
   X=2*cos(alph);
   Y=2*cos(3*alph);
   Z=2*sin(alph);
   hold on
   plot3(X,Y,Z,'r-','LineSmoothing','on','LineWidth',2);
   xlabel('X');
   ylabel('Y');
   zlabel('Z');
   hold on
   a=alpha+2*pi/3*[0 1 2 3];
   plot3(2*cos(a),2*cos(3*a),2*sin(a),'green','LineSmoothing','on','LineWidth',2);
   a=alpha+2*pi/3*[0 1 2];
   zero=[0 0 0];
   plot3([zero;2*cos(a)],[2*cos(3*a);2*cos(3*a)],[zero;2*sin(a)],'black','LineSmoothing','on','LineWidth',2);
   plot3([2*cos(a);2*cos(a)],[2*cos(3*a);2*cos(3*a)],[2*sin(a);zero],'cyan','LineSmoothing','on','LineWidth',2);    
   a=[alpha alpha+2*pi/3 alpha+4*pi/3 alpha+2*pi];
   plot3(2*cos(a),2*cos(3*a),0*a,'co-','MarkerSize',10,'LineSmoothing','on','LineWidth',2);
   view([42,26])
   axis tight
   axis equal
   drawnow;
   i=i+1;
   if i==1
   pause(2);
   end;
   pause(0.1);
   frame = getframe(myfig,[100 1 450 450]);
   im = frame2im(frame);
   [A,map] = rgb2ind(im,256); 

if i == 1; imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',0.05); else imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',0.05); end

end

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following licenses:
You may select the license of your choice.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current07:02, 12 October 2016Thumbnail for version as of 07:02, 12 October 2016450 × 450 (3.2 MB)Mnshahri (talk | contribs)Uploading a self-made file using File Upload Wizard

The following page uses this file: