File:HornerandNewton.gif
From DawoumWiki, the free Mathematics self-learning
HornerandNewton.gif (500 × 350 pixels, file size: 851 KB, MIME type: image/gif, looped, 109 frames, 22 s)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
DescriptionHornerandNewton.gif |
Português: Gif mostrando como encontrar raízes de um polinômio usando o método de Newton para aproximar as raízes e o método de horner para fazer deflexões no polinômio. English: Animation demonstrating how to find the roots of a polynomial using Newton's method and Horner's method together. |
|||
Date | 20 May 2009 (original upload date) | |||
Source | Own work | |||
Author | Philten at English Wikipedia | |||
Permission (Reusing this file) |
|
Source
Made using GNU Octave and compiled with the GIMP.
clear
epsilon = 0.01;
a = [1 4 -72 -214 1127 1602 -5040];
color = [0 0 0; 255 0 0; 255 255 0; 0 255 0; 0 0 255; 255 0 255]/255;
grad = [fliplr(0:0.1:1) 0:0.1:1];
xlim = [-9 8];
ylim = [-2000 2000];
x0 = 10;
x = [xlim(1):.01:xlim(2)];
roots(1) = newton(a,x0,epsilon);
b = a;
for i = 2:length(a)-1
[y a] = horner(b(i-1,:),roots(i-1));
b(i,:) = [0 a];
roots(i) = newton(b(i,:),roots(i-1),epsilon);
endfor
b(length(a),:) = b(1,:);
for i = 1:length(a)
# fancy graphics
for j = 1:length(grad)
shade = grad(j)*([1 1 1]-color(i,:));
hold off
plot(x,polyval(b(i,:),x),'color',color(i,:)+shade,'linewidth',3)
hold on
plot(x,polyval(b(1,:),x),'color',color(1,:),'linewidth',3)
plot(x,zeros(size(x)),'--k','linewidth',3)
for k = 1:i-1
plot(roots(k),0,'o','color',color(k,:),'markersize',1,'linewidth',3)
endfor
if j < length(grad)/2
plot(roots(i),0,'o','color',color(i,:)+shade,'markersize',1,'linewidth',3)
else
plot(roots(i),0,'o','color',color(i,:),'markersize',1,'linewidth',3)
endif
axis([xlim ylim])
print(strcat("frame",num2str(j+length(grad)*(i-1)),".eps"))
endfor
endfor
function z = newton(a,x0,epsilon)
x1 = epsilon*2+x0;
loops = 0;
for i = 1:length(a)-1
b(i) = a(i)*(length(a)-i);
endfor
while abs(x0-x1) > epsilon && loops < 500
x0 = x1;
f = horner(a,x0);
fp = horner(b,x0);
x1 = x0 - f/fp;
loops++;
endwhile
z = x1;
endfunction
function [y b] = horner(a,x)
b(1) = a(1);
for i = 2:length(a)
b(i) = a(i)+x*b(i-1);
endfor
y = b(length(a));
b = b(1:length(b)-1);
endfunction
Original upload log
The original description page was here. All following user names refer to en.wikipedia.
- 2009-05-20 01:30 Philten 500×350× (871553 bytes) made using GNU Octave and compiled with the GIMP clear epsilon = 0.01; a = [1 4 -72 -214 1127 1602 -5040]; color = [0 0 0; 255 0 0; 255 255 0; 0 255 0; 0 0 255; 255 0 255]/255; grad = [fliplr(0:0.1:1) 0:0.1:1]; xlim = [-9 8]; ylim = [-2000 2000];
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
20 May 2009
image/gif
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 00:42, 2 June 2013 | ![]() | 500 × 350 (851 KB) | wikimediacommons>OgreBot | (BOT): Uploading old version of file from en.wikipedia; originally uploaded on 2009-05-20 01:30:29 by Philten |
File usage
The following page uses this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
GIF file comment | Created with GIMP |
---|
Retrieved from "https://dawoum.duckdns.org/wiki/File:HornerandNewton.gif"