Files
HM1-Serie-Python/Kuengjoe_S04/Kuengjoe_S04_Aufg2.py
2025-10-16 17:33:34 +02:00

27 lines
591 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import numpy as np
def f(k: float, a: float) -> float:
return a * k *(1-k)
def iterate(a: float, k0: float= 0.1, steps: int = 100) -> float:
k = k0
for _ in range(steps):
k = f(k, a)
return k
alphas = np.arange(0.0, 4.01, 0.1)
print("α\tk_end\t\tFixpunkte (theoretisch)")
for alpha in alphas:
k_num = iterate(alpha)
k_fix1 = 0
if alpha <= 1:
k_fix2 = None
else:
k_fix2 = 1-1 / alpha
print(f"{alpha:3.1f}\t{k_num:7.4f}\t{k_fix1}", end="")
if k_fix2 is not None:
print(f", {k_fix2:.4f}")
else:
print("")