typst/schule/mathe/jupyter/sympy.ipynb

299 lines
9 KiB
Text
Raw Normal View History

2024-11-18 12:13:17 +01:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### **Grundlegende Operatoren und Funktionen**\n",
"\n",
"1. **Exponentiation** (Potenz)\n",
"\n",
" - `**`: Exponentiation\n",
" ```python\n",
" x**2 # x hoch 2\n",
" ```\n",
" - `exp(x)`: Exponentielle Funktion \\( e^x \\)\n",
" ```python\n",
" from sympy import exp\n",
" exp(x)\n",
" ```\n",
"\n",
"2. **Logarithmen**\n",
"\n",
" - `log(x)`: Natürlicher Logarithmus \\( \\ln(x) \\)\n",
" ```python\n",
" from sympy import log\n",
" log(x)\n",
" ```\n",
" - `log(x, base)`: Logarithmus zur Basis `base`\n",
" ```python\n",
" log(x, 10) # Logarithmus zur Basis 10\n",
" ```\n",
"\n",
"3. **Trigonometrische Funktionen**\n",
"\n",
" - `sin(x)`: Sinus\n",
" ```python\n",
" from sympy import sin\n",
" sin(x)\n",
" ```\n",
" - `cos(x)`: Kosinus\n",
" ```python\n",
" from sympy import cos\n",
" cos(x)\n",
" ```\n",
" - `tan(x)`: Tangens\n",
" ```python\n",
" from sympy import tan\n",
" tan(x)\n",
" ```\n",
" - `csc(x)`: Kosekans (1/sin(x))\n",
" ```python\n",
" from sympy import csc\n",
" csc(x)\n",
" ```\n",
" - `sec(x)`: Sekans (1/cos(x))\n",
" ```python\n",
" from sympy import sec\n",
" sec(x)\n",
" ```\n",
" - `cot(x)`: Kotangens (1/tan(x))\n",
" ```python\n",
" from sympy import cot\n",
" cot(x)\n",
" ```\n",
"\n",
"4. **Hyperbolische Funktionen**\n",
"\n",
" - `sinh(x)`: Sinus hyperbolicus\n",
" ```python\n",
" from sympy import sinh\n",
" sinh(x)\n",
" ```\n",
" - `cosh(x)`: Kosinus hyperbolicus\n",
" ```python\n",
" from sympy import cosh\n",
" cosh(x)\n",
" ```\n",
" - `tanh(x)`: Tangens hyperbolicus\n",
" ```python\n",
" from sympy import tanh\n",
" tanh(x)\n",
" ```\n",
"\n",
"5. **Trigonometrische Inverse Funktionen**\n",
" - `asin(x)`: Arkussinus (Inverser Sinus)\n",
" ```python\n",
" from sympy import asin\n",
" asin(x)\n",
" ```\n",
" - `acos(x)`: Arkuskosinus (Inverser Kosinus)\n",
" ```python\n",
" from sympy import acos\n",
" acos(x)\n",
" ```\n",
" - `atan(x)`: Arkustangens (Inverser Tangens)\n",
" ```python\n",
" from sympy import atan\n",
" atan(x)\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Algebraische Operationen**\n",
"\n",
"1. **Addition, Subtraktion, Multiplikation, Division**\n",
"\n",
" - `+`, `-`, `*`, `/`\n",
" ```python\n",
" x + y # Addition\n",
" x - y # Subtraktion\n",
" x * y # Multiplikation\n",
" x / y # Division\n",
" ```\n",
"\n",
"2. **Exponenten**\n",
"\n",
" - `**`: Potenz\n",
" ```python\n",
" x**2 # x hoch 2\n",
" ```\n",
"\n",
"3. **Wurzeln**\n",
" - `sqrt(x)`: Quadratwurzel\n",
" ```python\n",
" from sympy import sqrt\n",
" sqrt(x)\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Integral- und Ableitungsoperationen**\n",
"\n",
"1. **Ableitungen**\n",
"\n",
" - `diff(f, x)`: Erste Ableitung von `f` nach `x`\n",
" ```python\n",
" from sympy import diff\n",
" diff(f, x)\n",
" ```\n",
"\n",
"2. **Integrale**\n",
" - `integrate(f, x)`: Unbestimmtes Integral von `f` nach `x`\n",
" ```python\n",
" from sympy import integrate\n",
" integrate(f, x)\n",
" ```\n",
" - `integrate(f, (x, a, b))`: Bestimmtes Integral von `f` von `a` bis `b`\n",
" ```python\n",
" integrate(f, (x, 0, 1))\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Summen, Produkte und Faktorisierung**\n",
"\n",
"1. **Summe**\n",
"\n",
" - `sum(iterable)`: Summe über eine Reihe oder Liste\n",
" ```python\n",
" from sympy import Sum, symbols\n",
" n = symbols('n')\n",
" Sum(n, (n, 1, 10))\n",
" ```\n",
"\n",
"2. **Produkt**\n",
"\n",
" - `product(iterable)`: Produkt über eine Reihe oder Liste\n",
" ```python\n",
" from sympy import Product\n",
" Product(n, (n, 1, 10))\n",
" ```\n",
"\n",
"3. **Faktorisierung**\n",
"\n",
" - `factor(x)`: Faktorisieren eines Polynoms\n",
" ```python\n",
" from sympy import factor\n",
" factor(x**2 - 4)\n",
" ```\n",
"\n",
"4. **Entwicklung in Reihen**\n",
" - `series(f, x)`: Taylor-Reihe von `f` um `x`\n",
" ```python\n",
" from sympy import series\n",
" series(f, x)\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Matrixoperationen**\n",
"\n",
"1. **Matrix**\n",
"\n",
" - `Matrix([[1, 2], [3, 4]])`: Erstellen einer Matrix\n",
" ```python\n",
" from sympy import Matrix\n",
" A = Matrix([[1, 2], [3, 4]])\n",
" ```\n",
"\n",
"2. **Determinante**\n",
"\n",
" - `det(A)`: Determinante einer Matrix\n",
" ```python\n",
" A.det()\n",
" ```\n",
"\n",
"3. **Inverses einer Matrix**\n",
" - `inv(A)`: Inverse der Matrix `A`\n",
" ```python\n",
" A.inv()\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Grenzwerte und Limes**\n",
"\n",
"1. **Grenzwert (Limit)**\n",
"\n",
" - `limit(f, x, c)`: Grenzwert von `f` für `x → c`\n",
" ```python\n",
" from sympy import limit\n",
" limit(f, x, 0)\n",
" ```\n",
"\n",
"2. **Unendlicher Grenzwert**\n",
" - `limit(f, x, oo)`: Grenzwert für `x → ∞`\n",
" ```python\n",
" limit(f, x, float('inf'))\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Differentialgleichungen**\n",
"\n",
"1. **Lösen von Differentialgleichungen**\n",
" - `dsolve(eq, func)`: Lösen einer gewöhnlichen Differentialgleichung\n",
" ```python\n",
" from sympy import Function, dsolve, Derivative\n",
" f = Function('f')\n",
" dsolve(Derivative(f(x), x) - f(x), f(x))\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Sonstige nützliche Funktionen**\n",
"\n",
"1. **Ganze Zahlen (Modulararithmetik)**\n",
"\n",
" - `mod(x, y)`: Modulo-Operation\n",
" ```python\n",
" from sympy import mod\n",
" mod(x, y)\n",
" ```\n",
"\n",
"2. **Boden- und Deckenfunktion**\n",
" - `floor(x)`: Abrunden auf die nächste ganze Zahl\n",
" ```python\n",
" from sympy import floor\n",
" floor(x)\n",
" ```\n",
" - `ceiling(x)`: Aufrunden auf die nächste ganze Zahl\n",
" ```python\n",
" from sympy import ceiling\n",
" ceiling(x)\n",
" ```\n",
"\n",
"---\n",
"\n",
"### **Zusammenfassung der wichtigsten Funktionen**\n",
"\n",
"| **Funktion** | **SymPy-Befehl** | **Beschreibung** |\n",
"| --------------------------- | --------------------------------------------- | -------------------------------------- |\n",
"| Exponentiation | `exp(x)` | \\( e^x \\) |\n",
"| Trigonometrische Funktionen | `sin(x)`, `cos(x)`, `tan(x)` | Sinus, Kosinus, Tangens |\n",
"| Ableitung | `diff(f, x)` | Ableitung von `f` nach `x` |\n",
"| Integral | `integrate(f, x)` | Unbestimmtes Integral von `f` nach `x` |\n",
"| Summe | `Sum(expression, (variable, start, end))` | Summe über eine Reihe |\n",
"| Produkt | `Product(expression, (variable, start, end))` | Produkt über eine Reihe |\n",
"| Faktorisierung | `factor(f)` | Faktorisierung von `f` |\n",
"| Grenzwert | `limit(f, x, c)` | Grenzwert von `f` für `x → c` |\n",
"| Matrixoperationen | `Matrix([[1, 2], [3, 4]])` | Erstellen von Matrizen |\n",
"| Differentialgleichung lösen | `dsolve(eq, func)` | Lösen von Differentialgleichungen |\n",
"\n",
"---\n",
"\n",
"\n",
"<!--->siehe https://chatgpt.com/share/673b2049-b010-8013-a3d7-9552c03da480</--->\n"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}