mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-01-14 15:54:13 +01:00
Refactor code in numerical methods notebooks
- Updated import order in Point_Fixe.ipynb for consistency. - Changed lambda functions to regular function definitions for clarity in Point_Fixe.ipynb. - Added numpy import in TP1_EDO_EulerExp.ipynb, TP2_Lokta_Volterra.ipynb, and TP3_Convergence.ipynb for better readability. - Modified for loops in TP1_EDO_EulerExp.ipynb and TP2_Lokta_Volterra.ipynb to include strict=False for compatibility with future Python versions.
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\n",
|
||||
"from scipy.integrate import odeint"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"from sklearn.neural_network import MLPClassifier\n",
|
||||
"from sklearn.datasets import make_classification\n",
|
||||
"from sklearn.model_selection import train_test_split\n",
|
||||
"from sklearn.metrics import accuracy_score\n",
|
||||
"from sklearn.model_selection import train_test_split\n",
|
||||
"from sklearn.neural_network import MLPClassifier\n",
|
||||
"\n",
|
||||
"accuracies = []\n",
|
||||
"\n",
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\n",
|
||||
"import scipy.stats as stats"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from scipy.optimize import newton\n",
|
||||
"from scipy.integrate import quad, odeint"
|
||||
"import numpy as np\n",
|
||||
"from scipy.integrate import odeint, quad\n",
|
||||
"from scipy.optimize import newton"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -159,9 +159,11 @@
|
||||
"\n",
|
||||
" for n in range(N - 1):\n",
|
||||
" p1 = f(vt[n], yn[:, n])\n",
|
||||
" F1 = lambda p2: f(vt[n] + h / 3, yn[:, n] + h / 6 * (p1 + p2)) - p2\n",
|
||||
" def F1(p2):\n",
|
||||
" return f(vt[n] + h / 3, yn[:, n] + h / 6 * (p1 + p2)) - p2\n",
|
||||
" p2 = newton(F1, yn[:, n], fprime=None, tol=tol, maxiter=itmax)\n",
|
||||
" F2 = lambda yn1: yn[:, n] + h / 4 * (3 * p2 + f(vt[n + 1], yn1)) - yn1\n",
|
||||
" def F2(yn1):\n",
|
||||
" return yn[:, n] + h / 4 * (3 * p2 + f(vt[n + 1], yn1)) - yn1\n",
|
||||
" yn[:, n + 1] = newton(F2, yn[:, n], fprime=None, tol=tol, maxiter=itmax)\n",
|
||||
" return yn"
|
||||
]
|
||||
@@ -392,7 +394,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"display_name": "studies",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
@@ -406,7 +408,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.2"
|
||||
"version": "3.13.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user