File:Runge phenomenon equidist chebushev.gif
Summary
| Description |
Українська: Порівняння зміни помилки зі зростанням кількості вузлів інтерполяції функції Рунге використовуючи рівновіддалені вузли і вузли Чебишова |
| Date | |
| Source | Own work |
| Author | Igor Yalovecky |
| GIF development |
Licensing
I, the copyright holder of this work, hereby publish it under the following licenses:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
| Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License. |
You may select the license of your choice.
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.ticker as tckr
from matplotlib.animation import FuncAnimation
N=20
fig, (ax1, ax2) = plt.subplots(1,2)
fig.set_tight_layout(True)
def handle_nodes(x, order, ax, prefix):
y = lambda x : 1/(1+25*x*x);
p = np.poly1d(np.polyfit(x,y(x),order))
xd = np.linspace(-1,1,1000)
ax.cla()
ax.set_ylim(-5,5)
ax.set_title(prefix + ', порядок = ' + str(order))
ax.plot(xd,p(xd))
ax.plot(xd,y(xd))
(markerLines) = ax.stem(x,y(x),linefmt=' ',basefmt=' ',markerfmt='ro')
plt.setp(markerLines, markersize = 3)
def update(order):
if order >=2:
x = np.linspace(-1,1,order+1)
handle_nodes(x, order, ax1, 'рівновіддалені')
x = np.cos((2*np.arange(order+1)-1)*np.pi/(2*(order)))
handle_nodes(x, order, ax2, 'Чебишова')
else:
ax1.set_title('рівновіддалені вузли')
ax2.set_title('вузли Чебишова')
anim = FuncAnimation(fig, update, frames=np.arange(-10, N), interval=1000)
plt.show()