[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60839] linsolve returns an incorrect solution
From: |
anónimo |
Subject: |
[Octave-bug-tracker] [bug #60839] linsolve returns an incorrect solution with an inconsistent system |
Date: |
Sun, 27 Jun 2021 14:36:51 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0 |
URL:
<https://savannah.gnu.org/bugs/?60839>
Summary: linsolve returns an incorrect solution with an
inconsistent system
Project: GNU Octave
Submitted by: None
Submitted on: dom 27 jun 2021 18:36:50 UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Jose Luis Nuñez Crespi
Originator Email: joseluis.nunez@selenitas.es
Open/Closed: Open
Release: 6.2.0
Discussion Lock: Any
Operating System: GNU/Linux
_______________________________________________________
Details:
I have written a set of libraries in Java to deal with complex numbers with
several mathematical functions and arithmetic capablities.
I use GNU Octave, Maxima and sometimes Wolfram to check the results returned
from my progrmas.
In one of the tests I use the following system that is inconsistent
+(1)x0+(-1)x1+(1)x2+(1)x3+(-1)x4 = -1
+(1)x0+(-1)x1+(-1)x2+(1)x3+(-1)x4 = -1
+(1)x0+(-1)x1+(-1)x2+(1)x3+(-1)x4 = 1
+(-1)x0+(-1)x1+(1)x2+(1)x3+(-1)x4 = 1
+(-1)x0+(-1)x1+(1)x2+(-1)x3+(-1)x4 = 1
But Octave returns the following result, and I think that is incorrect, maybe
the warnings invalidate the result returned...
>> disp(Sol =
linsolve([1.000,-1.000,1.000,1.000,-1.000;1.000,-1.000,-1.000,1.000,-1.000;1.000,-1.000,-1.000,1.000,-1.000;-1.000,-1.000,1.000,1.000,-1.000;-1.000,-1.000,1.000,-1.000,-1.000],[-1.000;-1.000;1.000;1.000;1.000]))
warning: matrix singular to machine precision
warning: called from
linsolve at line 113 column 7
-1.0000e+00
-2.5000e-01
-5.0000e-01
-2.2204e-16
-2.5000e-01
>>
rank([1.00,-1.00,1.00,1.00,-1.00;1.00,-1.00,-1.00,1.00,-1.00;1.00,-1.00,-1.00,1.00,-1.00;-1.00,-1.00,1.00,1.00,-1.00;-1.00,-1.00,1.00,-1.00,-1.00])
ans = 4
>>
rank([1.00,-1.00,1.00,1.00,-1.00;1.00,-1.00,-1.00,1.00,-1.00;1.00,-1.00,-1.00,1.00,1.00;-1.00,-1.00,1.00,1.00,1.00;-1.00,-1.00,1.00,-1.00,1.00])
ans = 5
The answer given from Maxima for the same system is
(%i1)
expand(linsolve([+(1.000)*x0+(-1.000)*x1+(1.000)*x2+(1.000)*x3+(-1.000)*x4=-1.000,+(1.000)*x0+(-1.000)*x1+(-1.000)*x2+(1.000)*x3+(-1.000)*x4=-1.000,+(1.000)*x0+(-1.000)*x1+(-1.000)*x2+(1.000)*x3+(-1.000)*x4=1.000,+(-1.000)*x0+(-1.000)*x1+(1.000)*x2+(1.000)*x3+(-1.000)*x4=1.000,+(-1.000)*x0+(-1.000)*x1+(1.000)*x2+(-1.000)*x3+(-1.000)*x4=1.000],[x0,x1,x2,x3,x4]));
(%o1) []
And from my java program (https://github.com/ipserc/complexarith
TestSyseq1.java)
#===============================================================#
I I
I LINEAR EQUATIONS SYSTEM TEST I
I I
#===============================================================#
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: Equation System :
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+(1.000)x0+(-1.000)x1+(1.000)x2+(1.000)x3+(-1.000)x4 = -1.000
+(1.000)x0+(-1.000)x1+(-1.000)x2+(1.000)x3+(-1.000)x4 = -1.000
+(1.000)x0+(-1.000)x1+(-1.000)x2+(1.000)x3+(-1.000)x4 = 1.000
+(-1.000)x0+(-1.000)x1+(1.000)x2+(1.000)x3+(-1.000)x4 = 1.000
+(-1.000)x0+(-1.000)x1+(1.000)x2+(-1.000)x3+(-1.000)x4 = 1.000
The system is INCONSISTENT
+---------------------------------------------------------------+
| System Solve Commands |
+---------------------------------------------------------------+
MComplex:new
MatrixComplex("1.000,-1.000,1.000,1.000,-1.000,-1.000;1.000,-1.000,-1.000,1.000,-1.000,-1.000;1.000,-1.000,-1.000,1.000,-1.000,1.000;-1.000,-1.000,1.000,1.000,-1.000,1.000;-1.000,-1.000,1.000,-1.000,-1.000,1.000")
MAXIMA:expand(linsolve([+(1.000)*x0+(-1.000)*x1+(1.000)*x2+(1.000)*x3+(-1.000)*x4=-1.000,+(1.000)*x0+(-1.000)*x1+(-1.000)*x2+(1.000)*x3+(-1.000)*x4=-1.000,+(1.000)*x0+(-1.000)*x1+(-1.000)*x2+(1.000)*x3+(-1.000)*x4=1.000,+(-1.000)*x0+(-1.000)*x1+(1.000)*x2+(1.000)*x3+(-1.000)*x4=1.000,+(-1.000)*x0+(-1.000)*x1+(1.000)*x2+(-1.000)*x3+(-1.000)*x4=1.000],[x0,x1,x2,x3,x4]))
OCTAVE:disp(Sol =
linsolve([1.000,-1.000,1.000,1.000,-1.000;1.000,-1.000,-1.000,1.000,-1.000;1.000,-1.000,-1.000,1.000,-1.000;-1.000,-1.000,1.000,1.000,-1.000;-1.000,-1.000,1.000,-1.000,-1.000],[-1.000;-1.000;1.000;1.000;1.000]))
WOLFRAM:solve(+(1.000)*x0+(-1.000)*x1+(1.000)*x2+(1.000)*x3+(-1.000)*x4=-1.000,+(1.000)*x0+(-1.000)*x1+(-1.000)*x2+(1.000)*x3+(-1.000)*x4=-1.000,+(1.000)*x0+(-1.000)*x1+(-1.000)*x2+(1.000)*x3+(-1.000)*x4=1.000,+(-1.000)*x0+(-1.000)*x1+(1.000)*x2+(1.000)*x3+(-1.000)*x4=1.000,+(-1.000)*x0+(-1.000)*x1+(1.000)*x2+(-1.000)*x3+(-1.000)*x4=1.000,x0,x1,x2,x3,x4)
#===============================================================#
| System Solutions |
#===============================================================#
There are no solutions for an INCONSISTENT Equation System
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60839>
_______________________________________________
Mensaje enviado vía Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #60839] linsolve returns an incorrect solution with an inconsistent system,
anónimo <=