Datei:Metodo das secantes anime.gif

🌐Deutsch
Personen-Konto
Diese Datei stammt aus Wikimedia Commons und kann von anderen Projekten verwendet werden. Die Beschreibung von deren Dateibeschreibungsseite wird unten angezeigt.
NEWS0LernweltNOAH fragenBeschreibung
| BeschreibungMetodo das secantes anime.gif |
Português: Animação sobre o método das secantes.
English: Animation about the secant method. |
| Datum | |
| Quelle | Eigenes Werk |
| Urheber | Picknick |
Código fonte
<syntaxhighligh lang=python>
- !/usr/bin/env python3
- -*- coding: utf-8 -*-
Este trabalho está licenciado sob a Licença Creative Commons Atribuição-CompartilhaIgual 3.0 Não Adaptada. Para ver uma cópia desta licença, visite https://creativecommons.org/licenses/by-sa/3.0/ ou envie uma carta para Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
Author: Picknick - 09/2016
import numpy as np import scipy as sci from scipy import optimize import matplotlib.pyplot as plt import matplotlib.animation as animation
- canvas
fig = plt.figure(figsize=(3,3), dpi=300, linewidth=0.0, facecolor="white")
- axes definitions
ax = plt.subplot(1,1,1) ax.set_xlim(-1,3.5) ax.set_ylim(-5,30)
ax.set_xticks([]) ax.set_yticks([])
ax.set_frame_on(False)
a = 0.25 b = 2.75
def fun(x):
return 0.8*(x+0.5)**3-1
def rsec(x,x0,x1):
return (fun(x1)-fun(x0))/(x1-x0)*(x-x1) + fun(x1)
x = np.array([0.,0.,0.,0.]) x[0] = 2.65 x[1] = 2.15 x[2] = x[1] - fun(x[1])*(x[1]-x[0])/(fun(x[1])-fun(x[0])) x[3] = x[2] - fun(x[2])*(x[2]-x[1])/(fun(x[2])-fun(x[1]))
def init():
global ax ax.cla()
ax.set_xlim(-1,3.5) ax.set_ylim(-5,30)
ax.set_xticks([]) ax.set_yticks([])
ax.set_frame_on(False)
ax.arrow(-1, 0, 4.5, 0, length_includes_head=True, facecolor='black', head_length=0.1, head_width=0.5) ax.text(3.25,-3.5,r"$x$")
ax.arrow(0, -2, 0, 31, length_includes_head=True, facecolor='black', head_length=0.5, head_width=0.1) ax.text(-0.4, 27.5, r"$y$")
xx = np.linspace (a, b) ax.plot(xx, fun(xx), lw=1.5)
xstar = sci.optimize.fsolve(fun,a)
ax.plot ([xstar, xstar], [0, 0], 'ro', markersize=3)
ax.text (xstar - 0.25, 0.5, r"$x\!^{*}$")
def update(i):
global ax, x
print(i)
if (i == 0):
a = x[0]
ax.plot ([0, a], [fun(a), fun(a)], color='gray', linestyle='dashed')
ax.plot ([a, a], [fun(a), 0], color='gray', linestyle='dashed')
ax.plot (a, fun(a), 'ko', markersize=3)
ax.plot ([a, a], [-0.5, 0.5], color='black')
ax.plot ([-0.05, 0.05], [fun(a), fun(a)], color='black')
ax.text (-1, fun(a)-0.1, r"$f(x^{(1)})$")
ax.text (a - 0.25, -3.5, r"$x^{(1)}$")
a = x[1]
ax.plot ([0, a], [fun(a), fun(a)], color='gray', linestyle='dashed')
ax.plot ([a, a], [fun(a), 0], color='gray', linestyle='dashed')
ax.plot (a, fun(a), 'ko', markersize=3)
ax.plot ([a, a], [-0.5, 0.5], color='black')
ax.plot ([-0.05, 0.05], [fun(a), fun(a)], color='black')
ax.text (-1, fun(a)-0.1, r"$f(x^{(2)})$")
ax.text (a - 0.25, -3.5, r"$x^{(2)}$")
if (i == 1):
xx = np.linspace(x[1]-0.75,x[1]+0.7)
ax.plot(xx,rsec(xx,x[0],x[1]),color="gray",lw=0.75)
if (i == 2):
ax.plot ([x[2], x[2]], [-0.5, 0.5], color='black')
if (i == 3):
a = x[2]
ax.plot ([0, a], [fun(a), fun(a)], color='gray', linestyle='dashed')
ax.plot ([a, a], [fun(a), 0], color='gray', linestyle='dashed')
ax.plot (a, fun(a), 'ko', markersize=3)
ax.plot ([-0.05, 0.05], [fun(a), fun(a)], color='black')
ax.text (-1, fun(a)-0.1, r"$f(x^{(3)})$")
ax.text (a - 0.2, -3.5, r"$x^{(3)}$")
if (i == 4):
xx = np.linspace(x[2]-0.5,x[2]+1)
ax.plot(xx,rsec(xx,x[1],x[2]),color="gray",lw=0.75)
if (i == 5):
ax.plot ([x[3], x[3]], [-0.5, 0.5], color='black')
if (i == 6):
a = x[3]
ax.plot ([a, a], [-0.5, 0.5], color='black')
ax.text (a - 0.3, -3.5, r"$x^{(4)}$")
anime = animation.FuncAnimation(fig, update, np.arange(7), interval=2000, repeat=True, init_func=init, repeat_delay=3000) anime.save('metodo_das_secantes_anime.gif', writer='imagemagick') </syntaxhighligh>
Lizenz
- Dieses Werk darf von dir
- verbreitet werden – vervielfältigt, verbreitet und öffentlich zugänglich gemacht werden
- neu zusammengestellt werden – abgewandelt und bearbeitet werden
- Zu den folgenden Bedingungen:
- Namensnennung – Du musst angemessene Urheber- und Rechteangaben machen, einen Link zur Lizenz beifügen und angeben, ob Änderungen vorgenommen wurden. Diese Angaben dürfen in jeder angemessenen Art und Weise gemacht werden, allerdings nicht so, dass der Eindruck entsteht, der Lizenzgeber unterstütze gerade dich oder deine Nutzung besonders.
- Weitergabe unter gleichen Bedingungen – Wenn du das Material wiedermischst, transformierst oder darauf aufbaust, musst du deine Beiträge unter der gleichen oder einer kompatiblen Lizenz wie das Original verbreiten.
Kurzbeschreibungen
In dieser Datei abgebildete Objekte
Motiv
Einige Werte ohne einen Wikidata-Eintrag
3. September 2016
image/gif
Dateiversionen
Klicke auf einen Zeitpunkt, um diese Version zu laden.
| Version vom | Vorschaubild | Maße | Benutzer | Kommentar | |
|---|---|---|---|---|---|
| aktuell | 14:44, 3. Sep. 2016 | 300 × 300 (36 KB) | wikimediacommons>Picknick | User created page with UploadWizard |
Dateiverwendung
Die folgende Seite verwendet diese Datei: