first commit
This commit is contained in:
217
Mathematik für Ingenieure 1.ipynb
Normal file
217
Mathematik für Ingenieure 1.ipynb
Normal file
@@ -0,0 +1,217 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "902e4b59-77b9-4db6-9ec2-3cff55766dd5",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2026-03-14T20:09:28.272005Z",
|
||||
"start_time": "2026-03-14T20:09:28.181811Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"\n",
|
||||
"def abs(c):\n",
|
||||
" return (c.real**2 + c.imag**2)**0.5\n",
|
||||
"\n",
|
||||
"def add(c1, c2):\n",
|
||||
" return complex(c1.real + c2.real, c1.imag + c2.imag)\n",
|
||||
"\n",
|
||||
"def sub(c1, c2):\n",
|
||||
" # (a+bi) - (c+di) = (a-c) + (b-d)i\n",
|
||||
" return complex(c1.real - c2.real, c1.imag - c2.imag)\n",
|
||||
"\n",
|
||||
"def mul(c1, c2):\n",
|
||||
" # (a+bi)(c+di) = (ac-bd) + (ad+bc)i\n",
|
||||
" return complex(c1.real * c2.real - c1.imag * c2.imag, c1.real * c2.imag + c1.imag * c2.real)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"print(mul(1+2j, 2+1j))"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"5j\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "3fb82de2-875a-4dac-935a-e64bad48c895",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(5, 5)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def add(v1, v2):\n",
|
||||
" return (v1[0] + v2[0], v1[1] + v2[1])\n",
|
||||
"\n",
|
||||
"def sub(v1, v2):\n",
|
||||
" return (v1[0] - v2[0], v1[1] - v2[1])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"print(add((2, 1), (3, 4)))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "3a562f0e-162b-4760-ac6b-22587bf0bd60",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Intervall: Interval.Ropen(2, 5)\n",
|
||||
"Mengenangabe: (2 <= x) & (x < 5)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from sympy import Interval, Symbol\n",
|
||||
"\n",
|
||||
"# 1. Variable definieren\n",
|
||||
"x = Symbol('x')\n",
|
||||
"\n",
|
||||
"# 2. Intervall erstellen (z.B. [2, 5) - links abgeschlossen, rechts offen)\n",
|
||||
"# left_open=False (Standard) bedeutet inklusive 2, right_open=True bedeutet exklusive 5\n",
|
||||
"mein_intervall = Interval(2, 5, left_open=False, right_open=True)\n",
|
||||
"\n",
|
||||
"# 3. In Mengenangabe / Ungleichung umwandeln\n",
|
||||
"mengen_angabe = mein_intervall.as_relational(x)\n",
|
||||
"\n",
|
||||
"print(f\"Intervall: {mein_intervall}\")\n",
|
||||
"print(f\"Mengenangabe: {mengen_angabe}\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "5f024814-9f83-4d5f-a81f-4283e47e22b9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Interval.Ropen(2, 5)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from sympy import Symbol, And\n",
|
||||
"\n",
|
||||
"x = Symbol('x')\n",
|
||||
"\n",
|
||||
"# Eine Mengenangabe als logische Verknüpfung (2 <= x < 5)\n",
|
||||
"mengen_angabe = And(x >= 2, x < 5)\n",
|
||||
"\n",
|
||||
"# Umwandlung in ein Intervall-Objekt\n",
|
||||
"intervall = mengen_angabe.as_set()\n",
|
||||
"\n",
|
||||
"print(intervall) \n",
|
||||
"# Ausgabe: [2, 5)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "b58b7c16-2c79-46a4-bde0-1d8fcc16cfa9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Interval(-2, 2)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from sympy import Symbol, solve_univariate_inequality\n",
|
||||
"\n",
|
||||
"x = Symbol('x')\n",
|
||||
"\n",
|
||||
"# Eine Ungleichung definieren\n",
|
||||
"ungleichung = x**2 <= 4\n",
|
||||
"\n",
|
||||
"# Lösen und als Intervall ausgeben lassen (relational=False)\n",
|
||||
"intervall = solve_univariate_inequality(ungleichung, x, relational=False)\n",
|
||||
"\n",
|
||||
"print(intervall)\n",
|
||||
"# Ausgabe: [-2, 2]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "dd0522d3-0612-44f1-9504-1ba48542e37e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Interval.open(-8, 8)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"from sympy import Symbol, solve_univariate_inequality\n",
|
||||
"\n",
|
||||
"x = Symbol('x')\n",
|
||||
"\n",
|
||||
"# Eine Ungleichung definieren\n",
|
||||
"ungleichung = abs(x)<8\n",
|
||||
"\n",
|
||||
"# Lösen und als Intervall ausgeben lassen (relational=False)\n",
|
||||
"intervall = solve_univariate_inequality(ungleichung, x, relational=False)\n",
|
||||
"\n",
|
||||
"print(intervall)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "99ed5f78-8032-40eb-99ce-988de647549b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user