From f6872d827db343d06fcc23f8d129a11ef5c44f07 Mon Sep 17 00:00:00 2001 From: "dino.celebic" Date: Mon, 20 Oct 2025 23:48:46 +0200 Subject: [PATCH 1/2] ex2 --- ex2/task_c.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 ex2/task_c.py diff --git a/ex2/task_c.py b/ex2/task_c.py new file mode 100644 index 0000000..2a6a719 --- /dev/null +++ b/ex2/task_c.py @@ -0,0 +1,8 @@ +import numpy as numpy +import matplotlib.pyplot as plt + + +x = np.linspace(0,1,100) +p = [10**i for i in range(-3,4)] + +print(p) \ No newline at end of file From a1928ab84b27e66d364266a5e0174c34e2b36d8c Mon Sep 17 00:00:00 2001 From: "dino.celebic" Date: Mon, 20 Oct 2025 23:50:21 +0200 Subject: [PATCH 2/2] ex2 --- ex2/task_c.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ex2/task_c.py b/ex2/task_c.py index 2a6a719..a12ae74 100644 --- a/ex2/task_c.py +++ b/ex2/task_c.py @@ -1,8 +1,19 @@ -import numpy as numpy +import numpy as np import matplotlib.pyplot as plt +x = np.linspace(0,1,200) +p_list = [-100, -10, -1, 0, 1, 10, 100] -x = np.linspace(0,1,100) -p = [10**i for i in range(-3,4)] +for p in p_list: + if p != 0: + u = (np.exp(p*x)-1)/(np.exp(p)-1) + else: + u = x -print(p) \ No newline at end of file + plt.plot(x,u, label=f"p={p}") + +plt.xlabel("x") +plt.ylabel("u(x)") +plt.title("Solution of -u''+pu'=0 with u(0)=0 u(1)=1") +plt.legend() +plt.show() \ No newline at end of file