mnspy 0.9.18__tar.gz → 0.9.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mnspy-0.9.20/LICENSE +21 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/PKG-INFO +1 -1
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/bisecci/303/263n.py +7 -4
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/brent.py +7 -5
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/falsa_posicion.py +8 -5
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/muller.py +3 -3
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/newton_raphson.py +3 -3
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/punto_fijo.py +2 -3
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/raices.py +35 -19
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/secante.py +2 -3
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/secante_modificada.py +3 -3
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/wegstein.py +2 -3
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy.egg-info/PKG-INFO +1 -1
- {mnspy-0.9.18 → mnspy-0.9.20}/setup.py +1 -1
- mnspy-0.9.18/LICENSE +0 -674
- {mnspy-0.9.18 → mnspy-0.9.20}/README.md +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/derivada/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/derivada/derivada.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/derivada/derivada_discreta.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/derivada/richardson.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/cramer.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/descomposicion_LU.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/descomposicion_cholesky.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/ecuaciones_algebraicas_lineales.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/gauss.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/gauss_jordan.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/gauss_sediel.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_algebraicas_lineales/tridiagonal.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_ordinarias/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_ordinarias/ecuaciones_diferenciales_ordinarias.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_ordinarias/euler.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_ordinarias/heun.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_ordinarias/punto_medio.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_ordinarias/runge_kutta.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/ecuaciones_diferenciales_parciales.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/liebmann.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mdf/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mdf/mdf.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/armadura.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/barra.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/ensamble.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/marco.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/mef.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/resorte.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/triangular_cst.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mef/viga.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mvf/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mvf/mvf.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ecuaciones_diferenciales_parciales/mvf/volumen_finito.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/__init__.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/cuadratura_adaptativa.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/gauss_legendre.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/integral.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/romberg.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/simpson_1_3.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/simpson_3_8.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/trapezoidal.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/trapezoidal_desigual.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/integrales/trapezoidal_desigual_acumulado.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/interpolaci/303/263n/__init__.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/interpolaci/303/263n/inter_Lagrange.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/interpolaci/303/263n/inter_Newton.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/interpolaci/303/263n/inter_spline_cubica.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/interpolaci/303/263n/inter_spline_lineal.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/interpolaci/303/263n/interpolacion.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/ra/303/255ces/__init__.py" +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy/utilidades.py +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy.egg-info/SOURCES.txt +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy.egg-info/dependency_links.txt +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy.egg-info/requires.txt +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/mnspy.egg-info/top_level.txt +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/pyproject.toml +0 -0
- {mnspy-0.9.18 → mnspy-0.9.20}/setup.cfg +0 -0
mnspy-0.9.20/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Edwin Córdoba
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -23,7 +23,8 @@ class Biseccion(Raices):
|
|
|
23
23
|
Tipo de error a utilizar para la convergencia:
|
|
24
24
|
- ``'%'``: Error relativo porcentual.
|
|
25
25
|
- ``'/'``: Error relativo.
|
|
26
|
-
- ``'n'``: Número de cifras significativas.
|
|
26
|
+
- ``'n'``: Número de cifras significativas. εs = (0.5 * 10^(2-n))% [Scarborough, 1966]
|
|
27
|
+
- ``'t'``: Tolerancia. tol = |b - a|/2 (Solo aplica en los métodos cerrados)
|
|
27
28
|
|
|
28
29
|
Methods
|
|
29
30
|
-------
|
|
@@ -68,7 +69,7 @@ class Biseccion(Raices):
|
|
|
68
69
|
max_iter: int
|
|
69
70
|
Número máximo de iteraciones permitido.
|
|
70
71
|
tipo_error: str
|
|
71
|
-
Tipo de error a utilizar: ``'%'``, ``'/'`` o ``'
|
|
72
|
+
Tipo de error a utilizar: ``'%'``, ``'/'``, ``'n'`` o ``'t'``.
|
|
72
73
|
"""
|
|
73
74
|
super().__init__(f, x_min, x_max, tol, max_iter, tipo_error)
|
|
74
75
|
self._calcular()
|
|
@@ -135,9 +136,11 @@ class Biseccion(Raices):
|
|
|
135
136
|
linea_base.set_xdata([self._tabla['x_min'][i], self._tabla['x_max'][i]])
|
|
136
137
|
plt.title(f'x = {self.x}')
|
|
137
138
|
if self._error_porcentual:
|
|
138
|
-
plt.suptitle('Método de la Bisección (
|
|
139
|
-
|
|
139
|
+
plt.suptitle(r'Método de la Bisección ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
140
|
+
elif self._error_tolerancia:
|
|
140
141
|
plt.suptitle('Método de la Bisección (tol= ' + str(self._tol) + ')')
|
|
142
|
+
else:
|
|
143
|
+
plt.suptitle(r'Método de la Bisección ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
141
144
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
142
145
|
|
|
143
146
|
|
|
@@ -2,7 +2,6 @@ from mnspy.raíces import Raices
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
import matplotlib.pyplot as plt
|
|
4
4
|
import sys
|
|
5
|
-
plt.rcParams.update(plt.rcParamsDefault)
|
|
6
5
|
|
|
7
6
|
class Brent(Raices):
|
|
8
7
|
"""Clase para la implementación del cálculo de raíces por el método cerrado de Brent.
|
|
@@ -23,7 +22,8 @@ class Brent(Raices):
|
|
|
23
22
|
Tipo de error a utilizar para la convergencia:
|
|
24
23
|
- ``'%'``: Error relativo porcentual.
|
|
25
24
|
- ``'/'``: Error relativo.
|
|
26
|
-
- ``'n'``: Número de cifras significativas.
|
|
25
|
+
- ``'n'``: Número de cifras significativas. εs = (0.5 * 10^(2-n))% [Scarborough, 1966]
|
|
26
|
+
- ``'t'``: Tolerancia. tol = |b - a|/2 (Solo aplica en los métodos cerrados)
|
|
27
27
|
|
|
28
28
|
Methods
|
|
29
29
|
-------
|
|
@@ -62,7 +62,7 @@ class Brent(Raices):
|
|
|
62
62
|
max_iter: int
|
|
63
63
|
Número máximo de iteraciones permitido.
|
|
64
64
|
tipo_error: str
|
|
65
|
-
Tipo de error a utilizar: ``'%'``, ``'/'`` o ``'
|
|
65
|
+
Tipo de error a utilizar: ``'%'``, ``'/'``, ``'n'`` o ``'t'``.
|
|
66
66
|
"""
|
|
67
67
|
# Inicialización de la clase padre
|
|
68
68
|
super().__init__(f, x_min, x_max, tol, max_iter, tipo_error)
|
|
@@ -167,9 +167,11 @@ class Brent(Raices):
|
|
|
167
167
|
"""
|
|
168
168
|
plt.title(f'x = {self.x}')
|
|
169
169
|
if self._error_porcentual:
|
|
170
|
-
plt.suptitle('Método de Brent (
|
|
170
|
+
plt.suptitle(r'Método de la Brent ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
171
|
+
elif self._error_tolerancia:
|
|
172
|
+
plt.suptitle('Método de la Brent (tol= ' + str(self._tol) + ')')
|
|
171
173
|
else:
|
|
172
|
-
plt.suptitle('Método de Brent (
|
|
174
|
+
plt.suptitle(r'Método de la Brent ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
173
175
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
174
176
|
|
|
175
177
|
|
|
@@ -2,7 +2,7 @@ from mnspy.raíces import Raices
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
import matplotlib.pyplot as plt
|
|
4
4
|
import sys
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
|
|
7
7
|
class FalsaPosicion(Raices):
|
|
8
8
|
"""Clase para la implementación del cálculo de raíces por el método cerrado de la Falsa Posición.
|
|
@@ -23,7 +23,8 @@ class FalsaPosicion(Raices):
|
|
|
23
23
|
Tipo de error a utilizar para la convergencia:
|
|
24
24
|
- ``'%'``: Error relativo porcentual.
|
|
25
25
|
- ``'/'``: Error relativo.
|
|
26
|
-
- ``'n'``: Número de cifras significativas.
|
|
26
|
+
- ``'n'``: Número de cifras significativas. εs = (0.5 * 10^(2-n))% [Scarborough, 1966]
|
|
27
|
+
- ``'t'``: Tolerancia. tol = |b - a|/2 (Solo aplica en los métodos cerrados)
|
|
27
28
|
|
|
28
29
|
Methods
|
|
29
30
|
-------
|
|
@@ -65,7 +66,7 @@ class FalsaPosicion(Raices):
|
|
|
65
66
|
max_iter: int
|
|
66
67
|
Número máximo de iteraciones permitido.
|
|
67
68
|
tipo_error: str
|
|
68
|
-
Tipo de error a utilizar: ``'%'``, ``'/'`` o ``'
|
|
69
|
+
Tipo de error a utilizar: ``'%'``, ``'/'``, ``'n'`` o ``'t'``.
|
|
69
70
|
"""
|
|
70
71
|
super().__init__(f, x_min, x_max, tol, max_iter, tipo_error)
|
|
71
72
|
self._calcular()
|
|
@@ -127,9 +128,11 @@ class FalsaPosicion(Raices):
|
|
|
127
128
|
plt.plot([a, b], [self._f(a), self._f(b)], linestyle='dashed', c='purple', lw=1)
|
|
128
129
|
plt.title(f'x = {self.x}')
|
|
129
130
|
if self._error_porcentual:
|
|
130
|
-
plt.suptitle('Método de la Falsa Posición (
|
|
131
|
-
|
|
131
|
+
plt.suptitle(r'Método de la Falsa Posición ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
132
|
+
elif self._error_tolerancia:
|
|
132
133
|
plt.suptitle('Método de la Falsa Posición (tol= ' + str(self._tol) + ')')
|
|
134
|
+
else:
|
|
135
|
+
plt.suptitle(r'Método de la Falsa Posición ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
133
136
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
134
137
|
|
|
135
138
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from mnspy.raíces import Raices
|
|
2
2
|
import numpy as np
|
|
3
3
|
import matplotlib.pyplot as plt
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
|
|
6
6
|
class Muller(Raices):
|
|
7
7
|
"""Clase para la implementación del cálculo de raíces por el método abierto de Muller.
|
|
@@ -150,9 +150,9 @@ class Muller(Raices):
|
|
|
150
150
|
plt.autoscale(True)
|
|
151
151
|
plt.title(f'x = {self.x}')
|
|
152
152
|
if self._error_porcentual:
|
|
153
|
-
plt.suptitle('Método de Müller (
|
|
153
|
+
plt.suptitle(r'Método de Müller ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
154
154
|
else:
|
|
155
|
-
plt.suptitle('Método de Müller (
|
|
155
|
+
plt.suptitle(r'Método de Müller ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
156
156
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
157
157
|
|
|
158
158
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from mnspy.raíces import Raices
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
class NewtonRaphson(Raices):
|
|
6
6
|
"""Clase para la implementación del cálculo de raíces por el método abierto de Newton-Raphson.
|
|
@@ -155,9 +155,9 @@ class NewtonRaphson(Raices):
|
|
|
155
155
|
plt.plot([x_next, x_next], [0, self._f(x_next)], linestyle='dashed', c='purple', lw=1)
|
|
156
156
|
plt.title(f'x = {self.x}')
|
|
157
157
|
if self._error_porcentual:
|
|
158
|
-
plt.suptitle('Método de Newton-Raphson (
|
|
158
|
+
plt.suptitle(r'Método de Newton-Raphson ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
159
159
|
else:
|
|
160
|
-
plt.suptitle('Método de Newton-Raphson (
|
|
160
|
+
plt.suptitle(r'Método de Newton-Raphson ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
161
161
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
162
162
|
|
|
163
163
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from mnspy.raíces import Raices
|
|
2
2
|
import numpy as np
|
|
3
3
|
import matplotlib.pyplot as plt
|
|
4
|
-
plt.rcParams.update(plt.rcParamsDefault)
|
|
5
4
|
|
|
6
5
|
class PuntoFijo(Raices):
|
|
7
6
|
"""Clase para la implementación del cálculo de raíces por el método abierto de Newton-Raphson.
|
|
@@ -116,9 +115,9 @@ class PuntoFijo(Raices):
|
|
|
116
115
|
plt.plot([x, y], [y, y], linestyle='dashed', c='purple', lw=1)
|
|
117
116
|
plt.title(f'x = {self.x}')
|
|
118
117
|
if self._error_porcentual:
|
|
119
|
-
plt.suptitle('Método de Punto Fijo (
|
|
118
|
+
plt.suptitle(r'Método de Punto Fijo ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
120
119
|
else:
|
|
121
|
-
plt.suptitle('Método de Punto Fijo (
|
|
120
|
+
plt.suptitle(r'Método de Punto Fijo ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
122
121
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
123
122
|
|
|
124
123
|
|
|
@@ -4,7 +4,6 @@ from mnspy.utilidades import es_notebook
|
|
|
4
4
|
from tabulate import tabulate
|
|
5
5
|
import math
|
|
6
6
|
import sys
|
|
7
|
-
plt.rcParams.update(plt.rcParamsDefault)
|
|
8
7
|
|
|
9
8
|
class Raices:
|
|
10
9
|
"""
|
|
@@ -82,11 +81,13 @@ class Raices:
|
|
|
82
81
|
Tipo de error a utilizar para la convergencia:
|
|
83
82
|
- ``'%'``: Error relativo porcentual (por defecto).
|
|
84
83
|
- ``'/'``: Error relativo.
|
|
85
|
-
- ``'n'``: Número de cifras significativas. εs = (0.5 * 10^(2-n))
|
|
84
|
+
- ``'n'``: Número de cifras significativas. εs = (0.5 * 10^(2-n))% [Scarborough, 1966]
|
|
85
|
+
- ``'t'``: Tolerancia. tol = |b - a|/2 (Solo aplica en los métodos cerrados)
|
|
86
86
|
"""
|
|
87
87
|
self._f = f
|
|
88
88
|
self._tol = tol
|
|
89
|
-
# tipo de error es '%' , '/'
|
|
89
|
+
# tipo de error es '%' , '/' , 'n' ó 't'
|
|
90
|
+
self._error_tolerancia = False # Solo se puede usar en métodos cerrados
|
|
90
91
|
match tipo_error:
|
|
91
92
|
case "%":
|
|
92
93
|
self._error_porcentual = True
|
|
@@ -95,8 +96,11 @@ class Raices:
|
|
|
95
96
|
case "n":
|
|
96
97
|
self._tol = 0.5 * 10 ** (2 - tol)
|
|
97
98
|
self._error_porcentual = True
|
|
99
|
+
case "t":
|
|
100
|
+
self._error_porcentual = False
|
|
101
|
+
self._error_tolerancia = True
|
|
98
102
|
case _:
|
|
99
|
-
print("Tipo de error no valido, las opciones son: '%', '/', 'n'")
|
|
103
|
+
print("Tipo de error no valido, las opciones son: '%', '/', 'n', 't'")
|
|
100
104
|
sys.exit()
|
|
101
105
|
self._max_iter = max_iter
|
|
102
106
|
self._x_min = x_min
|
|
@@ -105,7 +109,7 @@ class Raices:
|
|
|
105
109
|
self._x_0 = None
|
|
106
110
|
self._x_1 = None
|
|
107
111
|
self._tabla = {'x_min': [], 'x_max': [], 'x': [], 'Ea': []}
|
|
108
|
-
self._fmt = {'iter': 'd', 'x_l': '.5f', 'x_u': '.5f', 'x': '.10f', 'f': '.8f', 'E_a': '0.5%', 'E_t': '0.5%'}
|
|
112
|
+
self._fmt = {'iter': 'd', 'x_l': '.5f', 'x_u': '.5f', 'x': '.10f', 'f': '.8f', 'E_a': '0.5%', 'E_t': '0.5%' , 'tol': '0.8f'}
|
|
109
113
|
self._converge = False
|
|
110
114
|
self._rango = x_min, x_max
|
|
111
115
|
plt.ioff() # deshabilitada interactividad matplotlib
|
|
@@ -115,7 +119,7 @@ class Raices:
|
|
|
115
119
|
Ajusta el formato de presentación de los datos en las tablas.
|
|
116
120
|
|
|
117
121
|
Por defecto el formato es
|
|
118
|
-
{'iter': 'd', 'x_l': '.5f', 'x_u': '.5f', 'x': '.10f', 'f': '.8f', 'E_a': '0.5%', 'E_t': '0.5%'}
|
|
122
|
+
{'iter': 'd', 'x_l': '.5f', 'x_u': '.5f', 'x': '.10f', 'f': '.8f', 'E_a': '0.5%', 'E_t': '0.5%', 'tol': '0.8f'}
|
|
119
123
|
|
|
120
124
|
Parameters
|
|
121
125
|
----------
|
|
@@ -128,8 +132,8 @@ class Raices:
|
|
|
128
132
|
-------
|
|
129
133
|
None
|
|
130
134
|
"""
|
|
131
|
-
if col == 'x_r' or col == 'x_i':
|
|
132
|
-
|
|
135
|
+
# if col == 'x_r' or col == 'x_i':
|
|
136
|
+
# col = 'x'
|
|
133
137
|
self._fmt[col] = fmt
|
|
134
138
|
|
|
135
139
|
def generar_tabla(self, valor_real: float = None, tablefmt=None):
|
|
@@ -160,41 +164,41 @@ class Raices:
|
|
|
160
164
|
if self._x_min is not None:
|
|
161
165
|
valores = np.array(
|
|
162
166
|
[self._tabla['x_min'], self._tabla['x_max'], self._tabla['x'], [self._f(val) for val in self._tabla['x']],
|
|
163
|
-
self._tabla['Ea']]).transpose()
|
|
167
|
+
self._tabla['Ea'], list(np.abs(np.array(self._tabla['x_max']) -np.array(self._tabla['x_min']))/2.0)]).transpose()
|
|
164
168
|
if es_notebook() and (tablefmt is None or tablefmt in render_notebook):
|
|
165
169
|
if tablefmt is None:
|
|
166
170
|
tablefmt = 'html'
|
|
167
171
|
if valor_real is None:
|
|
168
172
|
return tabulate(valores, ['Iteración', '$x_{l}$', '$x_{u}$', '$x_{r}$', r'$f\left(x_{r}\right)$',
|
|
169
|
-
r'$\varepsilon_{a}$'], showindex=list(range(1, len(self._tabla['x']) + 1)),
|
|
173
|
+
r'$\varepsilon_{a}$', 'Tolerancia'], showindex=list(range(1, len(self._tabla['x']) + 1)),
|
|
170
174
|
tablefmt=tablefmt, floatfmt=(
|
|
171
175
|
self._fmt['iter'], self._fmt['x_l'], self._fmt['x_u'], self._fmt['x'], self._fmt['f'],
|
|
172
|
-
self._fmt['E_a']), colalign=("center",))
|
|
176
|
+
self._fmt['E_a'], self._fmt['tol']), colalign=("center",))
|
|
173
177
|
else:
|
|
174
178
|
e_t = abs((np.array([self._tabla['x']]).transpose() - valor_real) / valor_real)
|
|
175
179
|
valores = np.hstack((valores, e_t))
|
|
176
180
|
return tabulate(valores, ['Iteración', '$x_{l}$', '$x_{u}$', '$x_{r}$', r'$f\left(x_{r}\right)$',
|
|
177
|
-
r'$\varepsilon_{a}$', r'$\varepsilon_{t}$'],
|
|
181
|
+
r'$\varepsilon_{a}$', 'Tolerancia' , r'$\varepsilon_{t}$'],
|
|
178
182
|
showindex=list(range(1, len(self._tabla['x']) + 1)), tablefmt=tablefmt, floatfmt=(
|
|
179
183
|
self._fmt['iter'], self._fmt['x_l'], self._fmt['x_u'], self._fmt['x'], self._fmt['f'],
|
|
180
|
-
self._fmt['E_a'], self._fmt['E_t']), colalign=("center",))
|
|
184
|
+
self._fmt['E_a'], self._fmt['tol'], self._fmt['E_t']), colalign=("center",))
|
|
181
185
|
else:
|
|
182
186
|
if tablefmt is None:
|
|
183
187
|
tablefmt = 'simple'
|
|
184
188
|
if valor_real is None:
|
|
185
|
-
print(tabulate(valores, ['Iteración', 'x_l', 'x_u', 'x_r', 'f(x_r)', 'E_a'],
|
|
189
|
+
print(tabulate(valores, ['Iteración', 'x_l', 'x_u', 'x_r', 'f(x_r)', 'E_a', 'tol'],
|
|
186
190
|
showindex=list(range(1, len(self._tabla['x']) + 1)), tablefmt=tablefmt,
|
|
187
191
|
floatfmt=(
|
|
188
|
-
self._fmt['iter'], self._fmt['x_l'], self._fmt['x_u'], self._fmt['x'], self._fmt['f'],
|
|
189
|
-
self._fmt['E_a']), colalign=("center",)))
|
|
192
|
+
self._fmt['iter'], self._fmt['x_l'], self._fmt['x_u'], self._fmt['x'], self._fmt['f'] ,
|
|
193
|
+
self._fmt['E_a'], self._fmt['tol']), colalign=("center",)))
|
|
190
194
|
else:
|
|
191
195
|
e_t = abs((np.array([self._tabla['x']]).transpose() - valor_real) / valor_real)
|
|
192
196
|
valores = np.hstack((valores, e_t))
|
|
193
|
-
print(tabulate(valores, ['Iteración', 'x_l', 'x_u', 'x_r', 'f(x_r)', 'E_a', 'E_t'],
|
|
197
|
+
print(tabulate(valores, ['Iteración', 'x_l', 'x_u', 'x_r', 'f(x_r)', 'E_a', 'tol','E_t'],
|
|
194
198
|
showindex=list(range(1, len(self._tabla['x']) + 1)), tablefmt=tablefmt,
|
|
195
199
|
floatfmt=(
|
|
196
200
|
self._fmt['iter'], self._fmt['x_l'], self._fmt['x_u'], self._fmt['x'], self._fmt['f'],
|
|
197
|
-
self._fmt['E_a'], self._fmt['E_t']), colalign=("center",)))
|
|
201
|
+
self._fmt['E_a'], self._fmt['tol'], self._fmt['E_t']), colalign=("center",)))
|
|
198
202
|
else:
|
|
199
203
|
valores = np.array([self._tabla['x'], self._f(np.array(self._tabla['x'])), self._tabla['Ea']]).transpose()
|
|
200
204
|
if es_notebook() and (tablefmt is None or tablefmt in render_notebook):
|
|
@@ -275,6 +279,16 @@ class Raices:
|
|
|
275
279
|
return False
|
|
276
280
|
else:
|
|
277
281
|
return False
|
|
282
|
+
elif self._error_tolerancia:
|
|
283
|
+
if self._rango == (None, None):
|
|
284
|
+
print('El tipo de error ''t'' solo aplica a los métodos cerrados')
|
|
285
|
+
return False
|
|
286
|
+
else:
|
|
287
|
+
if abs(self._tabla['x_max'][-1]-self._tabla['x_min'][-1])/2.0 < self._tol:
|
|
288
|
+
self._converge = True
|
|
289
|
+
return True
|
|
290
|
+
else:
|
|
291
|
+
return False
|
|
278
292
|
else:
|
|
279
293
|
lon = len(self._tabla['x'])
|
|
280
294
|
if lon > 1:
|
|
@@ -370,6 +384,9 @@ class Raices:
|
|
|
370
384
|
-------
|
|
371
385
|
Tabla con los resultados finales de la iteración.
|
|
372
386
|
"""
|
|
387
|
+
if type(self) is Raices: # Si la clase es Raíces, no tiene método asociado y solo sirve para graficar
|
|
388
|
+
print('No se generó solución')
|
|
389
|
+
return None
|
|
373
390
|
if self._converge:
|
|
374
391
|
if es_notebook():
|
|
375
392
|
valores = [['$x$:', self.x], ['$f(x)$:', self._f(self.x)],
|
|
@@ -400,6 +417,5 @@ def main():
|
|
|
400
417
|
graf = Raices(z, 0, 5)
|
|
401
418
|
graf.graficar()
|
|
402
419
|
|
|
403
|
-
|
|
404
420
|
if __name__ == '__main__':
|
|
405
421
|
main()
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from mnspy.raíces import Raices
|
|
2
2
|
import numpy as np
|
|
3
3
|
import matplotlib.pyplot as plt
|
|
4
|
-
plt.rcParams.update(plt.rcParamsDefault)
|
|
5
4
|
|
|
6
5
|
class Secante(Raices):
|
|
7
6
|
"""Clase para la implementación del cálculo de raíces por el método abierto de la Secante.
|
|
@@ -125,9 +124,9 @@ class Secante(Raices):
|
|
|
125
124
|
plt.plot([x_next, x_next], [0, self._f(x_next)], linestyle='dashed', c='purple', lw=1)
|
|
126
125
|
plt.title(f'x = {self.x}')
|
|
127
126
|
if self._error_porcentual:
|
|
128
|
-
plt.suptitle('Método de la Secante (
|
|
127
|
+
plt.suptitle(r'Método de la Secante ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
129
128
|
else:
|
|
130
|
-
plt.suptitle('Método de la Secante (
|
|
129
|
+
plt.suptitle(r'Método de la Secante ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
131
130
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
132
131
|
|
|
133
132
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from mnspy.raíces import Raices
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
class SecanteModificada(Raices):
|
|
6
6
|
"""Clase para la implementación del cálculo de raíces por el método abierto de la Secante Modificada.
|
|
@@ -120,10 +120,10 @@ class SecanteModificada(Raices):
|
|
|
120
120
|
plt.title(f'x = {self.x}')
|
|
121
121
|
if self._error_porcentual:
|
|
122
122
|
plt.suptitle(
|
|
123
|
-
r'Método de la Secante Modificada, $\delta$ = ' + str(self._delta) + ' (
|
|
123
|
+
r'Método de la Secante Modificada, $\delta$ = ' + str(self._delta) + r' ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
124
124
|
else:
|
|
125
125
|
plt.suptitle(
|
|
126
|
-
r'Método de la Secante Modificada, $\delta$ = ' + str(self._delta) + ' (
|
|
126
|
+
r'Método de la Secante Modificada, $\delta$ = ' + str(self._delta) + r' ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
127
127
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
128
128
|
|
|
129
129
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from mnspy.raíces import Raices
|
|
2
2
|
import matplotlib.pyplot as plt
|
|
3
|
-
plt.rcParams.update(plt.rcParamsDefault)
|
|
4
3
|
|
|
5
4
|
class Wegstein(Raices):
|
|
6
5
|
"""Clase para la implementación del cálculo de raíces por el método abierto de Wegstein.
|
|
@@ -132,9 +131,9 @@ class Wegstein(Raices):
|
|
|
132
131
|
plt.plot([x_next, x_next], [0, x_next], linestyle='dashed', c='purple', lw=1)
|
|
133
132
|
plt.title(f'x = {self.x}')
|
|
134
133
|
if self._error_porcentual:
|
|
135
|
-
plt.suptitle('Método de Wegstein (
|
|
134
|
+
plt.suptitle(r'Método de Wegstein ($\varepsilon_{s}[\%]$= ' + str(self._tol) + '%)')
|
|
136
135
|
else:
|
|
137
|
-
plt.suptitle('Método de Wegstein (
|
|
136
|
+
plt.suptitle(r'Método de Wegstein ($\varepsilon_{s}$= ' + str(self._tol) + ')')
|
|
138
137
|
super().graficar(mostrar_sol, mostrar_iter, mostrar_lin_iter, n_puntos)
|
|
139
138
|
|
|
140
139
|
|
|
@@ -2,7 +2,7 @@ from setuptools import setup
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='mnspy',
|
|
5
|
-
version='0.9.
|
|
5
|
+
version='0.9.20',
|
|
6
6
|
packages=['mnspy', 'mnspy.raíces', 'mnspy.derivada', 'mnspy.integrales', 'mnspy.interpolación',
|
|
7
7
|
'mnspy.ecuaciones_algebraicas_lineales', 'mnspy.ecuaciones_diferenciales_ordinarias',
|
|
8
8
|
'mnspy.ecuaciones_diferenciales_parciales', 'mnspy.ecuaciones_diferenciales_parciales.mdf',
|