fix project 1 q1 bug

This commit is contained in:
2025-10-21 16:25:27 -04:00
parent 5acb5d6900
commit 1ecd5a4bbe
4 changed files with 39 additions and 33 deletions

View File

@@ -4,8 +4,8 @@ Projection of b onto the column space of A(1): (Using proj function)
Projection of b onto the column space of A(1): (Using proj_SVD function)
[1.85714286 1. 3.14285714 1.28571429 3.85714286]
Difference between the two methods:
[ 1.77635684e-15 -2.22044605e-15 -8.88178420e-16 8.88178420e-16
0.00000000e+00]
[ 2.22044605e-16 1.55431223e-15 -4.44089210e-16 2.22044605e-16
-8.88178420e-16]
Question 1(b):
@@ -15,8 +15,8 @@ Projection of b onto the column space of A(1.0):
Projection of b onto the column space of A(1.0) using SVD:
[1.85714286 1. 3.14285714 1.28571429 3.85714286]
Difference between the two methods:
[ 1.77635684e-15 -2.22044605e-15 -8.88178420e-16 8.88178420e-16
0.00000000e+00]
[ 2.22044605e-16 1.55431223e-15 -4.44089210e-16 2.22044605e-16
-8.88178420e-16]
For ε = 0.1:
Projection of b onto the column space of A(0.1):
@@ -24,8 +24,8 @@ Projection of b onto the column space of A(0.1):
Projection of b onto the column space of A(0.1) using SVD:
[1.85714286 1. 3.14285714 1.28571429 3.85714286]
Difference between the two methods:
[ 7.28306304e-14 -4.44089210e-16 -2.66453526e-14 -1.62092562e-14
-5.28466160e-14]
[ 8.08242362e-14 5.87307980e-14 -8.88178420e-16 4.81836793e-14
-1.37667655e-14]
For ε = 0.01:
Projection of b onto the column space of A(0.01):
@@ -33,35 +33,37 @@ Projection of b onto the column space of A(0.01):
Projection of b onto the column space of A(0.01) using SVD:
[1.85714286 1. 3.14285714 1.28571429 3.85714286]
Difference between the two methods:
[-5.45297141e-12 -7.28239691e-12 -3.44613227e-13 -4.24371649e-12
-4.86499729e-12]
[-4.76907402e-12 -1.84297022e-14 5.53779245e-13 -4.00324218e-12
1.49613655e-12]
For ε = 0.0001:
Projection of b onto the column space of A(0.0001):
[1.85714297 1.00000012 3.14285716 1.28571442 3.85714302]
[1.85714282 1. 3.14285716 1.28571427 3.85714291]
Projection of b onto the column space of A(0.0001) using SVD:
[1.85714286 1. 3.14285714 1.28571429 3.85714286]
Difference between the two methods:
[1.11406275e-07 1.19209290e-07 1.91642426e-08 1.35516231e-07
1.67459071e-07]
[-3.59740875e-08 9.10937992e-13 1.94238092e-08 -1.19938544e-08
4.79721098e-08]
For ε = 1e-08:
LinAlgError for eps=1e-08: Singular matrix
Projection of b onto the column space of A(1e-08):
[-1.87500007 0.99999993 -3.12499997 -2.62500007 3.49999996]
Projection of b onto the column space of A(1e-08) using SVD:
[1.85714286 1. 3.14285714 1.28571428 3.85714286]
[1.85714286 1. 3.14285714 1.28571427 3.85714286]
Difference between the two methods:
Could not compute difference due to previous error.
[-3.73214294e+00 -7.45058057e-08 -6.26785711e+00 -3.91071435e+00
-3.57142909e-01]
For ε = 1e-16:
ValueError for eps=1e-16: Matrix A must be full rank.
Projection of b onto the column space of A(1e-16) using SVD:
[1.81820151 1. 3.18179849 2.29149804 2.89030045]
[3.4 1. 1.6 1.8 1.8]
Difference between the two methods:
Could not compute difference due to previous error.
For ε = 1e-32:
ValueError for eps=1e-32: Matrix A must be full rank.
Projection of b onto the column space of A(1e-32) using SVD:
[2. 1. 3. 2.5 2.5]
[3.4 1. 1.6 1.8 1.8]
Difference between the two methods:
Could not compute difference due to previous error.