Matlab Gaussian Elimination Question

I'm trying to find the difference in the values of C1 between solving the following system of equations using the attached gaussian elimination script, vs using the backslash command for matrices in matlab (i.e. x=A\b).
I'm getting an answer of 7.9936e-15, but the correct answer is supposedly 3.5527e-15.
I would appreciate it if someone else could try this quickly to tell me if I'm doing something wrong, or the answer is wrong.
I've simply calculated the matrix using the attached script, calculated the other matrix from the backslash command and then subtracted them from one another.
Thanks.

답변 (1개)

John D'Errico
John D'Errico 2016년 3월 14일
편집: John D'Errico 2016년 3월 14일

0 개 추천

No. What you fail to understand is those two results ARE the same. The same at least, to within floating point trash. Adding, subtracting and multiplying numbers in various orders does not yield identically the same results when you work in floating point arithmetic.
Do you believe me?
.3 - .2 - .1
ans =
-2.7756e-17
-(.1 + .2 - .3)
ans =
-5.5511e-17
Gosh. Different numbers, on the order of what you got, from what SHOULD be identically the same computation. This is as expected. Floating point arithmetic is NOT mathematics. It only looks like mathematics.

댓글 수: 1

Callum C
Callum C 2016년 3월 14일
I think I understand. So is the question proposed by my professor not valid?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2016년 3월 14일

댓글:

2016년 3월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by