File:Expinvsqlau GIF.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Expinvsqlau_GIF.gif (800 × 600 pixels, file size: 281 KB, MIME type: image/gif, looped, 11 frames, 11 s)
File information
Structured data
Captions
Summary
[edit]DescriptionExpinvsqlau GIF.gif |
English: GIF version to illustrate the Laurent approximation of the function f(x)=exp(-1/x^2). |
Date | |
Source | Own work |
Author | IkamusumeFan |
Matplotlib (Python)
[edit]# Author: Ika, 2013-08-24
import math as m
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
# import matplotlib.animation as animation
def draw_frame(n,filename,line_color):
fig = plt.figure()
plt.axes([0.02,0.13,0.9,0.8])
plt.hold(True)
plt.xlim(-3,3)
plt.ylim(-2,4)
# Set up the spines
ax = plt.gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data',0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data',0))
# Set up the label
ax.text(2,3,'N='+str(n),fontsize=24,color=line_color)
Q = []
X = np.arange(-3, 3, 0.001)
# Draw the original function (ORG) curve
ORG = np.exp(-1/(X*X))
a = plt.plot(X, ORG, '-', color='black', lw=4)
Q.append(a)
# Draw the approximation function (APPR) curve
i=1
APPR = 1+(-1)**i*(X**(-2*i))/m.factorial(i)
while (i<n):
i = i+1
APPR = APPR+(-1)**i*(X**(-2*i))/m.factorial(i)
a = plt.plot(X, APPR, '-', color=line_color, lw=4)
Q.append(a)
plt.savefig(filename)
draw_frame(1,'frame01.eps','#b30000')
draw_frame(2,'frame02.eps','#00b300')
draw_frame(3,'frame03.eps','#0000b3')
draw_frame(4,'frame04.eps','#b3b300')
draw_frame(5,'frame05.eps','#00b3b3')
draw_frame(6,'frame06.eps','#b300b3')
draw_frame(7,'frame07.eps','#b3b3b3')
draw_frame(10,'frame08.eps','#3300b3')
draw_frame(50,'frame09.eps','#33b300')
draw_frame(65,'frame10.eps','#0033b3')
draw_frame(80,'frame11.eps','#b3b333')
# To generate the final GIF file, use the shell command:
# convert -antialias -loop 0 -delay 100 -compress LZW frame* Expinvsqlau_GIF.gif
Licensing
[edit]I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported 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.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 16:36, 26 August 2013 | 800 × 600 (281 KB) | IkamusumeFan (talk | contribs) | Rescale the image for better display. | |
06:20, 26 August 2013 | 612 × 792 (81 KB) | IkamusumeFan (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on mr.wikipedia.org
- Usage on zh.wikipedia.org