From e2c95c4ba67fbbe0b3208ccb2223a43f3ecd316c Mon Sep 17 00:00:00 2001 From: hamzahs1 <84736257+hamzahs1@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:28:31 -0500 Subject: [PATCH 1/4] Create fixedpoint_iter added fixed point iteration algorithm --- .../arithmetic_analysis/fixedpoint_iter | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 algorithms/arithmetic_analysis/fixedpoint_iter diff --git a/algorithms/arithmetic_analysis/fixedpoint_iter b/algorithms/arithmetic_analysis/fixedpoint_iter new file mode 100644 index 0000000..4a42034 --- /dev/null +++ b/algorithms/arithmetic_analysis/fixedpoint_iter @@ -0,0 +1,31 @@ +function cobweb(f,a, b, x0, N) + +% generate the cobweb diagram associated with +% the iteration: x_{n+1}=f(x_n). +% N is the number of iterates, and +% (a,b) is the interval +% x0 is the initial point. +% plot y=f(x) + +x=a:.01:b; +y=f(x); +figure +hold on; +title('fixed point iteration') +plot(x,y,'k'); % plot the function +%pause +plot(x,x,'r'); % plot the straight line +%pause +x(1)=x0; % plot orbit starting at x0 +for i=1:N + x(i+1)=f(x(i)); + if i==1 + line([x(i),x(i)],[0,x(i+1)]); + else + line([x(i),x(i)],[x(i),x(i+1)]); + end + pause + line([x(i),x(i+1)],[x(i+1),x(i+1)]); + pause +end +hold off; From 4dadc46d7079b7f22c569a3b0ac8d9e53ea10474 Mon Sep 17 00:00:00 2001 From: hamzahs1 <84736257+hamzahs1@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:28:48 -0500 Subject: [PATCH 2/4] Rename fixedpoint_iter to fixed_point_iter --- .../arithmetic_analysis/{fixedpoint_iter => fixed_point_iter} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename algorithms/arithmetic_analysis/{fixedpoint_iter => fixed_point_iter} (100%) diff --git a/algorithms/arithmetic_analysis/fixedpoint_iter b/algorithms/arithmetic_analysis/fixed_point_iter similarity index 100% rename from algorithms/arithmetic_analysis/fixedpoint_iter rename to algorithms/arithmetic_analysis/fixed_point_iter From c6fd72b83b2b2edba63dee3cb24a19920115958f Mon Sep 17 00:00:00 2001 From: hamzahs1 <84736257+hamzahs1@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:34:21 -0500 Subject: [PATCH 3/4] Update fixed_point_iter --- algorithms/arithmetic_analysis/fixed_point_iter | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/algorithms/arithmetic_analysis/fixed_point_iter b/algorithms/arithmetic_analysis/fixed_point_iter index 4a42034..1a36423 100644 --- a/algorithms/arithmetic_analysis/fixed_point_iter +++ b/algorithms/arithmetic_analysis/fixed_point_iter @@ -1,4 +1,4 @@ -function cobweb(f,a, b, x0, N) +function fpi(f,a, b, x0, N) % generate the cobweb diagram associated with % the iteration: x_{n+1}=f(x_n). @@ -13,9 +13,7 @@ figure hold on; title('fixed point iteration') plot(x,y,'k'); % plot the function -%pause -plot(x,x,'r'); % plot the straight line -%pause +plot(x,x,'r'); % plot straight line x(1)=x0; % plot orbit starting at x0 for i=1:N x(i+1)=f(x(i)); From af1ca0c3f7537d9b1745de5ed4c3be5faaab5e14 Mon Sep 17 00:00:00 2001 From: hamzahs1 <84736257+hamzahs1@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:39:13 -0500 Subject: [PATCH 4/4] Added .m extension for MATLAB --- .../arithmetic_analysis/{fixed_point_iter => fixed_point_iter.m} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename algorithms/arithmetic_analysis/{fixed_point_iter => fixed_point_iter.m} (100%) diff --git a/algorithms/arithmetic_analysis/fixed_point_iter b/algorithms/arithmetic_analysis/fixed_point_iter.m similarity index 100% rename from algorithms/arithmetic_analysis/fixed_point_iter rename to algorithms/arithmetic_analysis/fixed_point_iter.m