fix project 1 q1 bug
This commit is contained in:
@@ -38,26 +38,26 @@ As $\epsilon \rightarrow 0$, the normal equation method becomes numerically unst
|
||||
\hline
|
||||
\textbf{$\epsilon$} & \textbf{Normal Equation Method \texttt{proj(A,b)}} & \textbf{SVD Method \texttt{proj\_SVD(A,b)}} & \textbf{Difference (Normal Eq - SVD)} \\
|
||||
\hline
|
||||
\textbf{1.0} & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [ 1.78e-15 -2.22e-15 -8.88e-16 8.88e-16 0.00e+00] \\
|
||||
\textbf{1.0} & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [ 2.22e-16 1.55e-15 -4.44e-16 2.22e-16 -8.88e-16] \\
|
||||
\hline
|
||||
\textbf{0.1} & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [ 7.28e-14 -4.44e-16 -2.66e-14 -1.62e-14 -5.28e-14] \\
|
||||
\textbf{0.1} & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [ 8.08e-14 5.87e-14 -8.88e-16 4.82e-14 -1.38e-14] \\
|
||||
\hline
|
||||
\textbf{0.01} & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [-5.45e-12 -7.28e-12 -3.45e-13 -4.24e-12 -4.86e-12] \\
|
||||
\textbf{0.01} & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [-4.77e-12 -1.84e-14 5.54e-13 -4.00e-12 1.50e-12] \\
|
||||
\hline
|
||||
\textbf{1e-4} & [1.85714297 1.00000012 3.14285716 1.28571442 3.85714302] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [1.11e-07 1.19e-07 1.92e-08 1.36e-07 1.67e-07] \\
|
||||
\textbf{1e-4} & [1.85714282 1. 3.14285716 1.28571427 3.85714291] & [1.85714286 1. 3.14285714 1.28571429 3.85714286] & [-3.60e-08 9.11e-13 1.94e-08 -1.20e-08 4.80e-08] \\
|
||||
\hline
|
||||
\textbf{1e-8} & \textbf{Error:} \texttt{LinAlgError: Singular matrix} & [1.85714286 1. 3.14285714 1.28571428 3.85714286] & Could not compute difference due to previous error. \\
|
||||
\textbf{1e-8} & [-1.87500007 0.99999993 -3.12499997 -2.62500007 3.49999996] & [1.85714286 1. 3.14285714 1.28571427 3.85714286] & [-3.73e+00 -7.45e-08 -6.27e+00 -3.91e+00 -3.57e-01] \\
|
||||
\hline
|
||||
\textbf{1e-16} & \textbf{Error:} \texttt{ValueError: Matrix A must be full rank} & [1.81820151 1. 3.18179849 2.29149804 2.89030045] & Could not compute difference due to previous error. \\
|
||||
\textbf{1e-16} & \textbf{Error:} \texttt{ValueError: Matrix A must be full rank} & [3.4 1. 1.6 1.8 1.8] & Could not compute difference due to previous error. \\
|
||||
\hline
|
||||
\textbf{1e-32} & \textbf{Error:} \texttt{ValueError: Matrix A must be full rank} & [2. 1. 3. 2.5 2.5] & Could not compute difference due to previous error. \\
|
||||
\textbf{1e-32} & \textbf{Error:} \texttt{ValueError: Matrix A must be full rank} & [3.4 1. 1.6 1.8 1.8] & Could not compute difference due to previous error. \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\caption{Comparison of results from the normal equation and SVD-based methods.}
|
||||
\label{tab:proj_results}
|
||||
\end{table}
|
||||
|
||||
\noindent Numerical experiments show that as $\epsilon$ becomes small, the difference between the two methods increases. When $\epsilon$ becomes very small (e.g., 1e-8), the normal equation method fails while the SVD method continues to provide a stable solution.
|
||||
\noindent Numerical experiments show that as $\epsilon$ becomes small, the difference between the two methods increases. When $\epsilon$ becomes very small (e.g., 1e-8), the normal equation method can't give a valid result and fails when $\epsilon$ continues to decrease (e.g., 1e-16), while the SVD method continues to provide a stable solution.
|
||||
|
||||
\section{QR Factorisation}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user