Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
48 views
ubuntu2004
Kernel: Python 3 (system-wide)
#Se precentan los codigos que se usaron para obtener los diferentes graficos e imagenes.
#Pregunta 1
import matplotlib.pyplot as plt from numpy import arange alpha = 0.5471 beta = 0.0481 gamma = 0.001 def f(x,t): return alpha*x - beta*x*t - gamma*x**2 a, b = 0.0, 60.0 N = 1000 h = 0.0001 x = 1.0 tpoints = arange(a, b, h) rk4_xpoints = [] for t in tpoints: rk4_xpoints.append(x) k1 = h*f(x, t) k2 = h*f(x+0.5*k1, t+0.5*h) k3 = h*f(x+0.5*k2, t+0.5*h) k4 = h*f(x+k3, t+h) x += (k1+2*k2+2*k3+k4)/6.0 plt.plot(tpoints, rk4_xpoints, label="RK4 depredador") plt.xlabel("$t$") plt.ylabel("$x(t)$") plt.legend() plt.show()
Image in a Jupyter notebook
delta = 0.0466 epsilon = 0.8439 zeta = 0.001 def f(x,t): return delta*t*x - epsilon*x - zeta*x**2 a, b = 0.0, 60.0 N = 1000 h = 0.0001 x = 1.0 tpoints = arange(a, b, h) rk4_xpoints = [] for t in tpoints: rk4_xpoints.append(x) k1 = h*f(x, t) k2 = h*f(x+0.5*k1, t+0.5*h) k3 = h*f(x+0.5*k2, t+0.5*h) k4 = h*f(x+k3, t+h) x += (k1+2*k2+2*k3+k4)/6.0 plt.plot(tpoints, rk4_xpoints, label="RK4 presa") plt.xlabel("$t$") plt.ylabel("$x(t)$") plt.legend() plt.show()
Image in a Jupyter notebook
alpha = 0.5471 beta = 0.0481 gamma = 0.001 def f(x,t): return alpha*x - beta*x*t - gamma*x**2 a, b = 0.0, 20.0 N = 1000 h = 0.0001 x = 60.0 tpoints = arange(a, b, h) rk4_xpoints = [] for t in tpoints: rk4_xpoints.append(x) k1 = h*f(x, t) k2 = h*f(x+0.5*k1, t+0.5*h) k3 = h*f(x+0.5*k2, t+0.5*h) k4 = h*f(x+k3, t+h) x += (k1+2*k2+2*k3+k4)/6.0 delta = 0.0466 epsilon = 0.8439 zeta = 0.001 def g(y,t): return delta*t*y - epsilon*y - zeta*y**2 a, b = 0.0, 20.0 N = 1000 h = 0.0001 y = 60.0 tpoints = arange(a, b, h) rk4_ypoints = [] for t in tpoints: rk4_ypoints.append(y) k1 = h*g(y, t) k2 = h*g(y+0.5*k1, t+0.5*h) k3 = h*g(y+0.5*k2, t+0.5*h) k4 = h*g(y+k3, t+h) y += (k1+2*k2+2*k3+k4)/6.0 plt.plot(tpoints, rk4_xpoints, label="RK4 depredador") plt.xlabel("$x(t)$") plt.ylabel("$t$") plt.plot(tpoints, rk4_ypoints, label="RK4 presa") plt.xlabel("$t$") plt.ylabel("$y(t)$") plt.legend() plt.show()
Image in a Jupyter notebook
import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy import integrate import ipywidgets as ipw alpha = 0.5471 beta = 0.0481 gamma = 0.001 delta = 0.0466 epsilon = 0.8439 zeta = 0.001 x0 = 10 y0 = 5 def derivative(X, t, alpha, beta, gamma, delta, epsilon, zeta): x, y = X dotx = alpha*x - beta*x*y - gamma*x**2 doty = delta*x*y - epsilon*y - zeta*y**2 return np.array([dotx, doty]) Nt = 1000 tmax = 30 t = np.linspace(0.,tmax, Nt) X0 = [x0, y0] res = integrate.odeint(derivative, X0, t, args = (alpha, beta, gamma, delta, epsilon, zeta)) x, y = res.T plt.figure() plt.grid() plt.title("odeint method") plt.plot(t, x, 'xb', label = 'Depredadores') plt.plot(t, y, '+r', label = "Presas") plt.xlabel('Time t, [days]') plt.ylabel('Population') plt.legend() plt.show()
Image in a Jupyter notebook
#Pregunta 2
import matplotlib.pyplot as plt import numpy as np #Mandelbrot def interate(x, y): C = complex(x, y) zp = complex(0, 0) for k in range(500): zp = zp**14 + C if abs(zp) > 2.5: return k+1 return 500 N = 500 u = np.linspace(-2.5, 2.5, N) v = np.linspace(-2.5, 2.5, N) M = np.zeros((N, N)) print(u) print(M) for i in range(N): for j in range(N): M[i][j] = interate(u[i], v[j]) print(M) plt.imshow(M) plt.show()
[-2.5 -2.48997996 -2.47995992 -2.46993988 -2.45991984 -2.4498998 -2.43987976 -2.42985972 -2.41983968 -2.40981964 -2.3997996 -2.38977956 -2.37975952 -2.36973948 -2.35971944 -2.3496994 -2.33967936 -2.32965932 -2.31963928 -2.30961924 -2.2995992 -2.28957916 -2.27955912 -2.26953908 -2.25951904 -2.249499 -2.23947896 -2.22945892 -2.21943888 -2.20941884 -2.1993988 -2.18937876 -2.17935872 -2.16933868 -2.15931864 -2.1492986 -2.13927856 -2.12925852 -2.11923848 -2.10921844 -2.0991984 -2.08917836 -2.07915832 -2.06913828 -2.05911824 -2.0490982 -2.03907816 -2.02905812 -2.01903808 -2.00901804 -1.998998 -1.98897796 -1.97895792 -1.96893788 -1.95891784 -1.9488978 -1.93887776 -1.92885772 -1.91883768 -1.90881764 -1.8987976 -1.88877756 -1.87875752 -1.86873747 -1.85871743 -1.84869739 -1.83867735 -1.82865731 -1.81863727 -1.80861723 -1.79859719 -1.78857715 -1.77855711 -1.76853707 -1.75851703 -1.74849699 -1.73847695 -1.72845691 -1.71843687 -1.70841683 -1.69839679 -1.68837675 -1.67835671 -1.66833667 -1.65831663 -1.64829659 -1.63827655 -1.62825651 -1.61823647 -1.60821643 -1.59819639 -1.58817635 -1.57815631 -1.56813627 -1.55811623 -1.54809619 -1.53807615 -1.52805611 -1.51803607 -1.50801603 -1.49799599 -1.48797595 -1.47795591 -1.46793587 -1.45791583 -1.44789579 -1.43787575 -1.42785571 -1.41783567 -1.40781563 -1.39779559 -1.38777555 -1.37775551 -1.36773547 -1.35771543 -1.34769539 -1.33767535 -1.32765531 -1.31763527 -1.30761523 -1.29759519 -1.28757515 -1.27755511 -1.26753507 -1.25751503 -1.24749499 -1.23747495 -1.22745491 -1.21743487 -1.20741483 -1.19739479 -1.18737475 -1.17735471 -1.16733467 -1.15731463 -1.14729459 -1.13727455 -1.12725451 -1.11723447 -1.10721443 -1.09719439 -1.08717435 -1.07715431 -1.06713427 -1.05711423 -1.04709419 -1.03707415 -1.02705411 -1.01703407 -1.00701403 -0.99699399 -0.98697395 -0.97695391 -0.96693387 -0.95691383 -0.94689379 -0.93687375 -0.92685371 -0.91683367 -0.90681363 -0.89679359 -0.88677355 -0.87675351 -0.86673347 -0.85671343 -0.84669339 -0.83667335 -0.82665331 -0.81663327 -0.80661323 -0.79659319 -0.78657315 -0.77655311 -0.76653307 -0.75651303 -0.74649299 -0.73647295 -0.72645291 -0.71643287 -0.70641283 -0.69639279 -0.68637275 -0.67635271 -0.66633267 -0.65631263 -0.64629259 -0.63627255 -0.62625251 -0.61623246 -0.60621242 -0.59619238 -0.58617234 -0.5761523 -0.56613226 -0.55611222 -0.54609218 -0.53607214 -0.5260521 -0.51603206 -0.50601202 -0.49599198 -0.48597194 -0.4759519 -0.46593186 -0.45591182 -0.44589178 -0.43587174 -0.4258517 -0.41583166 -0.40581162 -0.39579158 -0.38577154 -0.3757515 -0.36573146 -0.35571142 -0.34569138 -0.33567134 -0.3256513 -0.31563126 -0.30561122 -0.29559118 -0.28557114 -0.2755511 -0.26553106 -0.25551102 -0.24549098 -0.23547094 -0.2254509 -0.21543086 -0.20541082 -0.19539078 -0.18537074 -0.1753507 -0.16533066 -0.15531062 -0.14529058 -0.13527054 -0.1252505 -0.11523046 -0.10521042 -0.09519038 -0.08517034 -0.0751503 -0.06513026 -0.05511022 -0.04509018 -0.03507014 -0.0250501 -0.01503006 -0.00501002 0.00501002 0.01503006 0.0250501 0.03507014 0.04509018 0.05511022 0.06513026 0.0751503 0.08517034 0.09519038 0.10521042 0.11523046 0.1252505 0.13527054 0.14529058 0.15531062 0.16533066 0.1753507 0.18537074 0.19539078 0.20541082 0.21543086 0.2254509 0.23547094 0.24549098 0.25551102 0.26553106 0.2755511 0.28557114 0.29559118 0.30561122 0.31563126 0.3256513 0.33567134 0.34569138 0.35571142 0.36573146 0.3757515 0.38577154 0.39579158 0.40581162 0.41583166 0.4258517 0.43587174 0.44589178 0.45591182 0.46593186 0.4759519 0.48597194 0.49599198 0.50601202 0.51603206 0.5260521 0.53607214 0.54609218 0.55611222 0.56613226 0.5761523 0.58617234 0.59619238 0.60621242 0.61623246 0.62625251 0.63627255 0.64629259 0.65631263 0.66633267 0.67635271 0.68637275 0.69639279 0.70641283 0.71643287 0.72645291 0.73647295 0.74649299 0.75651303 0.76653307 0.77655311 0.78657315 0.79659319 0.80661323 0.81663327 0.82665331 0.83667335 0.84669339 0.85671343 0.86673347 0.87675351 0.88677355 0.89679359 0.90681363 0.91683367 0.92685371 0.93687375 0.94689379 0.95691383 0.96693387 0.97695391 0.98697395 0.99699399 1.00701403 1.01703407 1.02705411 1.03707415 1.04709419 1.05711423 1.06713427 1.07715431 1.08717435 1.09719439 1.10721443 1.11723447 1.12725451 1.13727455 1.14729459 1.15731463 1.16733467 1.17735471 1.18737475 1.19739479 1.20741483 1.21743487 1.22745491 1.23747495 1.24749499 1.25751503 1.26753507 1.27755511 1.28757515 1.29759519 1.30761523 1.31763527 1.32765531 1.33767535 1.34769539 1.35771543 1.36773547 1.37775551 1.38777555 1.39779559 1.40781563 1.41783567 1.42785571 1.43787575 1.44789579 1.45791583 1.46793587 1.47795591 1.48797595 1.49799599 1.50801603 1.51803607 1.52805611 1.53807615 1.54809619 1.55811623 1.56813627 1.57815631 1.58817635 1.59819639 1.60821643 1.61823647 1.62825651 1.63827655 1.64829659 1.65831663 1.66833667 1.67835671 1.68837675 1.69839679 1.70841683 1.71843687 1.72845691 1.73847695 1.74849699 1.75851703 1.76853707 1.77855711 1.78857715 1.79859719 1.80861723 1.81863727 1.82865731 1.83867735 1.84869739 1.85871743 1.86873747 1.87875752 1.88877756 1.8987976 1.90881764 1.91883768 1.92885772 1.93887776 1.9488978 1.95891784 1.96893788 1.97895792 1.98897796 1.998998 2.00901804 2.01903808 2.02905812 2.03907816 2.0490982 2.05911824 2.06913828 2.07915832 2.08917836 2.0991984 2.10921844 2.11923848 2.12925852 2.13927856 2.1492986 2.15931864 2.16933868 2.17935872 2.18937876 2.1993988 2.20941884 2.21943888 2.22945892 2.23947896 2.249499 2.25951904 2.26953908 2.27955912 2.28957916 2.2995992 2.30961924 2.31963928 2.32965932 2.33967936 2.3496994 2.35971944 2.36973948 2.37975952 2.38977956 2.3997996 2.40981964 2.41983968 2.42985972 2.43987976 2.4498998 2.45991984 2.46993988 2.47995992 2.48997996 2.5 ] [[0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] ... [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.]] [[1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.] ... [1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.]]
Image in a Jupyter notebook
#Mandelbar def interate(x, y): C = complex(x, y) zp = complex(0, 0) for k in range(500): zp = zp.conjugate()**14 + C if abs(zp) > 2.5: return k+1 return 500 N = 500 u = np.linspace(-2.5, 2.5, N) v = np.linspace(-2.5, 2.5, N) M = np.zeros((N, N)) print(u) print(M) for i in range(N): for j in range(N): M[i][j] = interate(u[i], v[j]) print(M.conjugate()) plt.imshow(M.conjugate()) plt.show() plt.show()
[-2.5 -2.48997996 -2.47995992 -2.46993988 -2.45991984 -2.4498998 -2.43987976 -2.42985972 -2.41983968 -2.40981964 -2.3997996 -2.38977956 -2.37975952 -2.36973948 -2.35971944 -2.3496994 -2.33967936 -2.32965932 -2.31963928 -2.30961924 -2.2995992 -2.28957916 -2.27955912 -2.26953908 -2.25951904 -2.249499 -2.23947896 -2.22945892 -2.21943888 -2.20941884 -2.1993988 -2.18937876 -2.17935872 -2.16933868 -2.15931864 -2.1492986 -2.13927856 -2.12925852 -2.11923848 -2.10921844 -2.0991984 -2.08917836 -2.07915832 -2.06913828 -2.05911824 -2.0490982 -2.03907816 -2.02905812 -2.01903808 -2.00901804 -1.998998 -1.98897796 -1.97895792 -1.96893788 -1.95891784 -1.9488978 -1.93887776 -1.92885772 -1.91883768 -1.90881764 -1.8987976 -1.88877756 -1.87875752 -1.86873747 -1.85871743 -1.84869739 -1.83867735 -1.82865731 -1.81863727 -1.80861723 -1.79859719 -1.78857715 -1.77855711 -1.76853707 -1.75851703 -1.74849699 -1.73847695 -1.72845691 -1.71843687 -1.70841683 -1.69839679 -1.68837675 -1.67835671 -1.66833667 -1.65831663 -1.64829659 -1.63827655 -1.62825651 -1.61823647 -1.60821643 -1.59819639 -1.58817635 -1.57815631 -1.56813627 -1.55811623 -1.54809619 -1.53807615 -1.52805611 -1.51803607 -1.50801603 -1.49799599 -1.48797595 -1.47795591 -1.46793587 -1.45791583 -1.44789579 -1.43787575 -1.42785571 -1.41783567 -1.40781563 -1.39779559 -1.38777555 -1.37775551 -1.36773547 -1.35771543 -1.34769539 -1.33767535 -1.32765531 -1.31763527 -1.30761523 -1.29759519 -1.28757515 -1.27755511 -1.26753507 -1.25751503 -1.24749499 -1.23747495 -1.22745491 -1.21743487 -1.20741483 -1.19739479 -1.18737475 -1.17735471 -1.16733467 -1.15731463 -1.14729459 -1.13727455 -1.12725451 -1.11723447 -1.10721443 -1.09719439 -1.08717435 -1.07715431 -1.06713427 -1.05711423 -1.04709419 -1.03707415 -1.02705411 -1.01703407 -1.00701403 -0.99699399 -0.98697395 -0.97695391 -0.96693387 -0.95691383 -0.94689379 -0.93687375 -0.92685371 -0.91683367 -0.90681363 -0.89679359 -0.88677355 -0.87675351 -0.86673347 -0.85671343 -0.84669339 -0.83667335 -0.82665331 -0.81663327 -0.80661323 -0.79659319 -0.78657315 -0.77655311 -0.76653307 -0.75651303 -0.74649299 -0.73647295 -0.72645291 -0.71643287 -0.70641283 -0.69639279 -0.68637275 -0.67635271 -0.66633267 -0.65631263 -0.64629259 -0.63627255 -0.62625251 -0.61623246 -0.60621242 -0.59619238 -0.58617234 -0.5761523 -0.56613226 -0.55611222 -0.54609218 -0.53607214 -0.5260521 -0.51603206 -0.50601202 -0.49599198 -0.48597194 -0.4759519 -0.46593186 -0.45591182 -0.44589178 -0.43587174 -0.4258517 -0.41583166 -0.40581162 -0.39579158 -0.38577154 -0.3757515 -0.36573146 -0.35571142 -0.34569138 -0.33567134 -0.3256513 -0.31563126 -0.30561122 -0.29559118 -0.28557114 -0.2755511 -0.26553106 -0.25551102 -0.24549098 -0.23547094 -0.2254509 -0.21543086 -0.20541082 -0.19539078 -0.18537074 -0.1753507 -0.16533066 -0.15531062 -0.14529058 -0.13527054 -0.1252505 -0.11523046 -0.10521042 -0.09519038 -0.08517034 -0.0751503 -0.06513026 -0.05511022 -0.04509018 -0.03507014 -0.0250501 -0.01503006 -0.00501002 0.00501002 0.01503006 0.0250501 0.03507014 0.04509018 0.05511022 0.06513026 0.0751503 0.08517034 0.09519038 0.10521042 0.11523046 0.1252505 0.13527054 0.14529058 0.15531062 0.16533066 0.1753507 0.18537074 0.19539078 0.20541082 0.21543086 0.2254509 0.23547094 0.24549098 0.25551102 0.26553106 0.2755511 0.28557114 0.29559118 0.30561122 0.31563126 0.3256513 0.33567134 0.34569138 0.35571142 0.36573146 0.3757515 0.38577154 0.39579158 0.40581162 0.41583166 0.4258517 0.43587174 0.44589178 0.45591182 0.46593186 0.4759519 0.48597194 0.49599198 0.50601202 0.51603206 0.5260521 0.53607214 0.54609218 0.55611222 0.56613226 0.5761523 0.58617234 0.59619238 0.60621242 0.61623246 0.62625251 0.63627255 0.64629259 0.65631263 0.66633267 0.67635271 0.68637275 0.69639279 0.70641283 0.71643287 0.72645291 0.73647295 0.74649299 0.75651303 0.76653307 0.77655311 0.78657315 0.79659319 0.80661323 0.81663327 0.82665331 0.83667335 0.84669339 0.85671343 0.86673347 0.87675351 0.88677355 0.89679359 0.90681363 0.91683367 0.92685371 0.93687375 0.94689379 0.95691383 0.96693387 0.97695391 0.98697395 0.99699399 1.00701403 1.01703407 1.02705411 1.03707415 1.04709419 1.05711423 1.06713427 1.07715431 1.08717435 1.09719439 1.10721443 1.11723447 1.12725451 1.13727455 1.14729459 1.15731463 1.16733467 1.17735471 1.18737475 1.19739479 1.20741483 1.21743487 1.22745491 1.23747495 1.24749499 1.25751503 1.26753507 1.27755511 1.28757515 1.29759519 1.30761523 1.31763527 1.32765531 1.33767535 1.34769539 1.35771543 1.36773547 1.37775551 1.38777555 1.39779559 1.40781563 1.41783567 1.42785571 1.43787575 1.44789579 1.45791583 1.46793587 1.47795591 1.48797595 1.49799599 1.50801603 1.51803607 1.52805611 1.53807615 1.54809619 1.55811623 1.56813627 1.57815631 1.58817635 1.59819639 1.60821643 1.61823647 1.62825651 1.63827655 1.64829659 1.65831663 1.66833667 1.67835671 1.68837675 1.69839679 1.70841683 1.71843687 1.72845691 1.73847695 1.74849699 1.75851703 1.76853707 1.77855711 1.78857715 1.79859719 1.80861723 1.81863727 1.82865731 1.83867735 1.84869739 1.85871743 1.86873747 1.87875752 1.88877756 1.8987976 1.90881764 1.91883768 1.92885772 1.93887776 1.9488978 1.95891784 1.96893788 1.97895792 1.98897796 1.998998 2.00901804 2.01903808 2.02905812 2.03907816 2.0490982 2.05911824 2.06913828 2.07915832 2.08917836 2.0991984 2.10921844 2.11923848 2.12925852 2.13927856 2.1492986 2.15931864 2.16933868 2.17935872 2.18937876 2.1993988 2.20941884 2.21943888 2.22945892 2.23947896 2.249499 2.25951904 2.26953908 2.27955912 2.28957916 2.2995992 2.30961924 2.31963928 2.32965932 2.33967936 2.3496994 2.35971944 2.36973948 2.37975952 2.38977956 2.3997996 2.40981964 2.41983968 2.42985972 2.43987976 2.4498998 2.45991984 2.46993988 2.47995992 2.48997996 2.5 ] [[0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] ... [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.]] [[1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.] ... [1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.] [1. 1. 1. ... 1. 1. 1.]]
Image in a Jupyter notebook
#Pregunta 3
import numpy as np import matplotlib.pyplot as plt def Roessler(x, y, z, a=0.1, b=0.1, c=14): x_dot = -y - z y_dot = x + a*y z_dot = b + z*(x - c) return x_dot, y_dot, z_dot dt = 0.01 num_steps = 10000 xs = np.empty(num_steps + 1) ys = np.empty(num_steps + 1) zs = np.empty(num_steps + 1) xs[0], ys[0], zs[0] = (0., 2., 1.) for i in range(num_steps): x_dot, y_dot, z_dot = Roessler(xs[i], ys[i], zs[i]) xs[i + 1] = xs[i] + (x_dot * dt) ys[i + 1] = ys[i] + (y_dot * dt) zs[i + 1] = zs[i] + (z_dot * dt) ax = plt.figure().add_subplot(projection='3d') ax.plot(xs, ys, zs, lw=1.) ax.set_xlabel("X") ax.set_ylabel("Y") ax.set_zlabel("Z") ax.set_title("Roessler") plt.show()
Image in a Jupyter notebook
def Roessler(x, y, z, a=0.1, b=0.1, c=14): x_dot = -y - z y_dot = x + a*y z_dot = 0 return x_dot, y_dot, z_dot dt = 0.01 num_steps = 10000 xs = np.empty(num_steps + 1) ys = np.empty(num_steps + 1) zs = np.empty(num_steps + 1) xs[0], ys[0], zs[0] = (1., 2., 1) for i in range(num_steps): x_dot, y_dot, z_dot = Roessler(xs[i], ys[i], zs[i]) xs[i + 1] = xs[i] + (x_dot * dt) ys[i + 1] = ys[i] + (y_dot * dt) zs[i + 1] = zs[i] + (z_dot * dt) ax = plt.figure().add_subplot(projection='3d') ax.plot(xs, ys, zs, lw=1.) ax.set_xlabel("X") ax.set_ylabel("Y") ax.set_zlabel("Z") ax.set_title("Roessler") plt.show()
Image in a Jupyter notebook
def Roessler(x, y, z, a=0.1, b=0.1, c=14): x_dot = -y - z y_dot = 0 z_dot = b + z*(x - c) return x_dot, y_dot, z_dot dt = 0.01 num_steps = 10000 xs = np.empty(num_steps + 1) ys = np.empty(num_steps + 1) zs = np.empty(num_steps + 1) xs[0], ys[0], zs[0] = (1., 2., 1) for i in range(num_steps): x_dot, y_dot, z_dot = Roessler(xs[i], ys[i], zs[i]) xs[i + 1] = xs[i] + (x_dot * dt) ys[i + 1] = ys[i] + (y_dot * dt) zs[i + 1] = zs[i] + (z_dot * dt) ax = plt.figure().add_subplot(projection='3d') ax.plot(xs, ys, zs, lw=1.) ax.set_xlabel("X") ax.set_ylabel("Y") ax.set_zlabel("Z") ax.set_title("Roessler") plt.show()
Image in a Jupyter notebook
def Roessler(x, y, z, a=0.1, b=0.1, c=14): x_dot = 0 y_dot = x + a*y z_dot = b + z*(x - c) return x_dot, y_dot, z_dot dt = 0.01 num_steps = 10000 xs = np.empty(num_steps + 1) ys = np.empty(num_steps + 1) zs = np.empty(num_steps + 1) xs[0], ys[0], zs[0] = (1., 2., 1) for i in range(num_steps): x_dot, y_dot, z_dot = Roessler(xs[i], ys[i], zs[i]) xs[i + 1] = xs[i] + (x_dot * dt) ys[i + 1] = ys[i] + (y_dot * dt) zs[i + 1] = zs[i] + (z_dot * dt) ax = plt.figure().add_subplot(projection='3d') ax.plot(xs, ys, zs, lw=1.) ax.set_xlabel("X") ax.set_ylabel("Y") ax.set_zlabel("Z") ax.set_title("Roessler") plt.show()
Image in a Jupyter notebook
from tqdm import tqdm import matplotlib.pyplot as plt import numpy as np def LogisticMap(): mu = np.arange(0, 2, 0.0001) a = 0.1 c = 14 y = 0.2 z = 0.1 x = 0.5 iters = 1000 last = 100 for i in tqdm(range(iters+last)): x = -(x + a*y) - (mu + z*(x - c)) if i >= iters: plt.plot(mu, x, ',k', alpha=0.25) plt.show() LogisticMap()
100%|██████████| 1100/1100 [00:00<00:00, 3082.29it/s]
Image in a Jupyter notebook
def LogisticMap(): mu = np.arange(0, 2, 0.0001) a = 0.1 c = 14 y = 0.2 z = 0.1 x = 1. iters = 1000 last = 100 for i in tqdm(range(iters+last)): x = -(x + a*y) - (mu + z*(x - c)) if i >= iters: plt.plot(mu, x, ',k', alpha=0.25) plt.show() LogisticMap()
100%|██████████| 1100/1100 [00:00<00:00, 2815.08it/s]
Image in a Jupyter notebook
def LogisticMap(): mu = np.arange(0, 2, 0.0001) a = 0.1 c = 14 y = 0.2 z = 0.1 x = 5.0 iters = 1000 last = 100 for i in tqdm(range(iters+last)): x = -(x + a*y) - (mu + z*(x - c)) if i >= iters: plt.plot(mu, x, ',k', alpha=0.25) plt.show() LogisticMap()
100%|██████████| 1100/1100 [00:00<00:00, 2308.86it/s]
Image in a Jupyter notebook