# Solution of symmeric/non-symmetric linear system

I would like to understand what happens in the following:

I have a really simple Poisson problem, in 1D, with $$u_0 = u_N = 0$$. I assembled the stiffness matrix and the right-hand side, and I applied the BCs, then forced $$A$$ to be symmetric.

I'm studying the stability of an iterative method for solving this linear system while increasing $$N$$. I put $$1e^{-10}$$ as tolerance and everything went ok until $$N =35000$$ where around $$1.2e^{-10}$$ the residual starts to oscillate.

As a test I tried a solving in Matlab (using A\b), and also there the residual did not go below $$1e^{-10}$$.

So I removed the symmetry from the stiffness matrix, and I retried on Matlab, and now the residual is in the order of $$1e^{-11}$$.

So, is it possible that a simple manipulation for making the matrix symmetric could cause my solution to be "worse"?

It could have changed the condition number adversely, yes, which would make it harder to solve. How are you forcing this matrix to be symmetric? Should be said that if you're solving the linear problem 10 orders, you're probably doing pretty well.

As whpowell pointed out in their comment matlab will use a different solver routine for symmetric vs. asymmetric. It will choose between one of two solvers for a symmetric matrix and from a different two solvers for an asymmetric matrix. So you're not only changing the matrix condition number, you're changing the solver as well.

• Also MATLAB uses different solver routines in blackslash if it detects a symmetric matrix so that could also be affecting things – whpowell96 May 26 '20 at 19:09
• Thank you! For making it symmetric I just put to zero A(2,1) and A(N-1,N). Since there BCs are $u_0 = u_N = 0$ this would not change the problem – Cla May 27 '20 at 8:16

Not really an answer, but too long for a comment.

In my experience, the best way to preserve symmetry and deal with boundary conditions is to use just internal points. "Penalization methods" (or big number approach, I know it has several names) is another possibility .

If your enumeration is $$x_1,\ldots,x_{n+1}$$, then work just on $$x_2, \ldots, x_{n}$$, as the values of $$u$$ at $$x_1,x_{n+1}$$ are given (in your case, just $$0$$). Ig they're not $$0$$, they will move on the rhs-vector

You reduce the d.o.f of the stiffness matrix by $$1$$, and preserve the symmetry. You'll obtain a solution vector, after the lin. system solution process, consisting of just the $$n-1$$ interal values. You can then add the known values at the end in the sol. vector if you want.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9392281,"math_prob":0.9963712,"size":829,"snap":"2021-31-2021-39","text_gpt3_token_len":209,"char_repetition_ratio":0.11515152,"word_repetition_ratio":0.0,"special_character_ratio":0.27503017,"punctuation_ratio":0.10119048,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9993747,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-07-30T03:52:06Z\",\"WARC-Record-ID\":\"<urn:uuid:07c8e269-d4df-4119-b225-d88b7f662cf7>\",\"Content-Length\":\"174933\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:028d91e7-e174-44b3-96d8-ce20c50f465d>\",\"WARC-Concurrent-To\":\"<urn:uuid:75340176-b0c9-4394-b700-0dc52dac914d>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://scicomp.stackexchange.com/questions/35224/solution-of-symmeric-non-symmetric-linear-system\",\"WARC-Payload-Digest\":\"sha1:BKSGLBSGSYLPFA6O536VDK6QAE2BIMDD\",\"WARC-Block-Digest\":\"sha1:W2G6EOMTPFMDB7P756RD6R55ITEYSNIF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046153931.11_warc_CC-MAIN-20210730025356-20210730055356-00313.warc.gz\"}"}